Add rotation component
parent
78c05fd9da
commit
fc9997d4db
|
@ -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)\
|
||||
|
|
|
@ -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) },
|
||||
|
|
|
@ -53,6 +53,7 @@ typedef struct entity_view {
|
|||
float vy;
|
||||
float tx;
|
||||
float ty;
|
||||
float angle;
|
||||
|
||||
float hp;
|
||||
float max_hp;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue