136 lines
3.3 KiB
C
136 lines
3.3 KiB
C
#ifndef SIM_H
|
|
#define SIM_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 SIM_LAYER_FLOOR_DECALS -300
|
|
#define SIM_LAYER_BULLETS -200
|
|
#define SIM_LAYER_TRACERS -100
|
|
#define SIM_LAYER_SHOULDERS 0
|
|
|
|
/* Relative layers */
|
|
#define SIM_LAYER_RELATIVE_DEFAULT 0
|
|
#define SIM_LAYER_RELATIVE_WEAPON 1
|
|
|
|
struct sim_startup_receipt { i32 _; };
|
|
struct sim_startup_receipt sim_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);
|
|
|
|
|
|
/* ========================== *
|
|
* Sim cmd
|
|
* ========================== */
|
|
|
|
enum sim_cmd_state {
|
|
SIM_CMD_STATE_STOP = -1,
|
|
SIM_CMD_STATE_NO_CHANGE = 0,
|
|
SIM_CMD_STATE_START = 1
|
|
};
|
|
|
|
enum sim_cmd_kind {
|
|
SIM_CMD_KIND_NONE,
|
|
|
|
SIM_CMD_KIND_PLAYER_MOVE,
|
|
SIM_CMD_KIND_PLAYER_FIRE,
|
|
|
|
SIM_CMD_KIND_SIM_CLIENT_CONNECT,
|
|
SIM_CMD_KIND_SIM_CLIENT_DISCONNECT,
|
|
|
|
/* Testing */
|
|
SIM_CMD_KIND_CLEAR_ALL,
|
|
SIM_CMD_KIND_SPAWN_TEST,
|
|
SIM_CMD_KIND_PAUSE,
|
|
SIM_CMD_KIND_STEP,
|
|
SIM_CMD_KIND_DRAG_OBJECT,
|
|
SIM_CMD_KIND_CURSOR_MOVE,
|
|
|
|
SIM_CMD_KIND_COUNT
|
|
};
|
|
|
|
struct sim_cmd {
|
|
enum sim_cmd_kind kind;
|
|
enum sim_cmd_state state;
|
|
struct host_channel_id channel_id;
|
|
|
|
/* SIM_CMD_KIND_PLAYER_MOVE */
|
|
struct v2 move_dir;
|
|
struct v2 aim_dir;
|
|
|
|
/* SIM_CMD_KIND_CURSOR_MOVE */
|
|
struct v2 cursor_pos;
|
|
|
|
/* SIM_CMD_KIND_PLAYER_DISCONNECT */
|
|
struct string disconnect_reason;
|
|
|
|
#if RTC
|
|
u32 collider_gjk_steps;
|
|
#endif
|
|
|
|
struct sim_cmd *next;
|
|
};
|
|
|
|
struct sim_cmd_list {
|
|
struct sim_cmd *first;
|
|
struct sim_cmd *last;
|
|
};
|
|
|
|
struct string sim_string_from_cmds(struct arena *arena, struct sim_cmd_list cmds);
|
|
void sim_cmds_from_host_events(struct arena *arena, struct host_event_array host_events, struct sim_cmd_list *cmds_out);
|
|
|
|
/* ========================== *
|
|
* Sim event
|
|
* ========================== */
|
|
|
|
enum sim_event_kind {
|
|
SIM_EVENT_KIND_NONE,
|
|
|
|
SIM_EVENT_KIND_CONNECT,
|
|
SIM_EVENT_KIND_DISCONNECT,
|
|
SIM_EVENT_KIND_SNAPSHOT_FULL,
|
|
|
|
//SIM_EVENT_KIND_ENTITY_UPDATE,
|
|
//SIM_EVENT_KIND_ENTITY_CREATE,
|
|
//SIM_EVENT_KIND_ENTITY_DESTROY
|
|
};
|
|
|
|
struct sim_event {
|
|
enum sim_event_kind kind;
|
|
struct host_channel_id channel_id;
|
|
|
|
struct string snapshot_data;
|
|
struct string disconnect_reason;
|
|
|
|
//struct sim_ent_handle entity;
|
|
//struct string update_data;
|
|
|
|
struct sim_event *next;
|
|
};
|
|
|
|
struct sim_event_list {
|
|
struct sim_event *first;
|
|
struct sim_event *last;
|
|
};
|
|
|
|
struct string sim_string_from_events(struct arena *arena, struct sim_event_list events);
|
|
void sim_events_from_host_events(struct arena *arena, struct host_event_array host_events, struct sim_event_list *events_out);
|
|
|
|
/* ========================== *
|
|
* Snapshot
|
|
* ========================== */
|
|
|
|
struct string sim_string_from_tick(struct arena *arena, struct world *tick);
|
|
void sim_tick_from_string(struct string str, struct world *tick_out);
|
|
|
|
#endif
|