Inline TryGetComponent completely, for real
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user