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().GetValue(); var entities = IoCManager.Resolve(); if (context.GetState().GetValue() is not {Valid: true} target || entities.Deleted(target) || entities.GetComponent(target).GridEntityId != entities.GetComponent(self).GridEntityId) { return 0.0f; } // Anything further than 100 tiles gets clamped return (entities.GetComponent(target).Coordinates.Position - entities.GetComponent(self).Coordinates.Position).Length / 100; } } }