Allow sound to play at the start of anomaly supercritical animation (#36260)
* Add datafield to AnomalyComponent to play a sound when an anomaly enters supercriticality * use Entity<T> pattern * use implicit default for nullable * don't forget to resolve the AnomalyComponent... * Add comment for StartSupercriticalEvent "ent" parameter * use implicit casts from Entity<T> to EntityUid * StartSupercriticalEvent requires AnomalyComponent to resolve
This commit is contained in:
@@ -44,10 +44,10 @@ public sealed partial class AnomalySystem
|
|||||||
if (!NetEntity.TryParse(args[0], out var uidNet) || !TryGetEntity(uidNet, out var uid))
|
if (!NetEntity.TryParse(args[0], out var uidNet) || !TryGetEntity(uidNet, out var uid))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!HasComp<AnomalyComponent>(uid))
|
if (!TryComp<AnomalyComponent>(uid, out var anomaly))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
StartSupercriticalEvent(uid.Value);
|
StartSupercriticalEvent((uid.Value, anomaly));
|
||||||
}
|
}
|
||||||
|
|
||||||
private CompletionResult GetAnomalyCompletion(IConsoleShell shell, string[] args)
|
private CompletionResult GetAnomalyCompletion(IConsoleShell shell, string[] args)
|
||||||
|
|||||||
@@ -129,6 +129,12 @@ public sealed partial class AnomalyComponent : Component
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField]
|
[DataField]
|
||||||
public SoundSpecifier? SupercriticalSound = new SoundCollectionSpecifier("Explosion");
|
public SoundSpecifier? SupercriticalSound = new SoundCollectionSpecifier("Explosion");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The sound plays at the start of the animation when an anomaly goes supercritical
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public SoundSpecifier? SupercriticalSoundAtAnimationStart;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -116,21 +116,26 @@ public abstract class SharedAnomalySystem : EntitySystem
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Begins the animation for going supercritical
|
/// Begins the animation for going supercritical
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="uid"></param>
|
/// <param name="ent">Entity to go supercritical</param>
|
||||||
public void StartSupercriticalEvent(EntityUid uid)
|
public void StartSupercriticalEvent(Entity<AnomalyComponent?> ent)
|
||||||
{
|
{
|
||||||
// don't restart it if it's already begun
|
// don't restart it if it's already begun
|
||||||
if (HasComp<AnomalySupercriticalComponent>(uid))
|
if (HasComp<AnomalySupercriticalComponent>(ent))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
AdminLog.Add(LogType.Anomaly, LogImpact.High, $"Anomaly {ToPrettyString(uid)} began to go supercritical.");
|
if(!Resolve(ent, ref ent.Comp))
|
||||||
if (_net.IsServer)
|
return;
|
||||||
Log.Info($"Anomaly is going supercritical. Entity: {ToPrettyString(uid)}");
|
|
||||||
|
|
||||||
var super = AddComp<AnomalySupercriticalComponent>(uid);
|
AdminLog.Add(LogType.Anomaly, LogImpact.High, $"Anomaly {ToPrettyString(ent.Owner)} began to go supercritical.");
|
||||||
|
if (_net.IsServer)
|
||||||
|
Log.Info($"Anomaly is going supercritical. Entity: {ToPrettyString(ent.Owner)}");
|
||||||
|
|
||||||
|
Audio.PlayPvs(ent.Comp.SupercriticalSoundAtAnimationStart, Transform(ent).Coordinates);
|
||||||
|
|
||||||
|
var super = AddComp<AnomalySupercriticalComponent>(ent);
|
||||||
super.EndTime = Timing.CurTime + super.SupercriticalDuration;
|
super.EndTime = Timing.CurTime + super.SupercriticalDuration;
|
||||||
Appearance.SetData(uid, AnomalyVisuals.Supercritical, true);
|
Appearance.SetData(ent, AnomalyVisuals.Supercritical, true);
|
||||||
Dirty(uid, super);
|
Dirty(ent, super);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -240,7 +245,7 @@ public abstract class SharedAnomalySystem : EntitySystem
|
|||||||
var newVal = component.Severity + change;
|
var newVal = component.Severity + change;
|
||||||
|
|
||||||
if (newVal >= 1)
|
if (newVal >= 1)
|
||||||
StartSupercriticalEvent(uid);
|
StartSupercriticalEvent((uid, component));
|
||||||
|
|
||||||
component.Severity = Math.Clamp(newVal, 0, 1);
|
component.Severity = Math.Clamp(newVal, 0, 1);
|
||||||
Dirty(uid, component);
|
Dirty(uid, component);
|
||||||
|
|||||||
Reference in New Issue
Block a user