Run orbital turret controllers in daemon

This commit is contained in:
Meta Vens 2026-07-17 02:40:34 +01:00
commit dda5c1787e
7 changed files with 348 additions and 43 deletions

View file

@ -176,6 +176,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
FossilVelocityBehaviorsRunInDaemonFlightStep,
ReflectorUsesSharedStellarLightFieldWithoutAccumulating,
SensorPingIsActorScopedEnergyGatedAndReconnectable,
TurretControllerAcquiresAimsAndTriggersExactWeapons,
TractorRampsAndPullsThroughYmirWithoutTeleportingCargo,
PickupIsCapacityCheckedExactlyOnceAndExpires,
TradePurchaseDerivesAcceptanceFromDaemonState,
@ -531,9 +532,9 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
Require(sensor.Pinging && !otherSensor.Pinging,
"sensor ping intent must retain actor identity instead of activating every sensor");
RequireEqual(2, sensor.PingedEntityCount,
"expanding ping must persist every crossed entity identity for reconnect-safe exactly-once boost");
"expanding ping must persist every crossed target index for reconnect-safe exactly-once boost");
Require(sensor.PingedEntityIndices.SequenceEqual(new[] { 1, 2 }),
"pinged entity identities must survive in stable order rather than only an unverifiable count");
"pinged target indices must survive in stable order rather than only an unverifiable count");
RequireNear(5, actor.BehaviorStates.Single(state => state.BehaviorKind == "Capacitor").CapacitorCharge,
0.000001, "accepted ping must consume its authored energy exactly once");
Require(actor.Contacts.Single(contact => contact.TargetEntityIndex == 2).Visible,
@ -544,6 +545,118 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
"accepted ping must emit one provider-owned start event");
}
private static void TurretControllerAcquiresAimsAndTriggersExactWeapons()
{
var weaponPayload = new AetheriaRuntimeBehaviorPayload(
0,
AetheriaRuntimeBehaviorKinds.InstantWeapon,
0,
[
new AetheriaRuntimeBehaviorField(2, PerformanceStat(10)),
new AetheriaRuntimeBehaviorField(5, PerformanceStat(0)),
new AetheriaRuntimeBehaviorField(6, PerformanceStat(200)),
new AetheriaRuntimeBehaviorField(16, PerformanceStat(100)),
new AetheriaRuntimeBehaviorField(17, PerformanceStat(1)),
new AetheriaRuntimeBehaviorField(19, PerformanceStat(0.1)),
new AetheriaRuntimeBehaviorField(21, PerformanceStat(100)),
new AetheriaRuntimeBehaviorField(22, PerformanceStat(0)),
new AetheriaRuntimeBehaviorField(23, PerformanceStat(180)),
new AetheriaRuntimeBehaviorField(24, PerformanceStat(1)),
new AetheriaRuntimeBehaviorField(25, PerformanceStat(1))
]);
var weaponItem = CatalogItem("turret-smoke-weapon", weaponPayload);
var controllerItem = CatalogItem(
"turret-smoke-controller",
new AetheriaRuntimeBehaviorPayload(0, AetheriaRuntimeBehaviorKinds.TurretController, 0, []));
var catalog = new AetheriaRuntimeCatalogSnapshot([controllerItem, weaponItem], [], []);
var uncontrolled = Entity(0, 0, "raider");
uncontrolled.DirectionX = 1;
uncontrolled.WeaponGroups = [new[] { 0 }];
uncontrolled.TargetEntityIndex = 1;
uncontrolled.Equipment = [new AetheriaRuntimeLoadoutItemSlotCommit
{
Item = new AetheriaRuntimeLoadoutItemCommit
{ ItemKey = weaponItem.ItemKey, Quality = 1, Durability = 1, Enabled = true }
}];
uncontrolled.Contacts = [new AetheriaRuntimeEntityContactCommit
{ TargetEntityIndex = 1, InfoGathered = 1, Visible = true, Hostile = true }];
var uncontrolledTarget = Entity(1, 100, "player");
var uncontrolledZone = new AetheriaRuntimeZoneSnapshotCommit
{ ZoneIndex = 0, Entities = [uncontrolled, uncontrolledTarget] };
var uncontrolledRun = new AetheriaRuntimeRunCheckpointCommit
{ RunId = "uncontrolled-hostile-smoke", Zones = [uncontrolledZone] };
using (var physics = NewPhysics())
{
for (var frame = 0; frame < 3; frame++)
AetheriaRuntimeDaemonSimulation.Step(
uncontrolledRun,
new AetheriaRuntimeDaemonIntentState(),
0.1,
new AetheriaRuntimeDaemonSimulationSettings(),
physics,
catalog,
frame,
frame * 0.1);
}
RequireEqual(0, uncontrolledRun.ShotReceipts.Count,
"non-player entities without a controller or command must not inherit the removed group-zero fire authority");
var turret = Entity(0, 0, "player");
turret.Kind = "station";
turret.DirectionX = 1;
turret.DirectionY = 0;
turret.Equipment =
[
new AetheriaRuntimeLoadoutItemSlotCommit
{
Item = new AetheriaRuntimeLoadoutItemCommit
{ ItemKey = controllerItem.ItemKey, Quality = 1, Durability = 1, Enabled = true }
},
new AetheriaRuntimeLoadoutItemSlotCommit
{
Rotation = "None",
Item = new AetheriaRuntimeLoadoutItemCommit
{ ItemKey = weaponItem.ItemKey, Quality = 1, Durability = 1, Enabled = true }
},
new AetheriaRuntimeLoadoutItemSlotCommit
{
Rotation = "Half",
Item = new AetheriaRuntimeLoadoutItemCommit
{ ItemKey = weaponItem.ItemKey, Quality = 1, Durability = 1, Enabled = true }
}
];
turret.WeaponGroups = [new[] { 1, 2 }];
turret.Contacts = [new AetheriaRuntimeEntityContactCommit
{ TargetEntityIndex = 1, InfoGathered = 1, Visible = true, Hostile = true }];
var target = Entity(1, 100, "raider");
target.VelocityY = 5;
var zone = new AetheriaRuntimeZoneSnapshotCommit { ZoneIndex = 0, Entities = [turret, target] };
var run = new AetheriaRuntimeRunCheckpointCommit { RunId = "turret-controller-smoke", Zones = [zone] };
using (var physics = NewPhysics())
{
AetheriaRuntimeDaemonSimulation.Step(run, new AetheriaRuntimeDaemonIntentState(), 0.1,
new AetheriaRuntimeDaemonSimulationSettings(), physics, catalog, 0, 0);
RequireEqual(target.EntityIndex, turret.TargetEntityIndex,
"an idle turret controller must acquire the first visible hostile ship without firing on the acquisition tick");
RequireEqual(0, run.ShotReceipts.Count,
"target acquisition must not smuggle an extra trigger into the same fossil controller tick");
AetheriaRuntimeDaemonSimulation.Step(run, new AetheriaRuntimeDaemonIntentState(), 0.1,
new AetheriaRuntimeDaemonSimulationSettings(), physics, catalog, 1, 0.1);
}
var controllerState = turret.BehaviorStates.Single(state =>
state.BehaviorKind == AetheriaRuntimeBehaviorKinds.TurretController);
RequireEqual(2, controllerState.TurretControllerWeaponCount,
"turret controller initialization must publish its exact operational weapon count");
Require(controllerState.TurretControllerPredictShots &&
Math.Abs(controllerState.TurretControllerShotSpeed - 100) < 0.000001 &&
turret.LookDirectionY > 0,
"projectile velocity must enable the fossil first-order intercept aim and persist its controller state");
Require(run.ShotReceipts.Count > 0 && run.ShotReceipts.All(receipt => receipt.WeaponOwnerIndex == 1),
"turret controller must trigger only the exact in-range aligned weapon behavior, not its group or reversed neighbor");
}
private static void DockingUsesRealBaysAndFossilUndockRules()
{
var catalog = new AetheriaRuntimeCatalogSnapshot(

View file

@ -20,6 +20,7 @@ namespace GameCult.Aetheria.State.Verse
public const string Reflector = "Reflector";
public const string Visibility = "Visibility";
public const string Sensor = "Sensor";
public const string TurretController = "TurretController";
private static readonly ISet<string> WeaponKinds = new HashSet<string>(StringComparer.Ordinal)
{

View file

@ -495,22 +495,17 @@ namespace GameCult.Aetheria.State.Verse
RefreshShieldProjection(entity, catalog);
foreach (var attacker in entities)
{
var weaponGroup = ResolveFireGroup(run, zone, attacker, intents);
StepDeployableWeapons(run, zone, attacker, weaponGroup, deltaSeconds, settings, catalog, frameId);
StepChargedWeapons(run, zone, attacker, byIndex, weaponGroup, deltaSeconds,
var requestedWeapons = ResolveWeaponTriggers(zone, attacker, entities, intents, catalog);
StepDeployableWeapons(run, zone, attacker, requestedWeapons, deltaSeconds, settings, catalog, frameId);
StepChargedWeapons(run, zone, attacker, byIndex, requestedWeapons, deltaSeconds,
settings, catalog, frameId);
StepConstantWeapons(run, zone, byIndex, attacker, weaponGroup, deltaSeconds,
StepConstantWeapons(run, zone, byIndex, attacker, requestedWeapons, deltaSeconds,
settings, catalog, frameId);
var weapons = ResolveWeapons(attacker, catalog, settings);
var requestedEquipment = weaponGroup >= 0 && weaponGroup <
(attacker.WeaponGroups ?? Array.Empty<IReadOnlyList<int>>()).Count
? attacker.WeaponGroups[weaponGroup] ?? Array.Empty<int>()
: Array.Empty<int>();
foreach (var weapon in weapons)
{
weapon.State.Firing = false;
if (weaponGroup >= 0 &&
(catalog == null || requestedEquipment.Contains(weapon.State.OwnerIndex)))
if (requestedWeapons.Contains(weapon.State.OwnerIndex, weapon.State.BehaviorIndex))
weapon.State.TriggerPending = true;
if (weapon.State.Reloading)
{
@ -659,19 +654,19 @@ namespace GameCult.Aetheria.State.Verse
AetheriaRuntimeRunCheckpointCommit run,
AetheriaRuntimeZoneSnapshotCommit zone,
AetheriaRuntimeEntitySnapshotCommit attacker,
int weaponGroup,
WeaponTriggerSet requestedWeapons,
double deltaSeconds,
AetheriaRuntimeDaemonSimulationSettings settings,
AetheriaRuntimeCatalogSnapshot? catalog,
long frameId)
{
foreach (var deployable in ResolveDeployableWeapons(attacker, weaponGroup, catalog, settings))
foreach (var deployable in ResolveDeployableWeapons(attacker, requestedWeapons, catalog, settings))
{
var weapon = deployable.Weapon;
weapon.State.Firing = false;
weapon.State.CooldownProgress = Math.Max(0, weapon.State.CooldownProgress - deltaSeconds);
weapon.State.CoolingDown = weapon.State.CooldownProgress > 0;
if (!IsAlive(attacker) || weaponGroup < 0 || weapon.State.CooldownProgress > 0) continue;
if (!IsAlive(attacker) || weapon.State.CooldownProgress > 0) continue;
var result = CommitWeaponRound(attacker, weapon, catalog);
PublishWeaponRoundResult(run, zone, attacker, weapon, frameId, result);
@ -813,13 +808,13 @@ namespace GameCult.Aetheria.State.Verse
AetheriaRuntimeZoneSnapshotCommit zone,
AetheriaRuntimeEntitySnapshotCommit attacker,
IReadOnlyDictionary<int, AetheriaRuntimeEntitySnapshotCommit> byIndex,
int requestedWeaponGroup,
WeaponTriggerSet requestedWeapons,
double deltaSeconds,
AetheriaRuntimeDaemonSimulationSettings settings,
AetheriaRuntimeCatalogSnapshot? catalog,
long frameId)
{
foreach (var weapon in ResolveChargedWeapons(attacker, requestedWeaponGroup, catalog, settings))
foreach (var weapon in ResolveChargedWeapons(attacker, requestedWeapons, catalog, settings))
{
var state = weapon.Base.State;
state.Firing = false;
@ -1006,13 +1001,13 @@ namespace GameCult.Aetheria.State.Verse
AetheriaRuntimeZoneSnapshotCommit zone,
IReadOnlyDictionary<int, AetheriaRuntimeEntitySnapshotCommit> byIndex,
AetheriaRuntimeEntitySnapshotCommit attacker,
int weaponGroup,
WeaponTriggerSet requestedWeapons,
double deltaSeconds,
AetheriaRuntimeDaemonSimulationSettings settings,
AetheriaRuntimeCatalogSnapshot? catalog,
long frameId)
{
foreach (var weapon in ResolveConstantWeapons(attacker, weaponGroup, catalog, settings))
foreach (var weapon in ResolveConstantWeapons(attacker, requestedWeapons, catalog, settings))
{
if (weapon.State.Reloading)
{
@ -1026,7 +1021,7 @@ namespace GameCult.Aetheria.State.Verse
}
byIndex.TryGetValue(attacker.TargetEntityIndex, out var selectedTarget);
var validTarget = IsAlive(attacker) && weaponGroup >= 0 &&
var validTarget = IsAlive(attacker) &&
attacker.TargetEntityIndex >= 0 && selectedTarget != null &&
IsAlive(selectedTarget) && Hostile(attacker, selectedTarget) &&
DistanceSq(attacker, selectedTarget) <= weapon.Range * weapon.Range;
@ -1408,20 +1403,33 @@ namespace GameCult.Aetheria.State.Verse
projectile.VelocityY = projectile.DirectionY * speed;
}
private static int ResolveFireGroup(
AetheriaRuntimeRunCheckpointCommit run,
private static WeaponTriggerSet ResolveWeaponTriggers(
AetheriaRuntimeZoneSnapshotCommit zone,
AetheriaRuntimeEntitySnapshotCommit attacker,
AetheriaRuntimeDaemonIntentState intents)
IReadOnlyList<AetheriaRuntimeEntitySnapshotCommit> entities,
AetheriaRuntimeDaemonIntentState intents,
AetheriaRuntimeCatalogSnapshot? catalog)
{
var intent = (intents == null
var triggers = new WeaponTriggerSet();
var groups = attacker.WeaponGroups ?? Array.Empty<IReadOnlyList<int>>();
foreach (var intent in (intents == null
? Enumerable.Empty<AetheriaRuntimeDaemonWeaponGroupIntent>()
: intents.WeaponGroups)
.LastOrDefault(intent => intent != null &&
.Where(intent => intent != null &&
ActorMatches(intent.ActorEntityKey, zone.ZoneIndex, attacker.EntityIndex) &&
intent.Fire &&
intent.Active);
return intent?.WeaponGroup ?? (IsPlayerOwned(attacker) ? -1 : 0);
intent.Active))
{
if (intent.WeaponGroup < 0 || intent.WeaponGroup >= groups.Count)
continue;
foreach (var equipmentIndex in groups[intent.WeaponGroup] ?? Array.Empty<int>())
triggers.RequestEquipment(equipmentIndex);
}
foreach (var request in AetheriaRuntimeTurretControllerSimulation.StepEntity(
attacker, entities, catalog))
triggers.RequestBehavior(request.EquipmentIndex, request.BehaviorIndex);
return triggers;
}
private static bool ActorMatches(string actorEntityKey, int zoneIndex, int entityIndex) =>
@ -1430,13 +1438,10 @@ namespace GameCult.Aetheria.State.Verse
private static IReadOnlyList<ResolvedConstantWeapon> ResolveConstantWeapons(
AetheriaRuntimeEntitySnapshotCommit entity,
int weaponGroup,
WeaponTriggerSet requestedWeapons,
AetheriaRuntimeCatalogSnapshot? catalog,
AetheriaRuntimeDaemonSimulationSettings settings)
{
var equipmentIndices = weaponGroup >= 0 && weaponGroup < (entity.WeaponGroups ?? Array.Empty<IReadOnlyList<int>>()).Count
? entity.WeaponGroups[weaponGroup] ?? Array.Empty<int>()
: Array.Empty<int>();
return AetheriaRuntimeEquippedBehaviorQueries.FindOperational(entity, catalog, AetheriaRuntimeBehaviorKinds.ConstantWeapon)
.Select(behavior =>
{
@ -1446,7 +1451,8 @@ namespace GameCult.Aetheria.State.Verse
magazineSize > 1 ? magazineSize : 1,
settings);
return new ResolvedConstantWeapon(
state, behavior.Item.ItemKey, equipmentIndices.Contains(behavior.EquipmentIndex),
state, behavior.Item.ItemKey,
requestedWeapons.Contains(behavior.EquipmentIndex, behavior.BehaviorIndex),
Math.Max(0, behavior.EvaluateStat(2)),
PositiveOr(behavior.EvaluateStat(6), 1),
Math.Max(0, behavior.EvaluateStat(9)),
@ -1463,15 +1469,12 @@ namespace GameCult.Aetheria.State.Verse
private static IReadOnlyList<ResolvedDeployableWeapon> ResolveDeployableWeapons(
AetheriaRuntimeEntitySnapshotCommit entity,
int weaponGroup,
WeaponTriggerSet requestedWeapons,
AetheriaRuntimeCatalogSnapshot? catalog,
AetheriaRuntimeDaemonSimulationSettings settings)
{
var equipmentIndices = weaponGroup >= 0 && weaponGroup < (entity.WeaponGroups ?? Array.Empty<IReadOnlyList<int>>()).Count
? entity.WeaponGroups[weaponGroup] ?? Array.Empty<int>()
: Array.Empty<int>();
return AetheriaRuntimeEquippedBehaviorQueries.FindOperational(entity, catalog, AetheriaRuntimeBehaviorKinds.DeployableWeapon)
.Where(behavior => equipmentIndices.Contains(behavior.EquipmentIndex))
.Where(behavior => requestedWeapons.Contains(behavior.EquipmentIndex, behavior.BehaviorIndex))
.Select(behavior => new ResolvedDeployableWeapon(
ResolveAuthoredWeapon(entity, behavior, settings),
Math.Max(0, ReadNumber(behavior.Payload, 26)),
@ -1815,17 +1818,15 @@ namespace GameCult.Aetheria.State.Verse
}
private static IReadOnlyList<ResolvedChargedWeapon> ResolveChargedWeapons(
AetheriaRuntimeEntitySnapshotCommit entity, int requestedWeaponGroup,
AetheriaRuntimeEntitySnapshotCommit entity, WeaponTriggerSet requestedWeapons,
AetheriaRuntimeCatalogSnapshot? catalog, AetheriaRuntimeDaemonSimulationSettings settings)
{
var requestedEquipment = requestedWeaponGroup >= 0 && requestedWeaponGroup <
(entity.WeaponGroups ?? Array.Empty<IReadOnlyList<int>>()).Count
? entity.WeaponGroups[requestedWeaponGroup] ?? Array.Empty<int>() : Array.Empty<int>();
return AetheriaRuntimeEquippedBehaviorQueries.FindOperational(entity, catalog, AetheriaRuntimeBehaviorKinds.ChargedWeapon)
.Where(value => string.Equals(value.Payload.Kind, AetheriaRuntimeBehaviorKinds.ChargedWeapon, StringComparison.Ordinal))
.Select(value => new ResolvedChargedWeapon(
ResolveAuthoredWeapon(entity, value, settings), value.Item,
requestedEquipment.Contains(value.EquipmentIndex), PositiveOr(value.EvaluateStat(21), 1),
requestedWeapons.Contains(value.EquipmentIndex, value.BehaviorIndex),
PositiveOr(value.EvaluateStat(21), 1),
Math.Max(0, value.EvaluateStat(22)), Math.Max(0, value.EvaluateStat(23)),
ReadNumber(value.Payload, 25), PositiveOr(ReadNumber(value.Payload, 26), 1),
PositiveOr(ReadNumber(value.Payload, 27), 1), PositiveOr(ReadNumber(value.Payload, 29), 1),
@ -2032,6 +2033,23 @@ namespace GameCult.Aetheria.State.Verse
AetheriaRuntimeThermalSimulation.ApplyWear(entity, state.OwnerIndex, wear * multiplier);
}
private sealed class WeaponTriggerSet
{
private readonly HashSet<int> _requestedEquipment = new HashSet<int>();
private readonly HashSet<(int EquipmentIndex, int BehaviorIndex)> _requestedBehaviors =
new HashSet<(int EquipmentIndex, int BehaviorIndex)>();
public void RequestEquipment(int equipmentIndex) =>
_requestedEquipment.Add(equipmentIndex);
public void RequestBehavior(int equipmentIndex, int behaviorIndex) =>
_requestedBehaviors.Add((equipmentIndex, behaviorIndex));
public bool Contains(int equipmentIndex, int behaviorIndex) =>
_requestedEquipment.Contains(equipmentIndex) ||
_requestedBehaviors.Contains((equipmentIndex, behaviorIndex));
}
private enum WeaponRoundResult { Fired, ReloadStarted, InsufficientEnergy, NoAmmo }
private sealed class ResolvedWeapon

View file

@ -0,0 +1,133 @@
using System;
using System.Collections.Generic;
using System.Linq;
#nullable enable
namespace GameCult.Aetheria.State.Verse
{
public sealed class AetheriaRuntimeTurretWeaponRequest
{
public AetheriaRuntimeTurretWeaponRequest(int equipmentIndex, int behaviorIndex)
{
EquipmentIndex = equipmentIndex;
BehaviorIndex = behaviorIndex;
}
public int EquipmentIndex { get; }
public int BehaviorIndex { get; }
}
public static class AetheriaRuntimeTurretControllerSimulation
{
public static IReadOnlyList<AetheriaRuntimeTurretWeaponRequest> StepEntity(
AetheriaRuntimeEntitySnapshotCommit entity,
IReadOnlyList<AetheriaRuntimeEntitySnapshotCommit> entities,
AetheriaRuntimeCatalogSnapshot? catalog)
{
var controllers = AetheriaRuntimeEquippedBehaviorQueries.FindOperational(
entity, catalog, AetheriaRuntimeBehaviorKinds.TurretController);
if (controllers.Count == 0)
return Array.Empty<AetheriaRuntimeTurretWeaponRequest>();
var weapons = AetheriaRuntimeEquippedBehaviorQueries.FindOperational(entity, catalog, "Weapon");
var shotSpeed = 0.0;
var predictShots = false;
foreach (var weapon in weapons)
{
var velocity = Math.Max(0, weapon.EvaluateStat(16, ThermalPerformance(entity, weapon.EquipmentIndex)));
if (velocity <= 0.1)
continue;
predictShots = true;
shotSpeed = velocity;
}
foreach (var controller in controllers)
{
controller.State.TurretControllerWeaponCount = weapons.Count;
controller.State.TurretControllerShotSpeed = shotSpeed;
controller.State.TurretControllerPredictShots = predictShots;
}
var target = entities.FirstOrDefault(candidate =>
candidate != null && candidate.EntityIndex == entity.TargetEntityIndex && candidate.IsActive);
if (target == null)
{
entity.TargetEntityIndex = SelectVisibleEnemyShip(entity, entities)?.EntityIndex ?? -1;
return Array.Empty<AetheriaRuntimeTurretWeaponRequest>();
}
var dx = target.PositionX - entity.PositionX;
var dz = target.PositionZ - entity.PositionZ;
var distance = Math.Sqrt(dx * dx + dz * dz);
var aim = predictShots
? InterceptDirection(dx, dz, target.VelocityX, target.VelocityY, shotSpeed)
: Normalize(dx, dz, 0, 1);
entity.LookDirectionX = aim.X;
entity.LookDirectionY = aim.Y;
var forward = Normalize(entity.DirectionX, entity.DirectionY, 0, 1);
return weapons
.Where(weapon => weapon.EvaluateStat(6, ThermalPerformance(entity, weapon.EquipmentIndex)) > distance)
.Where(weapon =>
{
var direction = AetheriaRuntimeEquipmentRotation.RotateQuarter(
forward.X,
forward.Y,
AetheriaRuntimeEquipmentRotation.QuarterTurns(weapon.Slot.Rotation));
return direction.X * aim.X + direction.Y * aim.Y > 0.99;
})
.Select(weapon => new AetheriaRuntimeTurretWeaponRequest(
weapon.EquipmentIndex, weapon.BehaviorIndex))
.ToArray();
}
private static AetheriaRuntimeEntitySnapshotCommit? SelectVisibleEnemyShip(
AetheriaRuntimeEntitySnapshotCommit observer,
IReadOnlyList<AetheriaRuntimeEntitySnapshotCommit> entities)
{
var visibleHostiles = (observer.Contacts ?? Array.Empty<AetheriaRuntimeEntityContactCommit>())
.Where(contact => contact != null && contact.Visible && contact.Hostile)
.Select(contact => contact.TargetEntityIndex)
.ToHashSet();
return entities.FirstOrDefault(candidate =>
candidate != null &&
candidate.IsActive &&
string.Equals(candidate.Kind, "ship", StringComparison.OrdinalIgnoreCase) &&
visibleHostiles.Contains(candidate.EntityIndex));
}
private static (double X, double Y) InterceptDirection(
double relativeX,
double relativeY,
double targetVelocityX,
double targetVelocityY,
double shotSpeed)
{
var relative = new CultMath.float3((float)relativeX, 0, (float)relativeY);
var velocity = new CultMath.float3((float)targetVelocityX, 0, (float)targetVelocityY);
var time = CultMath.math.first_order_intercept_time((float)shotSpeed, relative, velocity);
return Normalize(
relativeX + targetVelocityX * time,
relativeY + targetVelocityY * time,
relativeX,
relativeY);
}
private static double ThermalPerformance(AetheriaRuntimeEntitySnapshotCommit entity, int equipmentIndex) =>
(entity.EquipmentStates ?? Array.Empty<AetheriaRuntimeEquipmentStateCommit>())
.FirstOrDefault(state => state != null && state.EquipmentIndex == equipmentIndex)?
.ThermalPerformance ?? 1;
private static (double X, double Y) Normalize(
double x, double y, double fallbackX, double fallbackY)
{
var length = Math.Sqrt(x * x + y * y);
if (length > 0.000001)
return (x / length, y / length);
var fallbackLength = Math.Sqrt(fallbackX * fallbackX + fallbackY * fallbackY);
return fallbackLength > 0.000001
? (fallbackX / fallbackLength, fallbackY / fallbackLength)
: (0, 1);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a34ea05f7f6045f587f8d3f9432fb979
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -830,6 +830,35 @@ one `weapon.lock.acquired`, and one `shot.committed` event. Ymir reconstructs
process-local bodies from committed world state; it does not own weapon
lifecycle state.
### Daemon Orbital Turret Controller
- Owner: each operational installed `TurretController` behavior owns automatic
target acquisition, predictive look direction, and its exact per-weapon
trigger set. Ship agent combat remains owned by the task planner and pilot
fire remains an accepted command; neither path impersonates an orbital
controller.
- Inputs: visible hostile ship contacts in stable zone order, current target,
entity and target pose/velocity, operational weapon behaviors, evaluated
weapon range and velocity, and catalog placement rotation.
- Outputs: selected target, daemon look direction, reconnectable controller
weapon count/shot speed/predictive flag, and behavior-granular weapon
requests consumed by the ordinary instant, constant, charged, and deployable
weapon lifecycle.
- Derived state: turret tracking animation, barrel articulation, muzzle effects,
target indicators, and audio are Eve presentation of daemon aim, weapon state,
shot receipts, and feedback chronology.
- Forbidden writers: faction identity, entity kind, Unity update loops, and
generic Eve lowerers cannot grant automatic fire. The deleted non-player
group-zero fallback is not a compatibility path.
- Shared paths: pilot and ship-agent group commands expand to every weapon
behavior on their assigned equipment; turret control requests only the exact
aligned in-range behavior. All then enter the same lock, charge, burst,
energy, heat, wear, visibility, shot, and damage transactions.
- Verification: daemon smoke proves no controller/no command means no hostile
auto-fire; acquisition does not fire in the same fossil tick; projectile
velocity enables CultMath first-order intercept; and a forward weapon fires
while the reversed behavior remains inactive.
### Daemon Damage Transaction
- Owner: the daemon's canonical damage transaction owns damage-layer ordering

View file

@ -45,7 +45,7 @@ validation proves contract shape, not wiring, exclusivity, lowering, or parity.
| Starbridge | original/shared architecture intent | one daemon session | pilot + commander surfaces | Unity + Electron | commander task board and autonomous explore execution wired; Electron Eve lowering and split-target proof missing | commander orders plus four pilots and autonomous workers |
| Behavior engine | `ServerShared/Behaviors` composition | daemon | executable action/status projection | action bar and feedback | tick reconciles equipped catalog payloads into persistent behavior state; shared evaluated-stat query proven; execution families remain partial | every behavior family, ordering, resource transaction and modifier lifecycle |
| Sensors/visibility | installed sensor sensitivity and angular curve, `Visibility`, `Reflector`, decaying signature sources, stellar light, ping state, and observer information thresholds | daemon | accumulated contacts, named visibility sources, and ping events | indicators/maps and provider environment lowering | every operational installed Sensor executes the fossil visibility/sensitivity/angle/distance information equation and decay; visibility is thresholded by the provider setting. Actor-scoped ping owns energy, cooldown, expansion radius, reconnect-stable crossed-target state, one-time information boost, and transient signature. Operational `Visibility` equipment publishes evaluated constant signature; committed weapons publish authored signature including charged-shot multiplication; transient weapon and ping sources decay by the fossil exponential rule. Reflectors multiply evaluated cross-section by the exponent-8 stellar `PowerPulse` after thermal settlement. Gameplay light and environment projection share resolved authored orbit/body centers and provider-owned sun radius inputs. Contact refresh no longer invents perfect information or overwrites emitted visibility; docked craft consume one daemon-derived union of craft and dock-parent contacts through both Eve rows and SoA bodies, with sensor-source provenance | active consumable visibility/reflector effects, complete source cardinality, classification timelines, and canonical catalog station-array data |
| AI/tasks | corporation task scheduler plus agent state machines | daemon | commander task board, corporation survey ledger, and shared semantic controls | Eve commander/pilot clients | point exploration, loadout-driven attack, haul, mining/offload, resource surveying, physical station towing, persistent orbit patrol, route-aware assignment, and autonomous return home are wired through shared commands. Combat samples the fossil DPS/range policy, selects live weapon groups, leads projectiles, strafes relative to target attitude, and gates fire on catalog placement rotation. Cross-zone task and home routes now survive the full daemon-owned wormhole timeline instead of instant transfer; attack admission rejects missing/friendly targets and unavailable weapon groups before durable queueing | cancellation, reconnect, multi-client command transfer, and model-local barrel-direction metadata |
| AI/tasks | corporation task scheduler plus agent state machines and installed orbital `TurretController` | daemon | commander task board, corporation survey ledger, controller aim/state, and shared semantic controls | Eve commander/pilot clients | point exploration, loadout-driven attack, haul, mining/offload, resource surveying, physical station towing, persistent orbit patrol, route-aware assignment, and autonomous return home are wired through shared commands. Ship combat samples the fossil DPS/range policy, selects live weapon groups, leads projectiles, strafes relative to target attitude, and gates fire on catalog placement rotation. Operational orbital controllers independently acquire the first visible hostile ship, publish predictive look direction, and trigger only exact aligned in-range weapon behaviors through the shared combat lifecycle; non-player identity no longer grants implicit group-zero fire. Cross-zone task and home routes survive the full daemon-owned wormhole timeline; attack admission rejects missing/friendly targets and unavailable weapon groups before durable queueing | cancellation, reconnect, multi-client command transfer, and model-local barrel-direction metadata |
| Consumables | cargo-backed timed behavior containers | daemon | dynamic actions, active effects, and lifecycle facts | action bar/schematic | daemon atomically resolves typed metadata and concrete cargo, preserves consumed-instance quality, enforces authored stacking, evaluates effectiveness/quality, and executes ordered `EnergyDraw`, fossil-compatible no-op `Heat`, `ItemUsage`, and stateful `Cooldown` payloads after energy tick initialization; every effect and payload state has stable authored identity; cooldowns update before the ordered chain, require state strictly below zero, reset to one on success, and continue aging behind earlier failures; false and unsupported payloads stop later execution with a typed fact; timers retain the fossil's exact-zero final tick; Unity reconciles presentation by effect identity and cannot restore active behavior state by list index | catalog revision pinning, stat modifiers, remaining behavior families, and reconnect presentation proof |
## Ownership Invariants