diff --git a/code/foundation/src/models/components.h b/code/foundation/src/models/components.h index 9df038d..56b8017 100644 --- a/code/foundation/src/models/components.h +++ b/code/foundation/src/models/components.h @@ -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, @@ -254,6 +258,7 @@ typedef struct { X(Position)\ X(Velocity)\ X(InAir)\ + X(Rotation)\ X(TriggerOnly)\ X(PhysicsBody)\ X(Chunk)\ diff --git a/code/foundation/src/world/entity_view.c b/code/foundation/src/world/entity_view.c index 4d91417..0a6f424 100644 --- a/code/foundation/src/world/entity_view.c +++ b/code/foundation/src/world/entity_view.c @@ -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) }, diff --git a/code/foundation/src/world/entity_view.h b/code/foundation/src/world/entity_view.h index 795a036..4cfd4bb 100644 --- a/code/foundation/src/world/entity_view.h +++ b/code/foundation/src/world/entity_view.h @@ -53,6 +53,7 @@ typedef struct entity_view { float vy; float tx; float ty; + float angle; float hp; float max_hp; diff --git a/code/foundation/src/world/world.c b/code/foundation/src/world/world.c index 5c16c3f..1cd8a64 100644 --- a/code/foundation/src/world/world.c +++ b/code/foundation/src/world/world.c @@ -42,12 +42,17 @@ entity_view* world_build_entity_view(int64_t e) { view.y = pos->y; } - const Velocity* vel = ecs_get(world_ecs(), e, Velocity); - if (vel) { - view.flag |= EFLAG_INTERP; - view.vx = vel->x; - view.vy = vel->y; - } + const Velocity* vel = ecs_get(world_ecs(), e, Velocity); + if (vel) { + view.flag |= EFLAG_INTERP; + view.vx = vel->x; + 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) {