(e38a3fef5) Fixed characters not letting go of the character they're grabbing when the health interface is closed with Esc or by clicking outside the window.

This commit is contained in:
Joonas Rikkonen
2019-03-29 21:51:24 +02:00
parent c9db9ec4ff
commit 854c90c89a
2 changed files with 13 additions and 5 deletions
@@ -108,13 +108,15 @@ namespace Barotrauma
if (openHealthWindow == value) return;
if (value != null && !value.UseHealthWindow) return;
var prevOpenHealthWindow = openHealthWindow;
openHealthWindow = value;
toggledThisFrame = true;
if (Character.Controlled == null) { return; }
if (value == null &&
Character.Controlled?.SelectedCharacter?.CharacterHealth != null &&
Character.Controlled.SelectedCharacter.CharacterHealth == openHealthWindow &&
Character.Controlled.SelectedCharacter.CharacterHealth == prevOpenHealthWindow &&
!Character.Controlled.SelectedCharacter.CanInventoryBeAccessed)
{
Character.Controlled.DeselectCharacter();
@@ -545,11 +547,13 @@ namespace Barotrauma
}
if (PlayerInput.KeyHit(InputType.Health) && GUI.KeyboardDispatcher.Subscriber == null &&
Character.AllowInput && Character.FocusedCharacter == null && !toggledThisFrame)
Character.Controlled.AllowInput && !toggledThisFrame)
{
if (openHealthWindow != null)
{
OpenHealthWindow = null;
else
}
else if (Character.Controlled == Character && Character.Controlled.FocusedCharacter == null)
{
OpenHealthWindow = this;
forceAfflictionContainerUpdate = true;
@@ -562,7 +566,10 @@ namespace Barotrauma
HUD.CloseHUD(HUDLayoutSettings.HealthWindowAreaLeft))
{
//emulate a Health input to get the character to deselect the item server-side
Character.Keys[(int)InputType.Health].Hit = true;
if (GameMain.Client != null)
{
Character.Controlled.Keys[(int)InputType.Health].Hit = true;
}
OpenHealthWindow = null;
}
}
@@ -268,6 +268,7 @@ namespace Barotrauma
public Character FocusedCharacter
{
get { return focusedCharacter; }
set { focusedCharacter = value; }
}
public Character SelectedCharacter
@@ -1709,7 +1710,7 @@ namespace Barotrauma
}
}
if (SelectedCharacter != null && IsKeyHit(InputType.Grab)) //Let people use ladders and buttons and stuff when dragging chars
if (SelectedCharacter != null && (IsKeyHit(InputType.Grab) || IsKeyHit(InputType.Health))) //Let people use ladders and buttons and stuff when dragging chars
{
DeselectCharacter();
}