using Content.Shared.Item.ItemToggle.Components;
using Content.Shared.Light.Components;
using ItemTogglePointLightComponent = Content.Shared.Light.Components.ItemTogglePointLightComponent;
namespace Content.Shared.Light.EntitySystems;
///
/// Implements the behavior of , causing s to
/// enable and disable lights on the entity.
///
public sealed class ItemTogglePointLightSystem : EntitySystem
{
[Dependency] private readonly SharedPointLightSystem _light = default!;
[Dependency] private readonly SharedHandheldLightSystem _handheldLight = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent(OnLightToggled);
}
private void OnLightToggled(Entity ent, ref ItemToggledEvent args)
{
if (!_light.TryGetLight(ent.Owner, out var light))
return;
_light.SetEnabled(ent.Owner, args.Activated, comp: light);
if (TryComp(ent.Owner, out var handheldLight))
{
_handheldLight.SetActivated(ent.Owner, args.Activated, handheldLight);
}
}
}