Haulers cross zones by wormhole: waypoint, jump, and Fly off screen
HaulRun.Waypoint names the leg's orbit and the next hop toward it (FindPath); on screen HaulState flies to the zone's wormhole (MoveToPointState) and commands the Jump verb, which dives and transfers when the dive ends. Off screen RegionClock.Advance advances the zones of its set, then flies each hauler once (HaulRun.Fly: straight at the waypoint at Agent.TopSpeedOf, Call at a station when CanCall, Jump at a wormhole, stopping when it waits or lands outside the advanced set; into the player's zone it plays ExitWormhole). Step's boundary and Enter's settle both call Advance. Zone.AdvanceTo stays facilities and populations only. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d4dd0f9dcb
commit
c1890739e4
5 changed files with 155 additions and 16 deletions
|
|
@ -1,12 +1,18 @@
|
|||
// A hauler's pilot: it flies to the orbit of HaulRun.Leg and, within docking distance of a station where the call would move a unit,
|
||||
// commands the call (HaulRun.Call docks, moves the goods and undocks it, which gives it a fresh pilot on the same task). No field
|
||||
// but its child: the leg is derived from the hold on every update, so a hand-emptied hold changes it at once.
|
||||
using GameCult.Caching;
|
||||
|
||||
// A hauler's pilot: it flies to HaulRun.Waypoint, derived from the hold and the order on every update. With no hop it flies to the leg's
|
||||
// orbit and, within docking distance of a station where the call would move a unit, commands the call (HaulRun.Call docks, moves the
|
||||
// goods and undocks it, which gives it a fresh pilot on the same task). With a hop the leg lies in another zone: it flies to this zone's
|
||||
// wormhole toward it and, within the wormhole's reach, commands the jump (HaulRun.Jump). No field but its children: a hand-emptied hold
|
||||
// changes the waypoint at once.
|
||||
public class HaulState : BaseState
|
||||
{
|
||||
public HaulState(Agent agent) : base(agent)
|
||||
{
|
||||
var move = new MoveToOrbitState(agent);
|
||||
var leave = new MoveToPointState(agent);
|
||||
HaulOrderData Order() => _agent.Task is HaulingTask task ? HaulRun.OrderOf(_agent.ItemManager, task.Order) : null;
|
||||
(CultRecordKey Orbit, GalaxyZone Hop)? Way() => Order() is HaulOrderData order ? HaulRun.Waypoint(_agent.Ship, order) : null;
|
||||
OrbitalEntity Station() => HaulRun.Station(_agent.Ship.Zone, move.Orbit);
|
||||
bool Callable()
|
||||
{
|
||||
|
|
@ -14,10 +20,14 @@ public class HaulState : BaseState
|
|||
var station = order == null ? null : Station();
|
||||
return station != null && move.Distance < _agent.Settings.DockingDistance && HaulRun.CanCall(_agent.Ship, station, order);
|
||||
}
|
||||
bool Leaving() => leave.Distance < _agent.Settings.WormholeExitRadius && !_agent.Ship.WormholeAnimationInProgress;
|
||||
|
||||
Transitions.Add(new StateTransition(move, () => Order() != null, () => move.Orbit = HaulRun.Leg(_agent.Ship, Order())));
|
||||
// A changed leg re-enters this state, which points the child at it; a callable station commands the call.
|
||||
move.Transitions.Add(new StateTransition(this, () => Order() is HaulOrderData order && !HaulRun.Leg(_agent.Ship, order).Equals(move.Orbit), null));
|
||||
Transitions.Add(new StateTransition(move, () => Way() is { Hop: null }, () => move.Orbit = Way().Value.Orbit));
|
||||
Transitions.Add(new StateTransition(leave, () => Way() is { Hop: not null }, () => leave.Point = _agent.Ship.Zone.WormholeTo(Way().Value.Hop)));
|
||||
// A changed waypoint re-enters this state, which points the child at it; a callable station commands the call, a reached wormhole the jump.
|
||||
move.Transitions.Add(new StateTransition(this, () => !(Way() is { Hop: null } way && way.Orbit.Equals(move.Orbit)), null));
|
||||
move.Transitions.Add(new StateTransition(this, Callable, () => _agent.Ship.Command.Call(Station())));
|
||||
leave.Transitions.Add(new StateTransition(this, () => !(Way() is { Hop: not null } way && _agent.Ship.Zone.WormholeTo(way.Hop).Equals(leave.Point)), null));
|
||||
leave.Transitions.Add(new StateTransition(this, Leaving, () => _agent.Ship.Command.Jump(Way().Value.Hop)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,3 +36,11 @@ public class MoveToOrbitState : MoveToState
|
|||
|
||||
protected override float2 TargetPosition => _agent.Ship.Zone.GetOrbitPosition(Orbit);
|
||||
}
|
||||
|
||||
public class MoveToPointState : MoveToState
|
||||
{
|
||||
public float2 Point { get; set; }
|
||||
public MoveToPointState(Agent agent) : base(agent) { }
|
||||
|
||||
protected override float2 TargetPosition => Point;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue