Files
tbd-station-14/Content.Server/AI/Utility/ExpandableActions/Clothing/Gloves/PickUpAnyNearbyGlovesExp.cs
metalgearsloth 5391d3c72a Add utility AI (#806)
Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
2020-06-18 14:52:44 +02:00

30 lines
1.1 KiB
C#

using System.Collections.Generic;
using Content.Server.AI.Utility.Actions;
using Content.Server.AI.Utility.Actions.Clothing.Gloves;
using Content.Server.AI.WorldState;
using Content.Server.AI.WorldState.States;
using Content.Server.AI.WorldState.States.Clothing;
using Content.Server.GameObjects;
using Content.Shared.GameObjects.Components.Inventory;
namespace Content.Server.AI.Utility.ExpandableActions.Clothing.Gloves
{
public sealed class PickUpAnyNearbyGlovesExp : ExpandableUtilityAction
{
public override float Bonus => UtilityAction.NormalBonus;
public override IEnumerable<UtilityAction> GetActions(Blackboard context)
{
var owner = context.GetState<SelfState>().GetValue();
foreach (var entity in context.GetState<NearbyClothingState>().GetValue())
{
if (entity.TryGetComponent(out ClothingComponent clothing) &&
(clothing.SlotFlags & EquipmentSlotDefines.SlotFlags.GLOVES) != 0)
{
yield return new PickUpGloves(owner, entity, Bonus);
}
}
}
}
}