Merge cut feedback-1 (Soul verdict cut-feedback-1.s3)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-12 20:30:02 +02:00
commit 16ed52d890
11 changed files with 589 additions and 22 deletions

View file

@ -7,30 +7,35 @@ using UniRx;
using CultMath;
// Capability event contract (docs/headless-playground-cut.md fork L, operator ruling 2026-09-17):
// pickup, impact absorption, melee blade and propulsion are separate item capabilities. Simulation
// (not yet built -- this file only stands up the wire shape) will own each capability's rules and
// emit these events; any number of presentations (the field shield today, later an IFS shatter
// plane or an advected particle field) subscribe to the event kinds they visualize and decide
// nothing about the rule. This file has no engine dependency: it compiles into the headless
// Aetheria.Shared build (see Aetheria.Shared.csproj) with no publisher wired up yet.
// pickup, impact absorption, melee blade and propulsion are separate item capabilities. Simulation owns
// each capability's rules and emits these events (FireControl publishes Absorb; the others are not yet
// built); any number of presentations (the field shield today, later an IFS shatter plane or an advected
// particle field) subscribe to the event kinds they visualize and decide nothing about the rule. This file
// has no engine dependency: it compiles into the headless Aetheria.Shared build (see Aetheria.Shared.csproj).
// One absorbed impact: a hit landing on the item's shield/armor capability. DamageType rides along
// so presenters can vary visuals per type; the damage-type mask itself belongs to the absorb
// capability's own data and is out of scope for this cut (operator, 2026-09-17) -- this struct only
// carries the hit's existing type through, unfiltered.
// Which layer of the receiver took an absorbed impact.
public enum AbsorbLayer { Shield, Hull }
// One absorbed impact on a shield or a hull, published once per receiver by FireControl on that entity's
// Entity.Capabilities. Position is a world point on the receiver's sim pose at the tick the impact lands (a
// presenter draws it with DrawAhead.Carried); Direction is the way the impact travels. DamageType rides along
// so presenters can vary visuals per type; the damage-type mask itself belongs to the absorb capability's own
// data and is out of scope (operator, 2026-09-17) -- this struct only carries the hit's existing type through.
public readonly struct AbsorbEvent
{
public readonly float3 Position;
public readonly float3 Direction;
public readonly float Magnitude;
public readonly DamageType DamageType;
public readonly AbsorbLayer Layer;
public AbsorbEvent(float3 position, float3 direction, float magnitude, DamageType damageType)
public AbsorbEvent(float3 position, float3 direction, float magnitude, DamageType damageType, AbsorbLayer layer)
{
Position = position;
Direction = direction;
Magnitude = magnitude;
DamageType = damageType;
Layer = layer;
}
}
@ -101,10 +106,10 @@ public readonly struct ThrustEvent
}
}
// Per-entity (or per-item) source of capability events. One instance is owned by whatever will
// eventually decide these rules; today the FieldShieldTest scene stands in for that owner. Follows
// the Subject<T>-per-event-kind idiom already used on Entity (IncomingHit, HullDamage, etc): each
// event kind gets its own stream, and a subscriber to one kind never sees another.
// Per-entity source of capability events: one instance per Entity (Entity.Capabilities), published by
// FireControl for Absorb; the FieldShieldTest scene keeps its own instance. Follows the Subject<T>-per-event-kind
// idiom already used on Entity (IncomingHit, HullDamage, etc): each event kind gets its own stream, and a
// subscriber to one kind never sees another.
public class CapabilityEvents
{
private readonly Subject<AbsorbEvent> _absorb = new Subject<AbsorbEvent>();

View file

@ -61,14 +61,22 @@ public static class DrawAhead
return drawn + (end - drawn) * steer;
}
// The impact cell's centre on the target's drawn pose: the cell at the sim pose, drawn ahead by the target's last
// step velocity and turned by its last step turn for lead seconds, as Position and Rotation draw the entity.
// The impact cell's centre on the target's drawn pose.
public static float3 Impact(Entity target, int2 cell, float lead)
{
var world = target.ToWorldPoint((float2) cell);
return Carried(target, float3(world.x, target.Position.y, world.y), lead);
}
// A world point on the target's sim pose, moved and turned with the target for lead seconds exactly as Position and
// Rotation draw the entity: the one owner of where a point on a hull is drawn, for the drawn round's end and for
// impact presenters.
public static float3 Carried(Entity target, float3 simPoint, float lead)
{
var at = Position(target, lead);
var offset = target.ToWorldPoint((float2) cell) - target.Position.xz;
var offset = float2(simPoint.x - target.Position.x, simPoint.z - target.Position.z);
var turned = mul(offset, CultMath.float2x2.Rotate(Turn(target, lead)));
return float3(at.x + turned.x, at.y, at.z + turned.y);
return float3(at.x + turned.x, at.y + (simPoint.y - target.Position.y), at.z + turned.y);
}
// Whether the drawn flight is over by time: only a published miss ends by the clock. A hit or burst ends on ShotResolved.

View file

