Hi there,
In these lectures, if I understood well, the stats (damage or max health) are re-calculated every time we need them. For instance, every time we need to get the maxHealth (for printing on the UI), we execute a call to the getStat function, right? The same thing is happening when we need to apply damage?
I can’t really record because I chose a different way to do stat recalculation.
I went the “event way”, meaning that I subscribe to every possible event that would impact the stats, and then I recalculate -and cache- the stat value.
For example, when we level up, an event triggers and updates all the stats.
When we equip a weapon, we have an event that updates the weapon, why isn’t it that we also add, in the UpdateWeapon method (of fighter script) a call to the UpdateDamage method?
I mean: is generally recalculating stats every time we need them a better way than recalculating stats when an event (that could impact the stat) occurs?
What can help us decide which is the best implementation: recalculating the stat every time or only when an event triggers? On what basis can we chose one way or another or writing our code?
I am also wondering which way is more performant?
I feel like I missed something…
Thank you!