diff --git a/Content.Client/GameObjects/Components/Doors/AirlockVisualizer2D.cs b/Content.Client/GameObjects/Components/Doors/AirlockVisualizer2D.cs index 933dfe468c..0e95477979 100644 --- a/Content.Client/GameObjects/Components/Doors/AirlockVisualizer2D.cs +++ b/Content.Client/GameObjects/Components/Doors/AirlockVisualizer2D.cs @@ -5,6 +5,8 @@ using SS14.Client.GameObjects; using SS14.Client.GameObjects.Components.Animations; using SS14.Client.Interfaces.GameObjects.Components; using SS14.Shared.Interfaces.GameObjects; +using SS14.Shared.Utility; +using YamlDotNet.RepresentationModel; namespace Content.Client.GameObjects.Components.Doors { @@ -12,6 +14,41 @@ namespace Content.Client.GameObjects.Components.Doors { private const string AnimationKey = "airlock_animation"; + private Animation CloseAnimation; + private Animation OpenAnimation; + + public override void LoadData(YamlMappingNode node) + { + base.LoadData(node); + + var openSound = node.GetNode("open_sound").AsString(); + var closeSound = node.GetNode("close_sound").AsString(); + + CloseAnimation = new Animation {Length = TimeSpan.FromSeconds(1.2f)}; + { + var flick = new AnimationTrackSpriteFlick(); + CloseAnimation.AnimationTracks.Add(flick); + flick.LayerKey = DoorVisualLayers.Base; + flick.KeyFrames.Add(new AnimationTrackSpriteFlick.KeyFrame("closing", 0f)); + + var sound = new AnimationTrackPlaySound(); + CloseAnimation.AnimationTracks.Add(sound); + sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(closeSound, 0)); + } + + OpenAnimation = new Animation {Length = TimeSpan.FromSeconds(1.2f)}; + { + var flick = new AnimationTrackSpriteFlick(); + OpenAnimation.AnimationTracks.Add(flick); + flick.LayerKey = DoorVisualLayers.Base; + flick.KeyFrames.Add(new AnimationTrackSpriteFlick.KeyFrame("opening", 0f)); + + var sound = new AnimationTrackPlaySound(); + OpenAnimation.AnimationTracks.Add(sound); + sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(openSound, 0)); + } + } + public override void InitializeEntity(IEntity entity) { if (!entity.HasComponent()) @@ -29,19 +66,23 @@ namespace Content.Client.GameObjects.Components.Doors state = DoorVisualState.Closed; } - // TODO: need some sorta state to prevent resetting the animation if it's already playing. - // Because right now that could happen. - animPlayer.Stop(AnimationKey); switch (state) { case DoorVisualState.Closed: sprite.LayerSetState(DoorVisualLayers.Base, "closed"); break; case DoorVisualState.Closing: - animPlayer.Play(CloseAnimation, AnimationKey); + if (!animPlayer.HasRunningAnimation(AnimationKey)) + { + animPlayer.Play(CloseAnimation, AnimationKey); + } break; case DoorVisualState.Opening: - animPlayer.Play(OpenAnimation, AnimationKey); + if (!animPlayer.HasRunningAnimation(AnimationKey)) + { + animPlayer.Play(OpenAnimation, AnimationKey); + } + break; case DoorVisualState.Open: sprite.LayerSetState(DoorVisualLayers.Base, "open"); @@ -50,28 +91,6 @@ namespace Content.Client.GameObjects.Components.Doors throw new ArgumentOutOfRangeException(); } } - - private static readonly Animation CloseAnimation; - private static readonly Animation OpenAnimation; - - static AirlockVisualizer2D() - { - CloseAnimation = new Animation {Length = TimeSpan.FromSeconds(1.2f)}; - { - var flick = new AnimationTrackSpriteFlick(); - CloseAnimation.AnimationTracks.Add(flick); - flick.LayerKey = DoorVisualLayers.Base; - flick.KeyFrames.Add(new AnimationTrackSpriteFlick.KeyFrame("closing", 0f)); - } - - OpenAnimation = new Animation {Length = TimeSpan.FromSeconds(1.2f)}; - { - var flick = new AnimationTrackSpriteFlick(); - OpenAnimation.AnimationTracks.Add(flick); - flick.LayerKey = DoorVisualLayers.Base; - flick.KeyFrames.Add(new AnimationTrackSpriteFlick.KeyFrame("opening", 0f)); - } - } } public enum DoorVisualLayers diff --git a/Resources/Audio/machines/airlock_close.ogg b/Resources/Audio/machines/airlock_close.ogg new file mode 100644 index 0000000000..bd928cad8b Binary files /dev/null and b/Resources/Audio/machines/airlock_close.ogg differ diff --git a/Resources/Audio/machines/airlock_creaking.ogg b/Resources/Audio/machines/airlock_creaking.ogg new file mode 100644 index 0000000000..6ec4bfe313 Binary files /dev/null and b/Resources/Audio/machines/airlock_creaking.ogg differ diff --git a/Resources/Audio/machines/airlock_ext_close.ogg b/Resources/Audio/machines/airlock_ext_close.ogg new file mode 100644 index 0000000000..7257136297 Binary files /dev/null and b/Resources/Audio/machines/airlock_ext_close.ogg differ diff --git a/Resources/Audio/machines/airlock_ext_open.ogg b/Resources/Audio/machines/airlock_ext_open.ogg new file mode 100644 index 0000000000..e9613aaf84 Binary files /dev/null and b/Resources/Audio/machines/airlock_ext_open.ogg differ diff --git a/Resources/Audio/machines/airlock_open.ogg b/Resources/Audio/machines/airlock_open.ogg new file mode 100644 index 0000000000..d47c40d3fc Binary files /dev/null and b/Resources/Audio/machines/airlock_open.ogg differ diff --git a/Resources/Prototypes/Entities/Door.yml b/Resources/Prototypes/Entities/Door.yml index e48ba7bfc2..4a31c40571 100644 --- a/Resources/Prototypes/Entities/Door.yml +++ b/Resources/Prototypes/Entities/Door.yml @@ -27,6 +27,8 @@ - type: Appearance visuals: - type: AirlockVisualizer2D + open_sound: /Audio/machines/airlock_open.ogg + close_sound: /Audio/machines/airlock_close.ogg placement: mode: SnapgridBorder @@ -42,6 +44,12 @@ - type: Icon sprite: Buildings/airlock_external.rsi + - type: Appearance + visuals: + - type: AirlockVisualizer2D + open_sound: /Audio/machines/airlock_ext_open.ogg + close_sound: /Audio/machines/airlock_ext_close.ogg + - type: entity parent: airlock id: airlock_engineering