ItemToggle + slots stuff (#31312)

* ItemToggle + slots stuff

- Add component for itemslot locks to match LockComponent (surprised this didn't exist).
- Add thing for pointlight to match itemtoggle. In future should be used for PDAs and stuff but need to fix some other stuff first.

* Also this

* grill
This commit is contained in:
metalgearsloth
2024-08-25 22:30:28 +10:00
committed by GitHub
parent a89d4c750b
commit c0a07614c0
10 changed files with 163 additions and 17 deletions

View File

@@ -0,0 +1,29 @@
using Content.Shared.Item.ItemToggle.Components;
using Content.Shared.Toggleable;
using ItemTogglePointLightComponent = Content.Shared.Light.Components.ItemTogglePointLightComponent;
namespace Content.Shared.Light.EntitySystems;
/// <summary>
/// Handles ItemToggle for PointLight
/// </summary>
public sealed class ItemTogglePointLightSystem : EntitySystem
{
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedPointLightSystem _light = 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;
_appearance.SetData(ent, ToggleableLightVisuals.Enabled, args.Activated);
_light.SetEnabled(ent.Owner, args.Activated, comp: light);
}
}