Files
tbd-station-14/Content.Server/AI/Utility/Considerations/Movement/TargetDistanceCon.cs
metalgearsloth b34bd7c188 AI preset curves and expandable optimisation (#1346)
* AI preset curves and expandable optimisation

Added preset curves for considerations to use just to avoid repeating the same variables all over the shop.

Moved common considerations for expanded actions onto the expandable action e.g. you need a free hand to be able to PickUpGloves so we'll just check it the once rather than for each action.

* FIX PRAGMA

Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
2020-08-11 22:01:55 +02:00

22 lines
763 B
C#

using Content.Server.AI.WorldState;
using Content.Server.AI.WorldState.States;
namespace Content.Server.AI.Utility.Considerations.Movement
{
public sealed class TargetDistanceCon : Consideration
{
protected override float GetScore(Blackboard context)
{
var self = context.GetState<SelfState>().GetValue();
var target = context.GetState<TargetEntityState>().GetValue();
if (target == null || target.Transform.GridID != self.Transform.GridID)
{
return 0.0f;
}
// Anything further than 100 tiles gets clamped
return (target.Transform.GridPosition.Position - self.Transform.GridPosition.Position).Length / 100;
}
}
}