From 3f22b2e4df7e2df3b0c5c3520d1ae77e7f790e55 Mon Sep 17 00:00:00 2001 From: Regalis Date: Sun, 1 May 2016 18:55:44 +0300 Subject: [PATCH] GUIMessageBoxes are drawn on top of everything else (they were obstructed by shiftsummary), placing background sprites based on level seed, instructions for dealing with broken junction boxes in tutorial --- Farseer Physics Engine 3.5/Dynamics/World.cs | 2 + .../BackgroundSpriteManager.cs | 2 +- Subsurface/Source/GameMain.cs | 5 +- .../GameModes/Tutorials/BasicTutorial.cs | 59 +++++++++++-------- Subsurface/Source/Map/Levels/LevelRenderer.cs | 21 ++----- 5 files changed, 46 insertions(+), 43 deletions(-) diff --git a/Farseer Physics Engine 3.5/Dynamics/World.cs b/Farseer Physics Engine 3.5/Dynamics/World.cs index 633b362b0..ba87f248d 100644 --- a/Farseer Physics Engine 3.5/Dynamics/World.cs +++ b/Farseer Physics Engine 3.5/Dynamics/World.cs @@ -1132,6 +1132,8 @@ namespace FarseerPhysics.Dynamics Debug.Assert(!_bodyRemoveList.Contains(body), "The body is already marked for removal. You are removing the body more than once."); + Debug.Assert(body != null); + if (!_bodyRemoveList.Contains(body)) _bodyRemoveList.Add(body); diff --git a/Subsurface/Source/Characters/BackgroundSprite/BackgroundSpriteManager.cs b/Subsurface/Source/Characters/BackgroundSprite/BackgroundSpriteManager.cs index a445c20a7..457ecad00 100644 --- a/Subsurface/Source/Characters/BackgroundSprite/BackgroundSpriteManager.cs +++ b/Subsurface/Source/Characters/BackgroundSprite/BackgroundSpriteManager.cs @@ -148,7 +148,7 @@ namespace Barotrauma Vector2 dir = (closestEdge.point1 - closestEdge.point2) / length; Vector2 pos = closestEdge.Center; - pos = closestEdge.point2 + dir * Rand.Range(prefab.Sprite.size.X / 2.0f, length - prefab.Sprite.size.X / 2.0f); + pos = closestEdge.point2 + dir * Rand.Range(prefab.Sprite.size.X / 2.0f, length - prefab.Sprite.size.X / 2.0f, false); if (prefab.Alignment.HasFlag(Alignment.Top)) { diff --git a/Subsurface/Source/GameMain.cs b/Subsurface/Source/GameMain.cs index 03b42edca..a693c25e8 100644 --- a/Subsurface/Source/GameMain.cs +++ b/Subsurface/Source/GameMain.cs @@ -300,8 +300,6 @@ namespace Barotrauma if (!paused) Screen.Selected.Update(deltaTime); - GUI.Update((float)deltaTime); - if (NetworkMember != null) { NetworkMember.Update((float)deltaTime); @@ -310,6 +308,9 @@ namespace Barotrauma { NetworkEvent.Events.Clear(); } + + GUI.Update((float)deltaTime); + } CoroutineManager.Update((float)deltaTime, paused ? 0.0f : (float)deltaTime); diff --git a/Subsurface/Source/GameSession/GameModes/Tutorials/BasicTutorial.cs b/Subsurface/Source/GameSession/GameModes/Tutorials/BasicTutorial.cs index 122e046b0..104f066aa 100644 --- a/Subsurface/Source/GameSession/GameModes/Tutorials/BasicTutorial.cs +++ b/Subsurface/Source/GameSession/GameModes/Tutorials/BasicTutorial.cs @@ -36,7 +36,7 @@ namespace Barotrauma.Tutorials Door tutorialDoor = Item.ItemList.Find(i => i.HasTag("tutorialdoor")).GetComponent(); - while (!tutorialDoor.IsOpen) + while (!tutorialDoor.IsOpen && Character.Controlled.WorldPosition.X < tutorialDoor.Item.WorldPosition.X) { yield return CoroutineStatus.Running; } @@ -382,7 +382,7 @@ namespace Barotrauma.Tutorials Character.Controlled.ClosestItem != null && Character.Controlled.ClosestItem.Name == "Diving Suit") { infoBox = CreateInfoFrame("There can only be one item in each inventory slot, so you need to take off " - +"the jumpsuit if you wish to wear a diving suit."); + + "the jumpsuit if you wish to wear a diving suit."); divingMaskSelected = true; } @@ -450,7 +450,7 @@ namespace Barotrauma.Tutorials yield return CoroutineStatus.Running; } - moloch.AnimController.SetPosition(ConvertUnits.ToSimUnits(Character.Controlled.WorldPosition + Vector2.UnitY*1000.0f)); + moloch.AnimController.SetPosition(ConvertUnits.ToSimUnits(Character.Controlled.WorldPosition + Vector2.UnitY * 1000.0f)); infoBox = CreateInfoFrame("Now we're ready to shoot! Select the railgun controller."); @@ -523,10 +523,41 @@ namespace Barotrauma.Tutorials infoBox = CreateInfoFrame("The two pumps inside the ballast tanks " + "are connected straight to the navigation terminal and can't be manually controlled unless you mess with their wiring, " + "so you should only use the pump in the middle room to pump out the water. Select it, turn it on and adjust the pumping speed " + - "to start pumping water out."); + "to start pumping water out.", true); + while (infoBox != null) + { + yield return CoroutineStatus.Running; + } + + + bool brokenMsgShown = false; while (pump.Item.CurrentHull.Volume > 1000.0f) { + if (!brokenMsgShown && pump.Voltage < pump.MinVoltage && Character.Controlled.SelectedConstruction == pump.Item) + { + brokenMsgShown = true; + + infoBox = CreateInfoFrame("Looks like the pump isn't getting any power. The water must have short-circuited some of the junction " + +"boxes. You can check which boxes are broken by selecting them."); + + while (true) + { + if (Character.Controlled.SelectedConstruction!=null && + Character.Controlled.SelectedConstruction.GetComponent() != null && + Character.Controlled.SelectedConstruction.Condition == 0.0f) + { + infoBox = CreateInfoFrame("Here's our problem: this junction box is broken. Luckily engineers are adept at fixing electrical devices - " + +"you just need to find a spare wire and click the ''Fix''-button to repair the box."); + break; + } + + if (pump.Voltage > pump.MinVoltage) break; + + yield return CoroutineStatus.Running; + } + } + yield return CoroutineStatus.Running; } @@ -535,30 +566,10 @@ namespace Barotrauma.Tutorials yield return new WaitForSeconds(4.0f); - float endPreviewLength = 10.0f; - - DateTime endTime = DateTime.Now + new TimeSpan(0, 0, 0, 0, (int)(1000.0f * endPreviewLength)); - float secondsLeft = endPreviewLength; - Character.Controlled = null; GameMain.GameScreen.Cam.TargetPos = Vector2.Zero; GameMain.LightManager.LosEnabled = false; - //do - //{ - // secondsLeft = (float)(endTime - DateTime.Now).TotalSeconds; - - // float camAngle = (float)((DateTime.Now - endTime).TotalSeconds / endPreviewLength) * MathHelper.TwoPi; - // Vector2 offset = (new Vector2( - // (float)Math.Cos(camAngle) * (Submarine.Borders.Width / 2.0f), - // (float)Math.Sin(camAngle) * (Submarine.Borders.Height / 2.0f))); - - // GameMain.GameScreen.Cam.TargetPos = offset * 0.8f; - // //Game1.GameScreen.Cam.MoveCamera((float)deltaTime); - - // yield return CoroutineStatus.Running; - //} while (secondsLeft > 0.0f); - var cinematic = new TransitionCinematic(Submarine.Loaded, GameMain.GameScreen.Cam, 5.0f); while (cinematic.Running) diff --git a/Subsurface/Source/Map/Levels/LevelRenderer.cs b/Subsurface/Source/Map/Levels/LevelRenderer.cs index 21af54e53..088977214 100644 --- a/Subsurface/Source/Map/Levels/LevelRenderer.cs +++ b/Subsurface/Source/Map/Levels/LevelRenderer.cs @@ -106,13 +106,6 @@ namespace Barotrauma } } - - //backgroundPos = new Vector2(cam.WorldView.X, cam.WorldView.Y) + dustOffset; - ////if (Level.Loaded != null) backgroundPos -= Level.Loaded.Position; - - //Rectangle viewRect = cam.WorldView; - //viewRect.Y = -viewRect.Y; - spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.BackToFront, @@ -124,10 +117,6 @@ namespace Barotrauma if (backgroundCreatureManager!=null) backgroundCreatureManager.Draw(spriteBatch); - - - //new Vector2((-offset.X*cam.Zoom) % 1024, (-offset.Y*cam.Zoom) % 1024) - spriteBatch.End(); @@ -136,11 +125,9 @@ namespace Barotrauma SamplerState.LinearWrap, DepthStencilState.Default, null, null, cam.Transform); - - //float multiplier = 0.9f; for (int i = 1; i < 2; i++) { - Vector2 offset = new Vector2(cam.WorldView.X, cam.WorldView.Y);// *multiplier; + Vector2 offset = new Vector2(cam.WorldView.X, cam.WorldView.Y); dustParticles.SourceRect = new Rectangle((int)(offset.X), (int)(-offset.Y), (int)(1024), (int)(1024)); @@ -171,14 +158,16 @@ namespace Barotrauma foreach (GraphEdge edge in cell.edges) { GUI.DrawLine(spriteBatch, new Vector2(edge.point1.X, -edge.point1.Y), - new Vector2(edge.point2.X, -edge.point2.Y), Color.White); + new Vector2(edge.point2.X, -edge.point2.Y), cell.body==null ? Color.Gray : Color.White); } foreach (Vector2 point in cell.bodyVertices) { GUI.DrawRectangle(spriteBatch, new Vector2(point.X, -point.Y), new Vector2(10.0f, 10.0f), Color.White, true); } - } + } + + //RuinGeneration.RuinGenerator.Draw(spriteBatch); }