Add authoritative Ymir beam tracing

This commit is contained in:
Meta Vens 2026-07-12 00:23:08 +01:00
commit 03a9f949b2
6 changed files with 114 additions and 2 deletions

View file

@ -11,6 +11,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
public void Run()
{
YmirMovesProjectileAndReportsStableContact();
YmirBeamTraceReturnsFirstSpatialContact();
DaemonSimulationAppliesYmirHit();
ProjectileDeathEmitsOnce();
MissingPhysicsOwnerCannotAdvanceProjectiles();
@ -42,6 +43,27 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
AgentTowsStationIntoPersistentOrbit();
}
private static void YmirBeamTraceReturnsFirstSpatialContact()
{
var source = Entity(0, 0, "player");
var blocker = Entity(1, 40, "raider");
var selectedTarget = Entity(2, 90, "raider");
var zone = new AetheriaRuntimeZoneSnapshotCommit
{
ZoneIndex = 0,
Entities = [source, blocker, selectedTarget]
};
var hit = new AetheriaYmirProjectilePhysics().TraceBeam(
zone, zone.Entities, source.EntityIndex,
source.PositionX, source.PositionZ, 1, 0, 150, 0.1);
Require(hit != null, "Ymir beam trace must report an intersected body");
RequireEqual(blocker.EntityIndex, hit!.TargetEntityIndex,
"beam trace must return the first spatial contact rather than the selected target");
Require(hit.Distance > 0 && hit.Distance < 90,
"beam trace must publish the physical impact distance");
}
private static void AgentTowsStationIntoPersistentOrbit()
{
var tug = Entity(0, 0, "workers");

View file

@ -109,6 +109,51 @@ public sealed class AetheriaYmirProjectilePhysics : IAetheriaRuntimeProjectilePh
return new AetheriaRuntimeProjectileStep(survivors, hits);
}
public AetheriaRuntimeBeamHit? TraceBeam(
AetheriaRuntimeZoneSnapshotCommit zone,
IReadOnlyList<AetheriaRuntimeEntitySnapshotCommit> entities,
int sourceEntityIndex,
double originX,
double originZ,
double directionX,
double directionZ,
double range,
double radius)
{
ArgumentNullException.ThrowIfNull(zone);
var entityByBodyId = (entities ?? Array.Empty<AetheriaRuntimeEntitySnapshotCommit>())
.Where(entity => entity is { IsActive: true } && entity.EntityIndex != sourceEntityIndex)
.ToDictionary(entity => EntityBodyId(entity.EntityIndex), StringComparer.Ordinal);
var world = new YmirWorld((float)zone.SimulationTimeSeconds,
entityByBodyId.Select(pair => new PhysicsBody(
pair.Key,
new Vec2((float)pair.Value.PositionX, (float)pair.Value.PositionZ),
Vec2.Zero,
ResolveEntityRadius(pair.Value),
1.0f,
IsStatic: true)).ToArray(),
Array.Empty<RadialField>());
var hit = _simulator.CastCircle(new CircleCastQueryRequest(
new Vec2((float)originX, (float)originZ),
new Vec2((float)directionX, (float)directionZ),
(float)range,
(float)Math.Max(0, radius),
world))
.Hits.FirstOrDefault(candidate => entityByBodyId.ContainsKey(candidate.BodyId));
if (hit == null || !entityByBodyId.TryGetValue(hit.BodyId, out var target))
return null;
return new AetheriaRuntimeBeamHit
{
TargetEntityIndex = target.EntityIndex,
TargetBodyId = hit.BodyId,
PointX = hit.Point.X,
PointZ = hit.Point.Y,
NormalX = hit.Normal.X,
NormalZ = hit.Normal.Y,
Distance = hit.Distance
};
}
private static string ProjectileBodyId(string? projectileId) =>
ProjectileBodyPrefix + (projectileId ?? "");

View file

@ -5574,5 +5574,16 @@ public class DaemonRuntimeDocumentTests
zone.Projectiles,
Array.Empty<AetheriaRuntimeProjectileHit>());
}
public AetheriaRuntimeBeamHit TraceBeam(
AetheriaRuntimeZoneSnapshotCommit zone,
IReadOnlyList<AetheriaRuntimeEntitySnapshotCommit> entities,
int sourceEntityIndex,
double originX,
double originZ,
double directionX,
double directionZ,
double range,
double radius) => null;
}
}

View file

@ -76,7 +76,7 @@ namespace GameCult.Aetheria.State.Verse
Behavior("Capacitor", "", Stat("Capacity", 1), Stat("Efficiency", 2)),
Behavior("ChargedWeapon", AetheriaRuntimeBehaviorKinds.InstantWeapon, With(InstantWeaponFields, Stat("ChargeTime", 21), Stat("ChargeEnergy", 22), Stat("ChargeHeat", 23))),
Behavior("Cockpit", ""),
Behavior("ConstantWeapon", "Weapon", WeaponFields),
Behavior("ConstantWeapon", "Weapon", With(WeaponFields, Number("AmmoIntervalDuration", 17))),
Behavior(AetheriaRuntimeBehaviorKinds.GuidedWeapon, AetheriaRuntimeBehaviorKinds.InstantWeapon, With(InstantWeaponFields, Stat("MissileVelocity", 26))),
Behavior(AetheriaRuntimeBehaviorKinds.Launcher, "LockWeapon", With(LockWeaponFields, Stat("MissileVelocity", 31))),
Behavior("LockWeapon", AetheriaRuntimeBehaviorKinds.InstantWeapon, LockWeaponFields),

