Implement harvest worker AI
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
#include "game_state.h"
|
||||
#include "map_layers.h"
|
||||
|
||||
#include <raymath.h>
|
||||
|
||||
bool canPlaceBuilding(BzTileMap *map, BuildingType type, BzTile tileX, BzTile tileY) {
|
||||
i32 sizeX, sizeY;
|
||||
getBuildingSize(type, &sizeX, &sizeY);
|
||||
@@ -73,3 +75,20 @@ ecs_entity_t placeBuilding(BzTileMap *map, BuildingType type, BzTile tileX, BzTi
|
||||
return e;
|
||||
|
||||
}
|
||||
|
||||
Vector2 getPositionNearBuilding(ecs_entity_t building, Vector2 fromPos) {
|
||||
BZ_ASSERT(ecs_is_alive(ECS, building));
|
||||
BZ_ASSERT(ecs_has(ECS, building, Position));
|
||||
BZ_ASSERT(ecs_has(ECS, building, Size));
|
||||
|
||||
Vector2 pos = *ecs_get(ECS, building, Position);
|
||||
Vector2 size = *ecs_get(ECS, building, Size);
|
||||
|
||||
size = Vector2SubtractValue(size, 10.0f);
|
||||
|
||||
Vector2 dir = Vector2Normalize(Vector2Subtract(fromPos, pos));
|
||||
dir = Vector2Multiply(dir, size);
|
||||
|
||||
pos = Vector2Add(pos, dir);
|
||||
return pos;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user