From 53b3ef533ef47e5959da1c48391e4dce8da0866a Mon Sep 17 00:00:00 2001 From: Regalis Date: Mon, 5 Sep 2016 18:12:56 +0300 Subject: [PATCH 1/5] Moved the whitelist UI to server settings, GUITextBoxes can't be selected through other UI elements anymore --- Subsurface/Source/GUI/GUITextBox.cs | 38 ++++----- Subsurface/Source/Networking/GameServer.cs | 10 --- .../Source/Networking/GameServerSettings.cs | 26 ++---- Subsurface/Source/Networking/WhiteList.cs | 83 +++++++++---------- Subsurface/Source/Screens/NetLobbyScreen.cs | 4 - 5 files changed, 67 insertions(+), 94 deletions(-) diff --git a/Subsurface/Source/GUI/GUITextBox.cs b/Subsurface/Source/GUI/GUITextBox.cs index afbdaf3b8..e50f41320 100644 --- a/Subsurface/Source/GUI/GUITextBox.cs +++ b/Subsurface/Source/GUI/GUITextBox.cs @@ -223,26 +223,6 @@ namespace Barotrauma caretVisible = ((caretTimer * 1000.0f) % 1000) < 500; } - if (rect.Contains(PlayerInput.MousePosition)) - { - - state = ComponentState.Hover; - if (PlayerInput.LeftButtonClicked()) - { - if (MouseOn != null && MouseOn != this && MouseOn!=textBlock && !MouseOn.IsParentOf(this)) return; - - Select(); - if (OnSelected != null) OnSelected(this, Keys.None); - } - } - else - { - state = ComponentState.None; - - } - - textBlock.State = state; - if (keyboardDispatcher.Subscriber == this) { Character.DisableControls = true; @@ -268,6 +248,24 @@ namespace Barotrauma { if (!Visible) return; + if (rect.Contains(PlayerInput.MousePosition) && Enabled && + (MouseOn == null || MouseOn == this || IsParentOf(MouseOn) || MouseOn.IsParentOf(this))) + { + + state = ComponentState.Hover; + if (PlayerInput.LeftButtonClicked()) + { + Select(); + if (OnSelected != null) OnSelected(this, Keys.None); + } + } + else + { + state = ComponentState.None; + } + + textBlock.State = state; + DrawChildren(spriteBatch); if (!CaretEnabled) return; diff --git a/Subsurface/Source/Networking/GameServer.cs b/Subsurface/Source/Networking/GameServer.cs index 7f0848986..7b284a201 100644 --- a/Subsurface/Source/Networking/GameServer.cs +++ b/Subsurface/Source/Networking/GameServer.cs @@ -115,11 +115,6 @@ namespace Barotrauma.Networking settingsButton.UserData = "settingsButton"; whitelist = new WhiteList(); - - GUIButton whitelistButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 170 - 170 - 170 - 170, 20, 150, 20), "Whitelist", Alignment.TopLeft, GUI.Style, inGameHUD); - whitelistButton.OnClicked = ToggleWhiteListFrame; - whitelistButton.UserData = "whitelistButton"; - banList = new BanList(); LoadSettings(); @@ -288,7 +283,6 @@ namespace Barotrauma.Networking { if (ShowNetStats) netStats.Update(deltaTime); if (settingsFrame != null) settingsFrame.Update(deltaTime); - if (whitelist.WhiteListFrame != null) whitelist.WhiteListFrame.Update(deltaTime); if (!started) return; @@ -1305,10 +1299,6 @@ namespace Barotrauma.Networking log.LogFrame.Update(0.016f); log.LogFrame.Draw(spriteBatch); } - else if (whitelist.WhiteListFrame != null) - { - whitelist.WhiteListFrame.Draw(spriteBatch); - } if (!ShowNetStats) return; diff --git a/Subsurface/Source/Networking/GameServerSettings.cs b/Subsurface/Source/Networking/GameServerSettings.cs index 82d495148..7fc3f4d2c 100644 --- a/Subsurface/Source/Networking/GameServerSettings.cs +++ b/Subsurface/Source/Networking/GameServerSettings.cs @@ -265,14 +265,14 @@ namespace Barotrauma.Networking new GUITextBlock(new Rectangle(0, -5, 0, 20), "Settings", GUI.Style, innerFrame, GUI.LargeFont); - string[] tabNames = { "Rounds", "Server", "Banlist" }; + string[] tabNames = { "Rounds", "Server", "Banlist", "Whitelist" }; settingsTabs = new GUIFrame[tabNames.Length]; for (int i = 0; i < tabNames.Length; i++) { settingsTabs[i] = new GUIFrame(new Rectangle(0, 15, 0, innerFrame.Rect.Height - 120), null, Alignment.Center, GUI.Style, innerFrame); settingsTabs[i].Padding = new Vector4(40.0f, 20.0f, 40.0f, 40.0f); - var tabButton = new GUIButton(new Rectangle(105 * i, 35, 100, 20), tabNames[i], GUI.Style, innerFrame); + var tabButton = new GUIButton(new Rectangle(85 * i, 35, 80, 20), tabNames[i], GUI.Style, innerFrame); tabButton.UserData = i; tabButton.OnClicked = SelectSettingsTab; } @@ -524,6 +524,12 @@ namespace Barotrauma.Networking banList.CreateBanFrame(settingsTabs[2]); + + //-------------------------------------------------------------------------------- + // whitelist + //-------------------------------------------------------------------------------- + + whitelist.CreateWhiteListFrame(settingsTabs[3]); } @@ -647,21 +653,7 @@ namespace Barotrauma.Networking return false; } - - public bool ToggleWhiteListFrame(GUIButton button, object obj) - { - if (whitelist.WhiteListFrame == null) - { - whitelist.CreateWhiteListFrame(); - } - else - { - whitelist.CloseFrame(); - } - - return false; - } - + public void ManagePlayersFrame(GUIFrame infoFrame) { GUIListBox cList = new GUIListBox(new Rectangle(0, 0, 0, 300), Color.White * 0.7f, GUI.Style, infoFrame); diff --git a/Subsurface/Source/Networking/WhiteList.cs b/Subsurface/Source/Networking/WhiteList.cs index aa6459992..cc419eb70 100644 --- a/Subsurface/Source/Networking/WhiteList.cs +++ b/Subsurface/Source/Networking/WhiteList.cs @@ -30,21 +30,15 @@ namespace Barotrauma.Networking } private GUIComponent whitelistFrame; - private GUIComponent innerlistFrame; private GUITextBox nameBox; private GUITextBox ipBox; - public bool enabled; - - public GUIComponent WhiteListFrame - { - get { return whitelistFrame; } - } + public bool Enabled; public WhiteList() { - enabled = false; + Enabled = false; whitelistedPlayers = new List(); if (File.Exists(SavePath)) @@ -69,11 +63,11 @@ namespace Barotrauma.Networking Int32.TryParse(lineval, out intVal); if (lineval.ToLower() == "true" || intVal != 0) { - enabled = true; + Enabled = true; } else { - enabled = false; + Enabled = false; } } else @@ -96,7 +90,7 @@ namespace Barotrauma.Networking List lines = new List(); - if (enabled) + if (Enabled) { lines.Add("#true"); } @@ -121,56 +115,57 @@ namespace Barotrauma.Networking public bool IsWhiteListed(string name, string ip) { - if (!enabled) return true; + if (!Enabled) return true; WhiteListedPlayer wlp = whitelistedPlayers.Find(p => p.Name == name); if (wlp == null) return false; if (wlp.IP != ip && !string.IsNullOrWhiteSpace(wlp.IP)) return false; return true; } - public GUIComponent CreateWhiteListFrame() + public GUIComponent CreateWhiteListFrame(GUIComponent parent) { - whitelistFrame = new GUIFrame(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Black * 0.5f); + if (whitelistFrame!=null) + { + whitelistFrame.Parent.ClearChildren(); + whitelistFrame = null; + } - GUIFrame innerFrame = new GUIFrame(new Rectangle(0, 0, 500, 430), null, Alignment.Center, GUI.Style, whitelistFrame); - innerFrame.Padding = new Vector4(20.0f, 50.0f, 20.0f, 100.0f); + parent.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f); - var closeButton = new GUIButton(new Rectangle(0, 85, 100, 20), "Close", Alignment.BottomRight, GUI.Style, innerFrame); - closeButton.OnClicked = GameMain.Server.ToggleWhiteListFrame; - - new GUITextBlock(new Rectangle(0, -35, 200, 20), "Whitelist", GUI.Style, innerFrame, GUI.LargeFont); - var enabledTick = new GUITickBox(new Rectangle(200, -30, 20, 20), "Enabled", Alignment.Left, innerFrame); - enabledTick.Selected = enabled; + var enabledTick = new GUITickBox(new Rectangle(0, 0, 20, 20), "Enabled", Alignment.TopLeft, parent); + enabledTick.Selected = Enabled; enabledTick.OnSelected = (GUITickBox box) => { - enabled = !enabled; - if (enabled) + Enabled = !Enabled; + + if (Enabled) { foreach (Client c in GameMain.Server.ConnectedClients) { if (!IsWhiteListed(c.name,c.Connection.RemoteEndPoint.Address.ToString())) { whitelistedPlayers.Add(new WhiteListedPlayer(c.name, c.Connection.RemoteEndPoint.Address.ToString())); - CloseFrame(); CreateWhiteListFrame(); + if (whitelistFrame != null) CreateWhiteListFrame(whitelistFrame.Parent); } } } + Save(); return true; }; - new GUITextBlock(new Rectangle(0, 35, 90, 25), "Name:", GUI.Style, Alignment.BottomLeft, Alignment.TopLeft, innerFrame, false, GUI.Font); - nameBox = new GUITextBox(new Rectangle(100, 30, 170, 25), Alignment.BottomLeft, GUI.Style, innerFrame); + new GUITextBlock(new Rectangle(0, -25, 90, 20), "Name:", GUI.Style, Alignment.BottomLeft, Alignment.TopLeft, parent, false, GUI.Font); + nameBox = new GUITextBox(new Rectangle(100, -25, 170, 20), Alignment.BottomLeft, GUI.Style, parent); nameBox.Font = GUI.Font; - new GUITextBlock(new Rectangle(0, 65, 90, 25), "IP Address:", GUI.Style, Alignment.BottomLeft, Alignment.TopLeft, innerFrame, false, GUI.Font); - ipBox = new GUITextBox(new Rectangle(100, 60, 170, 25), Alignment.BottomLeft, GUI.Style, innerFrame); + new GUITextBlock(new Rectangle(0, 5, 90, 20), "IP Address:", GUI.Style, Alignment.BottomLeft, Alignment.TopLeft, parent, false, GUI.Font); + ipBox = new GUITextBox(new Rectangle(100, 5, 170, 20), Alignment.BottomLeft, GUI.Style, parent); ipBox.Font = GUI.Font; - var addnewButton = new GUIButton(new Rectangle(300, 45, 150, 20), "Add to whitelist", Alignment.BottomLeft, GUI.Style, innerFrame); + var addnewButton = new GUIButton(new Rectangle(0, 45, 150, 20), "Add to whitelist", Alignment.BottomLeft, GUI.Style, parent); addnewButton.OnClicked = AddToWhiteList; - innerlistFrame = new GUIListBox(new Rectangle(0, 0, 0, 0), GUI.Style, innerFrame); + whitelistFrame = new GUIListBox(new Rectangle(0, 30, 0, parent.Rect.Height-100), GUI.Style, parent); foreach (WhiteListedPlayer wlp in whitelistedPlayers) { @@ -180,7 +175,7 @@ namespace Barotrauma.Networking new Rectangle(0, 0, 0, 25), blockText, GUI.Style, - Alignment.Left, Alignment.Left, innerlistFrame); + Alignment.Left, Alignment.Left, whitelistFrame); textBlock.Padding = new Vector4(10.0f, 10.0f, 0.0f, 0.0f); textBlock.UserData = wlp; @@ -188,8 +183,8 @@ namespace Barotrauma.Networking removeButton.UserData = wlp; removeButton.OnClicked = RemoveFromWhiteList; } - - return whitelistFrame; + + return parent; } private bool RemoveFromWhiteList(GUIButton button, object obj) @@ -202,7 +197,12 @@ namespace Barotrauma.Networking whitelistedPlayers.Remove(wlp); Save(); - CloseFrame(); CreateWhiteListFrame(); + + if (whitelistFrame != null) + { + whitelistFrame.Parent.ClearChildren(); + CreateWhiteListFrame(whitelistFrame.Parent); + } return true; } @@ -210,17 +210,14 @@ namespace Barotrauma.Networking private bool AddToWhiteList(GUIButton button, object obj) { if (string.IsNullOrWhiteSpace(nameBox.Text)) return false; - if (whitelistedPlayers.Find(x => x.Name.ToLower() == nameBox.Text.ToLower() && x.IP == ipBox.Text) != null) return false; + if (whitelistedPlayers.Any(x => x.Name.ToLower() == nameBox.Text.ToLower() && x.IP == ipBox.Text)) return false; whitelistedPlayers.Add(new WhiteListedPlayer(nameBox.Text,ipBox.Text)); Save(); - CloseFrame(); CreateWhiteListFrame(); - return true; - } - - public bool CloseFrame(GUIButton button=null, object obj=null) - { - whitelistFrame = null; + if (whitelistFrame != null) + { + CreateWhiteListFrame(whitelistFrame.Parent); + } return true; } } diff --git a/Subsurface/Source/Screens/NetLobbyScreen.cs b/Subsurface/Source/Screens/NetLobbyScreen.cs index 351ff3f15..dc08f6bc9 100644 --- a/Subsurface/Source/Screens/NetLobbyScreen.cs +++ b/Subsurface/Source/Screens/NetLobbyScreen.cs @@ -398,10 +398,6 @@ namespace Barotrauma settingsButton.OnClicked = GameMain.Server.ToggleSettingsFrame; settingsButton.UserData = "settingsButton"; - GUIButton whitelistButton = new GUIButton(new Rectangle(-200, 0, 80, 30), "Whitelist", Alignment.BottomRight, GUI.Style, infoFrame); - whitelistButton.OnClicked = GameMain.Server.ToggleWhiteListFrame; - whitelistButton.UserData = "whitelistButton"; - if (subList.Selected == null) subList.Select(Math.Max(0, prevSelectedSub)); if (shuttleList.Selected == null) { From e61e40547b4fb3523919f2b6110baebd9dd7fb4e Mon Sep 17 00:00:00 2001 From: Regalis Date: Tue, 6 Sep 2016 19:14:27 +0300 Subject: [PATCH 2/5] Improved autopilot --- .../Items/Components/Machines/Engine.cs | 3 +- .../Items/Components/Machines/Steering.cs | 67 ++++++++++++++++--- 2 files changed, 58 insertions(+), 12 deletions(-) diff --git a/Subsurface/Source/Items/Components/Machines/Engine.cs b/Subsurface/Source/Items/Components/Machines/Engine.cs index bf3be00fe..7300050ad 100644 --- a/Subsurface/Source/Items/Components/Machines/Engine.cs +++ b/Subsurface/Source/Items/Components/Machines/Engine.cs @@ -133,8 +133,7 @@ namespace Barotrauma.Items.Components float tempForce; if (float.TryParse(signal, NumberStyles.Float, CultureInfo.InvariantCulture, out tempForce)) { - targetForce = tempForce; - targetForce = MathHelper.Clamp(targetForce, -100.0f, 100.0f); + targetForce = MathHelper.Clamp(tempForce, -100.0f, 100.0f); } } } diff --git a/Subsurface/Source/Items/Components/Machines/Steering.cs b/Subsurface/Source/Items/Components/Machines/Steering.cs index 9a4e6cdf4..7cc423a74 100644 --- a/Subsurface/Source/Items/Components/Machines/Steering.cs +++ b/Subsurface/Source/Items/Components/Machines/Steering.cs @@ -7,12 +7,13 @@ using System.Globalization; using System.Linq; using System.Text; using System.Xml.Linq; +using Voronoi2; namespace Barotrauma.Items.Components { class Steering : Powered { - private const float AutopilotRayCastInterval = 5.0f; + private const float AutopilotRayCastInterval = 0.5f; private Vector2 currVelocity; private Vector2 targetVelocity; @@ -178,9 +179,7 @@ namespace Barotrauma.Items.Components GUI.DrawString(spriteBatch, new Vector2(x + 20, y + height - 30), "Depth: " + (int)realWorldDepth + " m", Color.LightGreen, null, 0, GUI.SmallFont); } - - GUI.DrawLine(spriteBatch, new Vector2(velRect.Center.X,velRect.Center.Y), new Vector2(velRect.Center.X + currVelocity.X, velRect.Center.Y - currVelocity.Y), @@ -208,7 +207,7 @@ namespace Barotrauma.Items.Components } } } - + private void UpdateAutoPilot(float deltaTime) { if (posToMaintain != null) @@ -255,22 +254,72 @@ namespace Barotrauma.Items.Components SteerTowardsPosition(steeringPath.CurrentNode.WorldPosition); } + float avoidRadius = Math.Max(item.Submarine.Borders.Width, item.Submarine.Borders.Height) * 2.0f; + avoidRadius = Math.Max(avoidRadius, 2000.0f); + + Vector2 avoidStrength = Vector2.Zero; + + //steer away from nearby walls + var closeCells = Level.Loaded.GetCells(item.Submarine.WorldPosition, 4); + foreach (VoronoiCell cell in closeCells) + { + foreach (GraphEdge edge in cell.edges) + { + var intersection = MathUtils.GetLineIntersection(edge.point1, edge.point2, item.Submarine.WorldPosition, cell.Center); + if (intersection != null) + { + Vector2 diff = item.Submarine.WorldPosition - (Vector2)intersection; + + //far enough -> ignore + if (diff.Length() > avoidRadius) continue; + + float dot = item.Submarine.Velocity == Vector2.Zero ? + 0.0f : Vector2.Dot(Vector2.Normalize(item.Submarine.Velocity), -Vector2.Normalize(diff)); + + //heading away from the wall -> ignore + if (dot < 0) continue; + + Vector2 change = (Vector2.Normalize(diff) * Math.Max((avoidRadius - diff.Length()), 0.0f)) / avoidRadius; + + avoidStrength += change * dot; + } + } + } + + targetVelocity += avoidStrength * 100.0f; + + //steer away from other subs foreach (Submarine sub in Submarine.Loaded) { if (sub == item.Submarine) continue; + if (item.Submarine.DockedTo.Contains(sub)) continue; float thisSize = Math.Max(item.Submarine.Borders.Width, item.Submarine.Borders.Height); float otherSize = Math.Max(sub.Borders.Width, sub.Borders.Height); - - Vector2 diff = sub.WorldPosition - item.Submarine.WorldPosition; + + Vector2 diff = item.Submarine.WorldPosition - sub.WorldPosition; float dist = diff == Vector2.Zero ? 0.0f : diff.Length(); + //far enough -> ignore if (dist > thisSize + otherSize) continue; diff = Vector2.Normalize(diff); - TargetVelocity = Vector2.Lerp(-diff * 100.0f, TargetVelocity, (dist / (thisSize + otherSize)) - 0.5f); + float dot = item.Submarine.Velocity == Vector2.Zero ? + 0.0f : Vector2.Dot(Vector2.Normalize(item.Submarine.Velocity), -Vector2.Normalize(diff)); + + //heading away -> ignore + if (dot < 0.0f) continue; + + targetVelocity += diff * 200.0f; + } + + //clamp velocity magnitude to 100.0f + float velMagnitude = targetVelocity.Length(); + if (velMagnitude > 100.0f) + { + targetVelocity *= 100.0f / velMagnitude; } } @@ -291,10 +340,8 @@ namespace Barotrauma.Items.Components { TargetVelocity = targetSpeed/5.0f; } - - } - + private bool ToggleMaintainPosition(GUITickBox tickBox) { valueChanged = true; From d884f23a72c7267226fd8ed188641eca002b7456 Mon Sep 17 00:00:00 2001 From: Regalis Date: Wed, 7 Sep 2016 15:18:01 +0300 Subject: [PATCH 3/5] v5.1.3: the upper border of the level is one continuous body instead of two separate bodies at the entrance and exit --- Subsurface/Properties/AssemblyInfo.cs | 4 ++-- Subsurface/Source/Map/Levels/Level.cs | 24 ++++++++----------- Subsurface/Source/Map/Levels/LevelRenderer.cs | 15 ++++-------- Subsurface/Source/Map/TransitionCinematic.cs | 5 ++-- .../Source/Networking/RespawnManager.cs | 8 +++---- Subsurface/changelog.txt | 12 ++++++++++ 6 files changed, 34 insertions(+), 34 deletions(-) diff --git a/Subsurface/Properties/AssemblyInfo.cs b/Subsurface/Properties/AssemblyInfo.cs index 87be44ef2..019e0fc0a 100644 --- a/Subsurface/Properties/AssemblyInfo.cs +++ b/Subsurface/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.5.1.2")] -[assembly: AssemblyFileVersion("0.5.1.2")] +[assembly: AssemblyVersion("0.5.1.3")] +[assembly: AssemblyFileVersion("0.5.1.3")] diff --git a/Subsurface/Source/Map/Levels/Level.cs b/Subsurface/Source/Map/Levels/Level.cs index 2fb7dbe02..d60196be0 100644 --- a/Subsurface/Source/Map/Levels/Level.cs +++ b/Subsurface/Source/Map/Levels/Level.cs @@ -113,7 +113,7 @@ namespace Barotrauma private set; } - public Body[] ShaftBodies + public Body ShaftBody { get; private set; @@ -511,21 +511,17 @@ namespace Barotrauma cells.AddRange(wrappingWalls[side, i].Cells); } } + + ShaftBody = BodyFactory.CreateEdge(GameMain.World, + ConvertUnits.ToSimUnits(new Vector2(borders.X, 0)), + ConvertUnits.ToSimUnits(new Vector2(borders.Right, 0))); + ShaftBody.SetTransform(ConvertUnits.ToSimUnits(new Vector2(0.0f, borders.Height)), 0.0f); + + ShaftBody.BodyType = BodyType.Static; + ShaftBody.CollisionCategories = Physics.CollisionLevel; - ShaftBodies = new Body[2]; - for (int i = 0; i < 2; i++) - { - ShaftBodies[i] = BodyFactory.CreateRectangle(GameMain.World, 200.0f, ConvertUnits.ToSimUnits(ShaftHeight), 5.0f); - ShaftBodies[i].BodyType = BodyType.Static; - ShaftBodies[i].CollisionCategories = Physics.CollisionLevel; - - Vector2 shaftPos = (i == 0) ? startPosition : endPosition; - shaftPos.Y = borders.Height + 150.0f; - - ShaftBodies[i].SetTransform(ConvertUnits.ToSimUnits(shaftPos), 0.0f); - bodies.Add(ShaftBodies[i]); - } + bodies.Add(ShaftBody); foreach (VoronoiCell cell in cells) { diff --git a/Subsurface/Source/Map/Levels/LevelRenderer.cs b/Subsurface/Source/Map/Levels/LevelRenderer.cs index 6324bcd89..c2f64a0b3 100644 --- a/Subsurface/Source/Map/Levels/LevelRenderer.cs +++ b/Subsurface/Source/Map/Levels/LevelRenderer.cs @@ -172,11 +172,10 @@ namespace Barotrauma } } - //RuinGeneration.RuinGenerator.Draw(spriteBatch); } - Vector2 pos = new Vector2(0.0f, -level.Size.Y);// level.EndPosition; + Vector2 pos = new Vector2(0.0f, -level.Size.Y); if (GameMain.GameScreen.Cam.WorldView.Y < -pos.Y - 1024) return; @@ -184,20 +183,14 @@ namespace Barotrauma int width = (int)(Math.Ceiling(GameMain.GameScreen.Cam.WorldView.Width / 1024 + 4.0f) * 1024); - GUI.DrawRectangle(spriteBatch,new Rectangle((int)(MathUtils.Round(pos.X, 1024)), (int)-GameMain.GameScreen.Cam.WorldView.Y, width, (int)(GameMain.GameScreen.Cam.WorldView.Y - level.Size.Y) + 30),Color.Black, true); + GUI.DrawRectangle(spriteBatch,new Rectangle((int)(MathUtils.Round(pos.X, 1024)), (int)-GameMain.GameScreen.Cam.WorldView.Y, width, (int)(GameMain.GameScreen.Cam.WorldView.Y + pos.Y) - 30),Color.Black, true); spriteBatch.Draw(shaftTexture, - new Rectangle((int)(MathUtils.Round(pos.X, 1024)), (int)pos.Y, width, 1024), - new Rectangle(0, 0, width, 1024), + new Rectangle((int)(MathUtils.Round(pos.X, 1024)), (int)pos.Y-1000, width, 1024), + new Rectangle(0, 0, width, -1024), level.BackgroundColor, 0.0f, Vector2.Zero, SpriteEffects.None, 0.0f); - - - //background.DrawTiled(spriteBatch, - // (backgroundPos.Y < 0) ? new Vector2(0.0f, -backgroundPos.Y) : Vector2.Zero, - // new Vector2(GameMain.GraphicsWidth, 1024 - backgroundPos.Y), - // Vector2.Zero, level.BackgroundColor); } diff --git a/Subsurface/Source/Map/TransitionCinematic.cs b/Subsurface/Source/Map/TransitionCinematic.cs index 6d3449f6c..c6049a701 100644 --- a/Subsurface/Source/Map/TransitionCinematic.cs +++ b/Subsurface/Source/Map/TransitionCinematic.cs @@ -58,8 +58,7 @@ namespace Barotrauma //Vector2 diff = targetPos - sub.Position; float targetSpeed = 10.0f; - Level.Loaded.ShaftBodies[0].Enabled = false; - Level.Loaded.ShaftBodies[1].Enabled = false; + Level.Loaded.ShaftBody.Enabled = false; cam.TargetPos = Vector2.Zero; float timer = 0.0f; @@ -79,7 +78,7 @@ namespace Barotrauma cam.Zoom = Math.Max(0.2f, cam.Zoom - CoroutineManager.UnscaledDeltaTime * 0.1f); Vector2 cameraPos = subs.First().Position + Submarine.MainSub.HiddenSubPosition; - cameraPos.Y = Math.Min(cameraPos.Y, ConvertUnits.ToDisplayUnits(Level.Loaded.ShaftBodies[0].Position.Y) - cam.WorldView.Height/2.0f); + cameraPos.Y = Math.Min(cameraPos.Y, ConvertUnits.ToDisplayUnits(Level.Loaded.ShaftBody.Position.Y) - cam.WorldView.Height/2.0f); GUI.ScreenOverlayColor = Color.Lerp(Color.TransparentBlack, Color.Black, timer/duration); diff --git a/Subsurface/Source/Networking/RespawnManager.cs b/Subsurface/Source/Networking/RespawnManager.cs index 3940e64a3..f10a63004 100644 --- a/Subsurface/Source/Networking/RespawnManager.cs +++ b/Subsurface/Source/Networking/RespawnManager.cs @@ -232,7 +232,7 @@ namespace Barotrauma.Networking { updateReturnTimer = 0.0f; - respawnShuttle.SubBody.Body.IgnoreCollisionWith(Level.Loaded.ShaftBodies[0]); + respawnShuttle.SubBody.Body.IgnoreCollisionWith(Level.Loaded.ShaftBody); shuttleSteering.AutoPilot = true; shuttleSteering.MaintainPos = false; @@ -302,7 +302,7 @@ namespace Barotrauma.Networking private IEnumerable ForceShuttleToPos(Vector2 position, float speed) { - respawnShuttle.SubBody.Body.IgnoreCollisionWith(Level.Loaded.ShaftBodies[0]); + respawnShuttle.SubBody.Body.IgnoreCollisionWith(Level.Loaded.ShaftBody); while (Math.Abs(position.Y - respawnShuttle.WorldPosition.Y) > 100.0f) { @@ -313,7 +313,7 @@ namespace Barotrauma.Networking if (respawnShuttle.SubBody == null) yield return CoroutineStatus.Success; } - respawnShuttle.SubBody.Body.RestoreCollisionWith(Level.Loaded.ShaftBodies[0]); + respawnShuttle.SubBody.Body.RestoreCollisionWith(Level.Loaded.ShaftBody); yield return CoroutineStatus.Success; } @@ -378,7 +378,7 @@ namespace Barotrauma.Networking respawnShuttle.Velocity = Vector2.Zero; - respawnShuttle.SubBody.Body.RestoreCollisionWith(Level.Loaded.ShaftBodies[0]); + respawnShuttle.SubBody.Body.RestoreCollisionWith(Level.Loaded.ShaftBody); } diff --git a/Subsurface/changelog.txt b/Subsurface/changelog.txt index 6d3e0eb50..5e8767ab3 100644 --- a/Subsurface/changelog.txt +++ b/Subsurface/changelog.txt @@ -1,3 +1,15 @@ +--------------------------------------------------------------------------------------------------------- +v0.5.1.3 +--------------------------------------------------------------------------------------------------------- + +- server whitelists +- a new monster +- improved autopilot +- background sprites and creatures can be customized via Content Packages +- Linux clients can connect to Windows servers again (and vice versa) +- fixed the upper boundary of the level occasionally being possible to pass through +- textboxes can't be selected through other UI elements anymore + --------------------------------------------------------------------------------------------------------- v0.5.1.2 --------------------------------------------------------------------------------------------------------- From 9463b18993cca8247d5ee3f0e053927f40393c19 Mon Sep 17 00:00:00 2001 From: Regalis Date: Wed, 7 Sep 2016 18:19:42 +0300 Subject: [PATCH 4/5] Huskification bugfixes --- Subsurface/Source/Characters/Character.cs | 4 ++-- Subsurface/Source/Characters/HuskInfection.cs | 11 +---------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs index 337049b56..a9f4fed7d 100644 --- a/Subsurface/Source/Characters/Character.cs +++ b/Subsurface/Source/Characters/Character.cs @@ -1608,7 +1608,7 @@ namespace Barotrauma message.WriteRangedSingle(health, minHealth, maxHealth, 8); - if (AnimController.StunTimer <= 0.0f && bleeding <= 0.0f && oxygen > 99.0f) + if (AnimController.StunTimer <= 0.0f && bleeding <= 0.0f && oxygen > 99.0f && huskInfection == null) { message.Write(true); } @@ -1856,7 +1856,7 @@ namespace Barotrauma break; case NetworkEventType.EntityUpdate: - Enabled = true; + if (GameMain.Client != null) Enabled = true; Vector2 relativeCursorPos = Vector2.Zero; diff --git a/Subsurface/Source/Characters/HuskInfection.cs b/Subsurface/Source/Characters/HuskInfection.cs index dcd8243b0..4afbcff8f 100644 --- a/Subsurface/Source/Characters/HuskInfection.cs +++ b/Subsurface/Source/Characters/HuskInfection.cs @@ -99,14 +99,6 @@ namespace Barotrauma } character.AddDamage(CauseOfDeath.Husk, 0.5f*deltaTime, null); - - if (character.AnimController.limbJoints[0].LimitEnabled && - (character.AnimController.CurrentHull == null || - character.AnimController.CurrentHull.LethalPressure > 50.0f)) - { - character.BreakJoints(); - character.AnimController.limbJoints.Last().LimitEnabled = true; - } } @@ -142,11 +134,10 @@ namespace Barotrauma } var torso = character.AnimController.GetLimb(LimbType.Torso); - torso.body.SetTransform(torso.SimPosition, 0.0f); var newLimb = new Limb(character, limbElement); newLimb.body.Submarine = character.Submarine; - newLimb.body.SetTransform(torso.SimPosition, 0.0f); + newLimb.body.SetTransform(torso.SimPosition, torso.Rotation); character.AnimController.AddLimb(newLimb); character.AnimController.AddJoint(jointElement); From 94cec67a2b724c5e9a3b4ca3430fe5c6514c9be3 Mon Sep 17 00:00:00 2001 From: Regalis Date: Wed, 7 Sep 2016 20:18:52 +0300 Subject: [PATCH 5/5] Characters that aren't inside a hull or can't enter subs won't attempt to play a walking animation --- Subsurface/Source/Characters/Animation/FishAnimController.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Subsurface/Source/Characters/Animation/FishAnimController.cs b/Subsurface/Source/Characters/Animation/FishAnimController.cs index 3d9fee235..a800dd0e1 100644 --- a/Subsurface/Source/Characters/Animation/FishAnimController.cs +++ b/Subsurface/Source/Characters/Animation/FishAnimController.cs @@ -77,7 +77,7 @@ namespace Barotrauma { UpdateSineAnim(deltaTime); } - else + else if (currentHull != null && CanEnterSubmarine) { UpdateWalkAnim(deltaTime); } @@ -119,7 +119,6 @@ namespace Barotrauma } } - //if (stunTimer > gameTime.TotalGameTime.TotalMilliseconds) return; if (!flip) return; flipTimer += deltaTime;