@ -173,6 +173,8 @@ public abstract class Entity
VisibilitySources.Values.Where(s => s.Channel == channel).Sum(s => s.Strength);
public Subject<Entity> IncomingHit = new Subject<Entity>();
// One per entity, created with it, never replaced: FireControl publishes each landed impact on it (Absorb).
public readonly CapabilityEvents Capabilities = new CapabilityEvents();
public Subject<(int2 pos, float damage)> ArmorDamage = new Subject<(int2, float)>();
public Subject<(EquippedItem item, float damage)> ItemDamage = new Subject<(EquippedItem, float)>();
// public Subject<EquippedItem> ItemOffline = new Subject<EquippedItem>();

View file

@ -0,0 +1,40 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using CultMath;
using static CultMath.math;
// What an impact presenter renders, derived once. Engine-free and never called by ServerShared: FireControl
// publishes the fact (AbsorbEvent), this derives how it reads, and every presenter (visual, audio, camera) renders
// the same cue instead of computing its own.
public readonly struct ImpactCue
{
public readonly AbsorbLayer Layer;
public readonly float3 Position;
public readonly float3 Direction;
public readonly float Intensity;
public readonly float Shake;
public ImpactCue(AbsorbLayer layer, float3 position, float3 direction, float intensity, float shake)
{
Layer = layer;
Position = position;
Direction = direction;
Intensity = intensity;
Shake = shake;
}
}
public static class Feedback
{
// Intensity is the hit's share of what the receiver's hull can take, scaled by the presenter and saturated to
// 0..1; a receiver with no hull to measure against reads 0. Shake follows intensity for the player's own ship
// only, scaled by the player's ScreenShake preference.
public static ImpactCue Cue(AbsorbEvent e, float receiverMaxDurability, bool receiverIsPlayer, float shakePreference, float intensityScale)
{
var intensity = receiverMaxDurability > 0f ? saturate(e.Magnitude / receiverMaxDurability * intensityScale) : 0f;
var shake = receiverIsPlayer ? intensity * saturate(shakePreference) : 0f;
return new ImpactCue(e.Layer, e.Position, e.Direction, intensity, shake);
}
}

View file

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

View file

@ -1163,6 +1163,8 @@ public static class FireControl
if (shot.Outcome.Shielded)
{
Publish(shot.Target, AbsorbLayer.Shield, ImpactPoint(shot.Target, shot.Outcome.Cell),
float3(shot.TravelDirection.x, 0, shot.TravelDirection.y), shot.Damage, shot.DamageType);
shot.Target.Shield.TakeHit(shot.DamageType, shot.Damage);
return;
}
@ -1206,9 +1208,31 @@ public static class FireControl
for (var li = 0; li < laneCount; li++) ArrayPool<LaneCell>.Shared.Return(buffers[li]);
Publish(target, AbsorbLayer.Hull, ImpactPoint(target, shot.Outcome.Cell),
float3(shot.TravelDirection.x, 0, shot.TravelDirection.y), shot.Damage, shot.DamageType);
target.DamageHull(hullDamage);
}
// Where a landed direct hit meets the receiver: the impact cell's world point on its sim pose, at its height.
private static float3 ImpactPoint(Entity target, int2 cell)
{
var world = target.ToWorldPoint((float2) cell);
return float3(world.x, target.Position.y, world.y);
}
// The one publisher of an absorbed impact: once per receiver, on its Capabilities, before the damage it reports.
private static void Publish(Entity receiver, AbsorbLayer layer, float3 position, float3 direction, float magnitude, DamageType damageType) =>
receiver.Capabilities.PublishAbsorb(new AbsorbEvent(position, direction, magnitude, damageType, layer));
// A blast's impact on one entity: at the blast point (on the entity's height), travelling from the blast out through
// the entity's centre, or zero when they coincide.
private static void PublishBlast(Entity entity, float2 blast, AbsorbLayer layer, float magnitude, DamageType damageType)
{
var away = entity.Position.xz - blast;
var direction = lengthsq(away) > 0f ? normalize(away) : float2.zero;
Publish(entity, layer, float3(blast.x, entity.Position.y, blast.y), float3(direction.x, 0, direction.y), magnitude, damageType);
}
// Cut 12.4(b) (docs/fire-control-cut.md, "Where P is"): a contact or delayed blast needs a committed hit --
// on a miss nothing happens, exactly like a direct hit's own gate. IncomingHit fires once, for the host,
// before the blast is handed to Detonate (which then treats the host like any other entity in the radius:
@ -1591,6 +1615,7 @@ public static class FireControl
{
if (shield.CanTakeHit(damageType, totalShare))
{
PublishBlast(entity, worldPlanar, AbsorbLayer.Shield, totalShare, damageType);
shield.TakeHit(damageType, totalShare);
continue;
}
@ -1620,6 +1645,7 @@ public static class FireControl
for (var i = 0; i < amounts.Length; i++) hullTotal += amounts[i];
}
PublishBlast(entity, worldPlanar, AbsorbLayer.Hull, totalShare, damageType);
entity.DamageHull(hullTotal);
}
}

View file

@ -64,6 +64,8 @@ public class PlayerGraphicsSettings
{
[Key(0)] public Quality NebulaQuality = Quality.Normal;
[Key(1)] public bool ShowAsteroidsInMinimap;
// How hard the camera shakes when the player's ship takes an impact: 0 off, 1 full (Feedback.Cue).
[Key(2)] public float ScreenShake = 1f;
}
[MessagePackObject]