aboutsummaryrefslogtreecommitdiff
path: root/static/src/event.ts
diff options
context:
space:
mode:
Diffstat (limited to 'static/src/event.ts')
-rw-r--r--static/src/event.ts28
1 files changed, 28 insertions, 0 deletions
diff --git a/static/src/event.ts b/static/src/event.ts
new file mode 100644
index 0000000..cd50122
--- /dev/null
+++ b/static/src/event.ts
@@ -0,0 +1,28 @@
+export enum EventType {
+ INITIAL_STATE = "INITIAL_STATE",
+ SET_CONTROLLABLE = "SET_CONTROLLABLE",
+ ENTITY_BORN = "ENTITY_BORN",
+ ENTITY_DEATH = "ENTITY_DEATH",
+ ENTITY_POSITION_UPDATE = "ENTITY_POSITION_UPDATE",
+}
+
+export interface Event {
+ event_type: EventType;
+ data: any;
+}
+
+export interface InitialStateEvent extends Event {
+ event_type: EventType.INITIAL_STATE;
+ data: {
+ world: { width: number; height: number };
+ entities: any[];
+ };
+}
+
+export interface SetControllableEvent extends Event {
+ event_type: EventType.SET_CONTROLLABLE;
+ data: {
+ id: string;
+ client_id: string;
+ };
+}