From 9a095e259a6909089d0552cb55c8c3fad1410081 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Fri, 26 Jan 2018 10:59:53 +0200 Subject: [PATCH] Fixed mouselook distance calculations (the previous method allowed looking further when looking at stairs or platforms), mouselook is disabled when character control is disabled, speech bubbles appear also on the controlled character --- .../Source/Characters/Character.cs | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Characters/Character.cs b/Barotrauma/BarotraumaClient/Source/Characters/Character.cs index e0a44f04c..485390d78 100644 --- a/Barotrauma/BarotraumaClient/Source/Characters/Character.cs +++ b/Barotrauma/BarotraumaClient/Source/Characters/Character.cs @@ -121,18 +121,24 @@ namespace Barotrauma } Vector2 mouseSimPos = ConvertUnits.ToSimUnits(cursorPosition); - - if (Lights.LightManager.ViewTarget == this && Vector2.DistanceSquared(AnimController.Limbs[0].SimPosition, mouseSimPos) > 1.0f) + if (moveCam) { - Body body = Submarine.PickBody(AnimController.Limbs[0].SimPosition, mouseSimPos); - Structure structure = null; - if (body != null) structure = body.UserData as Structure; - if (structure != null) + if (DebugConsole.IsOpen || GUI.PauseMenuOpen || DisableControls || + (GameMain.GameSession?.CrewManager?.CrewCommander != null && GameMain.GameSession.CrewManager.CrewCommander.IsOpen)) { - if (!structure.CastShadow && moveCam) + if (deltaTime > 0.0f) cam.OffsetAmount = 0.0f; + } + else if (Lights.LightManager.ViewTarget == this && Vector2.DistanceSquared(AnimController.Limbs[0].SimPosition, mouseSimPos) > 1.0f) + { + Body body = Submarine.CheckVisibility(AnimController.Limbs[0].SimPosition, mouseSimPos); + Structure structure = body == null ? null : body.UserData as Structure; + + float sightDist = Submarine.LastPickedFraction; + if (body?.UserData is Structure && !((Structure)body.UserData).CastShadow) { - cam.OffsetAmount = MathHelper.Lerp(cam.OffsetAmount, 500.0f, 0.05f); + sightDist = 1.0f; } + cam.OffsetAmount = MathHelper.Lerp(cam.OffsetAmount, Math.Max(250.0f, sightDist * 500.0f), 0.05f); } } @@ -271,7 +277,7 @@ namespace Barotrauma if (aiTarget != null) aiTarget.Draw(spriteBatch); } - if (this == controlled || GUI.DisableHUD) return; + if (GUI.DisableHUD) return; Vector2 pos = DrawPosition; pos.Y = -pos.Y;