Inline TryGetComponent completely, for real
This commit is contained in:
@@ -3,6 +3,8 @@ using Content.Server.AI.WorldState.States.Clothing;
|
||||
using Content.Server.AI.WorldState.States.Inventory;
|
||||
using Content.Server.Clothing.Components;
|
||||
using Content.Shared.Inventory;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.AI.Utility.Considerations.Clothing
|
||||
{
|
||||
@@ -23,7 +25,7 @@ namespace Content.Server.AI.Utility.Considerations.Clothing
|
||||
|
||||
foreach (var entity in context.GetState<EnumerableInventoryState>().GetValue())
|
||||
{
|
||||
if (!entity.TryGetComponent(out ClothingComponent? clothingComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out ClothingComponent? clothingComponent))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States.Combat;
|
||||
using Content.Server.Weapon.Melee.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.AI.Utility.Considerations.Combat.Melee
|
||||
{
|
||||
@@ -10,7 +12,7 @@ namespace Content.Server.AI.Utility.Considerations.Combat.Melee
|
||||
{
|
||||
var target = context.GetState<WeaponEntityState>().GetValue();
|
||||
|
||||
if (target == null || !target.TryGetComponent(out MeleeWeaponComponent? meleeWeaponComponent))
|
||||
if (target == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent(target.Uid, out MeleeWeaponComponent? meleeWeaponComponent))
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States.Combat;
|
||||
using Content.Server.Weapon.Melee.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.AI.Utility.Considerations.Combat.Melee
|
||||
{
|
||||
@@ -10,7 +12,7 @@ namespace Content.Server.AI.Utility.Considerations.Combat.Melee
|
||||
{
|
||||
var target = context.GetState<WeaponEntityState>().GetValue();
|
||||
|
||||
if (target == null || !target.TryGetComponent(out MeleeWeaponComponent? meleeWeaponComponent))
|
||||
if (target == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent(target.Uid, out MeleeWeaponComponent? meleeWeaponComponent))
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Content.Server.AI.Utility.Considerations.Combat
|
||||
{
|
||||
var target = context.GetState<TargetEntityState>().GetValue();
|
||||
|
||||
if (target == null || !IoCManager.Resolve<IEntityManager>().EntityExists(target.Uid) || !target.TryGetComponent(out DamageableComponent? damageableComponent))
|
||||
if (target == null || !IoCManager.Resolve<IEntityManager>().EntityExists(target.Uid) || !IoCManager.Resolve<IEntityManager>().TryGetComponent(target.Uid, out DamageableComponent? damageableComponent))
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Shared.MobState.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.AI.Utility.Considerations.Combat
|
||||
{
|
||||
@@ -10,7 +12,7 @@ namespace Content.Server.AI.Utility.Considerations.Combat
|
||||
{
|
||||
var target = context.GetState<TargetEntityState>().GetValue();
|
||||
|
||||
if (target == null || !target.TryGetComponent(out MobStateComponent? mobState))
|
||||
if (target == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent(target.Uid, out MobStateComponent? mobState))
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Shared.MobState.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.AI.Utility.Considerations.Combat
|
||||
{
|
||||
@@ -10,7 +12,7 @@ namespace Content.Server.AI.Utility.Considerations.Combat
|
||||
{
|
||||
var target = context.GetState<TargetEntityState>().GetValue();
|
||||
|
||||
if (target == null || !target.TryGetComponent(out MobStateComponent? mobState))
|
||||
if (target == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent(target.Uid, out MobStateComponent? mobState))
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using Content.Server.Storage.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.AI.Utility.Considerations.Containers
|
||||
{
|
||||
@@ -24,7 +25,7 @@ namespace Content.Server.AI.Utility.Considerations.Containers
|
||||
|
||||
if (target.TryGetContainer(out var container))
|
||||
{
|
||||
if (container.Owner.TryGetComponent(out EntityStorageComponent? storageComponent))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(container.Owner.Uid, out EntityStorageComponent? storageComponent))
|
||||
{
|
||||
if (storageComponent.IsWeldedShut && !storageComponent.Open)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Server.Hands.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.AI.Utility.Considerations.Hands
|
||||
{
|
||||
@@ -10,7 +12,7 @@ namespace Content.Server.AI.Utility.Considerations.Hands
|
||||
{
|
||||
var owner = context.GetState<SelfState>().GetValue();
|
||||
|
||||
if (owner == null || !owner.TryGetComponent(out HandsComponent? handsComponent))
|
||||
if (owner == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent(owner.Uid, out HandsComponent? handsComponent))
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Server.Nutrition.Components;
|
||||
using Content.Shared.Nutrition.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.AI.Utility.Considerations.Nutrition.Drink
|
||||
{
|
||||
@@ -11,7 +13,7 @@ namespace Content.Server.AI.Utility.Considerations.Nutrition.Drink
|
||||
{
|
||||
var owner = context.GetState<SelfState>().GetValue();
|
||||
|
||||
if (owner == null || !owner.TryGetComponent(out ThirstComponent? thirst))
|
||||
if (owner == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent(owner.Uid, out ThirstComponent? thirst))
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Content.Server.AI.Utility.Considerations.Nutrition.Food
|
||||
var target = context.GetState<TargetEntityState>().GetValue();
|
||||
|
||||
if (target == null || !IoCManager.Resolve<IEntityManager>().EntityExists(target.Uid)
|
||||
|| !target.TryGetComponent<FoodComponent>(out var foodComp)
|
||||
|| !IoCManager.Resolve<IEntityManager>().TryGetComponent<FoodComponent?>(target.Uid, out var foodComp)
|
||||
|| !EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(target.Uid, foodComp.SolutionName, out var food))
|
||||
{
|
||||
return 0.0f;
|
||||
|
||||
@@ -2,6 +2,8 @@ using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Server.Nutrition.Components;
|
||||
using Content.Shared.Nutrition.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.AI.Utility.Considerations.Nutrition.Food
|
||||
{
|
||||
@@ -12,7 +14,7 @@ namespace Content.Server.AI.Utility.Considerations.Nutrition.Food
|
||||
{
|
||||
var owner = context.GetState<SelfState>().GetValue();
|
||||
|
||||
if (owner == null || !owner.TryGetComponent(out HungerComponent? hunger))
|
||||
if (owner == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent(owner.Uid, out HungerComponent? hunger))
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user