(050157f65) Fix bots not being able to use buttons or ladders because the were aiming. Don't aim when farther than 500 pixels away from the target.

This commit is contained in:
Joonas Rikkonen
2019-05-16 05:23:39 +03:00
parent 053ef60fc4
commit 52d25694ed
11 changed files with 385 additions and 51 deletions
@@ -344,7 +344,24 @@ namespace Barotrauma.Items.Components
character.CursorPosition = leak.Position + VectorExtensions.Forward(Item.body.TransformedRotation + (float)Math.Sin(sinTime), dist);
if (item.RequireAimToUse)
{
character.SetInput(InputType.Aim, false, true);
bool isOperatingButtons = false;
if (character.AIController.SteeringManager is IndoorsSteeringManager indoorSteering)
{
var door = indoorSteering.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();
}
}
if (!isOperatingButtons)
{
character.SetInput(InputType.Aim, false, true);
}
}
// Press the trigger only when the tool is approximately facing the target.
var angle = VectorExtensions.Angle(VectorExtensions.Forward(item.body.TransformedRotation), fromItemToLeak);