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:
@@ -108,11 +108,18 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
|
||||
public void PlayUseSound(float volume=-5f)
|
||||
{
|
||||
if(string.IsNullOrEmpty(UseSoundCollection))
|
||||
if (string.IsNullOrEmpty(UseSoundCollection))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(UseSound))
|
||||
{
|
||||
EntitySystem.Get<AudioSystem>()
|
||||
.PlayFromEntity(UseSound, Owner, AudioHelpers.WithVariation(0.15f).WithVolume(volume));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PlaySoundCollection(UseSoundCollection, volume);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user