2021-10-27 04:24:22 +03:00
|
|
|
using Content.Shared.Light;
|
|
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
using Robust.Client.GameObjects;
|
2021-11-22 23:22:59 -08:00
|
|
|
using Robust.Shared.GameObjects;
|
2021-12-05 18:09:01 +01:00
|
|
|
using Robust.Shared.IoC;
|
2021-10-27 04:24:22 +03:00
|
|
|
using Robust.Shared.Maths;
|
|
|
|
|
|
|
|
|
|
namespace Content.Client.Light.Visualizers
|
|
|
|
|
{
|
|
|
|
|
[UsedImplicitly]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class LightBulbVisualizer : AppearanceVisualizer
|
2021-10-27 04:24:22 +03:00
|
|
|
{
|
|
|
|
|
public override void OnChangeData(AppearanceComponent component)
|
|
|
|
|
{
|
|
|
|
|
base.OnChangeData(component);
|
|
|
|
|
|
2021-12-05 18:09:01 +01:00
|
|
|
var entities = IoCManager.Resolve<IEntityManager>();
|
|
|
|
|
if (!entities.TryGetComponent(component.Owner, out SpriteComponent sprite))
|
2021-10-27 04:24:22 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// update sprite state
|
|
|
|
|
if (component.TryGetData(LightBulbVisuals.State, out LightBulbState state))
|
|
|
|
|
{
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case LightBulbState.Normal:
|
|
|
|
|
sprite.LayerSetState(0, "normal");
|
|
|
|
|
break;
|
|
|
|
|
case LightBulbState.Broken:
|
|
|
|
|
sprite.LayerSetState(0, "broken");
|
|
|
|
|
break;
|
|
|
|
|
case LightBulbState.Burned:
|
|
|
|
|
sprite.LayerSetState(0, "burned");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// also update sprites color
|
|
|
|
|
if (component.TryGetData(LightBulbVisuals.Color, out Color color))
|
|
|
|
|
{
|
|
|
|
|
sprite.Color = color;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|