From 64bec6d3b9c18b67bf451f5e66e225d6d881bbab Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Wed, 3 Apr 2019 16:24:20 +0300 Subject: [PATCH] (684bcee1a) Merge branch 'dev' of https://github.com/Regalis11/Barotrauma-development into dev --- .../Source/Characters/Character.cs | 20 +++++-- .../BarotraumaClient/Source/GameSettings.cs | 60 ------------------- .../Source/Characters/Character.cs | 4 +- .../Characters/Health/CharacterHealth.cs | 1 + .../Items/Components/Signal/LightComponent.cs | 4 ++ .../BarotraumaShared/Source/Items/Item.cs | 4 +- .../Source/Physics/PhysicsBody.cs | 6 +- 7 files changed, 29 insertions(+), 70 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Characters/Character.cs b/Barotrauma/BarotraumaClient/Source/Characters/Character.cs index 133b7b355..8a797dfa8 100644 --- a/Barotrauma/BarotraumaClient/Source/Characters/Character.cs +++ b/Barotrauma/BarotraumaClient/Source/Characters/Character.cs @@ -23,6 +23,8 @@ namespace Barotrauma protected float hudInfoTimer; protected bool hudInfoVisible; + private float pressureParticleTimer; + private float findFocusedTimer; protected float lastRecvPositionUpdateTime; @@ -170,13 +172,23 @@ namespace Barotrauma { if (needsAir && pressureProtection < 80.0f && - (AnimController.CurrentHull == null || AnimController.CurrentHull.LethalPressure > 50.0f)) + (AnimController.CurrentHull == null || AnimController.CurrentHull.LethalPressure > 0.0f)) { float pressure = AnimController.CurrentHull == null ? 100.0f : AnimController.CurrentHull.LethalPressure; + if (pressure > 0.0f) + { + float zoomInEffectStrength = MathHelper.Clamp(pressure / 100.0f, 0.1f, 1.0f); + cam.Zoom = MathHelper.Lerp(cam.Zoom, + cam.DefaultZoom + (Math.Max(pressure, 10) / 150.0f) * Rand.Range(0.9f, 1.1f), + zoomInEffectStrength); - cam.Zoom = MathHelper.Lerp(cam.Zoom, - (pressure / 50.0f) * Rand.Range(1.0f, 1.05f), - (pressure - 50.0f) / 50.0f); + pressureParticleTimer += pressure * deltaTime; + if (pressureParticleTimer > 10.0f) + { + Particle p = GameMain.ParticleManager.CreateParticle("waterblood", WorldPosition + Rand.Vector(5.0f), Rand.Vector(10.0f)); + pressureParticleTimer = 0.0f; + } + } } if (IsHumanoid) diff --git a/Barotrauma/BarotraumaClient/Source/GameSettings.cs b/Barotrauma/BarotraumaClient/Source/GameSettings.cs index a875ec131..d46d171a6 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSettings.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSettings.cs @@ -666,66 +666,6 @@ namespace Barotrauma //spacing new GUIFrame(new RectTransform(new Vector2(1.0f, 0.02f), generalLayoutGroup.RectTransform), style: null); - //spacing - new GUIFrame(new RectTransform(new Vector2(1.0f, 0.02f), generalLayoutGroup.RectTransform), style: null); - - new GUIButton(new RectTransform(new Vector2(0.4f, 1.0f), buttonArea.RectTransform, Anchor.BottomLeft), - TextManager.Get("Cancel"), style: "GUIButtonLarge") - { - IgnoreLayoutGroups = true, - OnClicked = (x, y) => - { - if (UnsavedSettings) - { - LoadPlayerConfig(); - } - if (Screen.Selected == GameMain.MainMenuScreen) GameMain.MainMenuScreen.ReturnToMainMenu(null, null); - GUI.SettingsMenuOpen = false; - return true; - } - }; - - //spacing - new GUIFrame(new RectTransform(new Vector2(1.0f, 0.02f), generalLayoutGroup.RectTransform), style: null); - - new GUIButton(new RectTransform(new Vector2(0.4f, 1.0f), buttonArea.RectTransform, Anchor.BottomLeft), - TextManager.Get("Cancel"), style: "GUIButtonLarge") - { - IgnoreLayoutGroups = true, - OnClicked = (x, y) => - { - if (UnsavedSettings) - { - LoadPlayerConfig(); - } - if (Screen.Selected == GameMain.MainMenuScreen) GameMain.MainMenuScreen.ReturnToMainMenu(null, null); - GUI.SettingsMenuOpen = false; - return true; - } - }; - - //spacing - new GUIFrame(new RectTransform(new Vector2(1.0f, 0.02f), generalLayoutGroup.RectTransform), style: null); - - new GUIButton(new RectTransform(new Vector2(0.4f, 1.0f), buttonArea.RectTransform, Anchor.BottomLeft), - TextManager.Get("Cancel"), style: "GUIButtonLarge") - { - IgnoreLayoutGroups = true, - OnClicked = (x, y) => - { - if (UnsavedSettings) - { - LoadPlayerConfig(); - } - if (Screen.Selected == GameMain.MainMenuScreen) GameMain.MainMenuScreen.ReturnToMainMenu(null, null); - GUI.SettingsMenuOpen = false; - return true; - } - }; - - //spacing - new GUIFrame(new RectTransform(new Vector2(1.0f, 0.02f), generalLayoutGroup.RectTransform), style: null); - new GUIButton(new RectTransform(new Vector2(0.4f, 1.0f), buttonArea.RectTransform, Anchor.BottomLeft), TextManager.Get("Cancel"), style: "GUIButtonLarge") { diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Character.cs b/Barotrauma/BarotraumaShared/Source/Characters/Character.cs index c28d67aee..8d0463909 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Character.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Character.cs @@ -1898,7 +1898,7 @@ namespace Barotrauma //cannot be protected from pressure when below crush depth protectedFromPressure = protectedFromPressure && WorldPosition.Y > CharacterHealth.CrushDepth; //implode if not protected from pressure, and either outside or in a high-pressure hull - if (!protectedFromPressure && + if (!protectedFromPressure && (AnimController.CurrentHull == null || AnimController.CurrentHull.LethalPressure >= 80.0f)) { if (CharacterHealth.PressureKillDelay <= 0.0f) @@ -1913,7 +1913,7 @@ namespace Barotrauma if (PressureTimer >= 100.0f) { - if (Controlled == this) cam.Zoom = 5.0f; + if (Controlled == this) { cam.Zoom = 5.0f; } if (GameMain.NetworkMember == null || !GameMain.NetworkMember.IsClient) { Implode(); diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Health/CharacterHealth.cs b/Barotrauma/BarotraumaShared/Source/Characters/Health/CharacterHealth.cs index 5d6f70a83..e7f908c4e 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Health/CharacterHealth.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Health/CharacterHealth.cs @@ -103,6 +103,7 @@ namespace Barotrauma } public float CrushDepth { get; private set; } + public float PressureKillDelay { get; private set; } = 5.0f; public float Vitality { get; private set; } diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/LightComponent.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/LightComponent.cs index 7845f609c..eebf1146a 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/LightComponent.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/LightComponent.cs @@ -26,6 +26,10 @@ namespace Barotrauma.Items.Components private float blinkTimer; + private bool itemLoaded; + + private float blinkTimer; + public PhysicsBody ParentBody; [Editable(MinValueFloat = 0.0f, MaxValueFloat = 2048.0f), Serialize(100.0f, true)] diff --git a/Barotrauma/BarotraumaShared/Source/Items/Item.cs b/Barotrauma/BarotraumaShared/Source/Items/Item.cs index be9212854..0d2b87ba3 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Item.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Item.cs @@ -1208,9 +1208,9 @@ namespace Barotrauma public List GetConnectedComponents(bool recursive = false) where T : ItemComponent { - base.FlipY(relativeToSub); + List connectedComponents = new List(); - if (Prefab.CanSpriteFlipY) + if (recursive) { List alreadySearched = new List() { this }; GetConnectedComponentsRecursive(alreadySearched, connectedComponents); diff --git a/Barotrauma/BarotraumaShared/Source/Physics/PhysicsBody.cs b/Barotrauma/BarotraumaShared/Source/Physics/PhysicsBody.cs index e4ee52c4c..b8823bf70 100644 --- a/Barotrauma/BarotraumaShared/Source/Physics/PhysicsBody.cs +++ b/Barotrauma/BarotraumaShared/Source/Physics/PhysicsBody.cs @@ -646,7 +646,6 @@ namespace Barotrauma /// public void ApplyForce(Vector2 force, float maxVelocity) { - if (!IsValidValue(force, "force", -1e10f, 1e10f)) return; if (!IsValidValue(maxVelocity, "max velocity")) return; Vector2 velocityAddition = force / Mass * (float)Timing.Step; @@ -657,7 +656,10 @@ namespace Barotrauma { newVelocity = newVelocity.ClampLength(maxVelocity); } - body.ApplyForce((newVelocity - body.LinearVelocity) * Mass / (float)Timing.Step); + + Vector2 clampedForce = (newVelocity - body.LinearVelocity) * Mass / (float)Timing.Step; + if (!IsValidValue(force, "clamped force", -1e10f, 1e10f)) return; + body.ApplyForce(force); } public void ApplyForce(Vector2 force, Vector2 point)