TimeStone Class


The heart (or the eye...) of Agamotto!

The TimeStone is managing data though time for its TimeAgent list

The TimeStone can record to keep past data or run simulation to generate future data

The TimeStone can also playback its data on its TimeAgent list

Base Types
  • MonoBehaviour
graph BT Type-->Base0["MonoBehaviour"] Type["TimeStone"] class Type type-node


[AddComponentMenu("Agamotto/Time Stone")]
public class TimeStone : MonoBehaviour


You can have multiple stones in the scene

Use classes derived from AbstractTimeVisualizer to visualize TimeStone's data


Type Description


Name Constant Value Summary

The current tick index used by the stone to add new data.

If new data are generated by record or simulation, they will be added from this index in the timeLine.

You can get corresponding time using GetTimeAtTickIndex(int)

Current simulated frame time stack
Keeps the scene created for the last simulation alive. Otherwise, the scene is destroyed when the simulation end. A new scene is created for each simulation, even if this property is true
Activates log messages (except performances messages)
Activates performances messages
Is the stone's playback active.
The playback's speed

The current tick index used to playback the TimeLine.

It is also useful to use with a TimeSlider to control what index of the TimeLine to display

You can get corresponding time using GetTimeAtTickIndex(int)

The time scale used to playback stone's data
If true, using playback will update the addTickCursor so that it's synchronized with the playbackTickCursor. As a result, if you start recording or make a simulation after a playback, it will start where you stopped it.
The maximum record duration. If the TimeLine's duration is higher than this value during recording, oldest data are removed when adding new ones
Minimum delta time between record data, 0 or less will record on each Update() call (which while giving you great precision, will greatly impact performances)
The timescale used during recording
Activates recording on Start() If simulateOnStart is true, recordOnStart has no effect (because starting a simulation stops recording)
The time since current recording started.
If true, the addTickCursor will be placed at the simulation start tick when simulation ends.
A simulation is automatically started on TimeAgent
Should the simulations run the physics simulation on time agents
Should the simulations execute the TimeAgents simulation life cycle callbacks (SimulationUpdate, SimulationComplete, etc.)
The simulation maximum duration if simulationHasDuration is true.
If simulationSpeed is higher than 1.0, every simulation tick that should be made during a single frame will be grouped into one (with adapted delta time). This option makes the simulation faster but lowers the precision.
Defines if the simulation has a maximum duration. If not defined, simulation must be stopped using StopSimulation().
The maximum number of milliseconds consumed by the simulation every frame. The property let you limit the impact of the simulation on the framerate.
The physics scene of the simulationScene
If simulationUseUnityFixedDeltaTime is false, defines the step physics simulation uses
The scene created for the simulation. A new one is created everytime
The simulation speed. Example : Value of 2.0 will run the simulation twice as fast as real time

This value can be limited by simulationMaxMsByFrame

The tick index when current simulation started
The time since the current simulation started
The list of simulation time agents generated when CreateSimulationScene() is called.
The time scale used to execute the simulation
Delta time used during a simulation between frames if simulationUseUpdateDeltaTime is false
Simulation will use Time.fixedDeltaTime for physics simulation's step
Simulation execution will use Time.deltaTime or Time.unscaledDeltaTime. If simulationSpeed is higher than 1.0, every simulation tick during a frame will use the same deltaTime. If false, Simulation uses simulationUpdateStep;
The final list of time agents used by the stone. If you manage your TimeAgents manually, you can't add them directly in this list for simulations. You have to add them in timeAgentsManualInitList and then call onInitTimeAgentsList or use StartSimulation(bool) with the right parameter to initialize simulation agents
The layer's name used if the initialization mode is Layer
The initialization mode for the Time Agents.
The tag used if the initialization mode is Tag
The initialization list of the time agent. Different from the final time agent list because if parseChildren is activated, new time agents will be added.
The list of time agents, but without the children searched recursively if parseChildren is true on some TimeAgents.
The TimeLine holding the time agents data over time.
The selected behaviour on time line modification
If true, the playbackTickCursor is synchronized with the recording state, so that when recording is stopped, the timeline is synchronized with the time agents states


