2020-06-18 22:52:44 +10:00
|
|
|
using Content.Server.AI.WorldState;
|
|
|
|
|
using Content.Server.AI.WorldState.States;
|
2021-12-03 11:30:03 +01:00
|
|
|
using Robust.Shared.GameObjects;
|
|
|
|
|
using Robust.Shared.IoC;
|
2020-06-18 22:52:44 +10:00
|
|
|
|
|
|
|
|
namespace Content.Server.AI.Utility.Considerations.Movement
|
|
|
|
|
{
|
2020-08-12 06:01:55 +10:00
|
|
|
public sealed class TargetDistanceCon : Consideration
|
2020-06-18 22:52:44 +10:00
|
|
|
{
|
2020-07-08 09:37:35 +10:00
|
|
|
protected override float GetScore(Blackboard context)
|
2020-06-18 22:52:44 +10:00
|
|
|
{
|
|
|
|
|
var self = context.GetState<SelfState>().GetValue();
|
2021-12-05 18:09:01 +01:00
|
|
|
var entities = IoCManager.Resolve<IEntityManager>();
|
|
|
|
|
|
2021-12-09 12:29:27 +01:00
|
|
|
if (context.GetState<TargetEntityState>().GetValue() is not {Valid: true} target || entities.Deleted(target) ||
|
2021-12-05 18:09:01 +01:00
|
|
|
entities.GetComponent<TransformComponent>(target).GridID != entities.GetComponent<TransformComponent>(self).GridID)
|
2020-06-18 22:52:44 +10:00
|
|
|
{
|
|
|
|
|
return 0.0f;
|
|
|
|
|
}
|
2020-09-06 16:11:53 +02:00
|
|
|
|
2020-08-12 06:01:55 +10:00
|
|
|
// Anything further than 100 tiles gets clamped
|
2021-12-05 18:09:01 +01:00
|
|
|
return (entities.GetComponent<TransformComponent>(target).Coordinates.Position - entities.GetComponent<TransformComponent>(self).Coordinates.Position).Length / 100;
|
2020-06-18 22:52:44 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|