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; } InAir;
typedef struct { char _unused; } TriggerOnly; typedef struct { char _unused; } TriggerOnly;
typedef struct {
float angle;
} Rotation;
enum { enum {
PHYS_CIRCLE, PHYS_CIRCLE,
PHYS_AABB, PHYS_AABB,
@ -265,6 +269,7 @@ typedef struct {
X(Position)\ X(Position)\
X(Velocity)\ X(Velocity)\
X(InAir)\ X(InAir)\
X(Rotation)\
X(TriggerOnly)\ X(TriggerOnly)\
X(PhysicsBody)\ X(PhysicsBody)\
X(Chunk)\ X(Chunk)\

View File

@ -16,6 +16,7 @@ pkt_desc pkt_entity_view_desc[] = {
{ PKT_UINT(entity_view, flag) }, { PKT_UINT(entity_view, flag) },
{ PKT_HALF(entity_view, x) }, { PKT_HALF(entity_view, x) },
{ PKT_HALF(entity_view, y) }, { 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_KEEP_IF(entity_view, blocks_used, 0, 2) }, // NOTE(zaklaus): skip velocity for chunks
{ PKT_HALF(entity_view, vx) }, { PKT_HALF(entity_view, vx) },

View File

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

View File

@ -42,12 +42,17 @@ entity_view* world_build_entity_view(int64_t e) {
view.y = pos->y; view.y = pos->y;
} }
const Velocity* vel = ecs_get(world_ecs(), e, Velocity); const Velocity* vel = ecs_get(world_ecs(), e, Velocity);
if (vel) { if (vel) {
view.flag |= EFLAG_INTERP; view.flag |= EFLAG_INTERP;
view.vx = vel->x; view.vx = vel->x;
view.vy = vel->y; 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); const Health* health = ecs_get(world_ecs(), e, Health);
if (health) { if (health) {