replacing sound (collection) names with SoundSpecifier - part 1
This commit is contained in:
@@ -106,9 +106,9 @@ namespace Content.Server.Light.Components
|
||||
loopingSound.Play(LoopedSound, LoopedSoundParams);
|
||||
}
|
||||
|
||||
if (LitSound != string.Empty)
|
||||
if (LitSound.TryGetSound(out var litSound))
|
||||
{
|
||||
SoundSystem.Play(Filter.Pvs(Owner), LitSound, Owner);
|
||||
SoundSystem.Play(Filter.Pvs(Owner), litSound, Owner);
|
||||
}
|
||||
|
||||
if (IconStateLit != string.Empty)
|
||||
@@ -126,9 +126,9 @@ namespace Content.Server.Light.Components
|
||||
default:
|
||||
case ExpendableLightState.Dead:
|
||||
|
||||
if (DieSound != string.Empty)
|
||||
if (DieSound.TryGetSound(out var dieSound))
|
||||
{
|
||||
SoundSystem.Play(Filter.Pvs(Owner), DieSound, Owner);
|
||||
SoundSystem.Play(Filter.Pvs(Owner), dieSound, Owner);
|
||||
}
|
||||
|
||||
if (LoopedSound != string.Empty && Owner.TryGetComponent<LoopingLoopingSoundComponent>(out var loopSound))
|
||||
|
||||
@@ -13,6 +13,7 @@ using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Light.Component;
|
||||
using Content.Shared.Notification.Managers;
|
||||
using Content.Shared.Rounding;
|
||||
using Content.Shared.Sound;
|
||||
using Content.Shared.Verbs;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
@@ -46,9 +47,9 @@ namespace Content.Server.Light.Components
|
||||
|
||||
[ViewVariables] protected override bool HasCell => _cellSlot.HasCell;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)] [DataField("turnOnSound")] public string? TurnOnSound = "/Audio/Items/flashlight_toggle.ogg";
|
||||
[ViewVariables(VVAccess.ReadWrite)] [DataField("turnOnFailSound")] public string? TurnOnFailSound = "/Audio/Machines/button.ogg";
|
||||
[ViewVariables(VVAccess.ReadWrite)] [DataField("turnOffSound")] public string? TurnOffSound = "/Audio/Items/flashlight_toggle.ogg";
|
||||
[ViewVariables(VVAccess.ReadWrite)] [DataField("turnOnSound")] public SoundSpecifier TurnOnSound = new SoundPathSpecifier("/Audio/Items/flashlight_toggle.ogg");
|
||||
[ViewVariables(VVAccess.ReadWrite)] [DataField("turnOnFailSound")] public SoundSpecifier TurnOnFailSound = new SoundPathSpecifier("/Audio/Machines/button.ogg");
|
||||
[ViewVariables(VVAccess.ReadWrite)] [DataField("turnOffSound")] public SoundSpecifier TurnOffSound = new SoundPathSpecifier("/Audio/Items/flashlight_toggle.ogg");
|
||||
|
||||
[ComponentDependency] private readonly ItemActionsComponent? _itemActions = null;
|
||||
|
||||
@@ -120,9 +121,9 @@ namespace Content.Server.Light.Components
|
||||
UpdateLightAction();
|
||||
Owner.EntityManager.EventBus.QueueEvent(EventSource.Local, new DeactivateHandheldLightMessage(this));
|
||||
|
||||
if (makeNoise)
|
||||
if (makeNoise && TurnOffSound.TryGetSound(out var turnOffSound))
|
||||
{
|
||||
if (TurnOffSound != null) SoundSystem.Play(Filter.Pvs(Owner), TurnOffSound, Owner);
|
||||
SoundSystem.Play(Filter.Pvs(Owner), turnOffSound, Owner);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -137,7 +138,8 @@ namespace Content.Server.Light.Components
|
||||
|
||||
if (Cell == null)
|
||||
{
|
||||
if (TurnOnFailSound != null) SoundSystem.Play(Filter.Pvs(Owner), TurnOnFailSound, Owner);
|
||||
if (TurnOnFailSound.TryGetSound(out var turnOnFailSound))
|
||||
SoundSystem.Play(Filter.Pvs(Owner), turnOnFailSound, Owner);
|
||||
Owner.PopupMessage(user, Loc.GetString("handheld-light-component-cell-missing-message"));
|
||||
UpdateLightAction();
|
||||
return false;
|
||||
@@ -148,7 +150,8 @@ namespace Content.Server.Light.Components
|
||||
// Simple enough.
|
||||
if (Wattage > Cell.CurrentCharge)
|
||||
{
|
||||
if (TurnOnFailSound != null) SoundSystem.Play(Filter.Pvs(Owner), TurnOnFailSound, Owner);
|
||||
if (TurnOnFailSound.TryGetSound(out var turnOnFailSound))
|
||||
SoundSystem.Play(Filter.Pvs(Owner), turnOnFailSound, Owner);
|
||||
Owner.PopupMessage(user, Loc.GetString("handheld-light-component-cell-dead-message"));
|
||||
UpdateLightAction();
|
||||
return false;
|
||||
@@ -159,7 +162,8 @@ namespace Content.Server.Light.Components
|
||||
SetState(true);
|
||||
Owner.EntityManager.EventBus.QueueEvent(EventSource.Local, new ActivateHandheldLightMessage(this));
|
||||
|
||||
if (TurnOnSound != null) SoundSystem.Play(Filter.Pvs(Owner), TurnOnSound, Owner);
|
||||
if (TurnOnSound.TryGetSound(out var turnOnSound))
|
||||
SoundSystem.Play(Filter.Pvs(Owner), turnOnSound, Owner);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System;
|
||||
using Content.Shared.Acts;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Sound;
|
||||
using Content.Shared.Throwing;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio;
|
||||
@@ -71,6 +72,9 @@ namespace Content.Server.Light.Components
|
||||
private int _powerUse = 40;
|
||||
public int PowerUse => _powerUse;
|
||||
|
||||
[DataField("breakSound")]
|
||||
private SoundSpecifier _breakSound = new SoundCollectionSpecifier("GlassBreak");
|
||||
|
||||
/// <summary>
|
||||
/// The current state of the light bulb. Invokes the OnLightBulbStateChange event when set.
|
||||
/// It also updates the bulb's sprite accordingly.
|
||||
@@ -129,10 +133,8 @@ namespace Content.Server.Light.Components
|
||||
|
||||
public void PlayBreakSound()
|
||||
{
|
||||
var soundCollection = _prototypeManager.Index<SoundCollectionPrototype>("GlassBreak");
|
||||
var file = _random.Pick(soundCollection.PickFiles);
|
||||
|
||||
SoundSystem.Play(Filter.Pvs(Owner), file, Owner);
|
||||
if(_breakSound.TryGetSound(out var breakSound))
|
||||
SoundSystem.Play(Filter.Pvs(Owner), breakSound, Owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Threading.Tasks;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Smoking;
|
||||
using Content.Shared.Sound;
|
||||
using Content.Shared.Temperature;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio;
|
||||
@@ -30,7 +31,7 @@ namespace Content.Server.Light.Components
|
||||
/// <summary>
|
||||
/// Sound played when you ignite the matchstick.
|
||||
/// </summary>
|
||||
[DataField("igniteSound")] private string? _igniteSound;
|
||||
[DataField("igniteSound")] private SoundSpecifier _igniteSound = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Point light component. Gives matches a glow in dark effect.
|
||||
@@ -69,9 +70,9 @@ namespace Content.Server.Light.Components
|
||||
public void Ignite(IEntity user)
|
||||
{
|
||||
// Play Sound
|
||||
if (!string.IsNullOrEmpty(_igniteSound))
|
||||
if (_igniteSound.TryGetSound(out var igniteSound))
|
||||
{
|
||||
SoundSystem.Play(Filter.Pvs(Owner), _igniteSound, Owner,
|
||||
SoundSystem.Play(Filter.Pvs(Owner), igniteSound, Owner,
|
||||
AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f));
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ using Content.Shared.Interaction;
|
||||
using Content.Shared.Light;
|
||||
using Content.Shared.Notification;
|
||||
using Content.Shared.Notification.Managers;
|
||||
using Content.Shared.Sound;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Containers;
|
||||
@@ -49,6 +50,12 @@ namespace Content.Server.Light.Components
|
||||
private TimeSpan _lastThunk;
|
||||
private TimeSpan? _lastGhostBlink;
|
||||
|
||||
[DataField("burnHandSound")]
|
||||
private SoundSpecifier _burnHandSound = new SoundPathSpecifier("/Audio/Effects/lightburn.ogg");
|
||||
|
||||
[DataField("turnOnSound")]
|
||||
private SoundSpecifier _turnOnSound = new SoundPathSpecifier("/Audio/Machines/light_tube_on.ogg");
|
||||
|
||||
[DataField("hasLampOnSpawn")]
|
||||
private bool _hasLampOnSpawn = true;
|
||||
|
||||
@@ -119,7 +126,8 @@ namespace Content.Server.Light.Components
|
||||
{
|
||||
Owner.PopupMessage(eventArgs.User, Loc.GetString("powered-light-component-burn-hand"));
|
||||
damageableComponent.ChangeDamage(DamageType.Heat, 20, false, Owner);
|
||||
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/lightburn.ogg", Owner);
|
||||
if(_burnHandSound.TryGetSound(out var burnHandSound))
|
||||
SoundSystem.Play(Filter.Pvs(Owner), burnHandSound, Owner);
|
||||
}
|
||||
|
||||
void Eject()
|
||||
@@ -221,7 +229,8 @@ namespace Content.Server.Light.Components
|
||||
if (time > _lastThunk + _thunkDelay)
|
||||
{
|
||||
_lastThunk = time;
|
||||
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/light_tube_on.ogg", Owner, AudioParams.Default.WithVolume(-10f));
|
||||
if(_turnOnSound.TryGetSound(out var turnOnSound))
|
||||
SoundSystem.Play(Filter.Pvs(Owner), turnOnSound, Owner, AudioParams.Default.WithVolume(-10f));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user