Correctly populate Unit struct when creating entities

This commit is contained in:
2024-02-13 15:57:40 +01:00
parent 40712e13a9
commit 7ca294b962

View File

@@ -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;
}