Bunch more error fixes.
This commit is contained in:
@@ -171,9 +171,6 @@ namespace Content.Shared.Containers.ItemSlots
|
||||
|
||||
// Convenience properties
|
||||
public bool HasItem => ContainerSlot.ContainedEntity != null;
|
||||
public IEntity? Item => ContainerSlot.ContainedEntity;
|
||||
|
||||
// and to make it easier for whenever IEntity is removed
|
||||
public EntityUid? ItemUid => ContainerSlot.ContainedEntity;
|
||||
public EntityUid? Item => ContainerSlot.ContainedEntity;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace Content.Shared.Containers.ItemSlots
|
||||
continue;
|
||||
|
||||
args.Handled = true;
|
||||
TryEjectToHands(uid, slot, args.UserUid);
|
||||
TryEjectToHands(uid, slot, args.User);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -139,12 +139,12 @@ namespace Content.Shared.Containers.ItemSlots
|
||||
if (args.Handled)
|
||||
return;
|
||||
|
||||
if (!EntityManager.TryGetComponent(args.UserUid, out SharedHandsComponent? hands))
|
||||
if (!EntityManager.TryGetComponent(args.User, out SharedHandsComponent? hands))
|
||||
return;
|
||||
|
||||
foreach (var slot in itemSlots.Slots.Values)
|
||||
{
|
||||
if (!CanInsert(uid, args.UsedUid, slot, swap: slot.Swap, popup: args.UserUid))
|
||||
if (!CanInsert(uid, args.Used, slot, swap: slot.Swap, popup: args.User))
|
||||
continue;
|
||||
|
||||
// Drop the held item onto the floor. Return if the user cannot drop.
|
||||
@@ -152,7 +152,7 @@ namespace Content.Shared.Containers.ItemSlots
|
||||
return;
|
||||
|
||||
if (slot.Item != null)
|
||||
hands.TryPutInAnyHand(slot.Item);
|
||||
hands.TryPutInAnyHand(slot.Item.Value);
|
||||
|
||||
Insert(uid, slot, args.Used);
|
||||
args.Handled = true;
|
||||
@@ -166,7 +166,7 @@ namespace Content.Shared.Containers.ItemSlots
|
||||
/// Insert an item into a slot. This does not perform checks, so make sure to also use <see
|
||||
/// cref="CanInsert"/> or just use <see cref="TryInsert"/> instead.
|
||||
/// </summary>
|
||||
private void Insert(EntityUid uid, ItemSlot slot, IEntity item)
|
||||
private void Insert(EntityUid uid, ItemSlot slot, EntityUid item)
|
||||
{
|
||||
slot.ContainerSlot.Insert(item);
|
||||
// ContainerSlot automatically raises a directed EntInsertedIntoContainerMessage
|
||||
@@ -208,7 +208,7 @@ namespace Content.Shared.Containers.ItemSlots
|
||||
/// Tries to insert item into a specific slot.
|
||||
/// </summary>
|
||||
/// <returns>False if failed to insert item</returns>
|
||||
public bool TryInsert(EntityUid uid, string id, IEntity item, ItemSlotsComponent? itemSlots = null)
|
||||
public bool TryInsert(EntityUid uid, string id, EntityUid item, ItemSlotsComponent? itemSlots = null)
|
||||
{
|
||||
if (!Resolve(uid, ref itemSlots))
|
||||
return false;
|
||||
@@ -223,7 +223,7 @@ namespace Content.Shared.Containers.ItemSlots
|
||||
/// Tries to insert item into a specific slot.
|
||||
/// </summary>
|
||||
/// <returns>False if failed to insert item</returns>
|
||||
public bool TryInsert(EntityUid uid, ItemSlot slot, IEntity item)
|
||||
public bool TryInsert(EntityUid uid, ItemSlot slot, EntityUid item)
|
||||
{
|
||||
if (!CanInsert(uid, item, slot))
|
||||
return false;
|
||||
@@ -244,14 +244,14 @@ namespace Content.Shared.Containers.ItemSlots
|
||||
if (!hands.TryGetActiveHeldEntity(out var item))
|
||||
return false;
|
||||
|
||||
if (!CanInsert(uid, item, slot))
|
||||
if (!CanInsert(uid, item.Value, slot))
|
||||
return false;
|
||||
|
||||
// hands.Drop(item) checks CanDrop action blocker
|
||||
if (!_actionBlockerSystem.CanInteract(user) && hands.Drop(item))
|
||||
if (!_actionBlockerSystem.CanInteract(user) && hands.Drop(item.Value))
|
||||
return false;
|
||||
|
||||
Insert(uid, slot, item);
|
||||
Insert(uid, slot, item.Value);
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
@@ -261,7 +261,7 @@ namespace Content.Shared.Containers.ItemSlots
|
||||
/// Eject an item into a slot. This does not perform checks (e.g., is the slot locked?), so you should
|
||||
/// probably just use <see cref="TryEject"/> instead.
|
||||
/// </summary>
|
||||
private void Eject(EntityUid uid, ItemSlot slot, IEntity item)
|
||||
private void Eject(EntityUid uid, ItemSlot slot, EntityUid item)
|
||||
{
|
||||
slot.ContainerSlot.Remove(item);
|
||||
// ContainerSlot automatically raises a directed EntRemovedFromContainerMessage
|
||||
@@ -274,7 +274,7 @@ namespace Content.Shared.Containers.ItemSlots
|
||||
/// Try to eject an item from a slot.
|
||||
/// </summary>
|
||||
/// <returns>False if item slot is locked or has no item inserted</returns>
|
||||
public bool TryEject(EntityUid uid, ItemSlot slot, [NotNullWhen(true)] out IEntity? item)
|
||||
public bool TryEject(EntityUid uid, ItemSlot slot, [NotNullWhen(true)] out EntityUid? item)
|
||||
{
|
||||
item = null;
|
||||
|
||||
@@ -282,7 +282,7 @@ namespace Content.Shared.Containers.ItemSlots
|
||||
return false;
|
||||
|
||||
item = slot.Item;
|
||||
Eject(uid, slot, item);
|
||||
Eject(uid, slot, item.Value);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -290,7 +290,7 @@ namespace Content.Shared.Containers.ItemSlots
|
||||
/// Try to eject item from a slot.
|
||||
/// </summary>
|
||||
/// <returns>False if the id is not valid, the item slot is locked, or it has no item inserted</returns>
|
||||
public bool TryEject(EntityUid uid, string id, [NotNullWhen(true)] out IEntity? item, ItemSlotsComponent? itemSlots = null)
|
||||
public bool TryEject(EntityUid uid, string id, [NotNullWhen(true)] out EntityUid? item, ItemSlotsComponent? itemSlots = null)
|
||||
{
|
||||
item = null;
|
||||
|
||||
@@ -317,7 +317,7 @@ namespace Content.Shared.Containers.ItemSlots
|
||||
return false;
|
||||
|
||||
if (user != null && EntityManager.TryGetComponent(user.Value, out SharedHandsComponent? hands))
|
||||
hands.TryPutInAnyHand(item);
|
||||
hands.TryPutInAnyHand(item.Value);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -344,7 +344,7 @@ namespace Content.Shared.Containers.ItemSlots
|
||||
|
||||
var verbSubject = slot.Name != string.Empty
|
||||
? Loc.GetString(slot.Name)
|
||||
: IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(slot.Item!).EntityName ?? string.Empty;
|
||||
: IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(slot.Item!.Value).EntityName ?? string.Empty;
|
||||
|
||||
Verb verb = new();
|
||||
verb.Act = () => TryEjectToHands(uid, slot, args.User);
|
||||
@@ -379,7 +379,7 @@ namespace Content.Shared.Containers.ItemSlots
|
||||
|
||||
var verbSubject = slot.Name != string.Empty
|
||||
? Loc.GetString(slot.Name)
|
||||
: IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(slot.Item!).EntityName ?? string.Empty;
|
||||
: IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(slot.Item!.Value).EntityName ?? string.Empty;
|
||||
|
||||
Verb takeVerb = new();
|
||||
takeVerb.Act = () => TryEjectToHands(uid, slot, args.User);
|
||||
@@ -400,15 +400,15 @@ namespace Content.Shared.Containers.ItemSlots
|
||||
|
||||
foreach (var slot in itemSlots.Slots.Values)
|
||||
{
|
||||
if (!CanInsert(uid, args.Using, slot))
|
||||
if (!CanInsert(uid, args.Using.Value, slot))
|
||||
continue;
|
||||
|
||||
var verbSubject = slot.Name != string.Empty
|
||||
? Loc.GetString(slot.Name)
|
||||
: IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(args.Using).EntityName ?? string.Empty;
|
||||
: IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(args.Using.Value).EntityName ?? string.Empty;
|
||||
|
||||
Verb insertVerb = new();
|
||||
insertVerb.Act = () => Insert(uid, slot, args.Using);
|
||||
insertVerb.Act = () => Insert(uid, slot, args.Using.Value);
|
||||
|
||||
if (slot.InsertVerbText != null)
|
||||
{
|
||||
@@ -448,7 +448,7 @@ namespace Content.Shared.Containers.ItemSlots
|
||||
/// <summary>
|
||||
/// Get the contents of some item slot.
|
||||
/// </summary>
|
||||
public IEntity? GetItem(EntityUid uid, string id, ItemSlotsComponent? itemSlots = null)
|
||||
public EntityUid? GetItem(EntityUid uid, string id, ItemSlotsComponent? itemSlots = null)
|
||||
{
|
||||
if (!Resolve(uid, ref itemSlots))
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user