From 5fb983f48f3fa2acc1b16d7fe22e5b8f0a17d6d8 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Wed, 3 Apr 2019 16:26:44 +0300 Subject: [PATCH] (4082dd031) Implemented some more Steam achievements --- .../BarotraumaClient/Source/GameSettings.cs | 3 - .../Items/Components/Signal/LightComponent.cs | 4 ++ .../Source/SteamAchievementManager.cs | 56 ++++++++++++++++++- 3 files changed, 59 insertions(+), 4 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/GameSettings.cs b/Barotrauma/BarotraumaClient/Source/GameSettings.cs index 90b91af33..63584b441 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSettings.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSettings.cs @@ -667,9 +667,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") { 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/SteamAchievementManager.cs b/Barotrauma/BarotraumaShared/Source/SteamAchievementManager.cs index 04e32f2d0..8ab8db1a8 100644 --- a/Barotrauma/BarotraumaShared/Source/SteamAchievementManager.cs +++ b/Barotrauma/BarotraumaShared/Source/SteamAchievementManager.cs @@ -31,6 +31,8 @@ namespace Barotrauma public readonly HashSet ReactorMeltdown = new HashSet(); public readonly HashSet Casualties = new HashSet(); + + public bool SubWasDamaged; } private static RoundData roundData; @@ -110,7 +112,47 @@ namespace Barotrauma UnlockAchievement("subdeep", true, c => c != null && c.Submarine == sub && !c.IsDead && !c.IsUnconscious); } } - } + + if (!roundData.SubWasDamaged) + { + roundData.SubWasDamaged = SubWallsDamaged(Submarine.MainSub); + } + } + + if (GameMain.GameSession != null && Character.Controlled != null) + { + if (Character.Controlled.HasEquippedItem("clownmask") && + Character.Controlled.HasEquippedItem("clowncostume")) + { + UnlockAchievement(Character.Controlled, "clowncostume"); + } + + if (Submarine.MainSub != null && Character.Controlled.Submarine == null) + { + float dist = 500 / Physics.DisplayToRealWorldRatio; + if (Vector2.DistanceSquared(Character.Controlled.WorldPosition, Submarine.MainSub.WorldPosition) > + dist * dist) + { + UnlockAchievement(Character.Controlled, "crewaway"); + } + } + } + } + + private static bool SubWallsDamaged(Submarine sub) + { + foreach (Structure structure in Structure.WallList) + { + if (structure.Submarine != sub || structure.HasBody) { continue; } + for (int i = 0; i < structure.SectionCount; i++) + { + if (structure.SectionIsLeaking(i)) + { + return true; + } + } + } + return false; } public static void OnBiomeDiscovered(Biome biome) @@ -274,14 +316,21 @@ namespace Barotrauma //made it to the destination if (gameSession.Submarine.AtEndPosition) { + bool noDamageRun = !roundData.SubWasDamaged && !roundData.Casualties.Any(c => !(c.AIController is EnemyAIController)); + #if SERVER if (GameMain.Server != null) { //in MP all characters that were inside the sub during reactor meltdown and still alive at the end of the round get an achievement UnlockAchievement("survivereactormeltdown", true, c => c != null && !c.IsDead && roundData.ReactorMeltdown.Contains(c)); + if (noDamageRun) + { + UnlockAchievement("nodamagerun", true, c => c != null && !c.IsDead); + } } #endif #if CLIENT + if (noDamageRun) { UnlockAchievement("nodamagerun"); } if (roundData.ReactorMeltdown.Any()) //in SP getting to the destination after a meltdown is enough { UnlockAchievement("survivereactormeltdown"); @@ -302,6 +351,11 @@ namespace Barotrauma UnlockAchievement(charactersInSub[0], "lonesailor"); } } + foreach (Character character in charactersInSub) + { + if (character.Info.Job == null) { continue; } + UnlockAchievement(character, character.Info.Job.Prefab.Identifier + "round"); + } } }