Name Value Summary
onInitTimeAgentsList TimeStone.OnInitTimeAgentsListEvent
UnityEvent when stone has initialized its TimeAgent list with its initialization mode. This is the good event to use to initialize things if the stone is making record and simulation as it is called in both cases.
onRecordStart TimeStone.OnRecordStartEvent
UnityEvent when record starts
onRecordStop TimeStone.OnRecordStopEvent
UnityEvent when record stops
onSimulationComplete TimeStone.OnSimulationCompleteEvent
UnityEvent when simulation is complete
onSimulationSceneReady TimeStone.OnSimulationSceneReadyEvent
UnityEvent when the scene for the simulation is created and the time agents cloned
onSimulationStart TimeStone.OnSimulationStartEvent
UnityEvent when the simulation is starting to simulate
onTimeLineChange TimeStone.OnTimeLineChangeEvent
UnityEvent when timeLine is modified. For recording, this is called on every recorded tick. For simulation, this is called on every frame (multiples ticks simulated on the same frame don't trigger).
onTimeLineClear TimeStone.OnTimeLineClearEvent
UnityEvent when the TimeLine is cleared by calling Clear()
Recording bool
Is the stone recording. Use StartRecording() and StopRecording() to modify
Simulating bool
Is the stone simulating. Use StartSimulation(bool) and StopSimulation() to modify
SimulationComplete bool
Flag when simulation is complete


Name Value Summary
CleanTimeAgentsList() void
Remove eventual destroyed agents from the lists
Clear() void
Clear the timeLine's data (not its time agents)
ClearTimeAgentsList() void
Clears the time agents lists
FreezeTimeAgents(bool) void
Changes freeze state of timeAgents using PhysicsAutoSimulation for the physics.
FreezeTimeAgents(bool, TimeUtils.RigidbodyFreezeType) void
Changes freeze state of timeAgents using given physics freeze type
GetData<T>(string, bool) TimeLine.TimeData<T>
Get TimeData at the current played tick
GetDataAt<T>(int, TimeAgent, string, bool) TimeLine.TimeData<T>
Get TimeData at the given tick index
GetDataAtTime<T>(float, TimeAgent, string) TimeLine.TimeData<T>
Get the TimeData at the given Time
GetDataValue<T>(string, bool) T
Get TimeData Value at the current played tick
GetDataValueAt<T>(int, TimeAgent, string, bool) T
Get TimeData Value at the given tick index
GetPlaybackTime() float
Get playback's time, corresponding to current playbackTickCursor using GetTimeAtTickIndex(int)
GetTickCount() int
Get the number of ticks in the timeLine
GetTickIndexAtTime(float) int
Get the tick index at given time (in seconds). The result is an approximation, the closest tick corresponding to this time is returned. Therefore this method always returns an index, even if time does not exist in the timeLine
GetTimeAtTickIndex(int) float
Get the time (in seconds) corresponding to the tick index. If tick index does not exist in the timeLine then returns 0
GetTimeLineDuration() float
Get the timeLine duration (in seconds)
HasTimeAgent(TimeAgent) bool
Returns if the stone handles the timeAgent. This method does not check the timeAgent's state (active/inactive). TimeAgent are distinguished by the stone using their guid
InitSimulation(bool) void
Initialize the simulation data : scene, clone agents, etc.
InitTimeAgentsList() void
Initializes the time agent list using the defined mode
PersistData<T>(string, T) void
Persist data in the TimeStone's TimeLine using current persisted tick TimeAgent, TimeTickOrigin and DeltaTime.
PersistData<T>(TimeAgent, TimeStone.TimeTickOrigin, float, string, T) void
Persist timeAgent's data in the TimeStone's TimeLine.
PersistTick(TimeStone.TimeTickOrigin, float) void
Persist current tick
RemoveData(int, int) void
Remove timeLine's data from the stone. Cursors playbackTickCursor and addTickCursor are updates in consequence.
SetPlaybackTick(int, bool) void
Updates Time Agents with the TimeLine's data at tickIndex.
SetPlaybackTime(float, bool) void
Set playback time. Playback is based on playbackTickCursor, so the tick index value is deducted using GetTickIndexAtTime(float)
StartPlayback() void
Starts playback.

Playback is applying TimeLine's data to stone's timeAgents respecting the timing, it uses SetPlaybackTick(int, bool)

You can control the speed of the playback with playbackSpeed

You can stop playback using StopPlayback()

You can control if the playback synchronizes the addTickCursor with playbackUpdateAddTickCursor, with this option, you can start recording or simulating right after you stop playback and old and new data will be synchronized

StartRecording() void
Starts recording
StartSimulation(bool) void
Starts a new simulation. The simulation will really start to execute on next frame.
StopPlayback() void
Stops playback
StopRecording() void
Stops recording
StopSimulation() void
Stops running simulation