removed TryGetSound + made some SoundSpecifier datafields required

This commit is contained in:
Galactic Chimp
2021-07-31 19:52:33 +02:00
parent 8ff703c338
commit 57016d14b4
114 changed files with 519 additions and 785 deletions

View File

@@ -100,11 +100,8 @@ namespace Content.Server.Light.Components
switch (CurrentState)
{
case ExpendableLightState.Lit:
if (LitSound.TryGetSound(out var litSound))
{
SoundSystem.Play(Filter.Pvs(Owner), litSound, Owner);
}
SoundSystem.Play(Filter.Pvs(Owner), LitSound.GetSound(), Owner);
if (IconStateLit != string.Empty)
{
sprite.LayerSetState(2, IconStateLit);
@@ -119,11 +116,7 @@ namespace Content.Server.Light.Components
default:
case ExpendableLightState.Dead:
if (DieSound.TryGetSound(out var dieSound))
{
SoundSystem.Play(Filter.Pvs(Owner), dieSound, Owner);
}
SoundSystem.Play(Filter.Pvs(Owner), DieSound.GetSound(), Owner);
sprite.LayerSetState(0, IconStateSpent);
sprite.LayerSetShader(0, "shaded");

View File

@@ -120,9 +120,9 @@ namespace Content.Server.Light.Components
UpdateLightAction();
Owner.EntityManager.EventBus.QueueEvent(EventSource.Local, new DeactivateHandheldLightMessage(this));
if (makeNoise && TurnOffSound.TryGetSound(out var turnOffSound))
if (makeNoise)
{
SoundSystem.Play(Filter.Pvs(Owner), turnOffSound, Owner);
SoundSystem.Play(Filter.Pvs(Owner), TurnOffSound.GetSound(), Owner);
}
return true;
@@ -137,8 +137,7 @@ namespace Content.Server.Light.Components
if (Cell == null)
{
if (TurnOnFailSound.TryGetSound(out var turnOnFailSound))
SoundSystem.Play(Filter.Pvs(Owner), turnOnFailSound, Owner);
SoundSystem.Play(Filter.Pvs(Owner), TurnOnFailSound.GetSound(), Owner);
Owner.PopupMessage(user, Loc.GetString("handheld-light-component-cell-missing-message"));
UpdateLightAction();
return false;
@@ -149,8 +148,7 @@ namespace Content.Server.Light.Components
// Simple enough.
if (Wattage > Cell.CurrentCharge)
{
if (TurnOnFailSound.TryGetSound(out var turnOnFailSound))
SoundSystem.Play(Filter.Pvs(Owner), turnOnFailSound, Owner);
SoundSystem.Play(Filter.Pvs(Owner), TurnOnFailSound.GetSound(), Owner);
Owner.PopupMessage(user, Loc.GetString("handheld-light-component-cell-dead-message"));
UpdateLightAction();
return false;
@@ -161,8 +159,7 @@ namespace Content.Server.Light.Components
SetState(true);
Owner.EntityManager.EventBus.QueueEvent(EventSource.Local, new ActivateHandheldLightMessage(this));
if (TurnOnSound.TryGetSound(out var turnOnSound))
SoundSystem.Play(Filter.Pvs(Owner), turnOnSound, Owner);
SoundSystem.Play(Filter.Pvs(Owner), TurnOnSound.GetSound(), Owner);
return true;
}

View File

@@ -47,7 +47,8 @@ namespace Content.Server.Light.Components
[DataField("color")]
private Color _color = Color.White;
[ViewVariables(VVAccess.ReadWrite)] public Color Color
[ViewVariables(VVAccess.ReadWrite)]
public Color Color
{
get { return _color; }
set
@@ -78,7 +79,8 @@ namespace Content.Server.Light.Components
/// The current state of the light bulb. Invokes the OnLightBulbStateChange event when set.
/// It also updates the bulb's sprite accordingly.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)] public LightBulbState State
[ViewVariables(VVAccess.ReadWrite)]
public LightBulbState State
{
get { return _state; }
set
@@ -132,8 +134,7 @@ namespace Content.Server.Light.Components
public void PlayBreakSound()
{
if(_breakSound.TryGetSound(out var breakSound))
SoundSystem.Play(Filter.Pvs(Owner), breakSound, Owner);
SoundSystem.Play(Filter.Pvs(Owner), _breakSound.GetSound(), Owner);
}
}
}

View File

@@ -24,13 +24,14 @@ namespace Content.Server.Light.Components
/// <summary>
/// How long will matchstick last in seconds.
/// </summary>
[ViewVariables(VVAccess.ReadOnly)] [DataField("duration")]
[ViewVariables(VVAccess.ReadOnly)]
[DataField("duration")]
private int _duration = 10;
/// <summary>
/// Sound played when you ignite the matchstick.
/// </summary>
[DataField("igniteSound")] private SoundSpecifier _igniteSound = default!;
[DataField("igniteSound", required: true)] private SoundSpecifier _igniteSound = default!;
/// <summary>
/// Point light component. Gives matches a glow in dark effect.
@@ -69,11 +70,9 @@ namespace Content.Server.Light.Components
public void Ignite(IEntity user)
{
// Play Sound
if (_igniteSound.TryGetSound(out var igniteSound))
{
SoundSystem.Play(Filter.Pvs(Owner), igniteSound, Owner,
AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f));
}
SoundSystem.Play(
Filter.Pvs(Owner), _igniteSound.GetSound(), Owner,
AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f));
// Change state
CurrentState = SharedBurningStates.Lit;

View File

@@ -58,7 +58,8 @@ namespace Content.Server.Light.Components
[DataField("hasLampOnSpawn")]
private bool _hasLampOnSpawn = true;
[ViewVariables] [DataField("on")]
[ViewVariables]
[DataField("on")]
private bool _on = true;
[ViewVariables]
@@ -67,7 +68,8 @@ namespace Content.Server.Light.Components
[ViewVariables]
private bool _isBlinking;
[ViewVariables] [DataField("ignoreGhostsBoo")]
[ViewVariables]
[DataField("ignoreGhostsBoo")]
private bool _ignoreGhostsBoo;
[DataField("bulb")] private LightBulbType _bulbType = LightBulbType.Tube;
@@ -102,9 +104,9 @@ namespace Content.Server.Light.Components
Eject();
return false;
}
if(eventArgs.User.TryGetComponent(out HeatResistanceComponent? heatResistanceComponent))
if (eventArgs.User.TryGetComponent(out HeatResistanceComponent? heatResistanceComponent))
{
if(CanBurn(heatResistanceComponent.GetHeatResistance()))
if (CanBurn(heatResistanceComponent.GetHeatResistance()))
{
Burn();
return true;
@@ -125,8 +127,7 @@ namespace Content.Server.Light.Components
{
Owner.PopupMessage(eventArgs.User, Loc.GetString("powered-light-component-burn-hand"));
damageableComponent.ChangeDamage(DamageType.Heat, 20, false, Owner);
if(_burnHandSound.TryGetSound(out var burnHandSound))
SoundSystem.Play(Filter.Pvs(Owner), burnHandSound, Owner);
SoundSystem.Play(Filter.Pvs(Owner), _burnHandSound.GetSound(), Owner);
}
void Eject()
@@ -228,8 +229,7 @@ namespace Content.Server.Light.Components
if (time > _lastThunk + _thunkDelay)
{
_lastThunk = time;
if(_turnOnSound.TryGetSound(out var turnOnSound))
SoundSystem.Play(Filter.Pvs(Owner), turnOnSound, Owner, AudioParams.Default.WithVolume(-10f));
SoundSystem.Play(Filter.Pvs(Owner), _turnOnSound.GetSound(), Owner, AudioParams.Default.WithVolume(-10f));
}
}
else
@@ -338,7 +338,8 @@ namespace Content.Server.Light.Components
_lastGhostBlink = time;
ToggleBlinkingLight(true);
Owner.SpawnTimer(ghostBlinkingTime, () => {
Owner.SpawnTimer(ghostBlinkingTime, () =>
{
ToggleBlinkingLight(false);
});