Tweak wave times, fix Unit modification

This commit is contained in:
2024-02-13 15:55:14 +01:00
parent d8c7bb7074
commit 40712e13a9
4 changed files with 52 additions and 45 deletions

View File

@@ -9,7 +9,7 @@ ecs_entity_t entityCreateEmpty() {
}
ecs_entity_t entityCreateBaseUnit(const Position position, f32 size, Player player,
EntityType type, AnimType startAnim, Game *game) {
EntityType type, AnimType startAnim, Unit *unit, Game *game) {
BzTileset *tileset = &game->tileset;
BzTileID tileID = getEntityTile(type);
TextureRegion region = {
@@ -55,50 +55,55 @@ ecs_entity_t entityCreateBaseUnit(const Position position, f32 size, Player play
});
ecs_set(ECS, e, AIBlackboard, {.entity = e});
ecs_add_id(ECS, e, Selectable);
ecs_set(ECS, e, Unit, {
.attackElapsed = 0.0f,
.attackCooldown = 1.0f,
.minDamage = 1.0f,
.maxDamage = 2.0f,
.acceleration = 80.0f,
.maxSpeed = 15.0f,
.deceleration = 0.1f,
.unitType = type
});
Unit unitComp = {
.attackElapsed = 0.0f,
.attackCooldown = 1.0f,
.minDamage = 1.0f,
.maxDamage = 2.0f,
.acceleration = 80.0f,
.maxSpeed = 15.0f,
.deceleration = 0.1f,
.unitType = type
};
if (unit)
unitComp = *unit;
ecs_set_ptr(ECS, e, Unit, &unitComp);
ecs_set(ECS, e, ConsumePopCapacity, {1});
return e;
}
ecs_entity_t entityCreateSoldier(const Position position, Player player, Game *game) {
ecs_entity_t e = entityCreateBaseUnit(position, 10.0f, player, ENTITY_SOLDIER, ANIM_IDLE, game);
Unit unit = {0};
ecs_entity_t e = entityCreateBaseUnit(position, 10.0f, player, ENTITY_SOLDIER, ANIM_IDLE, &unit, game);
ecs_set(ECS, e, Health, {
.startHP = 40.0f,
.hp = 40.0f,
.lastChanged = -1000.0f
});
Unit *unit = ecs_get_mut(ECS, e, Unit);
unit->minDamage = 5.0f;
unit->maxDamage = 10.0f;
unit->attackCooldown = 1.0f;
unit.minDamage = 5.0f;
unit.maxDamage = 10.0f;
unit.attackCooldown = 1.0f;
ecs_set_ptr(ECS, e, Unit, &unit);
return e;
}
ecs_entity_t entityCreateWarrior(const Position position, Player player, Game *game) {
ecs_entity_t e = entityCreateBaseUnit(position, 10.0f, player, ENTITY_WARRIOR, ANIM_IDLE, game);
Unit unit = {0};
ecs_entity_t e = entityCreateBaseUnit(position, 10.0f, player, ENTITY_WARRIOR, ANIM_IDLE, &unit, game);
ecs_set(ECS, e, Health, {
.startHP = 80.0f,
.hp = 80.0f,
.lastChanged = -1000.0f
});
Unit *unit = ecs_get_mut(ECS, e, Unit);
unit->minDamage = 8.0f;
unit->maxDamage = 22.0f;
unit->attackCooldown = 1.8f;
unit.minDamage = 8.0f;
unit.maxDamage = 22.0f;
unit.attackCooldown = 1.8f;
ecs_set_ptr(ECS, e, Unit, &unit);
return e;
}
ecs_entity_t entityCreateWorker(const Position position, Player player, Game *game) {
BzTileset *tileset = &game->tileset;
ecs_entity_t e = entityCreateBaseUnit(position, 10.0f, player, ENTITY_WORKER, ANIM_IDLE, game);
Unit unit = {0};
ecs_entity_t e = entityCreateBaseUnit(position, 10.0f, player, ENTITY_WORKER, ANIM_IDLE, &unit, game);
ecs_set(ECS, e, Worker, {
.collectSpeed = 0.8f,
@@ -116,7 +121,8 @@ ecs_entity_t entityCreateWorker(const Position position, Player player, Game *ga
}
ecs_entity_t entityCreateSwarmGoblin(const Position position, Player player, Game *game) {
ecs_entity_t e = entityCreateBaseUnit(position, 10.0f, player, ENTITY_GOBLIN, ANIM_IDLE, game);
Unit unit = {0};
ecs_entity_t e = entityCreateBaseUnit(position, 10.0f, player, ENTITY_GOBLIN, ANIM_IDLE, &unit, game);
ecs_set(ECS, e, Swarm, {
.currWaypoint = 0,
});
@@ -126,16 +132,17 @@ ecs_entity_t entityCreateSwarmGoblin(const Position position, Player player, Gam
.lastChanged = -1000.0f
});
Unit *unit = ecs_get_mut(ECS, e, Unit);
unit->minDamage = 5.0f;
unit->maxDamage = 10.0f;
unit->attackCooldown = 1.0f;
unit->maxSpeed = 20.0f;
unit.minDamage = 5.0f;
unit.maxDamage = 10.0f;
unit.attackCooldown = 1.0f;
unit.maxSpeed = 20.0f;
ecs_set_ptr(ECS, e, Unit, &unit);
return e;
}
ecs_entity_t entityCreateSwarmOrc(const Position position, Player player, Game *game) {
ecs_entity_t e = entityCreateBaseUnit(position, 10.0f, player, ENTITY_ORC, ANIM_IDLE, game);
Unit unit = {0};
ecs_entity_t e = entityCreateBaseUnit(position, 10.0f, player, ENTITY_ORC, ANIM_IDLE, &unit, game);
ecs_set(ECS, e, Swarm, {
.currWaypoint = 0,
});
@@ -145,11 +152,11 @@ ecs_entity_t entityCreateSwarmOrc(const Position position, Player player, Game *
.lastChanged = -1000.0f
});
Unit *unit = ecs_get_mut(ECS, e, Unit);
unit->minDamage = 8.0f;
unit->maxDamage = 22.0f;
unit->attackCooldown = 1.8f;
unit->maxSpeed = 12.0f;
unit.minDamage = 8.0f;
unit.maxDamage = 22.0f;
unit.attackCooldown = 1.8f;
unit.maxSpeed = 12.0f;
ecs_set_ptr(ECS, e, Unit, &unit);
return e;
}