aboutsummaryrefslogtreecommitdiff
path: root/order.go
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2025-07-09 07:53:48 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2025-07-09 07:53:48 +0200
commit057adf65468e7b6ec544686b80433093a9f9deab (patch)
tree174ea7c587102120afa14b3530e199cf436d2c69 /order.go
parent5af6361f22d727a4abacd724cf9152e67f73328a (diff)
Extract entity main action
Diffstat (limited to 'order.go')
-rw-r--r--order.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/order.go b/order.go
index f1e89bc..f8ef06d 100644
--- a/order.go
+++ b/order.go
@@ -1,5 +1,7 @@
package main
+import "age_of_empires/physics"
+
type Order interface {
Update(e *Entity, g *Game)
}
@@ -10,3 +12,14 @@ func (e *Entity) UpdateOrder(g *Game) {
}
e.Order.Value.Update(e, g)
}
+
+func (e *Entity) MainAction(g *Game, destination physics.Point, entityAtDestination *Entity, moveMap physics.MoveMap) {
+ if !e.Selection.IsEnabled || !e.Selection.Value.IsSelected {
+ return
+ }
+ if entityAtDestination != nil && entityAtDestination.ResourceSource.IsEnabled {
+ Gather(e, entityAtDestination, g)
+ return
+ }
+ physics.StartMove(&e.Move, e.Position, destination, moveMap)
+}