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

@@ -9,6 +9,7 @@ using Content.Server.AI.WorldState.States;
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.ExpandableActions.Clothing.Gloves
@@ -37,7 +38,7 @@ namespace Content.Server.AI.Utility.ExpandableActions.Clothing.Gloves
foreach (var entity in context.GetState<EnumerableInventoryState>().GetValue())
{
if (entity.TryGetComponent(out ClothingComponent? clothing) &&
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out ClothingComponent? clothing) &&
(clothing.SlotFlags & EquipmentSlotDefines.SlotFlags.GLOVES) != 0)
{
yield return new EquipGloves {Owner = owner, Target = entity, Bonus = Bonus};

View File

@@ -9,6 +9,7 @@ using Content.Server.AI.WorldState.States;
using Content.Server.AI.WorldState.States.Clothing;
using Content.Server.Clothing.Components;
using Content.Shared.Inventory;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.AI.Utility.ExpandableActions.Clothing.Gloves
@@ -35,7 +36,7 @@ namespace Content.Server.AI.Utility.ExpandableActions.Clothing.Gloves
foreach (var entity in context.GetState<NearbyClothingState>().GetValue())
{
if (entity.TryGetComponent(out ClothingComponent? clothing) &&
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out ClothingComponent? clothing) &&
(clothing.SlotFlags & EquipmentSlotDefines.SlotFlags.GLOVES) != 0)
{
yield return new PickUpGloves {Owner = owner, Target = entity, Bonus = Bonus};

View File

@@ -9,6 +9,7 @@ using Content.Server.AI.WorldState.States;
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.ExpandableActions.Clothing.Head
@@ -36,7 +37,7 @@ namespace Content.Server.AI.Utility.ExpandableActions.Clothing.Head
foreach (var entity in context.GetState<EnumerableInventoryState>().GetValue())
{
if (entity.TryGetComponent(out ClothingComponent? clothing) &&
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out ClothingComponent? clothing) &&
(clothing.SlotFlags & EquipmentSlotDefines.SlotFlags.HEAD) != 0)
{
yield return new EquipHead {Owner = owner, Target = entity, Bonus = Bonus};

View File

@@ -9,6 +9,7 @@ using Content.Server.AI.WorldState.States;
using Content.Server.AI.WorldState.States.Clothing;
using Content.Server.Clothing.Components;
using Content.Shared.Inventory;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.AI.Utility.ExpandableActions.Clothing.Head
@@ -35,7 +36,7 @@ namespace Content.Server.AI.Utility.ExpandableActions.Clothing.Head
foreach (var entity in context.GetState<NearbyClothingState>().GetValue())
{
if (entity.TryGetComponent(out ClothingComponent? clothing) &&
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out ClothingComponent? clothing) &&
(clothing.SlotFlags & EquipmentSlotDefines.SlotFlags.HEAD) != 0)
{
yield return new PickUpHead {Owner = owner, Target = entity, Bonus = Bonus};

View File

@@ -9,6 +9,7 @@ using Content.Server.AI.WorldState.States;
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.ExpandableActions.Clothing.OuterClothing
@@ -37,7 +38,7 @@ namespace Content.Server.AI.Utility.ExpandableActions.Clothing.OuterClothing
foreach (var entity in context.GetState<EnumerableInventoryState>().GetValue())
{
if (entity.TryGetComponent(out ClothingComponent? clothing) &&
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out ClothingComponent? clothing) &&
(clothing.SlotFlags & EquipmentSlotDefines.SlotFlags.OUTERCLOTHING) != 0)
{
yield return new EquipOuterClothing {Owner = owner, Target = entity, Bonus = Bonus};

View File

@@ -9,6 +9,7 @@ using Content.Server.AI.WorldState.States;
using Content.Server.AI.WorldState.States.Clothing;
using Content.Server.Clothing.Components;
using Content.Shared.Inventory;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.AI.Utility.ExpandableActions.Clothing.OuterClothing
@@ -36,7 +37,7 @@ namespace Content.Server.AI.Utility.ExpandableActions.Clothing.OuterClothing
foreach (var entity in context.GetState<NearbyClothingState>().GetValue())
{
if (entity.TryGetComponent(out ClothingComponent? clothing) &&
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out ClothingComponent? clothing) &&
(clothing.SlotFlags & EquipmentSlotDefines.SlotFlags.OUTERCLOTHING) != 0)
{
yield return new PickUpOuterClothing {Owner = owner, Target = entity, Bonus = Bonus};

View File

@@ -9,6 +9,7 @@ using Content.Server.AI.WorldState.States;
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.ExpandableActions.Clothing.Shoes
@@ -37,7 +38,7 @@ namespace Content.Server.AI.Utility.ExpandableActions.Clothing.Shoes
foreach (var entity in context.GetState<EnumerableInventoryState>().GetValue())
{
if (entity.TryGetComponent(out ClothingComponent? clothing) &&
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out ClothingComponent? clothing) &&
(clothing.SlotFlags & EquipmentSlotDefines.SlotFlags.SHOES) != 0)
{
yield return new EquipShoes {Owner = owner, Target = entity, Bonus = Bonus};

View File

@@ -9,6 +9,7 @@ using Content.Server.AI.WorldState.States;
using Content.Server.AI.WorldState.States.Clothing;
using Content.Server.Clothing.Components;
using Content.Shared.Inventory;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.AI.Utility.ExpandableActions.Clothing.Shoes
@@ -36,7 +37,7 @@ namespace Content.Server.AI.Utility.ExpandableActions.Clothing.Shoes
foreach (var entity in context.GetState<NearbyClothingState>().GetValue())
{
if (entity.TryGetComponent(out ClothingComponent? clothing) &&
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out ClothingComponent? clothing) &&
(clothing.SlotFlags & EquipmentSlotDefines.SlotFlags.SHOES) != 0)
{
yield return new PickUpShoes {Owner = owner, Target = entity, Bonus = Bonus};

View File

@@ -31,7 +31,7 @@ namespace Content.Server.AI.Utility.ExpandableActions.Combat.Melee
public override IEnumerable<UtilityAction> GetActions(Blackboard context)
{
var owner = context.GetState<SelfState>().GetValue();
if (!owner.TryGetComponent(out AiControllerComponent? controller))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(owner.Uid, out AiControllerComponent? controller))
{
throw new InvalidOperationException();
}

View File

@@ -31,7 +31,7 @@ namespace Content.Server.AI.Utility.ExpandableActions.Combat.Melee
public override IEnumerable<UtilityAction> GetActions(Blackboard context)
{
var owner = context.GetState<SelfState>().GetValue();
if (!owner.TryGetComponent(out AiControllerComponent? controller))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(owner.Uid, out AiControllerComponent? controller))
{
throw new InvalidOperationException();
}