TimeAgent Class

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 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.

Namespace
RedGirafeGames.Agamotto.Scripts.Runtime.Agents
Base Types
  • MonoBehaviour
Derived Types
graph BT Type-->Base0["MonoBehaviour"] Type["TimeAgent"] class Type type-node Derived0["GenericTimeAgent"]-->Type click Derived0 "/api/RedGirafeGames.Agamotto.Scripts.Runtime.Agents/GenericTimeAgent"

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
AngularVelocityDataId RigidbodyAngularVelocity
Rigidbody.angularVelocity id to persist in the TimeStone
static
AnimatorStateHashDataId Animator#StateHash
Animator's state hash where DataIdUidToken is replaced with a unique identifier using GetUniqueDataId(string, int)
static
AnimatorStateInTransitionDataId Animator#InTransition
Animator's state transition status where DataIdUidToken is replaced with a unique identifier using GetUniqueDataId(string, int)
static
AnimatorStateLayerWeightDataId Animator#LayerWeight
Animator's state layer weight where DataIdUidToken is replaced with a unique identifier using GetUniqueDataId(string, int)
static
AnimatorStateNormalizedTimeDataId Animator#StateNormalizedTime
Animator state normalized time where DataIdUidToken is replaced with the layer num using GetAnimatorDataIdWithLayer
static
AnimatorTransitionDurationDataId Animator#TransitionDuration
Animator's transition duration where DataIdUidToken is replaced with a unique identifier using GetUniqueDataId(string, int)
static
AnimatorTransitionNextHashDataId Animator#TransitionNextHash
Animator's transition next hash where DataIdUidToken is replaced with a unique identifier using GetUniqueDataId(string, int)
static
AnimatorTransitionNextNormalizedTimeDataId Animator#TransitionNextNormalizedTime
Animator's transition next normalized time where DataIdUidToken is replaced with a unique identifier using GetUniqueDataId(string, int)
static
AnimatorTransitionNormalizedTimeDataId 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
applySimulationConfigOnChildren
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
ParticleSystemParticlesDataId ParticleSystem#Particles
ParticleSystem particles where DataIdUidToken is replaced with a unique identifier using GetParticleSystemUniqueDataId
static
ParticleSystemPlaybackStateDataId ParticleSystem#PlaybackState
ParticleSystem playback state where DataIdUidToken is replaced with a unique identifier using GetParticleSystemUniqueDataId
static
ParticleSystemTrailsDataId 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
persistAnimatorTransitions
Persist Animator's transitions between states.
persistParticles
Persist TimeAgent's particle systems in TimeStone
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
Persist Rigidbody.velocity and Rigidbody.angularVelocity in TimeStone
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
searchParticleChildren
Search for ParticleSystem in children
simulationCallbackPolicy
The simulation events receive policy. In most of the cases, original time agents won't have any use of these events, so setting the policy to CloneOnly there is no need in the code to check for IsClone
useLocalPosition
useLocalRotation
VelocityDataId RigidbodyVelocity
Rigidbody.velocity id to persist in the TimeStone
static

Properties

Methods

Name Value Summary
ApplyCachedInitDataOnClone() void
Applies the data cached on simulation initialization
Awake() void
CacheInitDataFromOriginal() void
Cache initialization data from the Original object to apply them on the cloned Simulation object when Simulation starts
ClonedForSimulation(TimeStone) 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(TimeStone) void
InitTimeAgentsList callback called by timeStone
PersistGameObjectState(TimeStone, TimeStone.TimeTickOrigin, float) void
Perists GameObject's data
PersistRigidbodyData(TimeStone, TimeStone.TimeTickOrigin, float) void
Persists Rigidbody's data
PersistTick(TimeStone, TimeStone.TimeTickOrigin, float) 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(TimeStone, TimeStone.TimeTickOrigin, float) void
Persists Transform's data
SetDataTick(TimeStone, int) 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(TimeStone, float) void
Set data from the stone but using time
SimulationComplete(TimeStone) void
SimulationComplete callback called by timeStone
SimulationFixedUpdate(float, TimeStone) void
SimulationUpdate callback called by timeStone
SimulationLateUpdate(float, TimeStone) void
SimulationLateUpdate callback called by timeStone
SimulationSceneReady(TimeStone) void
SimulationSceneReady callback called by timeStone
SimulationStart(TimeStone) void
SimulationStart callback called by timeStone
SimulationUpdate(float, TimeStone) void
SimulationUpdate callback called by timeStone.
TimeLineChange(TimeStone, TimeStone.TimeTickOrigin) void
TimeLineChange callback called by timeStone