2021-02-26 19:01:47 +00:00
|
|
|
using System.Linq;
|
|
|
|
|
using UniRx;
|
|
|
|
|
|
2026-10-08 14:18:41 +02:00
|
|
|
// The agent graph for a piloted ship. It executes the Task and Target its flight writes (Flight.cs) and decides
|
|
|
|
|
// neither: patrol and follow follow the Task kind, combat follows the Target.
|
2021-02-26 19:01:47 +00:00
|
|
|
public class Minion : Agent
|
|
|
|
|
{
|
2026-10-08 14:18:41 +02:00
|
|
|
public Minion(Ship ship, RoleDoctrine doctrine) : base(ship, doctrine)
|
2021-02-26 19:01:47 +00:00
|
|
|
{
|
|
|
|
|
var patrolState = new PatrolOrbitsState(this);
|
2026-10-08 14:18:41 +02:00
|
|
|
var followState = new FollowState(this);
|
|
|
|
|
void Patrol() => patrolState.Task = Task as PatrolOrbitsTask;
|
|
|
|
|
_rootState.AddTransition(patrolState, () => Task is PatrolOrbitsTask, Patrol);
|
|
|
|
|
_rootState.AddTransition(followState, () => Task is FollowTask);
|
2021-02-26 19:01:47 +00:00
|
|
|
|
2026-10-08 14:18:41 +02:00
|
|
|
// A Task change switches the substate in one update, from wherever the pilot is in the old task. includeChildren
|
2026-10-08 16:20:33 +02:00
|
|
|
// reaches the patrol sub-states (MoveToOrbit) that Update actually sits in; the walk never enters the other task's state.
|
2026-10-08 14:18:41 +02:00
|
|
|
patrolState.AddTransition(followState, () => Task is FollowTask, null, true, _rootState);
|
2026-10-08 16:20:33 +02:00
|
|
|
patrolState.AddTransition(_rootState, () => !(Task is PatrolOrbitsTask), null, true, _rootState, followState);
|
|
|
|
|
followState.AddTransition(patrolState, () => Task is PatrolOrbitsTask, Patrol);
|
|
|
|
|
followState.AddTransition(_rootState, () => !(Task is FollowTask));
|
2021-02-26 19:01:47 +00:00
|
|
|
|
|
|
|
|
var combatState = new CombatState(this);
|
2021-04-18 05:13:20 +01:00
|
|
|
_rootState.AddTransition(combatState,
|
Mining Cut 3: a chunk is a target, detected by reflected light
- Entity.Target is one slot of TargetRef, read-only from outside
(IReadOnlyReactiveProperty); Entity.SetTarget is its one writer. A chunk is
taken only while the entity can see it, so a rock in darkness cannot be
picked. Every handler, agent, turret and test writes through SetTarget.
- Entity.ChunkInfo (Q14 A): the value the per-tick sensor rule settles at,
computed on demand through Sensor.PassiveRate/Sensor.Gain -- sum of the
active sensors' passive rates over (sensors x TargetInfoDecay), capped at 1.
Stored nowhere; no per-tick loop over chunks. ChunkVisible is the detection
threshold through the chunk path.
- The lost-track rule reads through the chunk path: Activate's reconciliation
and a per-tick check of the one slot drop a chunk target that has gone dark.
- Entity.VisibleChunksInReach (Q13 A): visible chunks within the longest range
among active weapons -- the one reach rule for cycling and programmatic picks.
- Entity-only readers take .Entity: TargetedBy/TargetedByCount, target items,
the stance gate (a chunk has no stance), lock (Q12 A: never on a chunk),
turrets, Combat, Minion, FireControl (a chunk fires untargeted until Cut 4).
TargetRange and the arc gate read a chunk's planar position.
- ActionGameManager: the reticle and next/previous offer visible ships and
visible chunks in reach; nearest stays enemies-only; the target panel,
indicator and fire-control debug take TargetRef. EntityInstance reads .Entity.
- MiningCut3Tests pin parity, darkness, monotone brightness, wear and break,
reach, the chunk query, target survival and loss, TargetRef equality, lock,
and field-kind assignment at generation and first load.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 12:56:39 +02:00
|
|
|
() => Ship.Target.Value.Entity != null, null, true, _rootState);
|
2026-10-08 14:18:41 +02:00
|
|
|
|
2021-02-26 19:01:47 +00:00
|
|
|
combatState.AddTransition(_rootState,
|
Mining Cut 3: a chunk is a target, detected by reflected light
- Entity.Target is one slot of TargetRef, read-only from outside
(IReadOnlyReactiveProperty); Entity.SetTarget is its one writer. A chunk is
taken only while the entity can see it, so a rock in darkness cannot be
picked. Every handler, agent, turret and test writes through SetTarget.
- Entity.ChunkInfo (Q14 A): the value the per-tick sensor rule settles at,
computed on demand through Sensor.PassiveRate/Sensor.Gain -- sum of the
active sensors' passive rates over (sensors x TargetInfoDecay), capped at 1.
Stored nowhere; no per-tick loop over chunks. ChunkVisible is the detection
threshold through the chunk path.
- The lost-track rule reads through the chunk path: Activate's reconciliation
and a per-tick check of the one slot drop a chunk target that has gone dark.
- Entity.VisibleChunksInReach (Q13 A): visible chunks within the longest range
among active weapons -- the one reach rule for cycling and programmatic picks.
- Entity-only readers take .Entity: TargetedBy/TargetedByCount, target items,
the stance gate (a chunk has no stance), lock (Q12 A: never on a chunk),
turrets, Combat, Minion, FireControl (a chunk fires untargeted until Cut 4).
TargetRange and the arc gate read a chunk's planar position.
- ActionGameManager: the reticle and next/previous offer visible ships and
visible chunks in reach; nearest stays enemies-only; the target panel,
indicator and fire-control debug take TargetRef. EntityInstance reads .Entity.
- MiningCut3Tests pin parity, darkness, monotone brightness, wear and break,
reach, the chunk query, target survival and loss, TargetRef equality, lock,
and field-kind assignment at generation and first load.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 12:56:39 +02:00
|
|
|
() => Ship.Target.Value.Entity == null, null, true, _rootState);
|
2021-02-26 19:01:47 +00:00
|
|
|
}
|
2026-10-08 14:18:41 +02:00
|
|
|
}
|