misc flare fixes (#12942)

This commit is contained in:
Leon Friedrich
2022-12-14 09:46:58 +13:00
committed by GitHub
parent 5a756a0094
commit f65510ca81
5 changed files with 37 additions and 36 deletions

View File

@@ -1,6 +1,5 @@
using Content.Shared.Light.Component; using Content.Shared.Light.Component;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
namespace Content.Client.Light.Components namespace Content.Client.Light.Components
{ {

View File

@@ -0,0 +1,18 @@
using Content.Client.Light.Components;
namespace Content.Client.Light.EntitySystems;
public sealed class ExpendableLightSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ExpendableLightComponent, ComponentShutdown>(OnLightShutdown);
}
private void OnLightShutdown(EntityUid uid, ExpendableLightComponent component, ComponentShutdown args)
{
component.PlayingStream?.Stop();
}
}

View File

@@ -2,10 +2,6 @@ using Content.Client.Light.Components;
using Content.Shared.Light.Component; using Content.Shared.Light.Component;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Player;
namespace Content.Client.Light.Visualizers namespace Content.Client.Light.Visualizers
{ {
@@ -35,31 +31,21 @@ namespace Content.Client.Light.Visualizers
} }
} }
void TryStopStream(IPlayingAudioStream? stream)
{
stream?.Stop();
}
if (component.TryGetData(ExpendableLightVisuals.State, out ExpendableLightState state) if (component.TryGetData(ExpendableLightVisuals.State, out ExpendableLightState state)
&& entities.TryGetComponent(component.Owner, out ExpendableLightComponent? expendableLight)) && entities.TryGetComponent(component.Owner, out ExpendableLightComponent? expendableLight))
{ {
switch (state) switch (state)
{ {
case ExpendableLightState.Lit: case ExpendableLightState.Lit:
{ expendableLight.PlayingStream?.Stop();
TryStopStream(expendableLight.PlayingStream); expendableLight.PlayingStream = entities.EntitySysManager.GetEntitySystem<SharedAudioSystem>().PlayPvs(
if (expendableLight.LoopedSound != null) expendableLight.LoopedSound,
{ expendableLight.Owner,
expendableLight.PlayingStream = SoundSystem.Play(expendableLight.LoopedSound, Filter.Local(), SharedExpendableLightComponent.LoopedSoundParams);
expendableLight.Owner, SharedExpendableLightComponent.LoopedSoundParams.WithLoop(true));
}
break; break;
}
case ExpendableLightState.Dead: case ExpendableLightState.Dead:
{ expendableLight.PlayingStream?.Stop();
TryStopStream(expendableLight.PlayingStream);
break; break;
}
} }
} }
} }

View File

@@ -19,6 +19,7 @@ namespace Content.Server.Light.EntitySystems
[Dependency] private readonly SharedItemSystem _item = default!; [Dependency] private readonly SharedItemSystem _item = default!;
[Dependency] private readonly ClothingSystem _clothing = default!; [Dependency] private readonly ClothingSystem _clothing = default!;
[Dependency] private readonly TagSystem _tagSystem = default!; [Dependency] private readonly TagSystem _tagSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
public override void Initialize() public override void Initialize()
{ {
@@ -130,9 +131,7 @@ namespace Content.Server.Light.EntitySystems
switch (component.CurrentState) switch (component.CurrentState)
{ {
case ExpendableLightState.Lit: case ExpendableLightState.Lit:
{ _audio.PlayPvs(component.LitSound, component.Owner);
SoundSystem.Play(component.LitSound.GetSound(), Filter.Pvs(component.Owner), component.Owner);
if (component.IconStateLit != string.Empty) if (component.IconStateLit != string.Empty)
{ {
sprite.LayerSetState(2, component.IconStateLit); sprite.LayerSetState(2, component.IconStateLit);
@@ -141,22 +140,21 @@ namespace Content.Server.Light.EntitySystems
sprite.LayerSetVisible(1, true); sprite.LayerSetVisible(1, true);
break; break;
}
case ExpendableLightState.Fading: case ExpendableLightState.Fading:
{ {
break; break;
} }
default: default:
case ExpendableLightState.Dead: case ExpendableLightState.Dead:
{ _audio.PlayPvs(component.DieSound, component.Owner);
if (component.DieSound != null) if (!string.IsNullOrEmpty(component.IconStateSpent))
SoundSystem.Play(component.DieSound.GetSound(), Filter.Pvs(component.Owner), component.Owner); {
sprite.LayerSetState(0, component.IconStateSpent);
sprite.LayerSetShader(0, "shaded");
}
sprite.LayerSetState(0, component.IconStateSpent);
sprite.LayerSetShader(0, "shaded");
sprite.LayerSetVisible(1, false); sprite.LayerSetVisible(1, false);
break; break;
}
} }
} }

View File

@@ -52,11 +52,11 @@ namespace Content.Shared.Light.Component
[DataField("iconStateOn")] [DataField("iconStateOn")]
public string IconStateLit { get; set; } = string.Empty; public string IconStateLit { get; set; } = string.Empty;
[DataField("litSound", required: true)] [DataField("litSound")]
public SoundSpecifier LitSound { get; set; } = default!; public SoundSpecifier? LitSound { get; set; }
[DataField("loopedSound")] [DataField("loopedSound")]
public string? LoopedSound { get; set; } = null; public SoundSpecifier? LoopedSound { get; set; }
[DataField("dieSound")] [DataField("dieSound")]
public SoundSpecifier? DieSound { get; set; } = null; public SoundSpecifier? DieSound { get; set; } = null;