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.Hands;
|
|
|
|
|
using Content.Server.AI.WorldState.States.Inventory;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Server.Items;
|
2021-12-03 12:23:18 +01:00
|
|
|
using Robust.Shared.GameObjects;
|
|
|
|
|
using Robust.Shared.IoC;
|
2020-06-18 22:52:44 +10:00
|
|
|
|
|
|
|
|
namespace Content.Server.AI.Utility.Considerations.Inventory
|
|
|
|
|
{
|
2020-08-12 06:01:55 +10:00
|
|
|
public class CanPutTargetInInventoryCon : 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
|
|
|
{
|
|
|
|
|
// First check if target in inventory already
|
|
|
|
|
// If not then check if we have a free hand
|
|
|
|
|
var target = context.GetState<TargetEntityState>().GetValue();
|
|
|
|
|
|
2021-12-20 15:20:27 +01:00
|
|
|
if (target == null || !IoCManager.Resolve<IEntityManager>().HasComponent<ItemComponent>(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 context.GetState<AnyFreeHandState>().GetValue() ? 1.0f : 0.0f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|