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

@@ -3,6 +3,7 @@ using Content.Server.Inventory.Components;
using Content.Shared.Inventory;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.AI.WorldState.States.Clothing
{
@@ -15,7 +16,7 @@ namespace Content.Server.AI.WorldState.States.Clothing
{
var result = new Dictionary<EquipmentSlotDefines.Slots, IEntity>();
if (!Owner.TryGetComponent(out InventoryComponent? inventoryComponent))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out InventoryComponent? inventoryComponent))
{
return result;
}

View File

@@ -19,7 +19,7 @@ namespace Content.Server.AI.WorldState.States.Clothing
{
var result = new List<IEntity>();
if (!Owner.TryGetComponent(out AiControllerComponent? controller))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AiControllerComponent? controller))
{
return result;
}

View File

@@ -4,6 +4,7 @@ using Content.Server.AI.Utils;
using Content.Server.Weapon.Melee.Components;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.AI.WorldState.States.Combat.Nearby
{
@@ -16,7 +17,7 @@ namespace Content.Server.AI.WorldState.States.Combat.Nearby
{
var result = new List<IEntity>();
if (!Owner.TryGetComponent(out AiControllerComponent? controller))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AiControllerComponent? controller))
{
return result;
}

View File

@@ -1,5 +1,7 @@
using Content.Server.Hands.Components;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.AI.WorldState.States.Hands
{
@@ -9,7 +11,7 @@ namespace Content.Server.AI.WorldState.States.Hands
public override string Name => "AnyFreeHand";
public override bool GetValue()
{
if (!Owner.TryGetComponent(out HandsComponent? handsComponent))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out HandsComponent? handsComponent))
{
return false;
}

View File

@@ -1,6 +1,8 @@
using System.Collections.Generic;
using Content.Server.Hands.Components;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.AI.WorldState.States.Hands
{
@@ -13,7 +15,7 @@ namespace Content.Server.AI.WorldState.States.Hands
{
var result = new List<string>();
if (!Owner.TryGetComponent(out HandsComponent? handsComponent))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out HandsComponent? handsComponent))
{
return result;
}

View File

@@ -2,6 +2,7 @@ using System.Collections.Generic;
using Content.Server.Hands.Components;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.AI.WorldState.States.Hands
{
@@ -12,7 +13,7 @@ namespace Content.Server.AI.WorldState.States.Hands
public override List<IEntity> GetValue()
{
var result = new List<IEntity>();
if (!Owner.TryGetComponent(out HandsComponent? handsComponent))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out HandsComponent? handsComponent))
{
return result;
}

View File

@@ -1,6 +1,7 @@
using Content.Server.Hands.Components;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.AI.WorldState.States.Inventory
{
@@ -14,7 +15,7 @@ namespace Content.Server.AI.WorldState.States.Inventory
public override IEntity? GetValue()
{
if (!Owner.TryGetComponent(out HandsComponent? handsComponent))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out HandsComponent? handsComponent))
{
return null;
}

View File

@@ -13,7 +13,7 @@ namespace Content.Server.AI.WorldState.States.Inventory
public override IEnumerable<IEntity> GetValue()
{
if (Owner.TryGetComponent(out HandsComponent? handsComponent))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out HandsComponent? handsComponent))
{
foreach (var item in handsComponent.GetAllHeldItems())
{

View File

@@ -4,6 +4,7 @@ using Content.Server.AI.Utils;
using Content.Shared.Body.Components;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.AI.WorldState.States.Mobs
{
@@ -16,7 +17,7 @@ namespace Content.Server.AI.WorldState.States.Mobs
{
var result = new List<IEntity>();
if (!Owner.TryGetComponent(out AiControllerComponent? controller))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AiControllerComponent? controller))
{
return result;
}

View File

@@ -20,7 +20,7 @@ namespace Content.Server.AI.WorldState.States.Mobs
{
var result = new List<IEntity>();
if (!Owner.TryGetComponent(out AiControllerComponent? controller))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AiControllerComponent? controller))
{
return result;
}

View File

@@ -2,6 +2,8 @@ using System;
using Content.Server.Nutrition.Components;
using Content.Shared.Nutrition.Components;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.AI.WorldState.States.Nutrition
{
@@ -12,7 +14,7 @@ namespace Content.Server.AI.WorldState.States.Nutrition
public override bool GetValue()
{
if (!Owner.TryGetComponent(out HungerComponent? hungerComponent))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out HungerComponent? hungerComponent))
{
return false;
}

View File

@@ -19,7 +19,7 @@ namespace Content.Server.AI.WorldState.States.Nutrition
{
var result = new List<IEntity>();
if (!Owner.TryGetComponent(out AiControllerComponent? controller))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AiControllerComponent? controller))
{
return result;
}

View File

@@ -19,7 +19,7 @@ namespace Content.Server.AI.WorldState.States.Nutrition
{
var result = new List<IEntity>();
if (!Owner.TryGetComponent(out AiControllerComponent? controller))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AiControllerComponent? controller))
{
return result;
}

View File

@@ -2,6 +2,8 @@ using System;
using Content.Server.Nutrition.Components;
using Content.Shared.Nutrition.Components;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.AI.WorldState.States.Nutrition
{
@@ -12,7 +14,7 @@ namespace Content.Server.AI.WorldState.States.Nutrition
public override bool GetValue()
{
if (!Owner.TryGetComponent(out ThirstComponent? thirstComponent))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out ThirstComponent? thirstComponent))
{
return false;
}