mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* IoC source gen compatibility Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter. * Missed a spot
33 lines
1.2 KiB
C#
33 lines
1.2 KiB
C#
using Content.Shared.Item.ItemToggle.Components;
|
|
using Content.Shared.Light.Components;
|
|
using ItemTogglePointLightComponent = Content.Shared.Light.Components.ItemTogglePointLightComponent;
|
|
|
|
namespace Content.Shared.Light.EntitySystems;
|
|
|
|
/// <summary>
|
|
/// Implements the behavior of <see cref="ItemTogglePointLightComponent"/>, causing <see cref="ItemToggledEvent"/>s to
|
|
/// enable and disable lights on the entity.
|
|
/// </summary>
|
|
public sealed partial class ItemTogglePointLightSystem : EntitySystem
|
|
{
|
|
[Dependency] private SharedPointLightSystem _light = default!;
|
|
[Dependency] private SharedHandheldLightSystem _handheldLight = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<ItemTogglePointLightComponent, ItemToggledEvent>(OnLightToggled);
|
|
}
|
|
|
|
private void OnLightToggled(Entity<ItemTogglePointLightComponent> ent, ref ItemToggledEvent args)
|
|
{
|
|
if (!_light.TryGetLight(ent.Owner, out var light))
|
|
return;
|
|
|
|
_light.SetEnabled(ent.Owner, args.Activated, comp: light);
|
|
if (TryComp<HandheldLightComponent>(ent.Owner, out var handheldLight))
|
|
{
|
|
_handheldLight.SetActivated(ent.Owner, args.Activated, handheldLight);
|
|
}
|
|
}
|
|
}
|