add heading dir to input
parent
fc9997d4db
commit
8c288dc193
|
@ -3,13 +3,13 @@
|
|||
#include "models/assets.h"
|
||||
|
||||
#define ecs_get_mut_ex(world, entity, T) \
|
||||
(ECS_CAST(T*, world_component_cached(world, entity, ecs_id(T))))
|
||||
(ECS_CAST(T*, ecs_get_mut(world, entity, T)))
|
||||
|
||||
#define ecs_get_if(world, entity, T) \
|
||||
(world_entity_valid(entity) ? ecs_get(world, entity, T) : NULL)
|
||||
|
||||
#define ecs_get_mut_if_ex(world, entity, component) \
|
||||
(ecs_get_if(world, entity, component) ? ecs_get_mut_ex(world, entity, component) : NULL)
|
||||
(ecs_get_if(world, entity, component) ? ecs_get_mut(world, entity, component) : NULL)
|
||||
|
||||
#ifndef ecs_get_mut_if
|
||||
#define ecs_get_mut_if(world, entity, component)\
|
||||
|
@ -69,6 +69,8 @@ typedef struct {
|
|||
float my;
|
||||
float bx;
|
||||
float by;
|
||||
float hx;
|
||||
float hy;
|
||||
uint8_t use;
|
||||
uint8_t sprint;
|
||||
uint8_t ctrl;
|
||||
|
|
|
@ -19,12 +19,14 @@ uint64_t player_spawn(char *name) {
|
|||
|
||||
ecs_set_name(world_ecs(), e, name);
|
||||
ecs_set(world_ecs(), e, ClientInfo, {0});
|
||||
ecs_set(world_ecs(), e, Input, {0});
|
||||
ecs_set(world_ecs(), e, Inventory, {0});
|
||||
ecs_set(world_ecs(), e, Health, {.hp = PLAYER_MAX_HP, .max_hp = PLAYER_MAX_HP});
|
||||
ecs_set(world_ecs(), e, HealthRegen, {.amt = 15.0f});
|
||||
ecs_set(world_ecs(), e, Velocity, { 0 });
|
||||
ecs_set(world_ecs(), e, PhysicsBody, { .kind = PHYS_AABB, .mass = INFINITE_MASS });
|
||||
Input *i = ecs_get_mut(world_ecs(), e, Input);
|
||||
*i = (Input){ 0 };
|
||||
i->hx = 1.0f;
|
||||
|
||||
librg_entity_owner_set(world_tracker(), e, (int64_t)e);
|
||||
|
||||
|
|
|
@ -63,6 +63,8 @@ int32_t pkt_send_keystate_handler(pkt_header *header) {
|
|||
i->y = zpl_clamp(table.y, -1.0f, 1.0f);
|
||||
i->mx = table.mx;
|
||||
i->my = table.my;
|
||||
i->hx = (i->x != 0.0f) ? i->x : i->hx;
|
||||
i->hy = (i->y != 0.0f) ? i->y : i->hy;
|
||||
i->use |= table.use;
|
||||
i->sprint = table.sprint;
|
||||
i->ctrl = table.ctrl;
|
||||
|
|
|
@ -16,6 +16,8 @@ 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, hx) },
|
||||
{ PKT_HALF(entity_view, hy) },
|
||||
{ PKT_HALF(entity_view, angle) },
|
||||
|
||||
{ PKT_KEEP_IF(entity_view, blocks_used, 0, 2) }, // NOTE(zaklaus): skip velocity for chunks
|
||||
|
|
|
@ -53,6 +53,8 @@ typedef struct entity_view {
|
|||
float vy;
|
||||
float tx;
|
||||
float ty;
|
||||
float hx;
|
||||
float hy;
|
||||
float angle;
|
||||
|
||||
float hp;
|
||||
|
|
|
@ -87,6 +87,14 @@ entity_view* world_build_entity_view(int64_t e) {
|
|||
view.frame = spr->frame;
|
||||
}
|
||||
|
||||
{
|
||||
const Input* in = ecs_get(world_ecs(), e, Input);
|
||||
if (in) {
|
||||
view.hx = in->hx;
|
||||
view.hy = in->hy;
|
||||
}
|
||||
}
|
||||
|
||||
view.inside_vehicle = ecs_get(world_ecs(), e, IsInVehicle) != 0 ? true : false;
|
||||
|
||||
Inventory* inv = 0;
|
||||
|
|
Loading…
Reference in New Issue