Move Access & AccessReader to shared. (#5798)
* git mv * Move Access Component & system. - Name space changes - Rename AccessReader to AccessReaderComponent - Also need an abstract TryGetSlot function for SharedInventoryComponent * better TryGetSlot * Ah yes, tests exist.
This commit is contained in:
@@ -228,9 +228,17 @@ namespace Content.Client.Inventory
|
||||
_playerAttached = true;
|
||||
}
|
||||
|
||||
public bool TryGetSlot(Slots slot, [NotNullWhen(true)] out EntityUid item)
|
||||
public override bool TryGetSlot(Slots slot, [NotNullWhen(true)] out EntityUid? item)
|
||||
{
|
||||
return _slots.TryGetValue(slot, out item);
|
||||
// dict TryGetValue uses default EntityUid, not null.
|
||||
if (!_slots.ContainsKey(slot))
|
||||
{
|
||||
item = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
item = _slots[slot];
|
||||
return item != null;
|
||||
}
|
||||
|
||||
public bool TryFindItemSlots(EntityUid item, [NotNullWhen(true)] out Slots? slots)
|
||||
|
||||
@@ -35,9 +35,9 @@ namespace Content.Client.Inventory
|
||||
// jesus christ, this is duplicated to server/client, should really just be shared..
|
||||
private void OnSlipAttemptEvent(EntityUid uid, ClientInventoryComponent component, SlipAttemptEvent args)
|
||||
{
|
||||
if (component.TryGetSlot(EquipmentSlotDefines.Slots.SHOES, out EntityUid shoes))
|
||||
if (component.TryGetSlot(EquipmentSlotDefines.Slots.SHOES, out EntityUid? shoes))
|
||||
{
|
||||
RaiseLocalEvent(shoes, args, false);
|
||||
RaiseLocalEvent(shoes.Value, args, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@ namespace Content.Client.Inventory
|
||||
if (!Owner.TryGetSlot(slot, out var item))
|
||||
return;
|
||||
|
||||
if (!_itemSlotManager.OnButtonPressed(args, item))
|
||||
if (!_itemSlotManager.OnButtonPressed(args, item.Value))
|
||||
base.HandleInventoryKeybind(args, slot);
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ namespace Content.Client.Inventory
|
||||
|
||||
if (Owner.TryGetSlot(slot, out var entity))
|
||||
{
|
||||
AddToSlot(slot, entity);
|
||||
AddToSlot(slot, entity.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user