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

@@ -45,11 +45,11 @@ namespace Content.Server.Construction
// LEGACY CODE. See warning at the top of the file!
private IEnumerable<IEntity> EnumerateNearby(IEntity user)
{
if (user.TryGetComponent(out HandsComponent? hands))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(user.Uid, out HandsComponent? hands))
{
foreach (var itemComponent in hands?.GetAllHeldItems()!)
{
if (itemComponent.Owner.TryGetComponent(out ServerStorageComponent? storage))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(itemComponent.Owner.Uid, out ServerStorageComponent? storage))
{
foreach (var storedEntity in storage.StoredEntities!)
{
@@ -61,11 +61,11 @@ namespace Content.Server.Construction
}
}
if (user!.TryGetComponent(out InventoryComponent? inventory))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(user!.Uid, out InventoryComponent? inventory))
{
foreach (var held in inventory.GetAllHeldItems())
{
if (held.TryGetComponent(out ServerStorageComponent? storage))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(held.Uid, out ServerStorageComponent? storage))
{
foreach (var storedEntity in storage.StoredEntities!)
{
@@ -299,7 +299,7 @@ namespace Content.Server.Construction
if (user == null || !Get<ActionBlockerSystem>().CanInteract(user.Uid)) return;
if (!user.TryGetComponent(out HandsComponent? hands)) return;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(user.Uid, out HandsComponent? hands)) return;
foreach (var condition in constructionPrototype.Conditions)
{
@@ -328,7 +328,7 @@ namespace Content.Server.Construction
var item = await Construct(user, "item_construction", constructionGraph, edge, targetNode);
if(item != null && item.TryGetComponent(out ItemComponent? itemComp))
if(item != null && IoCManager.Resolve<IEntityManager>().TryGetComponent(item.Uid, out ItemComponent? itemComp))
hands.PutInHandOrDrop(itemComp);
}
@@ -399,7 +399,7 @@ namespace Content.Server.Construction
if (user == null
|| !Get<ActionBlockerSystem>().CanInteract(user.Uid)
|| !user.TryGetComponent(out HandsComponent? hands) || hands.GetActiveHand == null
|| !IoCManager.Resolve<IEntityManager>().TryGetComponent(user.Uid, out HandsComponent? hands) || hands.GetActiveHand == null
|| !user.InRangeUnobstructed(ev.Location, ignoreInsideBlocker:constructionPrototype.CanBuildInImpassable))
{
Cleanup();