aboutsummaryrefslogtreecommitdiff
path: root/gather_order.go
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2025-09-25 23:05:48 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2025-09-25 23:07:14 +0200
commitb457ffe1fbb7799beba0bc4b53bc3bf1309ae799 (patch)
tree91ecf7fc13aa6c490daa60afc874491ca214c3f0 /gather_order.go
parent7e94ae0184b94f247c16a775b4d6b0172e8b3027 (diff)
Get time from Game
Diffstat (limited to 'gather_order.go')
-rw-r--r--gather_order.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/gather_order.go b/gather_order.go
index 10cbcaf..eec9b99 100644
--- a/gather_order.go
+++ b/gather_order.go
@@ -1,10 +1,11 @@
package main
import (
- "age_of_empires/physics"
"math"
"time"
+ "age_of_empires/physics"
+
"golang.org/x/exp/slog"
)
@@ -23,7 +24,7 @@ func (o *GatherOrder) Update(e *Entity, g *Game) {
return
}
if physics.Distance(e.Position.Value, gatherer.CurrentTarget.Position.Value) <= 100 {
- o.updateGathering(gatherer, &gatherer.CurrentTarget.ResourceSource.Value)
+ o.updateGathering(g.Now(), gatherer, &gatherer.CurrentTarget.ResourceSource.Value)
return
}
if !e.Move.Value.IsActive {
@@ -31,8 +32,7 @@ func (o *GatherOrder) Update(e *Entity, g *Game) {
}
}
-func (*GatherOrder) updateGathering(gatherer *ResourceGatherer, source *ResourceSource) {
- now := time.Now()
+func (*GatherOrder) updateGathering(now time.Time, gatherer *ResourceGatherer, source *ResourceSource) {
if gatherer.CurrentVolume >= gatherer.MaxCapacity || gatherer.LastPickupTime.Add(200*time.Millisecond).After(now) {
return
}