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
|
|
@ -11,6 +11,7 @@ public class CombatState : BaseState
|
|||
{
|
||||
private const int DPS_SAMPLE_COUNT = 32;
|
||||
private float _optimumRange;
|
||||
public float OptimumRange => _optimumRange;
|
||||
private readonly List<(int index, float dps)> _availableGroups = new List<(int index, float dps)>();
|
||||
private readonly List<LockWeapon> _availableLockingWeapons = new List<LockWeapon>();
|
||||
|
||||
|
|
@ -118,7 +119,7 @@ public class CombatState : BaseState
|
|||
// fires at, and "the target is designated" for a fused one.
|
||||
foreach (var weapon in _agent.Ship.WeaponGroups[selectedGroup].weapons)
|
||||
{
|
||||
if (FireControl.AgentFires(weapon, _agent.Ship, target))
|
||||
if (FireControl.AgentFires(weapon, _agent.Ship, target, _agent.Doctrine.MinHitProbability))
|
||||
weapon.Activate();
|
||||
else if (weapon.Firing)
|
||||
weapon.Deactivate();
|
||||
|
|
@ -156,7 +157,7 @@ public class CombatState : BaseState
|
|||
}
|
||||
|
||||
// Multiply by range raised to a (sublinear) exponent to bias DPS preference towards longer ranges
|
||||
dps *= pow(range, _agent.Settings.AgentRangeExponent);
|
||||
dps *= pow(range, _agent.Doctrine.RangeExponent);
|
||||
|
||||
if (dps > optimumDPS)
|
||||
{
|
||||
|
|
|
|||
26
Assets/Scripts/ServerShared/Agents/States/Follow.cs
Normal file
26
Assets/Scripts/ServerShared/Agents/States/Follow.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
using CultMath;
|
||||
using static CultMath.math;
|
||||
using float2 = CultMath.float2;
|
||||
|
||||
// Hold a standoff from the anchor: match its velocity, and close or open the gap in proportion to the error.
|
||||
public class FollowState : BaseState
|
||||
{
|
||||
public FollowState(Agent agent) : base(agent) { }
|
||||
|
||||
public override void Update(float delta)
|
||||
{
|
||||
var task = _agent.Task as FollowTask;
|
||||
if (task?.Anchor == null) return;
|
||||
|
||||
var toAnchor = task.Anchor.Position.xz - _agent.Ship.Position.xz;
|
||||
var distance = length(toAnchor);
|
||||
var direction = distance > 0 ? toAnchor / distance : _agent.Ship.Direction;
|
||||
// Positive error: too far, close. Negative: too near, open.
|
||||
var error = distance - task.Standoff;
|
||||
var pull = direction * (float) sign(error) * saturate(abs(error) / max(task.Standoff, 1f));
|
||||
var desired = task.Anchor.Velocity + pull * _agent.TopSpeed;
|
||||
|
||||
_agent.Ship.Aim = float3(direction.x, 0, direction.y);
|
||||
_agent.Accelerate(desired);
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/ServerShared/Agents/States/Follow.cs.meta
Normal file
2
Assets/Scripts/ServerShared/Agents/States/Follow.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5cf86244ca6648a99f304b061b66348a
|
||||
Loading…
Reference in a new issue