diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2025-07-09 08:58:14 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2025-07-09 08:58:14 +0200 |
| commit | 9f30f800443e6496bbba264a375c126cb26b1760 (patch) | |
| tree | bc0da293f552a0ecf7cac356a6747c109ce9eb0c /spawn.go | |
| parent | 057adf65468e7b6ec544686b80433093a9f9deab (diff) | |
Spawn target for newly spawned units
Diffstat (limited to 'spawn.go')
| -rw-r--r-- | spawn.go | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -3,6 +3,7 @@ package main import ( "age_of_empires/ecs" "age_of_empires/physics" + "log/slog" "time" ) @@ -14,6 +15,7 @@ type Spawn struct { UnitResourceCost int UnitSpawnDuration time.Duration Requests []spawnRequest + SpawnTarget ecs.Component[physics.Point] } func NewSpawn(unitResourceCost int, unitSpawnDuration time.Duration) Spawn { @@ -44,6 +46,11 @@ func UpdateSpawn(g *Game, spawn *ecs.Component[Spawn], position ecs.Component[ph unit := g.UnitBuilder.Build() unit.Position = ecs.C(spawnPosition) g.Entities = append(g.Entities, &unit) + slog.Info("Spawned unit") + if spawn.Value.SpawnTarget.IsEnabled { + slog.Info("Unit has spawn target") + unit.MainAction(g, spawn.Value.SpawnTarget.Value, g.entityAt(spawn.Value.SpawnTarget.Value), g.getMoveMap()) + } spawn.Value.Requests = spawn.Value.Requests[1:] if len(spawn.Value.Requests) > 0 { spawn.Value.Requests[0].start = now |
