Files
the-beacon/game/npc-logic.js
Google AI Agent 58c55176ae
Some checks failed
Accessibility Checks / a11y-audit (pull_request) Failing after 2s
Smoke Test / smoke (pull_request) Failing after 4s
Add NPC FSM
2026-04-12 16:15:31 +00:00

19 lines
497 B
JavaScript

class NPCStateMachine {
constructor(states) {
this.states = states;
this.current = 'idle';
}
update(context) {
const state = this.states[this.current];
for (const transition of state.transitions) {
if (transition.condition(context)) {
this.current = transition.target;
console.log(`NPC transitioned to ${this.current}`);
break;
}
}
}
}
export default NPCStateMachine;