* 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>
22 lines
763 B
C#
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;
|
|
}
|
|
}
|
|
}
|