IHaveStats
v4.0
// TryGetGameStat()
public override bool TryGetGameStat(Stat stat, out GameStat gameStat)
=> TryGetGameStat(stat.Uid(), out gameStat);
public override bool TryGetGameStat(string uid, out GameStat gameStat)
{
gameStat = stats.Get(uid, false);
return gameStat != null;
}
// GetOtherLevels()
public virtual List<ModificationLevel> GetOtherLevels(bool cache = false)
{
if (_modificationLevels != null && !cache)
return _modificationLevels;
var otherModificationLevels = new List<ModificationLevel>();
// You would add the "Modification Levels" from other Game Module
// objects used on this object or actor.
otherModificationLevels.AddRange(conditions.ModificationLevels);
otherModificationLevels.AddRange(quests.ModificationLevels);
otherModificationLevels.AddRange(equippedItems.ModificationLevels);
// This example is from DemoActor.cs in the Party Based RPG demo game
if (!string.IsNullOrWhiteSpace(ActorRace.objectName))
otherModificationLevels.Add(ActorRace.ModificationLevel);
if (!string.IsNullOrWhiteSpace(ActorClass.objectName))
otherModificationLevels.Add(ActorClass.ModificationLevel);
_modificationLevels = otherModificationLevels;
return otherModificationLevels;
}
// SetStatsDirty()
public virtual void SetStatsDirty(List<Stat> statList)
{
ResetOtherLevels(false); // Set this to cache next time it is required
foreach (var stat in statList)
{
if (!TryGetGameStat(stat, out var gameStat)) continue;
gameStat.SetDirty();
}
}
// GetStat()
public virtual GameStat GetStat(Stat stat, bool addIfNull = true)
=> GetStat(stat.Uid(), addIfNull);
public virtual GameStat GetStat(string uid, bool addIfNull = true)
=> stats.Get(uid, addIfNull);Last updated