GameStatis the in-game, runtime object to use, representing a Stat made with the Stat module.
// View GameStat.cs for all the methods (There are more!!)
// Get the parent Stat (Scriptable Object)
Stat parentOfThisGameStat = gameStat.Parent;
// Get the GameStatList that is holding this Stat
GameStatList parentList = gameStat.ParentList;
// Get the IHaveStats owner who owns the ParentList
IHaveStats thisStatsOwner = gameStat.Owner;
// Access the Dictionaries on this GameStat
// This is useful when you want to access the values that may change at runtime
Dictionaries gameStatDictionaries = gameStat.dictionaries;
// Access the Dictionaries on the Stat (Scriptable Object) of this GameStat
// This is useful when you want to access the fixed values
Dictionaries statDictionaries = gameStat.Parent.dictionaries;
// Get the name of this GameStat & type of this GameStat
var name = gameStat.objectName;
var type = gameStat.objectType;
// Get the values from this GameStat
var points = gameStat.Points;
var finalValue = gameStat.FinalValue;
var finalProficiency = gameStat.FinalProficiency;
var finalStat = gameStat.FinalStat
// Get the current Mastery Level
var masteryLevel = gameStat.MasteryLevel
var masteryLevelName = gameStat.MasteryLevelName
GameStatwill 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:
GameStatwill be automated if the
autoComputevalue is true, which it is by default. When
SetDirty()is called, the
GameStatis 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
Awake()or the creation of the
To manually recompute the
The final stat is the computed float value that this
GameStatprovides given all the modifications from other
ItemAttributeand other Game Module objects.
GetOtherLevels()method on the
IHaveStatsowner needs to pass in the modification levels from the other Game Module objects which affect Stats.
// Just get the float value of the final stat as it is right now
float finalStat = gameStat.FinalStat();
// Recompute the final stat first, along with all the stats which feed into this stat
float finalStat = gameStat.FinalStat(true, true);
Points are intended to be modified only by the player or other factors in the game, but not by other
ItemObjectsetc. Consider these similar to "Skill Points", or "Gold", or "Hit Points" etc.
If you have set another
Statto modify this
Statspoint value by, that is
trueby default. Set the second parameter
falseif you'd like to not include this when adding the value.
// Add points (or add a negative value to subtract)
float newPoints = GameStat.AddPoints(pointsToAdd);
// Set the points value to a specific number
gameStat.SetPoints(newPointValue, false); // Will not modify the final value of the points