From 09782be2318f264aec504251ae166a57764baeac Mon Sep 17 00:00:00 2001 From: Regalis Date: Mon, 25 Jul 2016 18:30:13 +0300 Subject: [PATCH] - sonar shows the outlines of docked subs (instead of normal sonar blips) - fixed lights not being removed if the same explosion is triggered again before the previous one is finished - fixed electrical shocks from junction boxes stunning nearby players (and not just the player using the jb) - showing restart timer as mins + secs - more server settings --- .../Content/Items/Electricity/poweritems.xml | 2 +- .../Source/Items/Components/Machines/Radar.cs | 25 +++-- .../Components/Signal/ConnectionPanel.cs | 2 + Subsurface/Source/Map/Explosion.cs | 14 +-- .../Source/Networking/GameServerSettings.cs | 103 ++++++++++++++---- Subsurface/Source/Screens/GameScreen.cs | 3 +- Subsurface/Source/Screens/NetLobbyScreen.cs | 4 +- Subsurface/Source/Utils/ToolBox.cs | 17 +++ 8 files changed, 127 insertions(+), 43 deletions(-) diff --git a/Subsurface/Content/Items/Electricity/poweritems.xml b/Subsurface/Content/Items/Electricity/poweritems.xml index ec8bbc4fb..d7b33a2ad 100644 --- a/Subsurface/Content/Items/Electricity/poweritems.xml +++ b/Subsurface/Content/Items/Electricity/poweritems.xml @@ -23,7 +23,7 @@ - + diff --git a/Subsurface/Source/Items/Components/Machines/Radar.cs b/Subsurface/Source/Items/Components/Machines/Radar.cs index 905c6a1b8..7c23f8b02 100644 --- a/Subsurface/Source/Items/Components/Machines/Radar.cs +++ b/Subsurface/Source/Items/Components/Machines/Radar.cs @@ -114,7 +114,7 @@ namespace Barotrauma.Items.Components private void DrawRadar(SpriteBatch spriteBatch, Rectangle rect) { - Vector2 center = new Vector2(rect.X + rect.Width*0.75f, rect.Center.Y); + Vector2 center = new Vector2(rect.X + rect.Width*0.5f, rect.Center.Y); if (!IsActive) return; @@ -128,6 +128,8 @@ namespace Barotrauma.Items.Components foreach (Submarine submarine in Submarine.Loaded) { if (item.Submarine == submarine && !DetectSubmarineWalls) continue; + if (item.Submarine != null && item.Submarine.DockedTo.Contains(submarine)) continue; + if (submarine.HullVertices == null) continue; for (int i = 0; i < submarine.HullVertices.Count; i++) { @@ -152,16 +154,21 @@ namespace Barotrauma.Items.Components { float simScale = displayScale * Physics.DisplayToSimRation; - Vector2 offset = ConvertUnits.ToSimUnits(item.Submarine.WorldPosition - item.WorldPosition); - - for (int i = 0; i < item.Submarine.HullVertices.Count; i++) + foreach (Submarine submarine in Submarine.Loaded) { - Vector2 start = (item.Submarine.HullVertices[i] + offset) * simScale; - start.Y = -start.Y; - Vector2 end = (item.Submarine.HullVertices[(i + 1) % item.Submarine.HullVertices.Count] + offset) * simScale; - end.Y = -end.Y; + if (submarine != item.Submarine && !submarine.DockedTo.Contains(item.Submarine)) continue; - GUI.DrawLine(spriteBatch, center + start, center + end, Color.Green); + Vector2 offset = ConvertUnits.ToSimUnits(submarine.WorldPosition - item.WorldPosition); + + for (int i = 0; i < submarine.HullVertices.Count; i++) + { + Vector2 start = (submarine.HullVertices[i] + offset) * simScale; + start.Y = -start.Y; + Vector2 end = (submarine.HullVertices[(i + 1) % submarine.HullVertices.Count] + offset) * simScale; + end.Y = -end.Y; + + GUI.DrawLine(spriteBatch, center + start, center + end, Color.Green); + } } } diff --git a/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs b/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs index dbde159be..43a8be392 100644 --- a/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs +++ b/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs @@ -89,6 +89,8 @@ namespace Barotrauma.Items.Components float degreeOfSuccess = DegreeOfSuccess(character); if (Rand.Range(0.0f, 50.0f) < degreeOfSuccess) return false; + character.StartStun(5.0f); + item.ApplyStatusEffects(ActionType.OnFailure, 1.0f, character); return true; diff --git a/Subsurface/Source/Map/Explosion.cs b/Subsurface/Source/Map/Explosion.cs index e252a6d5f..de65641be 100644 --- a/Subsurface/Source/Map/Explosion.cs +++ b/Subsurface/Source/Map/Explosion.cs @@ -11,9 +11,7 @@ namespace Barotrauma private Attack attack; private float force; - - private LightSource light; - + public float CameraShake; private bool sparks, shockwave, flames; @@ -30,7 +28,7 @@ namespace Barotrauma CameraShake = ToolBox.GetAttributeFloat(element, "camerashake", attack.Range*0.1f); } - + public void Explode(Vector2 worldPosition) { Hull hull = Hull.FindHull(worldPosition); @@ -62,8 +60,8 @@ namespace Barotrauma float displayRange = attack.Range; if (displayRange < 0.1f) return; - light = new LightSource(worldPosition, displayRange, Color.LightYellow, null); - CoroutineManager.StartCoroutine(DimLight()); + var light = new LightSource(worldPosition, displayRange, Color.LightYellow, null); + CoroutineManager.StartCoroutine(DimLight(light)); float cameraDist = Vector2.Distance(GameMain.GameScreen.Cam.Position, worldPosition)/2.0f; GameMain.GameScreen.Cam.Shake = CameraShake * Math.Max((displayRange - cameraDist) / displayRange, 0.0f); @@ -92,7 +90,7 @@ namespace Barotrauma } - private IEnumerable DimLight() + private IEnumerable DimLight(LightSource light) { float currBrightness= 1.0f; float startRange = light.Range; @@ -102,7 +100,7 @@ namespace Barotrauma light.Color = new Color(light.Color.R, light.Color.G, light.Color.B, currBrightness); light.Range = startRange * currBrightness; - currBrightness -= 0.05f; + currBrightness -= CoroutineManager.DeltaTime*10.0f; yield return CoroutineStatus.Running; } diff --git a/Subsurface/Source/Networking/GameServerSettings.cs b/Subsurface/Source/Networking/GameServerSettings.cs index 5b0771e42..a11d2c2b1 100644 --- a/Subsurface/Source/Networking/GameServerSettings.cs +++ b/Subsurface/Source/Networking/GameServerSettings.cs @@ -34,7 +34,6 @@ namespace Barotrauma.Networking private TimeSpan sparseUpdateInterval = new TimeSpan(0, 0, 0, 3); private SelectionMode subSelectionMode, modeSelectionMode; - private bool registeredToMaster; @@ -57,6 +56,29 @@ namespace Barotrauma.Networking private set; } + + [HasDefaultValue(120.0f, true)] + public float RespawnInterval + { + get; + private set; + } + + [HasDefaultValue(60.0f, true)] + public float MaxTransportTime + { + get; + private set; + } + + [HasDefaultValue(0.2f, true)] + public float MinRespawnRatio + { + get; + private set; + } + + [HasDefaultValue(60.0f, true)] public float AutoRestartInterval { @@ -150,9 +172,19 @@ namespace Barotrauma.Networking private set; } - public float EndVoteRequiredRatio = 0.5f; + [HasDefaultValue(0.6f, true)] + public float EndVoteRequiredRatio + { + get; + private set; + } - public float KickVoteRequiredRatio = 0.5f; + [HasDefaultValue(0.6f, true)] + public float KickVoteRequiredRatio + { + get; + private set; + } private void SaveSettings() { @@ -195,7 +227,9 @@ namespace Barotrauma.Networking Enum.TryParse(ToolBox.GetAttributeString(doc.Root, "ModeSelection", "Manual"), out modeSelectionMode); Voting.AllowModeVoting = modeSelectionMode == SelectionMode.Vote; - FileStreamSender.MaxTransferDuration = new TimeSpan(0,0,ToolBox.GetAttributeInt(doc.Root, "MaxFileTransferDuration", 150)); + FileStreamSender.MaxTransferDuration = new TimeSpan(0,0,ToolBox.GetAttributeInt(doc.Root, "MaxFileTransferDuration", 150)); + + showLogButton.Visible = SaveServerLogs; } private void CreateSettingsFrame() @@ -221,14 +255,6 @@ namespace Barotrauma.Networking settingsTabs[2].Padding = Vector4.Zero; - //var gameTabButton = new GUIButton(new Rectangle(0, 35, 100, 20), "Rounds", GUI.Style, innerFrame); - //gameTabButton.UserData = 0; - //gameTabButton.OnClicked = SelectSettingsTab; - - //var serverTabButton = new GUIButton(new Rectangle(105, 35, 100, 20), "Server", GUI.Style, innerFrame); - //serverTabButton.UserData = 1; - //serverTabButton.OnClicked = SelectSettingsTab; - SelectSettingsTab(null, 0); var closeButton = new GUIButton(new Rectangle(10, 10, 100, 20), "Close", Alignment.BottomRight, GUI.Style, innerFrame); @@ -306,22 +332,48 @@ namespace Barotrauma.Networking return true; }; - y += 40; + var respawnIntervalText = new GUITextBlock(new Rectangle(20, y + 20, 20, 20), "Respawn interval", GUI.Style, settingsTabs[0], GUI.SmallFont); - var randomizeLevelBox = new GUITickBox(new Rectangle(0, y, 20, 20), "Randomize level seed between rounds", Alignment.Left, settingsTabs[0]); - randomizeLevelBox.Selected = RandomizeSeed; - randomizeLevelBox.OnSelected = (GUITickBox) => + var respawnIntervalSlider = new GUIScrollBar(new Rectangle(150, y + 22, 100, 10), GUI.Style, 0.1f, settingsTabs[0]); + respawnIntervalSlider.UserData = respawnIntervalText; + respawnIntervalSlider.Step = 0.05f; + respawnIntervalSlider.BarScroll = RespawnInterval / 600.0f; + respawnIntervalSlider.OnMoved = (GUIScrollBar scrollBar, float barScroll) => { - RandomizeSeed = GUITickBox.Selected; + GUITextBlock text = scrollBar.UserData as GUITextBlock; + + RespawnInterval = Math.Max(barScroll * 600.0f, 10.0f); + text.Text = "Interval: " + ToolBox.SecondsToReadableTime(RespawnInterval); return true; }; + respawnIntervalSlider.OnMoved(respawnIntervalSlider, respawnIntervalSlider.BarScroll); + + y += 40; + + var minRespawnText = new GUITextBlock(new Rectangle(0, y, 200, 20), "Minimum players to respawn", GUI.Style, settingsTabs[0]); + minRespawnText.ToolTip = "What percentage of players has to be dead/spectating until a respawn shuttle is dispatched"; + + var minRespawnSlider = new GUIScrollBar(new Rectangle(150, y + 22, 100, 10), GUI.Style, 0.1f, settingsTabs[0]); + minRespawnSlider.ToolTip = minRespawnText.ToolTip; + minRespawnSlider.UserData = minRespawnText; + minRespawnSlider.Step = 0.1f; + minRespawnSlider.BarScroll = MinRespawnRatio; + minRespawnSlider.OnMoved = (GUIScrollBar scrollBar, float barScroll) => + { + GUITextBlock voteText = scrollBar.UserData as GUITextBlock; + + MinRespawnRatio = barScroll; + voteText.Text = "Minimum players to respawn: " + (int)MathUtils.Round(MinRespawnRatio * 100.0f, 10.0f) + " %"; + return true; + }; + minRespawnSlider.OnMoved(minRespawnSlider, MinRespawnRatio); y += 40; //-------------------------------------------------------------------------------- - // game settings + // server settings //-------------------------------------------------------------------------------- y = 0; @@ -330,7 +382,7 @@ namespace Barotrauma.Networking var startIntervalText = new GUITextBlock(new Rectangle(-10, y, 100, 20), "Autorestart delay", GUI.Style, settingsTabs[1]); var startIntervalSlider = new GUIScrollBar(new Rectangle(10, y + 22, 100, 10), GUI.Style, 0.1f, settingsTabs[1]); startIntervalSlider.UserData = startIntervalText; - startIntervalSlider.Step = 0.1f; + startIntervalSlider.Step = 0.05f; startIntervalSlider.BarScroll = AutoRestartInterval / 300.0f; startIntervalSlider.OnMoved = (GUIScrollBar scrollBar, float barScroll) => { @@ -338,9 +390,7 @@ namespace Barotrauma.Networking AutoRestartInterval = Math.Max(barScroll * 300.0f, 10.0f); - var timeSpan = new TimeSpan(0, 0, (int)AutoRestartInterval); - - text.Text = "Autorestart delay: " + timeSpan.ToString("mm':'ss"); + text.Text = "Autorestart delay: " + ToolBox.SecondsToReadableTime(AutoRestartInterval); return true; }; startIntervalSlider.OnMoved(startIntervalSlider, startIntervalSlider.BarScroll); @@ -392,6 +442,15 @@ namespace Barotrauma.Networking return true; }; + y += 40; + + var randomizeLevelBox = new GUITickBox(new Rectangle(0, y, 20, 20), "Randomize level seed between rounds", Alignment.Left, settingsTabs[1]); + randomizeLevelBox.Selected = RandomizeSeed; + randomizeLevelBox.OnSelected = (GUITickBox) => + { + RandomizeSeed = GUITickBox.Selected; + return true; + }; y += 40; diff --git a/Subsurface/Source/Screens/GameScreen.cs b/Subsurface/Source/Screens/GameScreen.cs index aa1f947b1..426992eeb 100644 --- a/Subsurface/Source/Screens/GameScreen.cs +++ b/Subsurface/Source/Screens/GameScreen.cs @@ -92,7 +92,8 @@ namespace Barotrauma if (PlayerInput.KeyDown(Keys.J)) targetMovement.X -= 1.0f; if (PlayerInput.KeyDown(Keys.L)) targetMovement.X += 1.0f; - GameMain.GameSession.Submarine.ApplyForce(targetMovement * 100000.0f); + if (targetMovement != Vector2.Zero) + GameMain.GameSession.Submarine.ApplyForce(targetMovement * GameMain.GameSession.Submarine.SubBody.Body.Mass * 100.0f); } #endif diff --git a/Subsurface/Source/Screens/NetLobbyScreen.cs b/Subsurface/Source/Screens/NetLobbyScreen.cs index 5033aa858..5cede6890 100644 --- a/Subsurface/Source/Screens/NetLobbyScreen.cs +++ b/Subsurface/Source/Screens/NetLobbyScreen.cs @@ -136,10 +136,10 @@ namespace Barotrauma if (GameMain.Server != null) { if (!GameMain.Server.AutoRestart) return ""; - return "Restarting in " + (int)GameMain.Server.AutoRestartTimer; + return "Restarting in " + ToolBox.SecondsToReadableTime(GameMain.Server.AutoRestartTimer); } if (autoRestartTimer == 0.0f) return ""; - return "Restarting in " + (int)autoRestartTimer; + return "Restarting in " + ToolBox.SecondsToReadableTime(autoRestartTimer); } public NetLobbyScreen() diff --git a/Subsurface/Source/Utils/ToolBox.cs b/Subsurface/Source/Utils/ToolBox.cs index 295777dc5..49c1af3de 100644 --- a/Subsurface/Source/Utils/ToolBox.cs +++ b/Subsurface/Source/Utils/ToolBox.cs @@ -411,6 +411,23 @@ namespace Barotrauma return wrappedText.ToString(); } + public static string SecondsToReadableTime(float seconds) + { + if (seconds <= 60.0f) + { + return (int)seconds + " s"; + } + else + { + int m = (int)(seconds / 60.0f); + int s = (int)(seconds % 60.0f); + + return s == 0 ? + m + " m" : + m + " m " + s + " s"; + } + } + public static string GetRandomLine(string filePath) { try