Signatures: every light signature names its channel and item through Entity.SetSignature
VisibilitySources holds Signature (channel, strength, item); the eight direct writes go through the one writer; Visibility stays the sum; SignatureOn(channel) splits it. VisibilityData gains Key(3) Channel. No number changes. Not yet built or tested at this commit (verification follows). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e0b123a98d
commit
1d14edea3a
13 changed files with 431 additions and 16 deletions
|
|
@ -170,7 +170,7 @@ public class ConstantWeapon : Weapon, IProgressBehavior, IEventBehavior, IPowerC
|
|||
|
||||
CauseWearDamage(dt);
|
||||
AddHeat(Evaluate(_data.Heat) * dt);
|
||||
Entity.VisibilitySources[this] = Evaluate(_data.Visibility);
|
||||
Entity.SetSignature(this, SignatureChannel.LaunchFlash, Evaluate(_data.Visibility), Item);
|
||||
|
||||
// Cut 4 (docs/fire-control-cut.md): a beam is a sequence of rolls, not a continuous truth -- one
|
||||
// FireControl.Fire per BeamResolveInterval, for that interval's worth of Damage, through the same
|
||||
|
|
|
|||
|
|
@ -277,7 +277,7 @@ public class InstantWeapon : Weapon, IProgressBehavior, IEventBehavior, IPowerCo
|
|||
}
|
||||
CauseWearDamage(1);
|
||||
AddHeat(Heat);
|
||||
Entity.VisibilitySources[this] = Visibility;
|
||||
Entity.SetSignature(this, SignatureChannel.LaunchFlash, Visibility, Item);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ public class Radiator : Behavior, IAlwaysUpdatedBehavior, IInitializableBehavior
|
|||
Emissivity = Evaluate(_data.Emissivity);
|
||||
var rad = pow(RadiatorTemperature, ItemManager.GameplaySettings.HeatRadiationExponent) * ItemManager.GameplaySettings.HeatRadiationMultiplier * Emissivity;
|
||||
RadiatorTemperature -= rad * delta;
|
||||
Entity.VisibilitySources[this] = rad;
|
||||
Entity.SetSignature(this, SignatureChannel.Thermal, rad, Item);
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public class Reflector : Behavior
|
|||
|
||||
public override bool Execute(float dt)
|
||||
{
|
||||
Entity.VisibilitySources[this] = Evaluate(_data.CrossSection) * Entity.Zone.GetLight(Entity.Position.xz);
|
||||
Entity.SetSignature(this, SignatureChannel.Reflection, Evaluate(_data.CrossSection) * Entity.Zone.GetLight(Entity.Position.xz), Item);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ public class Sensor : Behavior, IEventBehavior, IPowerConsumer
|
|||
// nothing would ever fill this capacitor; bypass it rather than starving such an instance forever.
|
||||
if(_pingCooldown < 0 && (Item == null || _capacitor.TrySpend(_capacitor.Capacity)))
|
||||
{
|
||||
Entity.VisibilitySources[this] = Evaluate(_data.PingVisibility);
|
||||
Entity.SetSignature(this, SignatureChannel.Emission, Evaluate(_data.PingVisibility), Item); // interim: emissions-heard replaces this with a range-gated emission
|
||||
_pinging = true;
|
||||
_pingCooldown = 1;
|
||||
_pingLerp = 0;
|
||||
|
|
|
|||
|
|
@ -119,8 +119,8 @@ public class Thruster : Behavior, IPowerConsumer
|
|||
Entity.TurnRate += turnRate;
|
||||
AddHeat(_input * Evaluate(_data.Heat) * dt);
|
||||
var vis = _input * Evaluate(_data.Visibility);
|
||||
if (!Entity.VisibilitySources.ContainsKey(this) || vis > Entity.VisibilitySources[this])
|
||||
Entity.VisibilitySources[this] = vis;
|
||||
if (!Entity.VisibilitySources.TryGetValue(this, out var burn) || vis > burn.Strength)
|
||||
Entity.SetSignature(this, SignatureChannel.DrivePlume, vis, Item);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,9 @@ public class VisibilityData : BehaviorData
|
|||
|
||||
[Inspectable, JsonProperty("visibilityDecay"), Key(2)]
|
||||
public PerformanceStat VisibilityDecay = new PerformanceStat();
|
||||
|
||||
[Inspectable, JsonProperty("channel"), Key(3)]
|
||||
public SignatureChannel Channel = SignatureChannel.Thermal;
|
||||
|
||||
public override Behavior CreateInstance(EquippedItem item)
|
||||
{
|
||||
|
|
@ -41,7 +44,7 @@ public class Visibility : Behavior
|
|||
|
||||
public override bool Execute(float dt)
|
||||
{
|
||||
Entity.VisibilitySources[this] = Evaluate(_data.Visibility);
|
||||
Entity.SetSignature(this, _data.Channel, Evaluate(_data.Visibility), Item);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -85,7 +85,12 @@ public abstract class Entity
|
|||
// public Dictionary<Guid, float> Personality = new Dictionary<Guid, float>();
|
||||
|
||||
public readonly Dictionary<string, float> Messages = new Dictionary<string, float>();
|
||||
public readonly Dictionary<object, float> VisibilitySources = new Dictionary<object, float>();
|
||||
public readonly Dictionary<object, Signature> VisibilitySources = new Dictionary<object, Signature>();
|
||||
|
||||
// The one writer of VisibilitySources (the decay loop in Update is the one decayer). Every light signature
|
||||
// names its channel and the item that produced it (null for the hull).
|
||||
public void SetSignature(object source, SignatureChannel channel, float strength, EquippedItem item) =>
|
||||
VisibilitySources[source] = new Signature(channel, strength, item);
|
||||
public readonly ReactiveDictionary<Entity, float> EntityInfoGathered = new ReactiveDictionary<Entity, float>();
|
||||
|
||||
public (List<Weapon> weapons, List<EquippedItem> items)[] WeaponGroups;
|
||||
|
|
@ -158,7 +163,9 @@ public abstract class Entity
|
|||
public ItemManager ItemManager { get; }
|
||||
public int AssignedPopulation => PopulationAssignments.Sum(pa => pa.AssignedPopulation);
|
||||
public float Mass { get; private set; }
|
||||
public float Visibility => VisibilitySources.Values.Sum();
|
||||
public float Visibility => VisibilitySources.Values.Sum(s => s.Strength);
|
||||
public float SignatureOn(SignatureChannel channel) =>
|
||||
VisibilitySources.Values.Where(s => s.Channel == channel).Sum(s => s.Strength);
|
||||
|
||||
public Subject<Entity> IncomingHit = new Subject<Entity>();
|
||||
public Subject<(int2 pos, float damage)> ArmorDamage = new Subject<(int2, float)>();
|
||||
|
|
@ -1423,9 +1430,9 @@ public abstract class Entity
|
|||
|
||||
foreach (var v in VisibilitySources.Keys.ToArray())
|
||||
{
|
||||
VisibilitySources[v] = decay(VisibilitySources[v], ItemManager.GameplaySettings.VisibilityDecay, delta);
|
||||
VisibilitySources[v] = VisibilitySources[v].WithStrength(decay(VisibilitySources[v].Strength, ItemManager.GameplaySettings.VisibilityDecay, delta));
|
||||
|
||||
if (VisibilitySources[v] < 0.1f) VisibilitySources.Remove(v);
|
||||
if (VisibilitySources[v].Strength < 0.1f) VisibilitySources.Remove(v);
|
||||
}
|
||||
|
||||
UpdateTemperature(delta);
|
||||
|
|
@ -1616,7 +1623,7 @@ public abstract class Entity
|
|||
MaxTemp = NewTemperature[v.x, v.y];
|
||||
}
|
||||
|
||||
VisibilitySources[this] = radiation;
|
||||
SetSignature(this, SignatureChannel.Thermal, radiation, null);
|
||||
var swap = Temperature;
|
||||
Temperature = NewTemperature;
|
||||
NewTemperature = swap;
|
||||
|
|
|
|||
30
Assets/Scripts/ServerShared/Sensing.cs
Normal file
30
Assets/Scripts/ServerShared/Sensing.cs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/* 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/. */
|
||||
|
||||
// Light signatures split by channel (ruling visibility-per-capability-reveal): an observer learns what a ship
|
||||
// is by which channel carries the light. Append-only: values are serialized in VisibilityData.
|
||||
public enum SignatureChannel
|
||||
{
|
||||
Thermal,
|
||||
Reflection,
|
||||
DrivePlume,
|
||||
LaunchFlash,
|
||||
Emission
|
||||
}
|
||||
|
||||
public readonly struct Signature
|
||||
{
|
||||
public readonly SignatureChannel Channel;
|
||||
public readonly float Strength;
|
||||
public readonly EquippedItem Item;
|
||||
|
||||
public Signature(SignatureChannel channel, float strength, EquippedItem item)
|
||||
{
|
||||
Channel = channel;
|
||||
Strength = strength;
|
||||
Item = item;
|
||||
}
|
||||
|
||||
public Signature WithStrength(float strength) => new Signature(Channel, strength, Item);
|
||||
}
|
||||
11
Assets/Scripts/ServerShared/Sensing.cs.meta
Normal file
11
Assets/Scripts/ServerShared/Sensing.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a3c91e5d7b2f4086b1d4e9f07c6a2358
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in a new issue