diff --git a/Content.Server/GameObjects/Components/Mobs/StunnableComponent.cs b/Content.Server/GameObjects/Components/Mobs/StunnableComponent.cs index 5e6b6d95fe..55cfce3e1f 100644 --- a/Content.Server/GameObjects/Components/Mobs/StunnableComponent.cs +++ b/Content.Server/GameObjects/Components/Mobs/StunnableComponent.cs @@ -49,13 +49,6 @@ namespace Content.Server.GameObjects.Components.Mobs [ViewVariables] public float KnockdownCap => _knockdownCap; [ViewVariables] public float SlowdownCap => _slowdownCap; - public override void Initialize() - { - base.Initialize(); - - Timer.Spawn(1000, () => Slowdown(20f)); - } - public override void ExposeData(ObjectSerializer serializer) { base.ExposeData(serializer); diff --git a/Content.Server/GameObjects/Components/Weapon/Melee/StunbatonComponent.cs b/Content.Server/GameObjects/Components/Weapon/Melee/StunbatonComponent.cs index 59874ffe1a..0e1fd5c599 100644 --- a/Content.Server/GameObjects/Components/Weapon/Melee/StunbatonComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Melee/StunbatonComponent.cs @@ -1,13 +1,16 @@ using System.Collections.Generic; using Content.Server.GameObjects.Components.Mobs; using Content.Server.GameObjects.EntitySystems; +using Content.Shared.Audio; using Robust.Server.GameObjects; +using Robust.Server.GameObjects.EntitySystems; using Robust.Shared.GameObjects; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Random; using Robust.Shared.IoC; using Robust.Shared.Random; using Robust.Shared.Serialization; +using Robust.Shared.ViewVariables; namespace Content.Server.GameObjects.Components.Weapon.Melee { @@ -15,15 +18,22 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee public class StunbatonComponent : MeleeWeaponComponent, IUse { [Dependency] private IRobustRandom _robustRandom; + [Dependency] private IEntitySystemManager _entitySystemManager; public override string Name => "Stunbaton"; - private float _paralyzeTime = 10f; - private float _paralyzeChance = 0.25f; - private float _slowdownTime = 5f; - private bool _activated = false; + [ViewVariables(VVAccess.ReadWrite)] + private float _paralyzeChance = 0.25f; + + [ViewVariables(VVAccess.ReadWrite)] + private float _paralyzeTime = 10f; + + [ViewVariables(VVAccess.ReadWrite)] + private float _slowdownTime = 5f; + + [ViewVariables] public bool Activated => _activated; public override void ExposeData(ObjectSerializer serializer) @@ -37,9 +47,12 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee public override void OnHitEntities(IEnumerable entities) { - if (!_activated) + if (!Activated) return; + _entitySystemManager.GetEntitySystem() + .Play("/Audio/weapons/egloves.ogg", Owner, AudioHelpers.WithVariation(0.25f)); + foreach (var entity in entities) { if (!entity.TryGetComponent(out StunnableComponent stunnable)) continue; @@ -64,6 +77,9 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee } else { + _entitySystemManager.GetEntitySystem() + .Play(AudioHelpers.GetRandomFileFromSoundCollection("sparks"), Owner, AudioHelpers.WithVariation(0.25f)); + item.EquippedPrefix = "on"; sprite.LayerSetState(0, "stunbaton_on"); _activated = true; diff --git a/Content.Server/Mobs/StandingStateHelper.cs b/Content.Server/Mobs/StandingStateHelper.cs index 741b2e43da..36e1c584c2 100644 --- a/Content.Server/Mobs/StandingStateHelper.cs +++ b/Content.Server/Mobs/StandingStateHelper.cs @@ -34,7 +34,8 @@ namespace Content.Server.Mobs appearance.SetData(SharedSpeciesComponent.MobVisuals.RotationState, newState); if (playSound) - PlaySoundCollection("bodyfall", AudioHelpers.WithVariation(0.25f)); + IoCManager.Resolve().GetEntitySystem() + .Play(AudioHelpers.GetRandomFileFromSoundCollection("bodyfall"), entity, AudioHelpers.WithVariation(0.25f)); if(dropItems) DropAllItemsInHands(entity); @@ -69,13 +70,5 @@ namespace Content.Server.Mobs hands.Drop(heldItem.Owner); } } - - private static void PlaySoundCollection(string name, AudioParams parameters = default) - { - var soundCollection = IoCManager.Resolve().Index(name); - var file = IoCManager.Resolve().Pick(soundCollection.PickFiles); - IoCManager.Resolve().GetEntitySystem() - .Play(file, parameters); - } } } diff --git a/Resources/Audio/effects/Egloves.ogg b/Resources/Audio/effects/Egloves.ogg new file mode 100644 index 0000000000..c3ebddf0ff Binary files /dev/null and b/Resources/Audio/effects/Egloves.ogg differ diff --git a/Resources/Audio/effects/sparks1.ogg b/Resources/Audio/effects/sparks1.ogg new file mode 100644 index 0000000000..3cfecb9235 Binary files /dev/null and b/Resources/Audio/effects/sparks1.ogg differ diff --git a/Resources/Audio/effects/sparks2.ogg b/Resources/Audio/effects/sparks2.ogg new file mode 100644 index 0000000000..8dd8af7066 Binary files /dev/null and b/Resources/Audio/effects/sparks2.ogg differ diff --git a/Resources/Audio/effects/sparks3.ogg b/Resources/Audio/effects/sparks3.ogg new file mode 100644 index 0000000000..feb933cd54 Binary files /dev/null and b/Resources/Audio/effects/sparks3.ogg differ diff --git a/Resources/Audio/effects/sparks4.ogg b/Resources/Audio/effects/sparks4.ogg new file mode 100644 index 0000000000..3faca5ec2e Binary files /dev/null and b/Resources/Audio/effects/sparks4.ogg differ diff --git a/Resources/Audio/weapons/egloves.ogg b/Resources/Audio/weapons/egloves.ogg new file mode 100644 index 0000000000..5df3a1498f Binary files /dev/null and b/Resources/Audio/weapons/egloves.ogg differ diff --git a/Resources/Prototypes/SoundCollections/sparks.yml b/Resources/Prototypes/SoundCollections/sparks.yml new file mode 100644 index 0000000000..8f81b6055c --- /dev/null +++ b/Resources/Prototypes/SoundCollections/sparks.yml @@ -0,0 +1,7 @@ +- type: sound_collection + id: sparks + files: + - /Audio/effects/sparks1.ogg + - /Audio/effects/sparks2.ogg + - /Audio/effects/sparks3.ogg + - /Audio/effects/sparks4.ogg