Faction play 1: typed doctrine on Faction and one flight per faction per zone
FactionDoctrine/RoleDoctrine (Faction key 17), Flight as the only writer of members' Target and Task, hail/grace/compliance, FollowTask/FollowState, agent removal on Entities removal, doctrine-catalog command, FlightTests. Not yet built or run; verification follows in later commits. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
4d664b537f
commit
8f42265de3
24 changed files with 812 additions and 42 deletions
|
|
@ -1,23 +1,30 @@
|
|||
|
||||
using System.Linq;
|
||||
using UniRx;
|
||||
|
||||
// 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.
|
||||
public class Minion : Agent
|
||||
{
|
||||
public Minion(Ship ship) : base(ship)
|
||||
public Minion(Ship ship, RoleDoctrine doctrine) : base(ship, doctrine)
|
||||
{
|
||||
var patrolState = new PatrolOrbitsState(this);
|
||||
_rootState.AddTransition(patrolState,
|
||||
() => Task is PatrolOrbitsTask,
|
||||
() => patrolState.Task = Task as PatrolOrbitsTask);
|
||||
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);
|
||||
|
||||
Ship.VisibleEnemies.ObserveAdd().Where(_ => Ship.Target.Value.IsNone).Subscribe(add => Ship.SetTarget(add.Value));
|
||||
// A Task change switches the substate in one update, from wherever the pilot is in the old task. includeChildren
|
||||
// reaches the sub-states (MoveToOrbit) that Update actually sits in.
|
||||
patrolState.AddTransition(followState, () => Task is FollowTask, null, true, _rootState);
|
||||
followState.AddTransition(patrolState, () => Task is PatrolOrbitsTask, Patrol, true, _rootState);
|
||||
patrolState.AddTransition(_rootState, () => !(Task is PatrolOrbitsTask), null, true, _rootState);
|
||||
followState.AddTransition(_rootState, () => !(Task is FollowTask), null, true, _rootState);
|
||||
|
||||
var combatState = new CombatState(this);
|
||||
_rootState.AddTransition(combatState,
|
||||
() => Ship.Target.Value.Entity != null, null, true, _rootState);
|
||||
|
||||
|
||||
combatState.AddTransition(_rootState,
|
||||
() => Ship.Target.Value.Entity == null, null, true, _rootState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue