#ifndef GAME_H #define GAME_H #include "host.h" struct world; struct mixer_startup_receipt; struct sprite_startup_receipt; struct sound_startup_receipt; struct phys_startup_receipt; struct host_startup_receipt; /* Absolute layers */ #define GAME_LAYER_FLOOR_DECALS -300 #define GAME_LAYER_BULLETS -200 #define GAME_LAYER_TRACERS -100 #define GAME_LAYER_SHOULDERS 0 /* Relative layers */ #define GAME_LAYER_RELATIVE_DEFAULT 0 #define GAME_LAYER_RELATIVE_WEAPON 1 struct game_startup_receipt { i32 _; }; struct game_startup_receipt game_startup(struct mixer_startup_receipt *mixer_sr, struct sprite_startup_receipt *sheet_sr, struct sound_startup_receipt *sound_sr, struct phys_startup_receipt *phys_sr, struct host_startup_receipt *host_sr); /* ========================== * * Game cmd * ========================== */ enum game_cmd_state { GAME_CMD_STATE_STOP = -1, GAME_CMD_STATE_NO_CHANGE = 0, GAME_CMD_STATE_START = 1 }; enum game_cmd_kind { GAME_CMD_KIND_NONE, GAME_CMD_KIND_PLAYER_MOVE, GAME_CMD_KIND_PLAYER_FIRE, GAME_CMD_KIND_CLIENT_CONNECT, GAME_CMD_KIND_CLIENT_DISCONNECT, /* Testing */ GAME_CMD_KIND_CLEAR_ALL, GAME_CMD_KIND_SPAWN_TEST, GAME_CMD_KIND_PAUSE, GAME_CMD_KIND_STEP, GAME_CMD_KIND_DRAG_OBJECT, GAME_CMD_KIND_CURSOR_MOVE, GAME_CMD_KIND_COUNT }; struct game_cmd { enum game_cmd_kind kind; enum game_cmd_state state; struct host_channel_id channel_id; /* GAME_CMD_KIND_PLAYER_MOVE */ struct v2 move_dir; struct v2 aim_dir; /* GAME_CMD_KIND_CURSOR_MOVE */ struct v2 cursor_pos; /* GAME_CMD_KIND_PLAYER_DISCONNECT */ struct string disconnect_reason; #if RTC u32 collider_gjk_steps; #endif struct game_cmd *next; }; struct game_cmd_list { struct game_cmd *first; struct game_cmd *last; }; struct string game_string_from_cmds(struct arena *arena, struct game_cmd_list cmds); void game_cmds_from_host_events(struct arena *arena, struct host_event_array host_events, struct game_cmd_list *cmds_out); /* ========================== * * Game event * ========================== */ enum game_event_kind { GAME_EVENT_KIND_NONE, GAME_EVENT_KIND_CONNECT, GAME_EVENT_KIND_DISCONNECT, GAME_EVENT_KIND_SNAPSHOT_FULL, //GAME_EVENT_KIND_ENTITY_UPDATE, //GAME_EVENT_KIND_ENTITY_CREATE, //GAME_EVENT_KIND_ENTITY_DESTROY }; struct game_event { enum game_event_kind kind; struct host_channel_id channel_id; struct string snapshot_data; struct string disconnect_reason; //struct entity_handle entity; //struct string update_data; struct game_event *next; }; struct game_event_list { struct game_event *first; struct game_event *last; }; struct string game_string_from_events(struct arena *arena, struct game_event_list events); void game_events_from_host_events(struct arena *arena, struct host_event_array host_events, struct game_event_list *events_out); /* ========================== * * Snapshot * ========================== */ struct string game_string_from_tick(struct arena *arena, struct world *tick); void game_tick_from_string(struct string str, struct world *tick_out); #endif