View file

@ -13,6 +13,17 @@ namespace GameCult.Aetheria.State.Verse
AetheriaRuntimeZoneSnapshotCommit zone,
IReadOnlyList<AetheriaRuntimeEntitySnapshotCommit> entities,
double deltaSeconds);
AetheriaRuntimeBeamHit? TraceBeam(
AetheriaRuntimeZoneSnapshotCommit zone,
IReadOnlyList<AetheriaRuntimeEntitySnapshotCommit> entities,
int sourceEntityIndex,
double originX,
double originZ,
double directionX,
double directionZ,
double range,
double radius);
}
public sealed class AetheriaRuntimeProjectilePhysicsUnavailable : IAetheriaRuntimeProjectilePhysics
@ -34,6 +45,18 @@ namespace GameCult.Aetheria.State.Verse
throw new InvalidOperationException(
"Aetheria projectile simulation requires an injected authoritative physics owner.");
}
public AetheriaRuntimeBeamHit? TraceBeam(
AetheriaRuntimeZoneSnapshotCommit zone,
IReadOnlyList<AetheriaRuntimeEntitySnapshotCommit> entities,
int sourceEntityIndex,
double originX,
double originZ,
double directionX,
double directionZ,
double range,
double radius) => throw new InvalidOperationException(
"Aetheria beam tracing requires an injected authoritative physics owner.");
}
public sealed class AetheriaRuntimeProjectileStep
@ -70,4 +93,15 @@ namespace GameCult.Aetheria.State.Verse
public double NormalZ { get; set; }
}
public sealed class AetheriaRuntimeBeamHit
{
public int TargetEntityIndex { get; set; } = -1;
public string TargetBodyId { get; set; } = "";
public double PointX { get; set; }
public double PointZ { get; set; }
public double NormalX { get; set; }
public double NormalZ { get; set; }
public double Distance { get; set; }
}
}

View file

@ -24,7 +24,7 @@ validation proves contract shape, not wiring, exclusivity, lowering, or parity.
| Projectile flight | weapon/projectile classes | Ymir | projectile entity/event projection | native projectile visual | Ymir.Core adapter wired for spawn/travel/contact/despawn; native presentation and broader weapon parity incomplete | prove every authored projectile family and runtime visual lifecycle |
| Shield/hull damage | energy-funded shield, armor cells, equipment and hull | daemon | entity status + damage events | meters, impacts, damage VFX | synthetic scalar owner wired; not parity | typed absorption, penetration, item damage and death causes |
| Thermal/energy | cell conduction and capacitor/reactor/radiator network | daemon | ship/equipment status and warnings | schematic/post effects | cell conduction/radiation wired; energy network and medical thresholds remain reference | capacitor/reactor/radiator ordering, shared energy and medical timelines |
| Weapons | ServerShared behaviors + Unity effects | daemon + Ymir where spatial | action capability, weapon state, attack events | effects/audio/HUD | selected weapon groups resolve equipped typed-catalog behaviors for damage, range, cooldown, projectile velocity, heat, lock, energy, magazine, reload, burst count/time and single-ammo-burst parameters; persistent burst timer/remaining state emits every due round while cooldown overlaps from trigger time; damage/heat/energy divide across rounds and resource payment occurs once per burst or once per round as authored; each committed transaction drains canonical capacitor/reactor state and magazine before Ymir launch; empty magazines consume reserve cargo through the shared cargo transaction and enter reload without firing; catalog-free fixtures retain an explicit synthetic fallback | strict reload/cooldown boundary timeline, visibility/wear, and each remaining weapon family |
| Weapons | ServerShared behaviors + Unity effects | daemon + Ymir where spatial | action capability, weapon state, attack events | effects/audio/HUD | selected weapon groups resolve equipped typed-catalog instant weapons for damage, range, cooldown, projectile velocity, heat, lock, energy, magazine, reload, burst count/time and single-ammo-burst parameters; persistent burst timer/remaining state emits every due round while cooldown overlaps from trigger time; damage/heat/energy divide across rounds and resource payment occurs once per burst or once per round as authored; each committed transaction drains canonical capacitor/reactor state and magazine before Ymir launch; empty magazines consume reserve cargo through the shared cargo transaction and enter reload without firing; the physics port now exposes Ymir's ordered circle cast as an authoritative beam trace, proving first-contact occlusion and source exclusion for continuous weapons; ConstantWeapon field 17 is typed as `AmmoIntervalDuration` rather than an instant burst count | implement the distinct ConstantWeapon lifecycle over the beam trace, then charged/guided families, visibility/wear, penetration and damage curves |
| Destruction/drops | entity death and pickup paths | daemon | death/drop events and world entities | effects and pickups | fragments wired; chronology and original drop transaction absent | exactly-once drops and cleanup |
| Tractor/scoop | analog tractor and physical timed pickups | daemon + Ymir | tractor power, pickup body and receipt | beam/interaction feedback | fossil 2/s power ramp and authored forward radius/traction/distance feed pickup bodies into the shared Ymir world; shield contact collects exactly once when capacity permits or applies the fossil 25-unit rejection kick; 30s daemon lifetime; instant cargo teleport deleted | prove generic runtime beam, contact, success and rejection feedback |
| Dock/undock | wormhole-first interact; first eligible bay; component prerequisites | daemon + Ymir placement | dock commands/context | camera/UI transition | daemon path wired/projected; Ymir placement and parity unproven | priority, eligibility, placement and reconnect |