Files
tbd-station-14/Content.Server/AI/Utility/Considerations/Movement/TargetDistanceCon.cs
metalgearsloth 72e50cce94 AI pickup changes (#1811)
* AI pickup changes

Eating and drinking isn't spammed anymore.
AI can do InRangeUnobstructed checks for item pickups.
AI can open drink cans.

AI littering to be coded.

* #nullable enable

* github's nullable fails are actively shortening my lifespan

* Use a const instead

So it's easier to find given the performance implications.

Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
2020-08-22 12:03:24 +02:00

22 lines
781 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.Deleted || 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;
}
}
}