efd/v1
DavoSK 2023-02-02 17:22:07 +01:00
commit f89b35a856
4 changed files with 18 additions and 6 deletions

View File

@ -41,6 +41,10 @@ typedef Vector2D Velocity;
typedef struct { char _unused; } InAir;
typedef struct { char _unused; } TriggerOnly;
typedef struct {
float angle;
} Rotation;
enum {
PHYS_CIRCLE,
PHYS_AABB,
@ -265,6 +269,7 @@ typedef struct {
X(Position)\
X(Velocity)\
X(InAir)\
X(Rotation)\
X(TriggerOnly)\
X(PhysicsBody)\
X(Chunk)\

View File

@ -16,6 +16,7 @@ pkt_desc pkt_entity_view_desc[] = {
{ PKT_UINT(entity_view, flag) },
{ PKT_HALF(entity_view, x) },
{ PKT_HALF(entity_view, y) },
{ PKT_HALF(entity_view, angle) },
{ PKT_KEEP_IF(entity_view, blocks_used, 0, 2) }, // NOTE(zaklaus): skip velocity for chunks
{ PKT_HALF(entity_view, vx) },

View File

@ -53,6 +53,7 @@ typedef struct entity_view {
float vy;
float tx;
float ty;
float angle;
float hp;
float max_hp;

View File

@ -49,6 +49,11 @@ entity_view* world_build_entity_view(int64_t e) {
view.vy = vel->y;
}
const Rotation* rot = ecs_get(world_ecs(), e, Rotation);
if (rot) {
view.angle = rot->angle;
}
const Health* health = ecs_get(world_ecs(), e, Health);
if (health) {
view.hp = health->hp;