Behavior lifecycle: On enable, On disable and On destroy events (#42)
game-maker / suite (push) Successful in 7m29s
game-maker / suite (push) Successful in 7m29s
Order per instance: On start -> On enable -> On update ... -> On disable -> On destroy. On enable fires right after On start and whenever the behavior comes back on (itself and its parents); On disable in the frame it goes off, the instance stays frozen. On destroy fires when the entity leaves the world (Destroy node, child of a destroyed object) and when the world is torn down on stop/restart, preceded by On disable if still on. A new On start node added while playing still does not fire for a running instance (kept as is, documented in the wiki). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
f0673d1957
commit
6141d07d4f
8 files changed
+203
-8
No files matched your search
@@ -0,0 +1,12 @@
|
||||
import type { NodeDef } from '../../NodeRegistry';
|
||||
import { exec } from '../shared';
|
||||
|
||||
export const OnDestroy: NodeDef = {
|
||||
type: 'OnDestroy',
|
||||
label: 'On destroy',
|
||||
category: 'event',
|
||||
description: 'Runs once when the object is destroyed – also when the game stops or restarts.',
|
||||
inputs: [],
|
||||
outputs: [exec()],
|
||||
params: [],
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
import type { NodeDef } from '../../NodeRegistry';
|
||||
import { exec } from '../shared';
|
||||
|
||||
export const OnDisable: NodeDef = {
|
||||
type: 'OnDisable',
|
||||
label: 'On disable',
|
||||
category: 'event',
|
||||
description: 'Runs when the behavior is switched off (itself or a parent), and before On destroy.',
|
||||
inputs: [],
|
||||
outputs: [exec()],
|
||||
params: [],
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
import type { NodeDef } from '../../NodeRegistry';
|
||||
import { exec } from '../shared';
|
||||
|
||||
export const OnEnable: NodeDef = {
|
||||
type: 'OnEnable',
|
||||
label: 'On enable',
|
||||
category: 'event',
|
||||
description: 'Runs right after On start, and again each time the behavior is switched back on.',
|
||||
inputs: [],
|
||||
outputs: [exec()],
|
||||
params: [],
|
||||
};
|
||||
@@ -71,6 +71,9 @@ import { OnClick } from './events/OnClick';
|
||||
import { OnCollisionEnter } from './events/OnCollisionEnter';
|
||||
import { OnCollisionExit } from './events/OnCollisionExit';
|
||||
import { OnCollisionStay } from './events/OnCollisionStay';
|
||||
import { OnDestroy } from './events/OnDestroy';
|
||||
import { OnDisable } from './events/OnDisable';
|
||||
import { OnEnable } from './events/OnEnable';
|
||||
import { OnKeyDown } from './events/OnKeyDown';
|
||||
import { OnKeyHeld } from './events/OnKeyHeld';
|
||||
import { OnKeyUp } from './events/OnKeyUp';
|
||||
@@ -94,7 +97,10 @@ import { Variables } from './variable/Variables';
|
||||
*/
|
||||
export const BUILT_IN_NODES: readonly NodeDef[] = [
|
||||
OnStart,
|
||||
OnEnable,
|
||||
OnUpdate,
|
||||
OnDisable,
|
||||
OnDestroy,
|
||||
OnKeyDown,
|
||||
OnKeyUp,
|
||||
OnKeyHeld,
|
||||
|
||||
Reference in new issue
Block a user