aboutsummaryrefslogtreecommitdiff
path: root/spawn.go
diff options
context:
space:
mode:
Diffstat (limited to 'spawn.go')
-rw-r--r--spawn.go7
1 files changed, 7 insertions, 0 deletions
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