CatStation/Content.Client/Light/EntitySystems/LightBulbSystem.cs
Whatstone d9ffbf1d03
Cleanup: AppearanceSystem.TryGetData to AppearanceChangeEvent.TryGetData (#45373)
* First impl. of appearance TryGetData cleanup

* Handful of fixes

* DamageVisuals: fix HandleDamage call, inheritdoc

* bunch of unused AppearanceSystem instances

* Handful more unused appearance systems, inheritdoc

* JetpackSystem: Ent<T>

* cleanup roundup, more Ent<T>

* a few lingering AppearanceSystem.TryGetData calls

* more lingering AppearanceData access

* Remove unnecessary inheritdoc

* once again, with feeling
2026-10-05 00:45:37 +00:00

40 lines
1.4 KiB
C#

using Content.Shared.Light.Components;
using Content.Shared.Light.EntitySystems;
using Robust.Client.GameObjects;
namespace Content.Client.Light.EntitySystems;
public sealed partial class LightBulbSystem : SharedLightBulbSystem
{
[Dependency] private SpriteSystem _sprite = default!;
[SubscribeLocalEvent]
private void OnAppearanceChange(Entity<LightBulbComponent> ent, ref AppearanceChangeEvent args)
{
if (args.Sprite == null)
return;
// update sprite state
if (args.TryGetData<LightBulbState>(LightBulbVisuals.State, out var state))
{
switch (state)
{
case LightBulbState.Normal:
_sprite.LayerSetRsiState((ent, args.Sprite), LightBulbVisualLayers.Base, ent.Comp.NormalSpriteState);
break;
case LightBulbState.Broken:
_sprite.LayerSetRsiState((ent, args.Sprite), LightBulbVisualLayers.Base, ent.Comp.BrokenSpriteState);
break;
case LightBulbState.Burned:
_sprite.LayerSetRsiState((ent, args.Sprite), LightBulbVisualLayers.Base, ent.Comp.BurnedSpriteState);
break;
}
}
// also update sprites color
if (args.TryGetData<Color>(LightBulbVisuals.Color, out var color))
{
_sprite.SetColor((ent, args.Sprite), color);
}
}
}