Files
tbd-station-14/Content.Client/Light/Visualizers/LightBulbVisualizer.cs
Alex Evgrashin 6e00104260 Powered light ECS (#5028)
* Brrrr ECS

* Create lit on powered system

* Light bulb ECS

* Finishing porting to ECS

* Minor touches

* Removed events

* Removed old comments

* Fixed test

* To popup system
2021-10-27 12:24:22 +11:00

43 lines
1.3 KiB
C#

using Content.Shared.Light;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.Maths;
namespace Content.Client.Light.Visualizers
{
[UsedImplicitly]
public class LightBulbVisualizer : AppearanceVisualizer
{
public override void OnChangeData(AppearanceComponent component)
{
base.OnChangeData(component);
if (!component.Owner.TryGetComponent<SpriteComponent>(out var sprite))
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;
}
}
}
}