GenericTimeAgent |
TimeAgent implementation adding a generic way to persist custom properties.
This component is made to make things simple, but it should not be used in production if performances are critical.
Because Reflection is used to get custom properties values and it will always be way more slower than direct access.
To get the same result with no performance impact, use TimeAgent UnityEvent or extend TimeAgent with your own class
|
TimeAgent |
TimeAgent are the objects managed by the TimeStone.
This class natively handles Transform data, Rigidbody velocity, Animator data and ParticleSystem
To save custom data in the TimeStone, you can either use the onPersistTick and onSetDataTick UnityEvent
For example
var myTimeAgent = GetComponent(typeOf(TimeAgent));
timeAgent.onPersistTick.AddListener(PersistTick);
timeAgent.onSetDataTick.AddListener(SetDataTick);
[...]
private void PersistTick(TimeStone stone, TimeStone.TimeTickOrigin origin, float deltaTime)
{
stone.PersistData(minionsDeadDataId, minionsDead);
[...]
}
Or extend the class and override PersistTick(TimeStone, TimeStone.TimeTickOrigin, float) and SetDataTick(TimeStone, int) . see GenericTimeAgent for an example.
The TimeStone manage its TimeAgents by calling PersistTick(TimeStone, TimeStone.TimeTickOrigin, float) when data must be
persisted (during record or simulation) and SetDataTick(TimeStone, int) when data must be updated (during a playback).
ATTENTION : To Execute a simulation, the TimeStone clones the TimeAgent , so you must handle that
there are 2 versions of your TimeAgent during a simulation, the Original and the Clone. They can be differentiated using IsClone and
you can control which will receive callbacks using simulationCallbackPolicy
During a simulation, the TimeStone calls the lifeCycle callbacks on its TimeAgents : SimulationStart(TimeStone) , SimulationUpdate(float, TimeStone) , etc.
To add simulation code execution, you can either use the onSimulationUpdate , onSimulationStart , etc. UnityEvents or extend the class and override
SimulationUpdate(float, TimeStone) , SimulationStart(TimeStone) , etc.
|