2022-09-30 14:39:48 +10:00
|
|
|
using JetBrains.Annotations;
|
2022-09-06 00:28:23 +10:00
|
|
|
|
|
|
|
|
namespace Content.Server.NPC.HTN.PrimitiveTasks.Operators.Melee;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Selects a target for melee.
|
|
|
|
|
/// </summary>
|
2022-09-30 14:39:48 +10:00
|
|
|
[MeansImplicitUse]
|
2022-09-06 00:28:23 +10:00
|
|
|
public sealed class PickMeleeTargetOperator : NPCCombatOperator
|
|
|
|
|
{
|
2022-09-30 14:39:48 +10:00
|
|
|
protected override float GetRating(NPCBlackboard blackboard, EntityUid uid, EntityUid existingTarget, float distance, bool canMove, EntityQuery<TransformComponent> xformQuery)
|
2022-09-06 00:28:23 +10:00
|
|
|
{
|
|
|
|
|
var rating = 0f;
|
|
|
|
|
|
|
|
|
|
if (existingTarget == uid)
|
|
|
|
|
{
|
2022-09-30 14:39:48 +10:00
|
|
|
rating += 2f;
|
2022-09-06 00:28:23 +10:00
|
|
|
}
|
|
|
|
|
|
2022-09-30 14:39:48 +10:00
|
|
|
if (distance > 0f)
|
|
|
|
|
rating += 50f / distance;
|
2022-09-06 00:28:23 +10:00
|
|
|
|
|
|
|
|
return rating;
|
|
|
|
|
}
|
|
|
|
|
}
|