Buildings as entities instead of map layer
This commit is contained in:
@@ -2,6 +2,40 @@
|
||||
|
||||
#include "../game_state.h"
|
||||
|
||||
Rectangle calculateEntityBounds(Position pos, Size size) {
|
||||
return (Rectangle) {
|
||||
pos.x - size.x * 0.5f,
|
||||
pos.y - size.x * 0.5f,
|
||||
size.x, size.y
|
||||
};
|
||||
}
|
||||
|
||||
bool getEntityBounds(ecs_entity_t entity, Position *outPos, Size *outSize, Rectangle *outBounds) {
|
||||
if (!ecs_is_alive(ECS, entity))
|
||||
return false;
|
||||
const Position *pos = ecs_get(ECS, entity, Position);
|
||||
if (!pos)
|
||||
return false;
|
||||
const Size *size = ecs_get(ECS, entity, Size);
|
||||
if (!size)
|
||||
return false;
|
||||
|
||||
if (outPos) {
|
||||
*outPos = *pos;
|
||||
}
|
||||
if (outSize) {
|
||||
*outSize = *size;
|
||||
}
|
||||
if (outBounds) {
|
||||
*outBounds = (Rectangle) {
|
||||
pos->x - size->x * 0.5f,
|
||||
pos->y - size->y * 0.5f,
|
||||
size->x, size->y
|
||||
};
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
ecs_entity_t renderCollidersSystem;
|
||||
ecs_entity_t renderOrientDirSystem;
|
||||
ecs_entity_t renderArmPositionSystem;
|
||||
@@ -37,6 +71,7 @@ ECS_DTOR(Arms, arms, {
|
||||
ecs_delete(ECS, arms->secondary);
|
||||
arms->secondary = 0;
|
||||
}
|
||||
|
||||
})
|
||||
ECS_MOVE(Arms, dst, src, {
|
||||
*dst = *src;
|
||||
|
||||
Reference in New Issue
Block a user