2022-06-04 19:17:48 +12:00
|
|
|
using Content.Client.Light.Components;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Light.Component;
|
2020-09-03 16:02:40 -04:00
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
using Robust.Client.GameObjects;
|
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Client.Light.Visualizers
|
2020-09-03 16:02:40 -04:00
|
|
|
{
|
|
|
|
|
[UsedImplicitly]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class ExpendableLightVisualizer : AppearanceVisualizer
|
2020-09-03 16:02:40 -04:00
|
|
|
{
|
2022-08-14 07:28:34 +02:00
|
|
|
[Obsolete("Subscribe to AppearanceChangeEvent instead.")]
|
2020-09-03 16:02:40 -04:00
|
|
|
public override void OnChangeData(AppearanceComponent component)
|
|
|
|
|
{
|
|
|
|
|
base.OnChangeData(component);
|
|
|
|
|
|
2021-12-05 18:09:01 +01:00
|
|
|
var entities = IoCManager.Resolve<IEntityManager>();
|
2021-07-31 12:41:59 +02:00
|
|
|
if (component.TryGetData(ExpendableLightVisuals.Behavior, out string lightBehaviourID))
|
2020-09-03 16:02:40 -04:00
|
|
|
{
|
2022-06-04 19:17:48 +12:00
|
|
|
if (entities.TryGetComponent(component.Owner, out LightBehaviourComponent? lightBehaviour))
|
2020-09-03 16:02:40 -04:00
|
|
|
{
|
|
|
|
|
lightBehaviour.StopLightBehaviour();
|
|
|
|
|
|
|
|
|
|
if (lightBehaviourID != string.Empty)
|
|
|
|
|
{
|
|
|
|
|
lightBehaviour.StartLightBehaviour(lightBehaviourID);
|
|
|
|
|
}
|
2022-06-04 19:17:48 +12:00
|
|
|
else if (entities.TryGetComponent(component.Owner, out PointLightComponent? light))
|
2020-09-03 16:02:40 -04:00
|
|
|
{
|
|
|
|
|
light.Enabled = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-07-31 12:41:59 +02:00
|
|
|
|
|
|
|
|
if (component.TryGetData(ExpendableLightVisuals.State, out ExpendableLightState state)
|
2022-12-14 09:46:58 +13:00
|
|
|
&& entities.TryGetComponent(component.Owner, out ExpendableLightComponent? expendableLight))
|
2021-07-31 12:41:59 +02:00
|
|
|
{
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case ExpendableLightState.Lit:
|
2022-12-14 09:46:58 +13:00
|
|
|
expendableLight.PlayingStream?.Stop();
|
|
|
|
|
expendableLight.PlayingStream = entities.EntitySysManager.GetEntitySystem<SharedAudioSystem>().PlayPvs(
|
|
|
|
|
expendableLight.LoopedSound,
|
|
|
|
|
expendableLight.Owner,
|
|
|
|
|
SharedExpendableLightComponent.LoopedSoundParams);
|
2021-07-31 12:41:59 +02:00
|
|
|
break;
|
|
|
|
|
case ExpendableLightState.Dead:
|
2022-12-14 09:46:58 +13:00
|
|
|
expendableLight.PlayingStream?.Stop();
|
2021-07-31 12:41:59 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-09-03 16:02:40 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|