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 --- order.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'order.go') diff --git a/order.go b/order.go index f8ef06d..eba71f9 100644 --- a/order.go +++ b/order.go @@ -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) } -- cgit v1.3