diff --git a/Subsurface/Barotrauma.csproj b/Subsurface/Barotrauma.csproj index 20131a96c..3b5a9a494 100644 --- a/Subsurface/Barotrauma.csproj +++ b/Subsurface/Barotrauma.csproj @@ -610,6 +610,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -824,9 +827,6 @@ PreserveNewest - - PreserveNewest - Always diff --git a/Subsurface/Content/Items/Engine/engine.xml b/Subsurface/Content/Items/Engine/engine.xml index 741dc979e..a409935c7 100644 --- a/Subsurface/Content/Items/Engine/engine.xml +++ b/Subsurface/Content/Items/Engine/engine.xml @@ -5,6 +5,7 @@ name="Engine" linkable="true" category="Machine" + pickthroughwalls="true" pickdistance="150"> diff --git a/Subsurface/Content/Jobs.xml b/Subsurface/Content/Jobs.xml index 35fbd9766..58a332a92 100644 --- a/Subsurface/Content/Jobs.xml +++ b/Subsurface/Content/Jobs.xml @@ -46,15 +46,16 @@ + - + - - - + + + diff --git a/Subsurface/Content/Map/background.png b/Subsurface/Content/Map/background.png index d91e2e655..3a0044f6b 100644 Binary files a/Subsurface/Content/Map/background.png and b/Subsurface/Content/Map/background.png differ diff --git a/Subsurface/Content/Map/background2.png b/Subsurface/Content/Map/background2.png index 6d8c6f0a1..71a7675c7 100644 Binary files a/Subsurface/Content/Map/background2.png and b/Subsurface/Content/Map/background2.png differ diff --git a/Subsurface/Content/Map/dustparticles.png b/Subsurface/Content/Map/dustparticles.png index 0f8efffb1..607e7c33b 100644 Binary files a/Subsurface/Content/Map/dustparticles.png and b/Subsurface/Content/Map/dustparticles.png differ diff --git a/Subsurface/Source/Characters/AI/IndoorsSteeringManager.cs b/Subsurface/Source/Characters/AI/IndoorsSteeringManager.cs index 25c199891..3c9c41aee 100644 --- a/Subsurface/Source/Characters/AI/IndoorsSteeringManager.cs +++ b/Subsurface/Source/Characters/AI/IndoorsSteeringManager.cs @@ -115,7 +115,7 @@ namespace Barotrauma return currentTarget-pos2; } - if (canOpenDoors) CheckDoorsInPath(); + if (canOpenDoors && !character.LockHands) CheckDoorsInPath(); float allowedDistance = character.AnimController.InWater ? 1.0f : 0.6f; if (currentPath.CurrentNode!=null && currentPath.CurrentNode.SimPosition.Y > character.SimPosition.Y+1.0f) allowedDistance*=0.5f; @@ -199,7 +199,7 @@ namespace Barotrauma if (nextNode.Waypoint.ConnectedGap.Open > 0.9f) return 0.0f; if (nextNode.Waypoint.ConnectedGap.ConnectedDoor == null) return 100.0f; - if (!canOpenDoors) return null; + if (!canOpenDoors || character.LockHands) return null; var doorButtons = nextNode.Waypoint.ConnectedGap.ConnectedDoor.Item.GetConnectedComponents(); if (!doorButtons.Any()) return null; diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs index 19204dfcd..586a78a4b 100644 --- a/Subsurface/Source/Characters/Character.cs +++ b/Subsurface/Source/Characters/Character.cs @@ -1063,7 +1063,7 @@ namespace Barotrauma if (IsNetworkPlayer) { - Vector2 namePos = new Vector2(pos.X, pos.Y - 80.0f) - GUI.Font.MeasureString(Info.Name) * 0.5f; + Vector2 namePos = new Vector2(pos.X, pos.Y - 120.0f) - GUI.Font.MeasureString(Info.Name) * 0.5f; spriteBatch.DrawString(GUI.Font, Info.Name, namePos - new Vector2(1.0f, 1.0f), Color.Black); spriteBatch.DrawString(GUI.Font, Info.Name, namePos, Color.White); @@ -1081,10 +1081,8 @@ namespace Barotrauma if (isDead) return; Vector2 healthBarPos = new Vector2(pos.X - 50, DrawPosition.Y + 100.0f); - - - - GUI.DrawProgressBar(spriteBatch, healthBarPos, new Vector2(100.0f, 15.0f), health/maxHealth, Color.Lerp(Color.Red, Color.Green, health/maxHealth)*0.8f); + + GUI.DrawProgressBar(spriteBatch, healthBarPos, new Vector2(100.0f, 15.0f), health / maxHealth, Color.Lerp(Color.Red, Color.Green, health / maxHealth) * 0.8f); //GUI.DrawRectangle(spriteBatch, new Rectangle((int)healthBarPos.X - 2, (int)healthBarPos.Y - 2, 100 + 4, 15 + 4), Color.Black, false); //GUI.DrawRectangle(spriteBatch, new Rectangle((int)healthBarPos.X, (int)healthBarPos.Y, (int)(100.0f * (health / maxHealth)), 15), Color.Red, true); diff --git a/Subsurface/Source/GUI/GUI.cs b/Subsurface/Source/GUI/GUI.cs index 8a7e2be2e..a3cc951f0 100644 --- a/Subsurface/Source/GUI/GUI.cs +++ b/Subsurface/Source/GUI/GUI.cs @@ -152,7 +152,7 @@ namespace Barotrauma return true; } - public static void DrawLine(SpriteBatch sb, Vector2 start, Vector2 end, Color clr, float depth = 0.0f) + public static void DrawLine(SpriteBatch sb, Vector2 start, Vector2 end, Color clr, float depth = 0.0f, int width = 1) { Vector2 edge = end - start; // calculate angle to rotate line @@ -163,7 +163,7 @@ namespace Barotrauma (int)start.X, (int)start.Y, (int)edge.Length(), //sb will strech the texture to fill this rectangle - 1), //width of line, change this to make thicker line + width), //width of line, change this to make thicker line null, clr, //colour of line angle, //angle of line (calulated above) diff --git a/Subsurface/Source/GameSession/CrewManager.cs b/Subsurface/Source/GameSession/CrewManager.cs index d1b0ba614..c465fd207 100644 --- a/Subsurface/Source/GameSession/CrewManager.cs +++ b/Subsurface/Source/GameSession/CrewManager.cs @@ -286,7 +286,7 @@ namespace Barotrauma Character character = Character.Create(characterInfos[i], waypoints[i].WorldPosition); Character.Controlled = character; - if (!character.Info.StartItemsGiven) + if (character.Info!=null && !character.Info.StartItemsGiven) { character.GiveJobItems(waypoints[i]); character.Info.StartItemsGiven = true; diff --git a/Subsurface/Source/Items/Components/Door.cs b/Subsurface/Source/Items/Components/Door.cs index 8c485b99d..c9f0e7f4b 100644 --- a/Subsurface/Source/Items/Components/Door.cs +++ b/Subsurface/Source/Items/Components/Door.cs @@ -165,6 +165,12 @@ namespace Barotrauma.Items.Components private void UpdateConvexHulls() { + doorRect = new Rectangle( + item.Rect.Center.X - (int)(doorSprite.size.X / 2), + item.Rect.Y - item.Rect.Height / 2 + (int)(doorSprite.size.Y / 2.0f), + (int)doorSprite.size.X, + (int)doorSprite.size.Y); + Rectangle rect = doorRect; if (isHorizontal) { @@ -221,10 +227,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) + 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; + 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); return corners; } diff --git a/Subsurface/Source/Items/Components/Machines/Fabricator.cs b/Subsurface/Source/Items/Components/Machines/Fabricator.cs index e4eae4bb7..6d08d117d 100644 --- a/Subsurface/Source/Items/Components/Machines/Fabricator.cs +++ b/Subsurface/Source/Items/Components/Machines/Fabricator.cs @@ -29,11 +29,15 @@ namespace Barotrauma.Items.Components return; } - RequiredItems = new List>(); + RequiredTime = ToolBox.GetAttributeFloat(element, "requiredtime", 1.0f); + RequiredItems = new List>(); + string[] requiredItemNames = ToolBox.GetAttributeString(element, "requireditems", "").Split(','); foreach (string requiredItemName in requiredItemNames) { + if (string.IsNullOrWhiteSpace(requiredItemName)) continue; + ItemPrefab requiredItem = ItemPrefab.list.Find(ip => ip.Name.ToLower() == requiredItemName.Trim().ToLower()) as ItemPrefab; if (requiredItem == null) { @@ -57,7 +61,6 @@ namespace Barotrauma.Items.Components } - RequiredTime = ToolBox.GetAttributeFloat(element, "requiredtime", 1.0f); } } diff --git a/Subsurface/Source/Map/Levels/Level.cs b/Subsurface/Source/Map/Levels/Level.cs index c37692507..76acc6c00 100644 --- a/Subsurface/Source/Map/Levels/Level.cs +++ b/Subsurface/Source/Map/Levels/Level.cs @@ -64,6 +64,8 @@ namespace Barotrauma private List positionsOfInterest; + private Color backgroundColor; + public Vector2 StartPosition { get { return startPosition; } @@ -101,6 +103,11 @@ namespace Barotrauma private set; } + public Color BackgroundColor + { + get { return backgroundColor; } + } + public Level(string seed, float difficulty, int width, int height, int siteInterval) { this.seed = seed; @@ -148,6 +155,12 @@ namespace Barotrauma Rand.SetSyncedSeed(ToolBox.StringToInt(seed)); + float brightness = Rand.Range(1.0f, 1.3f, false); + backgroundColor = Color.Lerp(new Color(11, 18, 26), new Color(11, 26, 18), Rand.Range(0.0f, 1.0f, false)) * brightness; + + + backgroundColor = new Color(backgroundColor, 1.0f); + float minWidth = Submarine.Loaded == null ? 0.0f : Math.Max(Submarine.Borders.Width, Submarine.Borders.Height); minWidth = Math.Max(minWidth, 3500.0f); @@ -1049,8 +1062,10 @@ namespace Barotrauma } } - public void DrawBack(SpriteBatch spriteBatch, Camera cam, BackgroundCreatureManager backgroundSpriteManager = null) + public void DrawBack(GraphicsDevice graphics, SpriteBatch spriteBatch, Camera cam, BackgroundCreatureManager backgroundSpriteManager = null) { + graphics.Clear(backgroundColor); + if (renderer == null) return; renderer.DrawBackground(spriteBatch, cam, backgroundSpriteManager); } diff --git a/Subsurface/Source/Map/Levels/LevelRenderer.cs b/Subsurface/Source/Map/Levels/LevelRenderer.cs index 2cbd4fccf..fe94afd35 100644 --- a/Subsurface/Source/Map/Levels/LevelRenderer.cs +++ b/Subsurface/Source/Map/Levels/LevelRenderer.cs @@ -13,7 +13,7 @@ namespace Barotrauma private static BasicEffect basicEffect; private static Sprite background, backgroundTop; - private static Texture2D dustParticles; + private static Sprite dustParticles; private static Texture2D shaftTexture; private static BackgroundSpriteManager backgroundSpriteManager; @@ -33,9 +33,9 @@ namespace Barotrauma if (background==null) { - background = new Sprite("Content/Map/background.png", Vector2.Zero); - backgroundTop = new Sprite("Content/Map/background2.png", Vector2.Zero); - dustParticles = Sprite.LoadTexture("Content/Map/dustparticles.png"); + background = new Sprite("Content/Map/background2.png", Vector2.Zero); + backgroundTop = new Sprite("Content/Map/background.png", Vector2.Zero); + dustParticles = new Sprite("Content/Map/dustparticles.png", Vector2.Zero); } if (basicEffect == null) @@ -94,17 +94,24 @@ namespace Barotrauma background.DrawTiled(spriteBatch, (backgroundPos.Y < 0) ? new Vector2(0.0f, -backgroundPos.Y) : Vector2.Zero, new Vector2(GameMain.GraphicsWidth, 1024 - backgroundPos.Y), - Vector2.Zero, Color.White); + Vector2.Zero, level.BackgroundColor); } if (backgroundPos.Y < 0) { backgroundTop.SourceRect = new Rectangle((int)backgroundPos.X, (int)backgroundPos.Y, 1024, (int)Math.Min(-backgroundPos.Y, 1024)); backgroundTop.DrawTiled(spriteBatch, Vector2.Zero, new Vector2(GameMain.GraphicsWidth, Math.Min(-backgroundPos.Y, GameMain.GraphicsHeight)), - Vector2.Zero, Color.White); + Vector2.Zero, level.BackgroundColor); } } + + //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, @@ -116,25 +123,29 @@ namespace Barotrauma if (backgroundCreatureManager!=null) backgroundCreatureManager.Draw(spriteBatch); + + + //new Vector2((-offset.X*cam.Zoom) % 1024, (-offset.Y*cam.Zoom) % 1024) + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.BackToFront, - BlendState.AlphaBlend, - SamplerState.LinearWrap); + BlendState.Additive, + SamplerState.LinearWrap, DepthStencilState.Default, null, null, + cam.Transform); - 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; - - float multiplier = 0.8f; - for (int i = 1; i < 4; i++) + //float multiplier = 0.9f; + for (int i = 1; i < 2; i++) { - spriteBatch.Draw(dustParticles, new Rectangle(0,0,GameMain.GraphicsWidth,GameMain.GraphicsHeight), - new Rectangle((int)((backgroundPos.X * multiplier)), (int)((-backgroundPos.Y * multiplier)), cam.WorldView.Width*2, cam.WorldView.Height*2), - Color.White * multiplier, 0.0f, Vector2.Zero, SpriteEffects.None, 1.0f - multiplier); - multiplier -= 0.1f; + Vector2 offset = new Vector2(cam.WorldView.X, cam.WorldView.Y);// *multiplier; + + dustParticles.SourceRect = new Rectangle((int)(offset.X), (int)(-offset.Y), (int)(1024), (int)(1024)); + + dustParticles.DrawTiled(spriteBatch, new Vector2(cam.WorldView.X, -cam.WorldView.Y), + new Vector2(cam.WorldView.Width, cam.WorldView.Height), + Vector2.Zero, Color.White); } spriteBatch.End(); @@ -169,6 +180,7 @@ namespace Barotrauma * Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f; graphicsDevice.SamplerStates[0] = SamplerState.LinearWrap; + graphicsDevice.BlendState = BlendState.AlphaBlend; graphicsDevice.SetVertexBuffer(bodyVertices); basicEffect.VertexColorEnabled = true; diff --git a/Subsurface/Source/Map/Submarine.cs b/Subsurface/Source/Map/Submarine.cs index 907764a7b..7bfac6888 100644 --- a/Subsurface/Source/Map/Submarine.cs +++ b/Subsurface/Source/Map/Submarine.cs @@ -699,6 +699,37 @@ namespace Barotrauma } } + Vector2 topLeft = new Vector2(Hull.hullList[0].Rect.X, Hull.hullList[0].Rect.Y); + Vector2 bottomRight = new Vector2(Hull.hullList[0].Rect.X, Hull.hullList[0].Rect.Y); + foreach (Hull hull in Hull.hullList) + { + if (hull.Rect.X < topLeft.X) topLeft.X = hull.Rect.X; + if (hull.Rect.Y > topLeft.Y) topLeft.Y = hull.Rect.Y; + + if (hull.Rect.Right > bottomRight.X) bottomRight.X = hull.Rect.Right; + if (hull.Rect.Y - hull.Rect.Height < bottomRight.Y) bottomRight.Y = hull.Rect.Y - hull.Rect.Height; + } + + Vector2 center = (topLeft + bottomRight) / 2.0f; + + foreach (Item item in Item.ItemList) + { + var wire = item.GetComponent(); + if (wire == null) continue; + + for (int i = 0; i < wire.Nodes.Count; i++) + { + wire.Nodes[i] -= center; + } + } + + for (int i = 0; i < MapEntity.mapEntityList.Count; i++) + { + if (MapEntity.mapEntityList[i].Submarine == null) continue; + + MapEntity.mapEntityList[i].Move(-center); + } + subBody = new SubmarineBody(this); subBody.SetPosition(HiddenSubPosition); diff --git a/Subsurface/Source/Networking/GameServer.cs b/Subsurface/Source/Networking/GameServer.cs index ce544257f..d3e55f794 100644 --- a/Subsurface/Source/Networking/GameServer.cs +++ b/Subsurface/Source/Networking/GameServer.cs @@ -1305,7 +1305,7 @@ namespace Barotrauma.Networking List recipients = new List(); Client targetClient = null; - if (type==ChatMessageType.Server) + if (type == ChatMessageType.Server) { string command = GetChatMessageCommand(message).ToLower(); @@ -1363,7 +1363,7 @@ namespace Barotrauma.Networking { foreach (Client c in ConnectedClients) { - if (type != ChatMessageType.Dead || (c.Character != null && c.Character.IsDead)) recipients.Add(c); + if (type != ChatMessageType.Dead || (c.Character == null || c.Character.IsDead)) recipients.Add(c); } } diff --git a/Subsurface/Source/Screens/EditMapScreen.cs b/Subsurface/Source/Screens/EditMapScreen.cs index f5d9285ff..6bb028409 100644 --- a/Subsurface/Source/Screens/EditMapScreen.cs +++ b/Subsurface/Source/Screens/EditMapScreen.cs @@ -578,7 +578,12 @@ namespace Barotrauma cam.Transform); graphics.Clear(new Color(0.051f, 0.149f, 0.271f, 1.0f)); - + if (GameMain.DebugDraw) + { + GUI.DrawLine(spriteBatch, new Vector2(0.0f, -cam.WorldView.Y), new Vector2(0.0f, -(cam.WorldView.Y - cam.WorldView.Height)), Color.White*0.5f, 1.0f, (int)(2.0f/cam.Zoom)); + GUI.DrawLine(spriteBatch, new Vector2(cam.WorldView.X, -Submarine.HiddenSubPosition.Y), new Vector2(cam.WorldView.Right, -Submarine.HiddenSubPosition.Y), Color.White * 0.5f, 1.0f, (int)(2.0f / cam.Zoom)); + } + Submarine.Draw(spriteBatch, true); if (!characterMode) @@ -587,7 +592,8 @@ namespace Barotrauma MapEntity.DrawSelecting(spriteBatch, cam); } - + + spriteBatch.End(); //-------------------- HUD ----------------------------- diff --git a/Subsurface/Source/Screens/GameScreen.cs b/Subsurface/Source/Screens/GameScreen.cs index d1f52dc0b..1f3b4da72 100644 --- a/Subsurface/Source/Screens/GameScreen.cs +++ b/Subsurface/Source/Screens/GameScreen.cs @@ -226,9 +226,16 @@ namespace Barotrauma //---------------------------------------------------------------------------------------- graphics.SetRenderTarget(renderTarget); - graphics.Clear(new Color(11, 18, 26, 255)); + + if (Level.Loaded == null) + { + graphics.Clear(new Color(11, 18, 26, 255)); - if (Level.Loaded != null) Level.Loaded.DrawBack(spriteBatch, cam, BackgroundCreatureManager); + } + else + { + Level.Loaded.DrawBack(graphics, spriteBatch, cam, BackgroundCreatureManager); + } spriteBatch.Begin(SpriteSortMode.BackToFront, diff --git a/Subsurface/Source/Screens/MainMenuScreen.cs b/Subsurface/Source/Screens/MainMenuScreen.cs index 8c6b02cd8..ee8d0db1e 100644 --- a/Subsurface/Source/Screens/MainMenuScreen.cs +++ b/Subsurface/Source/Screens/MainMenuScreen.cs @@ -31,8 +31,6 @@ namespace Barotrauma { menuTabs = new GUIFrame[Enum.GetValues(typeof(Tab)).Length+1]; - - buttonsTab = new GUIFrame(new Rectangle(0,0,0,0), Color.Transparent, Alignment.Left | Alignment.CenterY); buttonsTab.Padding = new Vector4(20.0f, 20.0f, 20.0f, 20.0f); //menuTabs[(int)Tabs.Main].Padding = GUI.style.smallPadding; @@ -105,14 +103,14 @@ namespace Barotrauma } if (Submarine.SavedSubmarines.Count > 0) mapList.Select(Submarine.SavedSubmarines[0]); - new GUITextBlock(new Rectangle((int)(mapList.Rect.Width + 20), 0, 100, 20), + new GUITextBlock(new Rectangle((int)(mapList.Rect.Width + 30), 0, 100, 20), "Save name: ", GUI.Style, Alignment.Left, Alignment.Left, menuTabs[(int)Tab.NewGame]); saveNameBox = new GUITextBox(new Rectangle((int)(mapList.Rect.Width + 20), 30, 180, 20), Alignment.TopLeft, GUI.Style, menuTabs[(int)Tab.NewGame]); saveNameBox.Text = SaveUtil.CreateSavePath(); - new GUITextBlock(new Rectangle((int)(mapList.Rect.Width + 20), 60, 100, 20), + new GUITextBlock(new Rectangle((int)(mapList.Rect.Width + 30), 60, 100, 20), "Map Seed: ", GUI.Style, Alignment.Left, Alignment.Left, menuTabs[(int)Tab.NewGame]); seedBox = new GUITextBox(new Rectangle((int)(mapList.Rect.Width + 20), 90, 180, 20), diff --git a/Subsurface/changelog.txt b/Subsurface/changelog.txt index cc01a7654..3ebd04cdc 100644 --- a/Subsurface/changelog.txt +++ b/Subsurface/changelog.txt @@ -1,3 +1,18 @@ +--------------------------------------------------------------------------------------------------------- +v0.3.3.0 +--------------------------------------------------------------------------------------------------------- + +- more visible indicators when taking damage, running out of oxygen or being crushed by pressure +- handcuffs +- changes in the welding/cutting targeting logic: it's now possible to target "corners" of the hull +even if the section of the wall is obstructed by adjacent walls +- fixed submarines spawning in a wrong position (e.g. inside walls) if the submarine has been built +far away from the coordinates (0,0) +- fixed a memory leak caused by item sprites +- character/inventory syncing bugfixes +- fixed spectators not seeing their own chat messages +- scrollable list of clients in the network statistics view + --------------------------------------------------------------------------------------------------------- v0.3.2.6 --------------------------------------------------------------------------------------------------------- diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo index 64698d302..b53e89c63 100644 Binary files a/Subsurface_Solution.v12.suo and b/Subsurface_Solution.v12.suo differ