Inline TryGetComponent completely, for real

This commit is contained in:
Vera Aguilera Puerto
2021-12-03 14:17:01 +01:00
parent 2ff4ec65d5
commit 69b270017b
425 changed files with 1143 additions and 995 deletions

View File

@@ -225,7 +225,7 @@ namespace Content.Server.Inventory.Components
}
}
if (Owner.TryGetComponent(out IInventoryController? controller))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out IInventoryController? controller))
{
pass = controller.CanEquip(slot, item.Owner, pass, out var controllerReason);
reason = controllerReason ?? reason;
@@ -411,7 +411,7 @@ namespace Content.Server.Inventory.Components
if (container is not ContainerSlot slot || !_slotContainers.ContainsValue(slot))
return;
if (entity.TryGetComponent(out ItemComponent? itemComp))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out ItemComponent? itemComp))
{
itemComp.RemovedFromSlot();
}
@@ -434,7 +434,7 @@ namespace Content.Server.Inventory.Components
var hands = IoCManager.Resolve<IEntityManager>().GetComponent<HandsComponent>(Owner.Uid);
var activeHand = hands.ActiveHand;
var activeItem = hands.GetActiveHand;
if (activeHand != null && activeItem != null && activeItem.Owner.TryGetComponent(out ItemComponent? item))
if (activeHand != null && activeItem != null && IoCManager.Resolve<IEntityManager>().TryGetComponent(activeItem.Owner.Uid, out ItemComponent? item))
{
hands.TryDropNoInteraction();
if (!Equip(msg.Inventoryslot, item, true, out var reason))
@@ -511,7 +511,7 @@ namespace Content.Server.Inventory.Components
if (!HasSlot(msg.Slot)) // client input sanitization
return;
var item = GetSlotItem(msg.Slot);
if (item != null && item.Owner.TryGetComponent(out ServerStorageComponent? storage))
if (item != null && IoCManager.Resolve<IEntityManager>().TryGetComponent(item.Owner.Uid, out ServerStorageComponent? storage))
storage.OpenStorageUI(Owner);
break;
}

View File

@@ -38,7 +38,7 @@ namespace Content.Server.Inventory
}
// If this doesn't have an item component, then we can't do anything with it.
if (!item.TryGetComponent(out ItemComponent? itemComp))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(item.Uid, out ItemComponent? itemComp))
return DeleteItem();
// We finally try to equip the item, otherwise we delete it.