Inline TryGetComponent completely, for real
This commit is contained in:
@@ -29,7 +29,7 @@ namespace Content.Server.AI.Operators.Combat.Melee
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!_owner.TryGetComponent(out CombatModeComponent? combatModeComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out CombatModeComponent? combatModeComponent))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ namespace Content.Server.AI.Operators.Combat.Melee
|
||||
if (!base.Shutdown(outcome))
|
||||
return false;
|
||||
|
||||
if (_owner.TryGetComponent(out CombatModeComponent? combatModeComponent))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out CombatModeComponent? combatModeComponent))
|
||||
{
|
||||
combatModeComponent.IsInCombatMode = false;
|
||||
}
|
||||
@@ -62,13 +62,13 @@ namespace Content.Server.AI.Operators.Combat.Melee
|
||||
return Outcome.Success;
|
||||
}
|
||||
|
||||
if (!_owner.TryGetComponent(out HandsComponent? hands) || hands.GetActiveHand == null)
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out HandsComponent? hands) || hands.GetActiveHand == null)
|
||||
{
|
||||
return Outcome.Failed;
|
||||
}
|
||||
|
||||
var meleeWeapon = hands.GetActiveHand.Owner;
|
||||
meleeWeapon.TryGetComponent(out MeleeWeaponComponent? meleeWeaponComponent);
|
||||
IoCManager.Resolve<IEntityManager>().TryGetComponent(meleeWeapon.Uid, out MeleeWeaponComponent? meleeWeaponComponent);
|
||||
|
||||
if ((_target.Transform.Coordinates.Position - _owner.Transform.Coordinates.Position).Length >
|
||||
meleeWeaponComponent?.Range)
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Content.Server.AI.Operators.Combat.Melee
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!_owner.TryGetComponent(out CombatModeComponent? combatModeComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out CombatModeComponent? combatModeComponent))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -39,7 +39,7 @@ namespace Content.Server.AI.Operators.Combat.Melee
|
||||
combatModeComponent.IsInCombatMode = true;
|
||||
}
|
||||
|
||||
if (_owner.TryGetComponent(out UnarmedCombatComponent? unarmedCombatComponent))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out UnarmedCombatComponent? unarmedCombatComponent))
|
||||
{
|
||||
_unarmedCombat = unarmedCombatComponent;
|
||||
}
|
||||
@@ -56,7 +56,7 @@ namespace Content.Server.AI.Operators.Combat.Melee
|
||||
if (!base.Shutdown(outcome))
|
||||
return false;
|
||||
|
||||
if (_owner.TryGetComponent(out CombatModeComponent? combatModeComponent))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out CombatModeComponent? combatModeComponent))
|
||||
{
|
||||
combatModeComponent.IsInCombatMode = false;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using Content.Server.Storage.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Interaction.Helpers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.AI.Operators.Inventory
|
||||
{
|
||||
@@ -58,7 +59,7 @@ namespace Content.Server.AI.Operators.Inventory
|
||||
return Outcome.Failed;
|
||||
}
|
||||
|
||||
if (!_target.TryGetComponent(out EntityStorageComponent? storageComponent) ||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_target.Uid, out EntityStorageComponent? storageComponent) ||
|
||||
storageComponent.IsWeldedShut)
|
||||
{
|
||||
return Outcome.Failed;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Content.Server.Hands.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.AI.Operators.Inventory
|
||||
{
|
||||
@@ -20,7 +21,7 @@ namespace Content.Server.AI.Operators.Inventory
|
||||
/// <returns></returns>
|
||||
public override Outcome Execute(float frameTime)
|
||||
{
|
||||
if (!_owner.TryGetComponent(out HandsComponent? handsComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out HandsComponent? handsComponent))
|
||||
{
|
||||
return Outcome.Failed;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Content.Server.Hands.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.AI.Operators.Inventory
|
||||
{
|
||||
@@ -14,7 +15,7 @@ namespace Content.Server.AI.Operators.Inventory
|
||||
|
||||
public override Outcome Execute(float frameTime)
|
||||
{
|
||||
if (!_owner.TryGetComponent(out HandsComponent? handsComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out HandsComponent? handsComponent))
|
||||
{
|
||||
return Outcome.Failed;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Content.Server.Hands.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.AI.Operators.Inventory
|
||||
{
|
||||
@@ -15,7 +16,7 @@ namespace Content.Server.AI.Operators.Inventory
|
||||
|
||||
public override Outcome Execute(float frameTime)
|
||||
{
|
||||
if (!_owner.TryGetComponent(out HandsComponent? handsComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out HandsComponent? handsComponent))
|
||||
{
|
||||
return Outcome.Failed;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Content.Server.AI.Operators.Inventory
|
||||
return Outcome.Failed;
|
||||
}
|
||||
|
||||
if (_owner.TryGetComponent(out CombatModeComponent? combatModeComponent))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out CombatModeComponent? combatModeComponent))
|
||||
{
|
||||
combatModeComponent.IsInCombatMode = false;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using Content.Shared.Interaction;
|
||||
using Content.Shared.Interaction.Helpers;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.AI.Operators.Inventory
|
||||
{
|
||||
@@ -34,7 +35,7 @@ namespace Content.Server.AI.Operators.Inventory
|
||||
return Outcome.Failed;
|
||||
}
|
||||
|
||||
if (!container.Owner.TryGetComponent(out EntityStorageComponent? storageComponent) ||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(container.Owner.Uid, out EntityStorageComponent? storageComponent) ||
|
||||
storageComponent.IsWeldedShut)
|
||||
{
|
||||
return Outcome.Failed;
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Content.Server.AI.Operators.Inventory
|
||||
return Outcome.Failed;
|
||||
}
|
||||
|
||||
if (!_owner.TryGetComponent(out HandsComponent? handsComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out HandsComponent? handsComponent))
|
||||
{
|
||||
return Outcome.Failed;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Content.Server.Hands.Components;
|
||||
using Content.Server.Items;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.AI.Operators.Inventory
|
||||
{
|
||||
@@ -21,12 +22,12 @@ namespace Content.Server.AI.Operators.Inventory
|
||||
public override Outcome Execute(float frameTime)
|
||||
{
|
||||
// TODO: Also have this check storage a la backpack etc.
|
||||
if (!_owner.TryGetComponent(out HandsComponent? handsComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out HandsComponent? handsComponent))
|
||||
{
|
||||
return Outcome.Failed;
|
||||
}
|
||||
|
||||
if (!_target.TryGetComponent(out ItemComponent? itemComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_target.Uid, out ItemComponent? itemComponent))
|
||||
{
|
||||
return Outcome.Failed;
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ namespace Content.Server.AI.Operators.Nutrition
|
||||
|
||||
// TODO: Also have this check storage a la backpack etc.
|
||||
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(_target.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(_target.Uid).EntityLifeStage) >= EntityLifeStage.Deleted ||
|
||||
!_owner.TryGetComponent(out HandsComponent? handsComponent) ||
|
||||
!_target.TryGetComponent(out ItemComponent? itemComponent))
|
||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out HandsComponent? handsComponent) ||
|
||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent(_target.Uid, out ItemComponent? itemComponent))
|
||||
{
|
||||
return Outcome.Failed;
|
||||
}
|
||||
@@ -43,7 +43,7 @@ namespace Content.Server.AI.Operators.Nutrition
|
||||
{
|
||||
if (handsComponent.GetItem(slot) != itemComponent) continue;
|
||||
handsComponent.ActiveHand = slot;
|
||||
if (!_target.TryGetComponent(out drinkComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_target.Uid, out drinkComponent))
|
||||
{
|
||||
return Outcome.Failed;
|
||||
}
|
||||
@@ -59,7 +59,7 @@ namespace Content.Server.AI.Operators.Nutrition
|
||||
}
|
||||
|
||||
if (drinkComponent.Deleted || EntitySystem.Get<DrinkSystem>().IsEmpty(drinkComponent.Owner.Uid, drinkComponent)
|
||||
|| _owner.TryGetComponent(out ThirstComponent? thirstComponent) &&
|
||||
|| IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out ThirstComponent? thirstComponent) &&
|
||||
thirstComponent.CurrentThirst >= thirstComponent.ThirstThresholds[ThirstThreshold.Okay])
|
||||
{
|
||||
return Outcome.Success;
|
||||
|
||||
@@ -30,8 +30,8 @@ namespace Content.Server.AI.Operators.Nutrition
|
||||
|
||||
// TODO: Also have this check storage a la backpack etc.
|
||||
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(_target.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(_target.Uid).EntityLifeStage) >= EntityLifeStage.Deleted ||
|
||||
!_owner.TryGetComponent(out HandsComponent? handsComponent) ||
|
||||
!_target.TryGetComponent(out ItemComponent? itemComponent))
|
||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out HandsComponent? handsComponent) ||
|
||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent(_target.Uid, out ItemComponent? itemComponent))
|
||||
{
|
||||
return Outcome.Failed;
|
||||
}
|
||||
@@ -42,7 +42,7 @@ namespace Content.Server.AI.Operators.Nutrition
|
||||
{
|
||||
if (handsComponent.GetItem(slot) != itemComponent) continue;
|
||||
handsComponent.ActiveHand = slot;
|
||||
if (!_target.TryGetComponent(out foodComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_target.Uid, out foodComponent))
|
||||
{
|
||||
return Outcome.Failed;
|
||||
}
|
||||
@@ -59,7 +59,7 @@ namespace Content.Server.AI.Operators.Nutrition
|
||||
|
||||
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(_target.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(_target.Uid).EntityLifeStage) >= EntityLifeStage.Deleted ||
|
||||
foodComponent.UsesRemaining == 0 ||
|
||||
_owner.TryGetComponent(out HungerComponent? hungerComponent) &&
|
||||
IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out HungerComponent? hungerComponent) &&
|
||||
hungerComponent.CurrentHunger >= hungerComponent.HungerThresholds[HungerThreshold.Okay])
|
||||
{
|
||||
return Outcome.Success;
|
||||
|
||||
Reference in New Issue
Block a user