Files
tbd-station-14/Content.Shared/Light/SharedRgbLightControllerSystem.cs
Tayrtahn 4a83c36585 Code cleanup: Dirty(Comp) (#26238)
* Replaced uses of Dirty(Component) with Dirty(Uid, Component)
Modified some systems (notably pulling-related) to use uids.

* Missed a few

* Revert changes to pulling

* No
2024-03-19 23:27:02 -04:00

38 lines
1.0 KiB
C#

using Content.Shared.Light.Components;
using Robust.Shared.GameStates;
namespace Content.Shared.Light;
public abstract class SharedRgbLightControllerSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<RgbLightControllerComponent, ComponentGetState>(OnGetState);
}
private void OnGetState(EntityUid uid, RgbLightControllerComponent component, ref ComponentGetState args)
{
args.State = new RgbLightControllerState(component.CycleRate, component.Layers);
}
public void SetLayers(EntityUid uid, List<int>? layers, RgbLightControllerComponent? rgb = null)
{
if (!Resolve(uid, ref rgb))
return;
rgb.Layers = layers;
Dirty(uid, rgb);
}
public void SetCycleRate(EntityUid uid, float rate, RgbLightControllerComponent? rgb = null)
{
if (!Resolve(uid, ref rgb))
return;
rgb.CycleRate = Math.Clamp(0.01f, rate, 1); // lets not give people seizures
Dirty(uid, rgb);
}
}