From 7ca294b962bb4c141ff7ba5167b5b71f54321e7f Mon Sep 17 00:00:00 2001 From: Klemen Plestenjak Date: Tue, 13 Feb 2024 15:57:40 +0100 Subject: [PATCH] Correctly populate Unit struct when creating entities --- game/entity_factory.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/game/entity_factory.c b/game/entity_factory.c index 654e020..e471ef5 100644 --- a/game/entity_factory.c +++ b/game/entity_factory.c @@ -65,9 +65,11 @@ ecs_entity_t entityCreateBaseUnit(const Position position, f32 size, Player play .deceleration = 0.1f, .unitType = type }; - if (unit) - unitComp = *unit; - ecs_set_ptr(ECS, e, Unit, &unitComp); + if (unit) { + *unit = unitComp; + } else { + ecs_set_ptr(ECS, e, Unit, &unitComp); + } ecs_set(ECS, e, ConsumePopCapacity, {1}); return e; }