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

@ -157,6 +157,8 @@ public class ActionGameManager : MonoBehaviour
public Prototype FriendlyTargetIndicator;
public PlaceUIElementWorldspace ViewDot;
public Prototype LockIndicator;
// Presentation tuning: how far from the ship, toward the locker, the incoming-lock indicator sits.
public float IncomingLockIndicatorDistance = 30;
public PlaceUIElementWorldspace[] Crosshairs;
public GameObject HitMarker;
public float HitMarkerDuration;
@ -195,6 +197,7 @@ public class ActionGameManager : MonoBehaviour
private TextMeshProUGUI _faceAimMark;
private (HardpointData[] hardpoints, Transform[] barrels, PlaceUIElementWorldspace crosshair)[] _articulationGroups;
private (LockWeapon targetLock, PlaceUIElementWorldspace indicator, Rotate spin)[] _lockingIndicators;
private (PlaceUIElementWorldspace indicator, Rotate spin) _incomingLockIndicator;
private Dictionary<Entity, VisibleTargetIndicator> _visibleHostileIndicators = new Dictionary<Entity, VisibleTargetIndicator>();
private Dictionary<Entity, VisibleTargetIndicator> _visibleFriendlyIndicators = new Dictionary<Entity, VisibleTargetIndicator>();
private List<IDisposable> _shipSubscriptions = new List<IDisposable>();
@ -999,6 +1002,8 @@ public class ActionGameManager : MonoBehaviour
if(_lockingIndicators!=null) foreach(var (_, indicator, _) in _lockingIndicators)
indicator.GetComponent<Prototype>().ReturnToPool();
if(_incomingLockIndicator.indicator != null) _incomingLockIndicator.indicator.GetComponent<Prototype>().ReturnToPool();
_incomingLockIndicator = default;
DisablePlayerInput();
Cursor.lockState = CursorLockMode.None;
GameplayUI.gameObject.SetActive(false);
@ -1142,6 +1147,10 @@ public class ActionGameManager : MonoBehaviour
var i = LockIndicator.Instantiate<PlaceUIElementWorldspace>();
return (x, i, i.GetComponent<Rotate>());
}).ToArray();
var incoming = LockIndicator.Instantiate<PlaceUIElementWorldspace>();
incoming.gameObject.SetActive(false);
_incomingLockIndicator = (incoming, incoming.GetComponent<Rotate>());
}
private void UpdatePlayerPanel()
@ -1444,11 +1453,33 @@ public class ActionGameManager : MonoBehaviour
if(showLockingIndicator)
{
indicator.Target = CurrentEntity.Target.Value.Entity.Position.ToUnity();
indicator.NoiseAmplitude = Settings.GameplaySettings.LockIndicatorNoiseAmplitude * (1 - targetLock.Lock);
indicator.NoiseFrequency = Settings.GameplaySettings.LockIndicatorFrequency.Evaluate(targetLock.Lock);
spin.Speed = Settings.GameplaySettings.LockSpinSpeed.Evaluate(targetLock.Lock);
ApplyLockProgress(indicator, spin, targetLock.Lock);
}
}
// The strongest lock on the player's ship, read only from IncomingLocks (never another ship's LockWeapon).
// Same curves as the outgoing indicator, driven by the warning's Strength.
var warnings = CurrentEntity.IncomingLocks;
var strongest = -1;
for (var w = 0; w < warnings.Count; w++)
if (strongest < 0 || warnings[w].Strength > warnings[strongest].Strength) strongest = w;
var (incomingIndicator, incomingSpin) = _incomingLockIndicator;
incomingIndicator.gameObject.SetActive(strongest >= 0);
if (strongest >= 0)
{
var warning = warnings[strongest];
incomingIndicator.Target = CurrentEntity.Position.ToUnity() +
new Vector3(warning.Bearing.x, 0, warning.Bearing.y) * IncomingLockIndicatorDistance;
ApplyLockProgress(incomingIndicator, incomingSpin, warning.Strength);
}
}
// The one lock-indicator curve: outgoing (the player's own lock) and incoming (the warning's strength) both tighten through it.
private void ApplyLockProgress(PlaceUIElementWorldspace indicator, Rotate spin, float progress)
{
indicator.NoiseAmplitude = Settings.GameplaySettings.LockIndicatorNoiseAmplitude * (1 - progress);
indicator.NoiseFrequency = Settings.GameplaySettings.LockIndicatorFrequency.Evaluate(progress);
spin.Speed = Settings.GameplaySettings.LockSpinSpeed.Evaluate(progress);
}
}

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);