Files
tbd-station-14/Content.Server/AI/Utility/Considerations/Combat/TargetHealthCon.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

23 lines
717 B
C#

using Content.Server.AI.WorldState;
using Content.Server.AI.WorldState.States;
using Content.Server.GameObjects.Components.Damage;
using Content.Shared.GameObjects.Components.Damage;
namespace Content.Server.AI.Utility.Considerations.Combat
{
public sealed class TargetHealthCon : Consideration
{
protected override float GetScore(Blackboard context)
{
var target = context.GetState<TargetEntityState>().GetValue();
if (target == null || target.Deleted || !target.TryGetComponent(out IDamageableComponent damageableComponent))
{
return 0.0f;
}
return damageableComponent.TotalDamage / 300.0f;
}
}
}