Dynamic anomaly scanner texture (#37585)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.Anomaly.Components;
|
||||
using Content.Shared.Anomaly.Prototypes;
|
||||
@@ -140,6 +141,7 @@ public abstract class SharedAnomalySystem : EntitySystem
|
||||
var super = AddComp<AnomalySupercriticalComponent>(ent);
|
||||
super.EndTime = Timing.CurTime + ent.Comp.SupercriticalDuration;
|
||||
Appearance.SetData(ent, AnomalyVisuals.Supercritical, true);
|
||||
SetScannerSupercritical((ent, ent.Comp), true);
|
||||
Dirty(ent, super);
|
||||
}
|
||||
|
||||
@@ -340,7 +342,8 @@ public abstract class SharedAnomalySystem : EntitySystem
|
||||
ChangeAnomalyHealth(ent, anomaly.HealthChangePerSecond * frameTime, anomaly);
|
||||
}
|
||||
|
||||
if (Timing.CurTime > anomaly.NextPulseTime)
|
||||
var secondsUntilNextPulse = (anomaly.NextPulseTime - Timing.CurTime).TotalSeconds;
|
||||
if (secondsUntilNextPulse < 0)
|
||||
{
|
||||
DoAnomalyPulse(ent, anomaly);
|
||||
}
|
||||
@@ -366,6 +369,18 @@ public abstract class SharedAnomalySystem : EntitySystem
|
||||
}
|
||||
}
|
||||
|
||||
private void SetScannerSupercritical(Entity<AnomalyComponent> anomalyEnt, bool value)
|
||||
{
|
||||
var scannerQuery = EntityQueryEnumerator<AnomalyScannerComponent>();
|
||||
while (scannerQuery.MoveNext(out var scannerUid, out var scanner))
|
||||
{
|
||||
if (scanner.ScannedAnomaly != anomalyEnt)
|
||||
continue;
|
||||
|
||||
Appearance.SetData(scannerUid, AnomalyScannerVisuals.AnomalyIsSupercritical, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets random points around the anomaly based on the given parameters.
|
||||
/// </summary>
|
||||
@@ -441,6 +456,33 @@ public abstract class SharedAnomalySystem : EntitySystem
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
public bool TryGetStabilityVisual(Entity<AnomalyComponent?> ent, [NotNullWhen(true)] out AnomalyStabilityVisuals? visual)
|
||||
{
|
||||
visual = null;
|
||||
if (!Resolve(ent, ref ent.Comp, logMissing: false))
|
||||
return false;
|
||||
|
||||
visual = AnomalyStabilityVisuals.Stable;
|
||||
if (ent.Comp.Stability <= ent.Comp.DecayThreshold)
|
||||
{
|
||||
visual = AnomalyStabilityVisuals.Decaying;
|
||||
}
|
||||
else if (ent.Comp.Stability >= ent.Comp.GrowthThreshold)
|
||||
{
|
||||
visual = AnomalyStabilityVisuals.Growing;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public AnomalyStabilityVisuals GetStabilityVisualOrStable(Entity<AnomalyComponent?> ent)
|
||||
{
|
||||
if(TryGetStabilityVisual(ent, out var visual))
|
||||
return visual.Value;
|
||||
|
||||
return AnomalyStabilityVisuals.Stable;
|
||||
}
|
||||
}
|
||||
|
||||
[DataRecord]
|
||||
|
||||
Reference in New Issue
Block a user