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.GameObjects;
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 JetBrains.Annotations;
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
{
@@ -35,33 +31,23 @@ namespace Content.Client.Light.Visualizers
}
}
void TryStopStream(IPlayingAudioStream? stream)
{
stream?.Stop();
}
if (component.TryGetData(ExpendableLightVisuals.State, out ExpendableLightState state)
&& entities.TryGetComponent(component.Owner, out ExpendableLightComponent? expendableLight))
{
switch (state)
{
case ExpendableLightState.Lit:
{
TryStopStream(expendableLight.PlayingStream);
if (expendableLight.LoopedSound != null)
{
expendableLight.PlayingStream = SoundSystem.Play(expendableLight.LoopedSound, Filter.Local(),
expendableLight.Owner, SharedExpendableLightComponent.LoopedSoundParams.WithLoop(true));
}
expendableLight.PlayingStream?.Stop();
expendableLight.PlayingStream = entities.EntitySysManager.GetEntitySystem<SharedAudioSystem>().PlayPvs(
expendableLight.LoopedSound,
expendableLight.Owner,
SharedExpendableLightComponent.LoopedSoundParams);
break;
}
case ExpendableLightState.Dead:
{
TryStopStream(expendableLight.PlayingStream);
expendableLight.PlayingStream?.Stop();
break;
}
}
}
}
}
}

View File

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

View File

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