2021-05-05 09:25:05 +00:00
|
|
|
#pragma once
|
|
|
|
#include "system.h"
|
|
|
|
|
|
|
|
#define ZPL_PICO
|
|
|
|
#include "zpl.h"
|
|
|
|
|
2021-05-06 18:24:01 +00:00
|
|
|
typedef enum {
|
2021-05-09 10:27:10 +00:00
|
|
|
EKIND_PLAYER = 0,
|
2021-05-08 09:05:15 +00:00
|
|
|
EKIND_THING,
|
2021-05-06 18:24:01 +00:00
|
|
|
EKIND_CHUNK,
|
|
|
|
FORCE_EKIND_UINT16 = UINT16_MAX
|
|
|
|
} entity_kind;
|
|
|
|
|
2021-05-09 10:27:10 +00:00
|
|
|
typedef enum {
|
|
|
|
EFLAG_INTERP = (1 << 0),
|
|
|
|
FORCE_EFLAG_UINT16 = UINT16_MAX
|
|
|
|
} entity_flag;
|
|
|
|
|
2021-05-09 22:40:25 +00:00
|
|
|
typedef enum {
|
|
|
|
ETRAN_NONE,
|
|
|
|
ETRAN_FADEOUT,
|
|
|
|
ETRAN_FADEIN,
|
|
|
|
ETRAN_REMOVE,
|
|
|
|
FORCE_ETRAN_UINT8 = UINT8_MAX
|
|
|
|
} entity_transition_effect;
|
|
|
|
|
2021-05-05 09:25:05 +00:00
|
|
|
typedef struct entity_view {
|
2021-05-09 22:40:25 +00:00
|
|
|
int64_t ent_id;
|
2021-05-06 18:24:01 +00:00
|
|
|
entity_kind kind;
|
2021-05-09 10:27:10 +00:00
|
|
|
entity_flag flag;
|
2021-05-08 15:42:47 +00:00
|
|
|
float x;
|
|
|
|
float y;
|
2021-05-09 10:27:10 +00:00
|
|
|
float vx;
|
|
|
|
float vy;
|
|
|
|
float tx;
|
|
|
|
float ty;
|
2021-05-09 13:52:46 +00:00
|
|
|
|
2021-07-18 11:23:59 +00:00
|
|
|
// TODO(zaklaus): Find a way to stream dynamic arrays
|
|
|
|
uint8_t blocks_used;
|
|
|
|
uint8_t blocks[256];
|
2021-07-27 11:30:43 +00:00
|
|
|
uint32_t color;
|
|
|
|
uint8_t is_dirty;
|
2021-07-18 18:30:27 +00:00
|
|
|
int64_t tex;
|
2021-07-18 11:23:59 +00:00
|
|
|
|
2021-05-09 13:52:46 +00:00
|
|
|
// NOTE(zaklaus): internals
|
|
|
|
uint8_t layer_id;
|
2021-05-09 14:41:19 +00:00
|
|
|
uint64_t last_update;
|
2021-05-09 22:40:25 +00:00
|
|
|
|
|
|
|
// NOTE(zaklaus): fade in-out effect
|
|
|
|
entity_transition_effect tran_effect;
|
|
|
|
float tran_time;
|
2021-05-05 09:25:05 +00:00
|
|
|
} entity_view;
|
|
|
|
|
|
|
|
ZPL_TABLE_DECLARE(, entity_view_tbl, entity_view_tbl_, entity_view);
|
|
|
|
|
2021-05-06 15:30:38 +00:00
|
|
|
void entity_view_init(entity_view_tbl *map);
|
|
|
|
void entity_view_free(entity_view_tbl *map);
|
2021-05-05 09:25:05 +00:00
|
|
|
|
2021-05-06 15:30:38 +00:00
|
|
|
void entity_view_update_or_create(entity_view_tbl *map, uint64_t ent_id, entity_view data);
|
|
|
|
void entity_view_destroy(entity_view_tbl *map, uint64_t ent_id);
|
2021-05-05 09:25:05 +00:00
|
|
|
|
2021-05-06 15:30:38 +00:00
|
|
|
entity_view *entity_view_get(entity_view_tbl *map, uint64_t ent_id);
|
2021-07-18 18:30:27 +00:00
|
|
|
void entity_view_map(entity_view_tbl *map, void (*map_proc)(uint64_t key, entity_view *value));
|
2021-05-06 16:26:52 +00:00
|
|
|
|
2021-05-06 18:24:01 +00:00
|
|
|
size_t entity_view_pack_struct(void *data, size_t len, entity_view view);
|
2021-05-06 16:26:52 +00:00
|
|
|
entity_view entity_view_unpack_struct(void *data, size_t len);
|
2021-05-09 22:40:25 +00:00
|
|
|
|
|
|
|
void entity_view_mark_for_removal(entity_view_tbl *map, uint64_t ent_id);
|
2021-05-10 11:27:01 +00:00
|
|
|
void entity_view_mark_for_fadein(entity_view_tbl *map, uint64_t ent_id);
|
2021-07-18 18:30:27 +00:00
|
|
|
void entity_view_update_chunk_texture(entity_view_tbl *map, uint64_t ent_id, void *view);
|
|
|
|
void entity_view_remove_chunk_texture(entity_view_tbl *map, uint64_t ent_id);
|