Created
January 21, 2020 03:44
-
-
Save msg555/c4c7fe81cfcb344b5c13297e291c484f to your computer and use it in GitHub Desktop.
Sample script using the subframe callback API.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class script : callback_base { | |
scene@ g; | |
array<dustman@> players; | |
script() { | |
@g = get_scene(); | |
} | |
void step(int num_entities) { | |
int nc = num_cameras(); | |
puts("STEP"); | |
players.resize(nc); | |
for (int i = 0; i < nc; i++) { | |
dustman@ dm = @controller_entity(i).as_dustman(); | |
if (@dm != null && !dm.is_same(@players[i])) { | |
puts("REGISTER CALLBACK"); | |
dm.on_subframe_end_callback(this, "subframe_cb", i); | |
} | |
@players[i] = @dm; | |
} | |
} | |
void subframe_cb(dustman@ dm, int player_index) { | |
puts("SUBSTEP " + player_index); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment