From 9f30f800443e6496bbba264a375c126cb26b1760 Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Wed, 9 Jul 2025 08:58:14 +0200 Subject: Spawn target for newly spawned units --- spawn.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'spawn.go') diff --git a/spawn.go b/spawn.go index 85ce24e..bf0e561 100644 --- a/spawn.go +++ b/spawn.go @@ -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 -- cgit v1.3