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
This commit is contained in:
Exp
2020-07-29 15:14:04 +02:00
committed by GitHub
parent c1e328bf43
commit a7b2a1ad2f
3 changed files with 28 additions and 7 deletions

View File

@@ -108,11 +108,18 @@ namespace Content.Server.GameObjects.Components.Interactable
public void PlayUseSound(float volume=-5f) public void PlayUseSound(float volume=-5f)
{ {
if(string.IsNullOrEmpty(UseSoundCollection)) if (string.IsNullOrEmpty(UseSoundCollection))
EntitySystem.Get<AudioSystem>() {
.PlayFromEntity(UseSound, Owner, AudioHelpers.WithVariation(0.15f).WithVolume(volume)); if (!string.IsNullOrEmpty(UseSound))
{
EntitySystem.Get<AudioSystem>()
.PlayFromEntity(UseSound, Owner, AudioHelpers.WithVariation(0.15f).WithVolume(volume));
}
}
else else
{
PlaySoundCollection(UseSoundCollection, volume); PlaySoundCollection(UseSoundCollection, volume);
}
} }
} }
} }

View File

@@ -17,6 +17,7 @@ using Robust.Shared.IoC;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Utility; using Robust.Shared.Utility;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
using Robust.Shared.Serialization;
namespace Content.Server.GameObjects.Components.Interactable namespace Content.Server.GameObjects.Components.Interactable
{ {
@@ -49,6 +50,8 @@ namespace Content.Server.GameObjects.Components.Interactable
private SolutionComponent? _solutionComponent; private SolutionComponent? _solutionComponent;
private PointLightComponent? _pointLightComponent; private PointLightComponent? _pointLightComponent;
public string? WeldSoundCollection { get; set; }
[ViewVariables] [ViewVariables]
public float Fuel => _solutionComponent?.Solution.GetReagentQuantity("chem.WeldingFuel").Float() ?? 0f; public float Fuel => _solutionComponent?.Solution.GetReagentQuantity("chem.WeldingFuel").Float() ?? 0f;
@@ -82,6 +85,11 @@ namespace Content.Server.GameObjects.Components.Interactable
Owner.TryGetComponent(out _pointLightComponent); Owner.TryGetComponent(out _pointLightComponent);
} }
public override void ExposeData(ObjectSerializer serializer)
{
serializer.DataField(this, collection => WeldSoundCollection, "weldSoundCollection", string.Empty);
}
public override ComponentState GetComponentState() public override ComponentState GetComponentState()
{ {
return new WelderComponentState(FuelCapacity, Fuel, WelderLit); return new WelderComponentState(FuelCapacity, Fuel, WelderLit);
@@ -116,7 +124,13 @@ namespace Content.Server.GameObjects.Components.Interactable
if (_solutionComponent == null) if (_solutionComponent == null)
return false; 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) private bool CanWeld(float value)
@@ -206,7 +220,7 @@ namespace Content.Server.GameObjects.Components.Interactable
{ {
if (TryWeld(5, victim, silent: true)) 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 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; return SuicideKind.Heat;
} }

View File

@@ -1,4 +1,4 @@
- type: entity - type: entity
name: wirecutter name: wirecutter
parent: BaseItem parent: BaseItem
id: Wirecutter id: Wirecutter
@@ -97,7 +97,7 @@
- ReagentId: chem.WeldingFuel - ReagentId: chem.WeldingFuel
Quantity: 100 Quantity: 100
- type: Welder - type: Welder
useSoundCollection: Welder weldSoundCollection: Welder
- type: PointLight - type: PointLight
enabled: false enabled: false
radius: 1.5 radius: 1.5