2020-06-18 22:52:44 +10:00
|
|
|
using Content.Server.AI.WorldState;
|
|
|
|
|
using Content.Server.AI.WorldState.States;
|
|
|
|
|
using Content.Server.AI.WorldState.States.Inventory;
|
2021-12-30 22:56:10 +01:00
|
|
|
using Content.Shared.Item;
|
2020-06-18 22:52:44 +10:00
|
|
|
|
|
|
|
|
namespace Content.Server.AI.Utility.Considerations.Inventory
|
|
|
|
|
{
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class TargetInOurInventoryCon : Consideration
|
2020-06-18 22:52:44 +10:00
|
|
|
{
|
2020-07-08 09:37:35 +10:00
|
|
|
protected override float GetScore(Blackboard context)
|
2020-06-18 22:52:44 +10:00
|
|
|
{
|
|
|
|
|
var target = context.GetState<TargetEntityState>().GetValue();
|
|
|
|
|
|
2021-12-30 22:56:10 +01:00
|
|
|
if (target == null || !IoCManager.Resolve<IEntityManager>().HasComponent<SharedItemComponent>(target))
|
2020-06-18 22:52:44 +10:00
|
|
|
{
|
|
|
|
|
return 0.0f;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-08 09:37:35 +10:00
|
|
|
foreach (var item in context.GetState<EnumerableInventoryState>().GetValue())
|
2020-06-18 22:52:44 +10:00
|
|
|
{
|
|
|
|
|
if (item == target)
|
|
|
|
|
{
|
|
|
|
|
return 1.0f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0.0f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|