eco2d/code/common/entity_view.h

36 lines
948 B
C
Raw Normal View History

2021-05-05 09:25:05 +00:00
#pragma once
#include "system.h"
#define ZPL_PICO
#include "zpl.h"
2021-05-06 16:26:52 +00:00
#include "packet_utils.h"
2021-05-06 18:24:01 +00:00
typedef enum {
EKIND_PLAYER,
EKIND_CHUNK,
FORCE_EKIND_UINT16 = UINT16_MAX
} entity_kind;
2021-05-05 09:25:05 +00:00
typedef struct entity_view {
2021-05-06 18:24:01 +00:00
entity_kind kind;
2021-05-05 10:14:52 +00:00
double x;
double y;
2021-05-05 09:25:05 +00:00
} entity_view;
ZPL_TABLE_DECLARE(, entity_view_tbl, entity_view_tbl_, entity_view);
2021-05-06 16:26:52 +00:00
pkt_desc pkt_entity_view_desc[];
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);
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);