GameStat.cs
v4.0
GameStat
is the in-game, runtime object to use, representing a Stat made with the Stat module.
Creating a GameStat
Generally a GameStat
will live inside a GameStatList
. Objects can have multiple lists, such as an Actor which has "Stats" and "Skills". However, they can live outside of a list as well.
All Game Module "Lists" have multiple Add()
and two "Transfer" methods: TransferTo()
and ReceiveTransfer()
.
See the Game Modules "Lists" page details on how to create a GameStat.
Automation
The GameStat
will be automated if the autoCompute
value is true, which it is by default. When SetDirty()
is called, the GameStat
is added to the "recompute queue" on the Stats Repository in your scene.
If you do not want this to occur, code the value of autoCompute to false at Start()
or Awake()
or the creation of the GameStat
.
To manually recompute the GameStat
value, call gameStat.Recompute()
.
Get the Final Stat
The final stat is the computed float value that this GameStat
provides given all the modifications from other Stats
, ItemObject
, Conditions
, ItemAttribute
and other Game Module objects.
Remember the GetOtherLevels()
method on the IHaveStats
owner needs to pass in the modification levels from the other Game Module objects which affect Stats.
I stronly suggest your Actors inherit from GameModulesActor
. If so, all of this is already coded for you. Check the Game Modules Actor page for more details.
Modifying Points (Stat as a Counter)
Points are intended to be modified only by the player or other factors in the game, but not by other Stats
or ItemObjects
etc. Consider these similar to "Skill Points", or "Gold", or "Hit Points" etc.
If you have set another Stat
to modify this Stats
point value by, that is true
by default. Set the second parameter false
if you'd like to not include this when adding the value.
Last updated