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 /order.go | |
| parent | 057adf65468e7b6ec544686b80433093a9f9deab (diff) | |
Spawn target for newly spawned units
Diffstat (limited to 'order.go')
| -rw-r--r-- | order.go | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -1,6 +1,10 @@ package main -import "age_of_empires/physics" +import ( + "age_of_empires/ecs" + "age_of_empires/physics" + "log/slog" +) type Order interface { Update(e *Entity, g *Game) @@ -14,12 +18,17 @@ func (e *Entity) UpdateOrder(g *Game) { } func (e *Entity) MainAction(g *Game, destination physics.Point, entityAtDestination *Entity, moveMap physics.MoveMap) { - if !e.Selection.IsEnabled || !e.Selection.Value.IsSelected { + if entityAtDestination != nil && entityAtDestination.ResourceSource.IsEnabled && e.ResourceGatherer.IsEnabled { + Gather(e, entityAtDestination, g) return } - if entityAtDestination != nil && entityAtDestination.ResourceSource.IsEnabled { - Gather(e, entityAtDestination, g) + if e.Move.IsEnabled { + physics.StartMove(&e.Move, e.Position, destination, moveMap) + return + } + if e.Spawn.IsEnabled { + slog.Info("Setting spawn target") + e.Spawn.Value.SpawnTarget = ecs.C(destination) return } - physics.StartMove(&e.Move, e.Position, destination, moveMap) } |
