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