-
Notifications
You must be signed in to change notification settings - Fork 0
Game Ticks
Tianyi Ma edited this page Jul 27, 2017
·
5 revisions
The game thread handles timing of game ticks and is in charge of triggering the game_tick
event. Ticks are timed to occur every 500±1ms. At the start of each tick, the game thread will attempt to execute and clear the action queue, then trigger the game_tick
event. Game logic should ideally populate the action queue instead of executing the action directly.
Scripts can hook the game_tick
event by registering a Trigger.
// Writing your own Trigger
var Trigger = Java.type('com.worldstone.worldengine.trigger.Trigger');
var MyGameTickTrigger = Java.extend(Trigger, {
resolve: function(attributes) {
print(attributes);
}
});
// Register MyTrigger with the TriggerController
var TriggerController = Java.type('com.worldstone.worldengine.trigger.TriggerController');
TriggerController.registerTrigger(new MyGameTickTrigger('my_game_tick_trigger', 'game_tick'));