From a7b2a1ad2fc1bd246b7b30f849b1a3de03de69d5 Mon Sep 17 00:00:00 2001 From: Exp Date: Wed, 29 Jul 2020 15:14:04 +0200 Subject: [PATCH] Fix welder making unwanted sounds (#1536) * Fix Welding making sounds if not actually welded something * Fix Sound Error * -Hardcode bad -Removed duplicate sound on suicide --- .../Components/Interactable/ToolComponent.cs | 13 ++++++++++--- .../Components/Interactable/WelderComponent.cs | 18 ++++++++++++++++-- .../Entities/Objects/Tools/tools.yml | 4 ++-- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/Content.Server/GameObjects/Components/Interactable/ToolComponent.cs b/Content.Server/GameObjects/Components/Interactable/ToolComponent.cs index 1e4002bae8..0b1b6ad0ab 100644 --- a/Content.Server/GameObjects/Components/Interactable/ToolComponent.cs +++ b/Content.Server/GameObjects/Components/Interactable/ToolComponent.cs @@ -108,11 +108,18 @@ namespace Content.Server.GameObjects.Components.Interactable public void PlayUseSound(float volume=-5f) { - if(string.IsNullOrEmpty(UseSoundCollection)) - EntitySystem.Get() - .PlayFromEntity(UseSound, Owner, AudioHelpers.WithVariation(0.15f).WithVolume(volume)); + if (string.IsNullOrEmpty(UseSoundCollection)) + { + if (!string.IsNullOrEmpty(UseSound)) + { + EntitySystem.Get() + .PlayFromEntity(UseSound, Owner, AudioHelpers.WithVariation(0.15f).WithVolume(volume)); + } + } else + { PlaySoundCollection(UseSoundCollection, volume); + } } } } diff --git a/Content.Server/GameObjects/Components/Interactable/WelderComponent.cs b/Content.Server/GameObjects/Components/Interactable/WelderComponent.cs index 5171782416..39aadea5ae 100644 --- a/Content.Server/GameObjects/Components/Interactable/WelderComponent.cs +++ b/Content.Server/GameObjects/Components/Interactable/WelderComponent.cs @@ -17,6 +17,7 @@ using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Utility; using Robust.Shared.ViewVariables; +using Robust.Shared.Serialization; namespace Content.Server.GameObjects.Components.Interactable { @@ -49,6 +50,8 @@ namespace Content.Server.GameObjects.Components.Interactable private SolutionComponent? _solutionComponent; private PointLightComponent? _pointLightComponent; + public string? WeldSoundCollection { get; set; } + [ViewVariables] public float Fuel => _solutionComponent?.Solution.GetReagentQuantity("chem.WeldingFuel").Float() ?? 0f; @@ -82,6 +85,11 @@ namespace Content.Server.GameObjects.Components.Interactable Owner.TryGetComponent(out _pointLightComponent); } + public override void ExposeData(ObjectSerializer serializer) + { + serializer.DataField(this, collection => WeldSoundCollection, "weldSoundCollection", string.Empty); + } + public override ComponentState GetComponentState() { return new WelderComponentState(FuelCapacity, Fuel, WelderLit); @@ -116,7 +124,13 @@ namespace Content.Server.GameObjects.Components.Interactable if (_solutionComponent == null) return false; - return _solutionComponent.TryRemoveReagent("chem.WeldingFuel", ReagentUnit.New(value)); + bool succeeded = _solutionComponent.TryRemoveReagent("chem.WeldingFuel", ReagentUnit.New(value)); + + if (succeeded && !silent) + { + PlaySoundCollection(WeldSoundCollection); + } + return succeeded; } private bool CanWeld(float value) @@ -206,7 +220,7 @@ namespace Content.Server.GameObjects.Components.Interactable { if (TryWeld(5, victim, silent: true)) { - PlaySoundCollection("Welder", -5); + PlaySoundCollection(WeldSoundCollection); chat.EntityMe(victim, Loc.GetString("welds {0:their} every orifice closed! It looks like {0:theyre} trying to commit suicide!", victim)); //TODO: theyre macro return SuicideKind.Heat; } diff --git a/Resources/Prototypes/Entities/Objects/Tools/tools.yml b/Resources/Prototypes/Entities/Objects/Tools/tools.yml index 87dd6e570a..f56c6f2264 100644 --- a/Resources/Prototypes/Entities/Objects/Tools/tools.yml +++ b/Resources/Prototypes/Entities/Objects/Tools/tools.yml @@ -1,4 +1,4 @@ -- type: entity +- type: entity name: wirecutter parent: BaseItem id: Wirecutter @@ -97,7 +97,7 @@ - ReagentId: chem.WeldingFuel Quantity: 100 - type: Welder - useSoundCollection: Welder + weldSoundCollection: Welder - type: PointLight enabled: false radius: 1.5