mirror of
https://github.com/motajs/template.git
synced 2026-11-24 06:34:30 +08:00
feat(event): complete phase one event system
This commit is contained in:
1 parent
b9213ddf22
commit
a297311ea6
51 files changed
+3261
-1114
No files matched your search
@@ -0,0 +1,3 @@
|
||||
export * from './executor';
|
||||
export * from './system';
|
||||
export * from './types';
|
||||
@@ -0,0 +1,23 @@
|
||||
import { IStateBase } from '@user/data-base';
|
||||
import { IGameEventStore } from '@user/data-common';
|
||||
import { AnonTokyoInterpreter } from 'anon-tokyo';
|
||||
import { EventExecutor } from './executor';
|
||||
import { IGameEventExecutor, IGameEventSystem } from './types';
|
||||
|
||||
export class GameEventSystem implements IGameEventSystem {
|
||||
readonly executor: IGameEventExecutor;
|
||||
store: IGameEventStore | null;
|
||||
|
||||
constructor(readonly state: IStateBase) {
|
||||
this.store = state.eventStore;
|
||||
const interpreter = new AnonTokyoInterpreter({
|
||||
builtInFunctions: [],
|
||||
globalFunctions: []
|
||||
});
|
||||
this.executor = new EventExecutor(interpreter, () => this.store);
|
||||
}
|
||||
|
||||
useStore(store: IGameEventStore | null): void {
|
||||
this.store = store;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user