add entity start on play

This commit is contained in:
John Alanbrook 2024-08-29 16:55:01 -05:00
parent dc25e23aa8
commit 2c1f34177b
2 changed files with 10 additions and 2 deletions

View file

@ -201,10 +201,12 @@ var entity = {
check_registers(ent);
if (ent.load instanceof Function) ent.load();
if (sim.playing())
if (sim.playing()) {
ent._started = true;
if (ent.start instanceof Function) ent.start();
}
Object.hide(ent, 'ur', 'components', 'objects', 'timers', 'guid', 'master');
Object.hide(ent, 'ur', 'components', 'objects', 'timers', 'guid', 'master', 'guid');
ent._ed = {
selectable: true,

View file

@ -28,6 +28,12 @@ sim.mode = "play";
sim.play = function () {
this.mode = "play";
os.reindex_static();
game.all_objects(o => {
if (!o._started) {
o._started = true;
o.start?.();
}
});
};
sim.playing = function () {
return this.mode === "play";