aboutsummaryrefslogtreecommitdiff
path: root/patrol_order.go
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2025-07-04 17:55:53 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2025-07-04 23:02:21 +0200
commita5fef758107888853c14a592696b45768ef56df8 (patch)
tree9d1fd0b0abb49ce6814b8868926bf7af83611303 /patrol_order.go
parente3f14fc0b375b4b7c2204a669d058ac124b78e92 (diff)
Refactor into packages
Diffstat (limited to 'patrol_order.go')
-rw-r--r--patrol_order.go16
1 files changed, 10 insertions, 6 deletions
diff --git a/patrol_order.go b/patrol_order.go
index b7201ed..eb9dfb0 100644
--- a/patrol_order.go
+++ b/patrol_order.go
@@ -1,10 +1,14 @@
package main
-import "golang.org/x/exp/slog"
+import (
+ "age_of_empires/physics"
+
+ "golang.org/x/exp/slog"
+)
type PatrolOrder struct {
- origin Point
- destination Point
+ origin physics.Point
+ destination physics.Point
}
func (o *PatrolOrder) Update(e *Entity, g *Game) {
@@ -12,15 +16,15 @@ func (o *PatrolOrder) Update(e *Entity, g *Game) {
if !e.Move.Value.IsActive {
moveMap := g.getMoveMap()
if e.Position.Value == o.destination {
- e.StartMove(o.origin, moveMap)
+ physics.StartMove(&e.Move, e.Position, o.origin, moveMap)
} else {
- e.StartMove(o.destination, moveMap)
+ physics.StartMove(&e.Move, e.Position, o.destination, moveMap)
}
}
}
}
-func Patrol(e *Entity, destination Point) Order {
+func Patrol(e *Entity, destination physics.Point) Order {
if e.Selection.IsEnabled && e.Position.IsEnabled && e.Move.IsEnabled && e.Order.IsEnabled {
if e.Selection.Value.IsSelected {
origin := e.Position.Value