The Condition Scriptable Object will not be serialized at runtime, and is intended to store permenent data, rather than mutable data that may change during the game. The GameCondition is used for runtime use instead. It implements IHaveDictionaries.
GameCondition.cs
// Owner will be the owner of the GameConditionList this is in. If it is not in a// List, then it will be the value of _owner. The Owner is the IHaveStats object// which is affected by the stat effects on these objects.public IHaveStats Owner => ParentList ==null? _owner :ParentList.Owner;publicItemObjectParent() // Get the Condition scriptable objcetpublic string Uid() // Uid of the parentpublic virtual string GameId(bool forceNew =false) // In game unique ID of this GameConditionpublic string ObjectName() // The name of thispublic string ObjectType() // The type this ispublic float endTime; // Time when the GameCondition will delete itselfpublicfloat nextEffect; // Next time when the periodic effects will triggerpublicstring DisplayNamepublicstring Descriptionpublicbool Stackpublicbool Instantpublicint Levelpublic Condition ExpirationConditionpublicboolExpired()public bool WillBeExpired(float gameTime)public bool PeriodicReady()public bool WillBePeriodicReady(float gameTime)public float TimeActive()public string uid => GetUid(); // Will return the uid, which can be serialized and used to look up the Scriptable Object
If your Actor inherits from GameModulesActor then all of this is handled automatically.
Constructor
Pass in the Condition and the target which implements IHaveConditions and source which implements IHaveStats. Often actors or objects will implement both. The owner of the condition will be set to the target provided.
You also pass the current gametime, which is required so the script knows how long to keep the Condition active. Gametime module can be used, but if you are using your own script, this assumes the value is in "game minutes".
The constructor will clone the dictionaries of the Condition scriptable object, set up the time values based on the Stats of the source object, as well as the condition values -- the effect the GameCondition will have on the target.
public GameCondition(Condition condition, IHaveConditions target, IHaveStats source, float gametimeNow, int newMasteryLevelIndex = 0)
{ // Set basic details dictionaries =condition.dictionaries?.Clone(); // Clone the dictionary from the condition _uid =condition.uid; // Set the uid objectName =condition.objectName; // Set name objectType =condition.objectType; // Set type _source = source; // Set the source of this conditionGameId();SetParentList(parentList);SetupGameTimeValues(source); // Set the time values for thisSetupGameConditionValues(source); // Set the final impact values for this}
Methods
View the GameCondition.cs script for full details on all the methods and how they work.
GameCondition objects are handled exclusively by the GameConditionList. While you can call these methods manually, if you utilize the GameConditionList, you will not need to.
// Trigger the "Point" effectsgameCondition.PointActions();// Trigger the periodic effect (point effects) and reset the countergameCondition.PeriodicActions();