From b457ffe1fbb7799beba0bc4b53bc3bf1309ae799 Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Thu, 25 Sep 2025 23:05:48 +0200 Subject: Get time from Game --- gather_order.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'gather_order.go') 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 } -- cgit v1.3