Inline HasComponent entirely

This commit is contained in:
Vera Aguilera Puerto
2021-12-03 12:23:18 +01:00
parent 88141ae6b8
commit 0feebbff00
117 changed files with 201 additions and 158 deletions

View File

@@ -1,6 +1,8 @@
using Content.Server.AI.WorldState;
using Content.Server.AI.WorldState.States;
using Content.Server.Weapon.Melee.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.AI.Utility.Considerations.Combat.Melee
{
@@ -8,7 +10,13 @@ namespace Content.Server.AI.Utility.Considerations.Combat.Melee
{
protected override float GetScore(Blackboard context)
{
return context.GetState<SelfState>().GetValue()?.HasComponent<UnarmedCombatComponent>() ?? false ? 1.0f : 0.0f;
IEntity tempQualifier = context.GetState<SelfState>().GetValue();
if (tempQualifier != null)
{
IoCManager.Resolve<IEntityManager>().HasComponent<UnarmedCombatComponent>(tempQualifier.Uid);
}
return RETURNED_VALUE ?? false ? 1.0f : 0.0f;
}
}
}

View File

@@ -1,6 +1,8 @@
using Content.Server.AI.WorldState;
using Content.Server.AI.WorldState.States.Inventory;
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
{
foreach (var item in context.GetState<EnumerableInventoryState>().GetValue())
{
if (item.HasComponent<MeleeWeaponComponent>())
if (IoCManager.Resolve<IEntityManager>().HasComponent<MeleeWeaponComponent>(item.Uid))
{
return 1.0f;
}

View File

@@ -1,6 +1,8 @@
using Content.Server.AI.WorldState;
using Content.Server.AI.WorldState.States.Inventory;
using Content.Server.Weapon.Melee.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.AI.Utility.Considerations.Combat.Melee
{
@@ -15,7 +17,7 @@ namespace Content.Server.AI.Utility.Considerations.Combat.Melee
return 0.0f;
}
return equipped.HasComponent<MeleeWeaponComponent>() ? 1.0f : 0.0f;
return IoCManager.Resolve<IEntityManager>().HasComponent<MeleeWeaponComponent>(equipped.Uid) ? 1.0f : 0.0f;
}
}
}

View File

@@ -3,6 +3,8 @@ using Content.Server.AI.WorldState.States;
using Content.Server.AI.WorldState.States.Hands;
using Content.Server.AI.WorldState.States.Inventory;
using Content.Server.Items;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.AI.Utility.Considerations.Inventory
{
@@ -14,7 +16,7 @@ namespace Content.Server.AI.Utility.Considerations.Inventory
// If not then check if we have a free hand
var target = context.GetState<TargetEntityState>().GetValue();
if (target == null || !target.HasComponent<ItemComponent>())
if (target == null || !IoCManager.Resolve<IEntityManager>().HasComponent<ItemComponent>(target.Uid))
{
return 0.0f;
}

View File

@@ -2,6 +2,8 @@ using Content.Server.AI.WorldState;
using Content.Server.AI.WorldState.States;
using Content.Server.AI.WorldState.States.Inventory;
using Content.Server.Items;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.AI.Utility.Considerations.Inventory
{
@@ -11,7 +13,7 @@ namespace Content.Server.AI.Utility.Considerations.Inventory
{
var target = context.GetState<TargetEntityState>().GetValue();
if (target == null || !target.HasComponent<ItemComponent>())
if (target == null || !IoCManager.Resolve<IEntityManager>().HasComponent<ItemComponent>(target.Uid))
{
return 0.0f;
}