(24bcea40e) Fix the ai checks about door buttons. Don't aim at targets that cannot be seen.

This commit is contained in:
Joonas Rikkonen
2019-05-16 05:25:52 +03:00
parent bd4b3bd7f9
commit 812598774e
11 changed files with 268 additions and 176 deletions
@@ -330,24 +330,22 @@ namespace Barotrauma
{
float squaredDistance = Vector2.DistanceSquared(character.Position, Enemy.Position);
character.CursorPosition = Enemy.Position;
float engageDistance = 500;
if (squaredDistance > engageDistance * engageDistance) { return; }
bool canSeeTarget = character.CanSeeCharacter(Enemy);
if (!canSeeTarget && character.CurrentHull != Enemy.CurrentHull) { return; }
if (Weapon.RequireAimToUse)
{
bool isOperatingButtons = false;
float engageDistance = 500;
if (SteeringManager == PathSteering)
{
var door = PathSteering.CurrentPath?.CurrentNode?.ConnectedDoor;
if (door != null && !door.IsOpen)
{
var buttons = door.Item.GetComponents<Controller>();
if (buttons.None())
{
buttons = door.Item.GetConnectedComponents<Controller>(true);
}
isOperatingButtons = buttons.Any();
isOperatingButtons = door.HasIntegratedButtons || door.Item.GetConnectedComponents<Controller>(true).Any();
}
}
if (!isOperatingButtons && character.SelectedConstruction == null && (Enemy.CurrentHull == character.CurrentHull || squaredDistance < engageDistance * engageDistance))
if (!isOperatingButtons && character.SelectedConstruction == null)
{
character.SetInput(InputType.Aim, false, true);
}