GameCondition.cs

v3.0

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;
public ItemObject Parent() // Get the Condition scriptable objcet
public string Uid() // Uid of the parent
public virtual string GameId(bool forceNew = false) // In game unique ID of this GameCondition

public string ObjectName() // The name of this
public string ObjectType() // The type this is

public float endTime; // Time when the GameCondition will delete itself
public float nextEffect; // Next time when the periodic effects will trigger
        
public string DisplayName
public string Description
public bool Stack
public bool Instant
public int Level
public Condition ExpirationCondition

public bool Expired()
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 condition

     GameId();
     SetParentList(parentList);

     SetupGameTimeValues(source); // Set the time values for this
     SetupGameConditionValues(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" effects
gameCondition.PointActions();

// Trigger the periodic effect (point effects) and reset the counter
gameCondition.PeriodicActions();

Last updated