Merge eureka/aetheria-release-lock-warning: a painted ship owns a typed incoming-lock warning

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-11 03:53:33 +02:00
commit e386e1c437
5 changed files with 431 additions and 4 deletions

View file

@ -102,6 +102,7 @@ public class LockWeapon : InstantWeapon
{
var lerp = 1 - unlerp(0, 90, degrees);
_lock = saturate(_lock + pow(lerp, DirectionImpact) * dt * LockSpeed * pow(Entity.EntityInfoGathered[target], SensorImpact));
target.ReceivePaint(Entity.Position, Item?.Data, Lock);
}
else _lock = saturate(_lock - dt * Decay);
}
@ -110,3 +111,18 @@ public class LockWeapon : InstantWeapon
}
}
// What a painted ship senses of one beam on it (ruling sensor-stat-set item 4; strength per ruling
// lock-warning-strength). Strength is the emitter's own lock progress at the paint, 0..1, never summed.
public readonly struct LockWarning
{
public readonly float2 Bearing;
public readonly EquippableItemData EmitterClass;
public readonly float Strength;
public LockWarning(float2 bearing, EquippableItemData emitterClass, float strength)
{
Bearing = bearing;
EmitterClass = emitterClass;
Strength = strength;
}
}

View file

@ -173,6 +173,12 @@ public abstract class Entity
public Subject<Unit> HypothermiaDeath = new Subject<Unit>();
public Subject<Entity> TargetedBy = new Subject<Entity>();
public ReactiveProperty<int> TargetedByCount = new ReactiveProperty<int>(0);
// TargetedBy counts selection, which emits nothing; a lock warning comes only from a paint. LockWeapon.Execute
// reports each tick it paints this ship into the inbox; Update publishes the inbox once, so a warning lives
// exactly one tick after its last paint.
private readonly List<LockWarning> _paintInbox = new List<LockWarning>();
private readonly List<LockWarning> _incomingLocks = new List<LockWarning>();
public IReadOnlyList<LockWarning> IncomingLocks => _incomingLocks;
public ReactiveProperty<SecurityLevel> CurrentSecurityLevel = new ReactiveProperty<SecurityLevel>(SecurityLevel.Open);
public ReadOnlyReactiveProperty<bool> PresencePermitted;
@ -783,6 +789,25 @@ public abstract class Entity
VisibleEntities.Clear();
VisibleEnemies.Clear();
VisibleFriendlies.Clear();
_paintInbox.Clear();
_incomingLocks.Clear();
}
// Zone.Update runs this on every entity before any entity updates, so a paint made during tick N is published
// at the start of tick N+1 whatever order the emitter and this ship update in; a paint that stops is gone
// one tick later for every ordering.
internal void PublishPaints()
{
_incomingLocks.Clear();
_incomingLocks.AddRange(_paintInbox);
_paintInbox.Clear();
}
// The only caller is LockWeapon.Execute; strength is the emitter's own Lock at that paint.
internal void ReceivePaint(float3 emitterPosition, EquippableItemData emitterClass, float strength)
{
if (!_active) return;
_paintInbox.Add(new LockWarning(normalize((emitterPosition - Position).xz), emitterClass, strength));
}
public Entity(ItemManager itemManager, Zone zone, EquippableItem hull, EntitySettings settings)

View file

@ -226,7 +226,9 @@ public class Zone
foreach(var agent in Agents)
agent.Update(deltaTime);
foreach (var entity in Entities.ToArray()) entity.Update(deltaTime);
var entities = Entities.ToArray();
foreach (var entity in entities) entity.PublishPaints();
foreach (var entity in entities) entity.Update(deltaTime);
StepMines(deltaTime);
StepClouds(deltaTime);