diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs index 54feae451..1e1be8458 100644 --- a/Subsurface/Source/Characters/Character.cs +++ b/Subsurface/Source/Characters/Character.cs @@ -1104,6 +1104,8 @@ namespace Barotrauma { if (controlled != this) yield return CoroutineStatus.Success; + Character.controlled = null; + float dimDuration = 8.0f; float timer = 0.0f; @@ -1114,13 +1116,12 @@ namespace Barotrauma { timer += CoroutineManager.DeltaTime; - if (controlled == this) - { - if (cam != null) cam.OffsetAmount = 0.0f; + if (cam != null) cam.OffsetAmount = 0.0f; - GameMain.LightManager.AmbientLight = Color.Lerp(prevAmbientLight, darkLight, timer / dimDuration); - } + cam.TargetPos = WorldPosition; + GameMain.LightManager.AmbientLight = Color.Lerp(prevAmbientLight, darkLight, timer / dimDuration); + yield return CoroutineStatus.Running; } @@ -1138,6 +1139,8 @@ namespace Barotrauma yield return CoroutineStatus.Running; } + cam.TargetPos = Vector2.Zero; + yield return CoroutineStatus.Success; } diff --git a/Subsurface/Source/Items/Components/Door.cs b/Subsurface/Source/Items/Components/Door.cs index ba43bf53e..695ff9dfa 100644 --- a/Subsurface/Source/Items/Components/Door.cs +++ b/Subsurface/Source/Items/Components/Door.cs @@ -143,13 +143,6 @@ namespace Barotrauma.Items.Components //string spritePath = Path.GetDirectoryName(item.Prefab.ConfigFile) + "\\"+ ToolBox.GetAttributeString(element, "sprite", ""); - Vector2[] corners = GetConvexHullCorners(doorRect); - - convexHull = new ConvexHull(corners, Color.Black, item.CurrentHull == null ? null : item.CurrentHull.Submarine); - if (window!=Rectangle.Empty) convexHull2 = new ConvexHull(corners, Color.Black, item.CurrentHull == null ? null : item.CurrentHull.Submarine); - - UpdateConvexHulls(); - IsActive = true; } @@ -210,10 +203,10 @@ namespace Barotrauma.Items.Components private Vector2[] GetConvexHullCorners(Rectangle rect) { Vector2[] corners = new Vector2[4]; - corners[0] = new Vector2(rect.X, rect.Y - rect.Height); - corners[1] = new Vector2(rect.X, rect.Y); - corners[2] = new Vector2(rect.Right, rect.Y); - corners[3] = new Vector2(rect.Right, rect.Y - rect.Height); + corners[0] = new Vector2(rect.X, rect.Y - rect.Height) + Submarine.HiddenSubPosition; + corners[1] = new Vector2(rect.X, rect.Y) + Submarine.HiddenSubPosition; + corners[2] = new Vector2(rect.Right, rect.Y) + Submarine.HiddenSubPosition; + corners[3] = new Vector2(rect.Right, rect.Y - rect.Height) + Submarine.HiddenSubPosition; return corners; } @@ -331,6 +324,13 @@ namespace Barotrauma.Items.Components public override void OnMapLoaded() { LinkedGap.ConnectedDoor = this; + + Vector2[] corners = GetConvexHullCorners(doorRect); + + convexHull = new ConvexHull(corners, Color.Black, item); + if (window != Rectangle.Empty) convexHull2 = new ConvexHull(corners, Color.Black, item); + + UpdateConvexHulls(); } public override void Remove() diff --git a/Subsurface/Source/Map/Lights/ConvexHull.cs b/Subsurface/Source/Map/Lights/ConvexHull.cs index adba60532..1b12d2454 100644 --- a/Subsurface/Source/Map/Lights/ConvexHull.cs +++ b/Subsurface/Source/Map/Lights/ConvexHull.cs @@ -148,6 +148,8 @@ namespace Barotrauma.Lights cachedShadows.Clear(); vertices = points; + + CalculateDimensions(); } public bool Intersects(Rectangle rect) @@ -307,6 +309,7 @@ namespace Barotrauma.Lights else { cachedShadow = new CachedShadow(shadowVertices, penumbraVertices, light.Position, shadowVertexCount, 0); + cachedShadows.Remove(light); cachedShadows.Add(light, cachedShadow); } } @@ -350,7 +353,7 @@ namespace Barotrauma.Lights else { shadowEffect.CurrentTechnique.Passes[0].Apply(); - graphicsDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, shadowVertexCount); + graphicsDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, shadowVertexCount*2 - 2); } } diff --git a/Subsurface/Source/Map/Lights/LightSource.cs b/Subsurface/Source/Map/Lights/LightSource.cs index 5bf53393c..0eb9fee15 100644 --- a/Subsurface/Source/Map/Lights/LightSource.cs +++ b/Subsurface/Source/Map/Lights/LightSource.cs @@ -21,6 +21,9 @@ namespace Barotrauma.Lights public Entity Submarine; + //what was the range of the light when HullsInRange were last updated + private float prevHullUpdateRange; + private Vector2 position; public Vector2 Position { @@ -64,11 +67,11 @@ namespace Barotrauma.Lights set { - float prevRange = range; range = MathHelper.Clamp(value, 0.0f, 2048.0f); - if (Math.Abs(prevRange - range)<5.0f) return; + if (Math.Abs(prevHullUpdateRange - range)>5.0f) return; UpdateHullsInRange(); + prevHullUpdateRange = range; } } diff --git a/Subsurface/Source/Map/Submarine.cs b/Subsurface/Source/Map/Submarine.cs index e2868a5d5..f42e4a647 100644 --- a/Subsurface/Source/Map/Submarine.cs +++ b/Subsurface/Source/Map/Submarine.cs @@ -301,7 +301,10 @@ namespace Barotrauma public static Body PickBody(Vector2 rayStart, Vector2 rayEnd, List ignoredBodies = null, Category? collisionCategory = null) { - if (Vector2.DistanceSquared(rayStart, rayEnd) < 0.0f) return null; + if (Vector2.DistanceSquared(rayStart, rayEnd) < 0.00001f) + { + rayEnd += Vector2.UnitX * 0.001f; + } float closestFraction = 1.0f; Body closestBody = null; diff --git a/Subsurface/Source/Map/TransitionCinematic.cs b/Subsurface/Source/Map/TransitionCinematic.cs index acd4cd5b9..6eb51f51e 100644 --- a/Subsurface/Source/Map/TransitionCinematic.cs +++ b/Subsurface/Source/Map/TransitionCinematic.cs @@ -55,12 +55,12 @@ namespace Barotrauma GUI.ScreenOverlayColor = Color.Lerp(Color.TransparentBlack, Color.Black, timer/duration); - cam.Translate((cameraPos - cam.Position) * CoroutineManager.DeltaTime); + cam.Translate((cameraPos - cam.Position) * CoroutineManager.DeltaTime*10.0f); cam.Zoom = Math.Max(0.2f, cam.Zoom - CoroutineManager.DeltaTime * 0.1f); sub.ApplyForce((Vector2.Normalize(diff) * targetSpeed - sub.Velocity) * 500.0f); - timer -= CoroutineManager.DeltaTime; + timer += CoroutineManager.DeltaTime; yield return CoroutineStatus.Running; } diff --git a/Subsurface/Source/Networking/GameClient.cs b/Subsurface/Source/Networking/GameClient.cs index 992cae94e..3d3e15c38 100644 --- a/Subsurface/Source/Networking/GameClient.cs +++ b/Subsurface/Source/Networking/GameClient.cs @@ -356,7 +356,7 @@ namespace Barotrauma.Networking { if (myCharacter.IsDead) { - Character.Controlled = null; + //Character.Controlled = null; //GameMain.GameScreen.Cam.TargetPos = Vector2.Zero; } else if (gameStarted) @@ -610,7 +610,7 @@ namespace Barotrauma.Networking (float)Math.Cos(camAngle) * (Submarine.Borders.Width / 2.0f), (float)Math.Sin(camAngle) * (Submarine.Borders.Height / 2.0f))); - GameMain.GameScreen.Cam.TargetPos = Submarine.Loaded.Position + offset * 0.8f; + GameMain.GameScreen.Cam.TargetPos = Submarine.Loaded.DrawPosition + offset * 0.8f; //Game1.GameScreen.Cam.MoveCamera((float)deltaTime); messageBox.Text = endMessage + "\nReturning to lobby in " + (int)secondsLeft + " s"; @@ -742,6 +742,7 @@ namespace Barotrauma.Networking float closestDist = 0.0f; foreach (WayPoint wp in WayPoint.WayPointList) { + if (wp.SpawnType != SpawnType.Human) continue; float dist = Vector2.Distance(wp.WorldPosition, position); if (closestWaypoint != null && dist > closestDist) continue; diff --git a/Subsurface/Source/Screens/GameScreen.cs b/Subsurface/Source/Screens/GameScreen.cs index 1c1bb5bb2..3e2649c02 100644 --- a/Subsurface/Source/Screens/GameScreen.cs +++ b/Subsurface/Source/Screens/GameScreen.cs @@ -39,7 +39,15 @@ namespace Barotrauma { base.Select(); - if (Submarine.Loaded != null) cam.TargetPos = Submarine.Loaded.Position; + if (Character.Controlled!=null) + { + cam.Position = Character.Controlled.WorldPosition; + } + else if (Submarine.Loaded != null) + { + cam.Position = Submarine.Loaded.Position; + } + foreach (MapEntity entity in MapEntity.mapEntityList) entity.IsHighlighted = false; diff --git a/Subsurface/Source/Screens/NetLobbyScreen.cs b/Subsurface/Source/Screens/NetLobbyScreen.cs index e56595e34..4a6958866 100644 --- a/Subsurface/Source/Screens/NetLobbyScreen.cs +++ b/Subsurface/Source/Screens/NetLobbyScreen.cs @@ -839,7 +839,9 @@ namespace Barotrauma public bool TrySelectSub(string subName, string md5Hash) { - Submarine sub = Submarine.SavedSubmarines.Find(m => m.Name == subName); + subName = subName.ToLower(); + + Submarine sub = Submarine.SavedSubmarines.Find(m => m.Name.ToLower() == subName); if (sub == null) { new GUIMessageBox("Submarine not found!","The submarine ''" + subName + "'' has been selected by the server. Matching file not found in your map folder."); diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo index 2539b262f..0593a725b 100644 Binary files a/Subsurface_Solution.v12.suo and b/Subsurface_Solution.v12.suo differ