import type { NodeDef } from '../../NodeRegistry'; import { asBoolean, asEntity } from '../../values'; import { bool, exec, obj, withDefault } from '../shared'; export const SetEnabled: NodeDef = { type: 'SetEnabled', label: 'Set enabled', category: 'action', description: 'Switches an object on or off. A disabled object is not drawn, does not collide and its behavior stops – ' + 'and so does everything parented below it. This is how screens (title, win, lose) are shown and hidden.', inputs: [exec(), obj('object'), withDefault(bool('enabled'), true)], outputs: [exec()], params: [], run: (_ctx, inputs) => { const target = asEntity(inputs.object); if (target) target.props.enabled = asBoolean(inputs.enabled); return { next: 'exec' }; }, };