is there any way to make something be checked for every time a field is updated or do i need to use
the property Energy is based on the field CurrentEnergy. CurrentEnergy is the one that keeps being set, and energy is only computed every now and then. any way to link this check to every update of CurrentEnergy? [this is all inside a class]
7 Replies
link between the two, if necessary
use a setter
That maybe calls an event
Something like that
that is also similar to what UI frameworks do
that's definitely very useful to know about
thanks 👍
honestly at the end of the day this still doesn't work because i need to add to the output string, which is only declared in certain scopes, so i wound up modifying some other properties to make this work
You should probably check the new value of CurrentEnergy before actually updating it. Setting a value in a property getter is typically a nono
In the same CurrentEnergy setter, you can then check if the new value equals the max energy, and if so, increment output by Phase3()
honestly, yeah, that's fair, and i did try changing that for a few other properties that had the same problem, but i then realised some of my code is based on the asusmption that those values are not updated until checked.... so yeah i'm probably gonna need to rework my code soon lmao
for now, i'd rather have it this way than have a strange and unclear discrepancy between when to update Energy vs CurrentEnergy or something like that.