diff options
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) } |
