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:
36
Content.Shared/Containers/ItemSlot/ItemSlotsSystem.Lock.cs
Normal file
36
Content.Shared/Containers/ItemSlot/ItemSlotsSystem.Lock.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using Content.Shared.Lock;
|
||||
|
||||
namespace Content.Shared.Containers.ItemSlots;
|
||||
|
||||
public sealed partial class ItemSlotsSystem
|
||||
{
|
||||
private void InitializeLock()
|
||||
{
|
||||
SubscribeLocalEvent<ItemSlotsLockComponent, MapInitEvent>(OnLockMapInit);
|
||||
SubscribeLocalEvent<ItemSlotsLockComponent, LockToggledEvent>(OnLockToggled);
|
||||
}
|
||||
|
||||
private void OnLockMapInit(Entity<ItemSlotsLockComponent> ent, ref MapInitEvent args)
|
||||
{
|
||||
if (!TryComp(ent.Owner, out LockComponent? lockComp))
|
||||
return;
|
||||
|
||||
UpdateLocks(ent, lockComp.Locked);
|
||||
}
|
||||
|
||||
private void OnLockToggled(Entity<ItemSlotsLockComponent> ent, ref LockToggledEvent args)
|
||||
{
|
||||
UpdateLocks(ent, args.Locked);
|
||||
}
|
||||
|
||||
private void UpdateLocks(Entity<ItemSlotsLockComponent> ent, bool value)
|
||||
{
|
||||
foreach (var slot in ent.Comp.Slots)
|
||||
{
|
||||
if (!TryGetSlot(ent.Owner, slot, out var itemSlot))
|
||||
continue;
|
||||
|
||||
SetLock(ent.Owner, itemSlot, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user