Summary
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
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);
[...]
}
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.
- Namespace
- RedGirafeGames
.Agamotto .Scripts .Runtime .Agents - Base Types
-
- MonoBehaviour
- Derived Types
Syntax
[AddComponentMenu("Agamotto/Time Agent")]
public class TimeAgent : MonoBehaviour
Remarks
Add this component to any object you want to be managed by a TimeStone
Attributes
Type | Description |
---|---|
AddComponentMenu |
Fields
Name | Constant Value | Summary |
---|---|---|
ActiveDataId | GameObjectActiveSelf |
GameObject.activeSelf id to persist in the TimeStone
static
|
agentAnimator |
The
Animator component to persist. If not defined, automatically get gameObject's Animator
|
|
agentRigidbody |
Cached value of Rigidbody
|
|
Angular |
RigidbodyAngularVelocity |
Rigidbody.angularVelocity id to persist in the TimeStone
static
|
Animator |
Animator#StateHash |
Animator 's state hash where DataIdUidToken is replaced with a unique identifier using GetUniqueDataId(string, int)
static
|
Animator |
Animator#InTransition |
Animator 's state transition status where DataIdUidToken is replaced with a unique identifier using GetUniqueDataId(string, int)
static
|
Animator |
Animator#LayerWeight |
Animator 's state layer weight where DataIdUidToken is replaced with a unique identifier using GetUniqueDataId(string, int)
static
|
Animator |
Animator#StateNormalizedTime |
Animator state normalized time where
DataIdUidToken is replaced with the layer num using GetAnimatorDataIdWithLayer
static
|
Animator |
Animator#TransitionDuration |
Animator 's transition duration where DataIdUidToken is replaced with a unique identifier using GetUniqueDataId(string, int)
static
|
Animator |
Animator#TransitionNextHash |
Animator 's transition next hash where DataIdUidToken is replaced with a unique identifier using GetUniqueDataId(string, int)
static
|
Animator |
Animator#TransitionNextNormalizedTime |
Animator 's transition next normalized time where DataIdUidToken is replaced with a unique identifier using GetUniqueDataId(string, int)
static
|
Animator |
Animator#TransitionNormalizedTime |
Animator 's transition normalized time where DataIdUidToken is replaced with a unique identifier using GetUniqueDataId(string, int)
static
|
applyColorToClone |
Applies
cloneColor to the clone material
|
|
apply |
If true,
cloneColor and cloneMaterial are applied on clone's children recursively
|
|
cloneColor |
The color applied to the clone if
applyColorToClone is true
|
|
cloneMaterial |
The material applied to the clone.
If null, no material is applied.
|
|
guid |
Unique ID shared by the original TimeAgent and the cloned TimeAgent used by simulations
|
|
hidePolicy |
How the simulation clone is hidden (or not)
|
|
logDebug |
Log all messages
|
|
parseChildren |
TimeAgents will be searched in children on TimeStone initialization
|
|
Particle |
ParticleSystem#Particles |
ParticleSystem particles where
DataIdUidToken is replaced with a unique identifier using GetParticleSystemUniqueDataId
static
|
Particle |
ParticleSystem#PlaybackState |
ParticleSystem playback state where
DataIdUidToken is replaced with a unique identifier using GetParticleSystemUniqueDataId
static
|
Particle |
ParticleSystem#Trails |
ParticleSystem trails where
DataIdUidToken is replaced with a unique identifier using GetParticleSystemUniqueDataId
static
|
persistActive |
Persist
GameObject.activeSelf in TimeStone
|
|
persistAnimator |
Persist
Animator 's state in TimeStone
|
|
persist |
Persist
Animator 's transitions between states.
|
|
persistParticles | ||
persistParticlesList |
The list of
ParticleSystem to persist. If empty, automatically get gameObject's ParticleSystem
|
|
persistPosition |
Persist
Transform.position in TimeStone
|
|
persistRotation |
Persist
Transform.rotation in TimeStone
|
|
persistScale |
Persist
Transform.localScale in TimeStone
|
|
persistVelocity | ||
PositionDataId | TransformPosition |
Transform.position id to persist in the TimeStone
static
|
PositionLocalDataId | TransformLocalPosition |
Transform.localPosition id to persist in the TimeStone
static
|
RotationDataId | TransformRotation |
Transform.rotation id to persist in the TimeStone
static
|
RotationLocalDataId | TransformLocalRotation |
Transform.localRotation id to persist in the TimeStone
static
|
ScaleDataId | TransformScale |
Transform.localScale id to persist in the TimeStone
static
|
search |
Search for
ParticleSystem in children
|
|
simulation |
||
useLocalPosition | ||
useLocalRotation | ||
VelocityDataId | RigidbodyVelocity |
Rigidbody.velocity id to persist in the TimeStone
static
|
Properties
Name | Value | Summary |
---|---|---|
IsClone | bool |
Is this instance a clone used for simulation
|
onInitTimeAgentsList | TimeAgent |
|
onPersistTick | TimeAgent |
|
onSetDataTick | TimeAgent |
|
onSimulationComplete | TimeAgent |
|
on |
TimeAgent |
|
on |
TimeAgent |
|
onSimulationStart | TimeAgent |
|
onSimulationUpdate | TimeAgent |
|
onTimeLineChange | TimeAgent |
|
Original | TimeAgent | |
SimulationClone | TimeAgent |
If this instance is the original TimeAgent, SimulationClone is a reference to the clone used in simulations by the stone
|
Methods
Name | Value | Summary |
---|---|---|
Apply |
void |
Applies the data cached on simulation initialization
|
Awake |
void | |
Cache |
void |
Cache initialization data from the Original object to apply them on the cloned Simulation object when Simulation starts
|
ClonedForSimulation |
void |
ClonedForSimulation callback called by timeStone
|
GetClone |
GameObject |
Cloning method called by the TimeStone when creating a simulation scene.
You can override it to modify the way the object is cloned.
|
InitTimeAgentsList |
void |
InitTimeAgentsList callback called by timeStone
|
Persist |
void |
Perists GameObject's data
|
PersistRigidbodyData |
void |
Persists Rigidbody's data
|
PersistTick |
void |
PersistTick callback called by the stone when it persist TimeAgents state for a tick.
This is the callback where you store custom data of your gameObject.
|
PersistTransformData |
void |
Persists Transform's data
|
SetDataTick |
void |
SetDataTick callback called by the stone when it applies a tick's state to TimeAgents
This is the callback where you apply your custom data of your gameObject.
|
SetDataTime |
void |
Set data from the stone but using time
|
SimulationComplete |
void |
SimulationComplete callback called by timeStone
|
Simulation |
void |
SimulationUpdate callback called by timeStone
|
SimulationLateUpdate |
void |
SimulationLateUpdate callback called by timeStone
|
SimulationSceneReady |
void |
SimulationSceneReady callback called by timeStone
|
SimulationStart |
void |
SimulationStart callback called by timeStone
|
SimulationUpdate |
void |
SimulationUpdate callback called by timeStone.
|
TimeLineChange |
void |
TimeLineChange callback called by timeStone
|