Available Callbacks
General
void Main()- called once when the plugin is loaded, enabled or reloaded.void OnDisabled()- called when the plugin is disabled, removed or the game is closing.void Render()- called on every game frame. You can use this function to render standalone UI windows. To determine how much time has passed since the last frame, useTime::Now.void OnGameStateChanged(TM::GameState state)- called when the game state changes.-
void OnCommandListChanged(CommandList@ prev, CommandList@ current, CommandListChangeReason reason)- called when current the command list changes. The callback provides the previous and new command list, as well as the reason for the change. You may hold a reference to the current command list if needed, but it is recommended that you reset the handle as soon as possible to avoid TMInterface from keeping the list in memory when it unloads.If a new command list was loaded, the
currentparameter will contain the new command list. You can then get the filename as well as the content of the list. A plugin can decide to do additional processing on the list. In this case, the plugin can set a new command list as the current one by using SetCurrentCommandList function. If the set call is made directly in the callback, you must prevent infinite recursion by saving state in the plugin and checking it when you get another callback. It is recommended to callSetCurrentCommandListoutside of the function, for example in theRendercallback.The
currentlist may not be associated with any file (filename will be an empty string). In this case, the command list was created in the event of loading inputs from a validated replay or executing a timed command directly in the console without any input file being loaded. If the list is being cloned by the plugin, the new command list should be created accordingly (call empty constructor if the filename is empty and the path constructor otherwise).The
currentlist will not be parsed yet at the time of the callback. To force parsing, call theProcessmethod on thecurrentlist with theOnlyParseoption in the callback. PluginInfo@ GetPluginInfo()- called beforeMain(), this function should only return aPluginInfoobject with information about the plugin. Any init logic should be contained within theMain()function, and not in this function. This function is required to be implemented.
Race
void OnRunStep(SimulationManager@ simManager)- called on every race step (when in normal race). Note thatOnRunStepwill be called before the race begins (simManager.RaceTime < 0) and after it ends (simManager.TickTime > simManager.RaceTime).
Simulation
void OnSimulationBegin(SimulationManager@ simManager)- called when the simulation begins (when clicking the Validate button in the Replays menu).void OnSimulationStep(SimulationManager@ simManager, bool userCancelled)- called on every simulation step.userCancelledswitches to true and if the user cancelled the simulation. The value stays true until the nextOnSimulationBegincall.void OnSimulationEnd(SimulationManager@ simManager, SimulationResult result)- called when the simulation ends (that matches theOnSimulationBegincall).
Race & simulation events
-
void OnCheckpointCountChanged(SimulationManager@ simManager, int current, int target)- called when a new checkpoint is passed. InspectsimManager.PlayerInfo.CheckpointStatesto get which checkpoint has been just passed. While the conditioncurrent == targetcan be used to determine if the race has finished, it is recommended to evaluatesimManager.PlayerInfo.RaceFinishedinstead. -
void OnLapCountChanged(SimulationManager@ simManager, int current, int target)- called when a new lap is passed.