Files
tbd-station-14/Content.Server/AI/Utility/Considerations/Clothing/ClothingInSlotCon.cs
metalgearsloth 5aefae184c Refactor AI considerations (#1278)
Considerations are now instantiated under a manager and re-used between entities where they pass in their blackboard to get a score back.
Also makes the API a bit nicer to use.
Also some random cleanup.

Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
2020-07-08 01:37:35 +02:00

24 lines
788 B
C#

using Content.Server.AI.WorldState;
using Content.Server.AI.WorldState.States.Clothing;
using Content.Shared.GameObjects.Components.Inventory;
namespace Content.Server.AI.Utility.Considerations.Clothing
{
public class ClothingInSlotCon : Consideration
{
public ClothingInSlotCon Slot(EquipmentSlotDefines.Slots slot, Blackboard context)
{
context.GetState<ClothingSlotConState>().SetValue(slot);
return this;
}
protected override float GetScore(Blackboard context)
{
var slot = context.GetState<ClothingSlotConState>().GetValue();
var inventory = context.GetState<EquippedClothingState>().GetValue();
return inventory.ContainsKey(slot) ? 1.0f : 0.0f;
}
}
}