diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2025-07-24 15:05:22 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2025-07-24 15:05:22 +0200 |
| commit | 337dee61ada57e1d44079822abc437b8fc168843 (patch) | |
| tree | 1a87534523882d8fc1d862df017396dbdd376f3b /gather_order.go | |
| parent | e6e4ce18083ae5552563eab3291ac1642371d025 (diff) | |
refactor: Extract closest
Diffstat (limited to 'gather_order.go')
| -rw-r--r-- | gather_order.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/gather_order.go b/gather_order.go index be98ca4..10cbcaf 100644 --- a/gather_order.go +++ b/gather_order.go @@ -46,7 +46,7 @@ func (o *GatherOrder) updateGathererFull(e *Entity, g *Game, gatherer *ResourceG return } storageDockings := getAllStorageDockings(g) - destination, distance := g.Closest(e.Position.Value, storageDockings) + destination, distance := physics.Closest(e.Position.Value, storageDockings, g.getMoveMap()) if distance == math.MaxInt { slog.Info("no accessible storage, canceling gather order") e.Order.Value = nil @@ -65,7 +65,7 @@ func (o *GatherOrder) updateGathererFull(e *Entity, g *Game, gatherer *ResourceG func (o *GatherOrder) startMoveToSource(e *Entity, gatherer *ResourceGatherer, g *Game) { sourceDockings := physics.AdjacentPoints(gatherer.CurrentTarget.Position.Value) - destination, distance := g.Closest(e.Position.Value, sourceDockings) + destination, distance := physics.Closest(e.Position.Value, sourceDockings, g.getMoveMap()) if distance == math.MaxInt { slog.Info("no accessible storage, canceling gather order") e.Order.Value = nil @@ -92,7 +92,7 @@ func Gather(e *Entity, source *Entity, g *Game) Order { e.Order.Value = &GatherOrder{source: source} e.ResourceGatherer.Value.CurrentTarget = source sourceDockings := physics.AdjacentPoints(source.Position.Value) - destination, distance := g.Closest(e.Position.Value, sourceDockings) + destination, distance := physics.Closest(e.Position.Value, sourceDockings, g.getMoveMap()) if distance == math.MaxInt { slog.Info("no accessible storage, canceling gather order") e.Order.Value = nil |
