Add door emag visuals and sound (#6971)

Co-authored-by: fishfish458 <fishfish458>
This commit is contained in:
Fishfish458 2022-03-19 14:00:01 -05:00 committed by GitHub
parent 16b80e6f85
commit 4500f88737
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 57 additions and 5 deletions

View File

@ -26,6 +26,10 @@ namespace Content.Client.Doors
[DataField("denyAnimationTime")]
private float _denyDelay = 0.3f;
[DataField("emagAnimationTime")]
private float _delayEmag = 1.5f;
/// <summary>
/// Whether the maintenance panel is animated or stays static.
/// False for windoors.
@ -55,6 +59,7 @@ namespace Content.Client.Doors
private Animation CloseAnimation = default!;
private Animation OpenAnimation = default!;
private Animation DenyAnimation = default!;
private Animation EmaggingAnimation = default!;
void ISerializationHooks.AfterDeserialization()
{
@ -107,6 +112,13 @@ namespace Content.Client.Doors
}
}
}
EmaggingAnimation = new Animation {Length = TimeSpan.FromSeconds(_delay)};
{
var flickUnlit = new AnimationTrackSpriteFlick();
EmaggingAnimation.AnimationTracks.Add(flickUnlit);
flickUnlit.LayerKey = DoorVisualLayers.BaseUnlit;
flickUnlit.KeyFrames.Add(new AnimationTrackSpriteFlick.KeyFrame("sparks", 0f));
}
if (!_simpleVisuals)
{
@ -186,6 +198,9 @@ namespace Content.Client.Doors
case DoorState.Welded:
weldedVisible = true;
break;
case DoorState.Emagging:
animPlayer.Play(EmaggingAnimation, AnimationKey);
break;
default:
throw new ArgumentOutOfRangeException();
}

View File

@ -18,6 +18,7 @@ using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Player;
using Content.Shared.Hands.Components;
using System.Linq;
namespace Content.Server.Doors.Systems;
@ -288,18 +289,35 @@ public sealed class DoorSystem : SharedDoorSystem
if(!container.Insert(board))
Logger.Warning($"Couldn't insert board {ToPrettyString(board)} into door {ToPrettyString(uid)}!");
}
private void OnEmagged(EntityUid uid, DoorComponent door, GotEmaggedEvent args)
{
if(TryComp<AirlockComponent>(uid, out var airlockComponent))
{
if (door.State == DoorState.Closed)
{
StartOpening(uid);
airlockComponent?.SetBoltsWithAudio(!airlockComponent.IsBolted());
SetState(uid, DoorState.Emagging, door);
PlaySound(uid, door.SparkSound.GetSound(), AudioParams.Default.WithVolume(8), args.UserUid, false);
args.Handled = true;
}
}
}
public override void StartOpening(EntityUid uid, DoorComponent? door = null, EntityUid? user = null, bool predicted = false)
{
if (!Resolve(uid, ref door))
return;
DoorState lastState = door.State;
SetState(uid, DoorState.Opening, door);
if (door.OpenSound != null)
PlaySound(uid, door.OpenSound.GetSound(), AudioParams.Default.WithVolume(-5), user, predicted);
if(lastState == DoorState.Emagging && TryComp<AirlockComponent>(door.Owner, out var airlockComponent))
airlockComponent?.SetBoltsWithAudio(!airlockComponent.IsBolted());
}
}
public sealed class PryFinishedEvent : EntityEventArgs { }

View File

@ -59,6 +59,9 @@ public sealed class DoorComponent : Component, ISerializationHooks
[DataField("denyDuration")]
public readonly TimeSpan DenyDuration = TimeSpan.FromSeconds(0.45f);
[DataField("emagDuration")]
public readonly TimeSpan EmagDuration = TimeSpan.FromSeconds(0.8f);
/// <summary>
/// When the door is active, this is the time when the state will next update.
/// </summary>
@ -116,6 +119,12 @@ public sealed class DoorComponent : Component, ISerializationHooks
/// </summary>
[DataField("tryOpenDoorSound")]
public SoundSpecifier TryOpenDoorSound = new SoundPathSpecifier("/Audio/Effects/bang.ogg");
/// <summary>
/// Sound to play when door has been emagged or possibly electrically tampered
/// </summary>
[DataField("sparkSound")]
public SoundSpecifier SparkSound = new SoundCollectionSpecifier("sparks");
#endregion
#region Crushing
@ -230,6 +239,7 @@ public enum DoorState
Opening,
Welded,
Denying,
Emagging
}
[Serializable, NetSerializable]

View File

@ -135,6 +135,11 @@ public abstract class SharedDoorSystem : EntitySystem
door.NextStateChange = GameTiming.CurTime + door.DenyDuration;
break;
case DoorState.Emagging:
_activeDoors.Add(door);
door.NextStateChange = GameTiming.CurTime + door.EmagDuration;
break;
case DoorState.Open:
case DoorState.Closed:
door.Partial = false;
@ -579,6 +584,10 @@ public abstract class SharedDoorSystem : EntitySystem
SetState(door.Owner, DoorState.Closed, door);
break;
case DoorState.Emagging:
StartOpening(door.Owner, door);
break;
case DoorState.Open:
// This door is open, and queued for an auto-close.
if (!TryClose(door.Owner, door, predicted: true))

View File

@ -131,7 +131,7 @@
]
},
{
"name":"spark",
"name":"sparks",
"directions":4,
"delays":[
[

View File

Before

Width:  |  Height:  |  Size: 518 B

After

Width:  |  Height:  |  Size: 518 B