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
6 changed files with 57 additions and 5 deletions

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
@@ -164,7 +173,7 @@ public sealed class DoorComponent : Component, ISerializationHooks
_secondsUntilStateChange = null;
return;
};
var curTime = IoCManager.Resolve<IGameTiming>().CurTime;
_secondsUntilStateChange = (float) (NextStateChange.Value - curTime).TotalSeconds;
}
@@ -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;
@@ -352,7 +357,7 @@ public abstract class SharedDoorSystem : EntitySystem
SetCollidable(uid, true, door, physics);
door.NextStateChange = GameTiming.CurTime + door.CloseTimeTwo;
_activeDoors.Add(door);
// Crush any entities. Note that we don't check airlock safety here. This should have been checked before
// the door closed.
Crush(uid, door, physics);
@@ -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))