From da23df950e453dc812f9523b49f4c93bbeb9227d Mon Sep 17 00:00:00 2001 From: Byte-Nova <159603018+Byte-Nova@users.noreply.github.com> Date: Sun, 6 Oct 2024 12:30:59 +0200 Subject: [PATCH] Small tweaks and cleaning before release --- Source/Client/Managers/RimworldManager.cs | 17 +++++++++-------- Source/Client/Patches/Pages/MainMenuPatches.cs | 17 +++++++++++++++++ Source/Shared/Misc/CommonValues.cs | 2 +- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/Source/Client/Managers/RimworldManager.cs b/Source/Client/Managers/RimworldManager.cs index 56254f29..f11de3f4 100644 --- a/Source/Client/Managers/RimworldManager.cs +++ b/Source/Client/Managers/RimworldManager.cs @@ -228,18 +228,19 @@ public static Pawn[] GetAllSettlementPawns(Faction faction, bool includeAnimals) public static Pawn[] GetPawnsFromMap(Map map, Faction faction, bool includeAnimals) { - if (includeAnimals) return map.mapPawns.AllPawns.Where(fetch => fetch.Faction == faction).ToArray(); - else return map.mapPawns.AllPawns.Where(fetch => fetch.Faction == faction && !DeepScribeHelper.CheckIfThingIsAnimal(fetch)).ToArray(); + if (map == null || map.mapPawns == null) return new Pawn[0]; + else + { + if (includeAnimals) return map.mapPawns.AllPawns.Where(fetch => fetch.Faction == faction).ToArray(); + else return map.mapPawns.AllPawns.Where(fetch => fetch.Faction == faction && !DeepScribeHelper.CheckIfThingIsAnimal(fetch)).ToArray(); + } } public static bool CheckIfMapHasPlayerPawns(Map map) { - if (map == null) return false; - else - { - if (map.mapPawns.AllPawns.FirstOrDefault(fetch => fetch.Faction == Faction.OfPlayer) != null) return true; - else return false; - } + if (map == null || map.mapPawns == null) return false; + else if (map.mapPawns.AllPawns.FirstOrDefault(fetch => fetch.Faction == Faction.OfPlayer) != null) return true; + else return false; } } } diff --git a/Source/Client/Patches/Pages/MainMenuPatches.cs b/Source/Client/Patches/Pages/MainMenuPatches.cs index a4573756..f6ee155b 100644 --- a/Source/Client/Patches/Pages/MainMenuPatches.cs +++ b/Source/Client/Patches/Pages/MainMenuPatches.cs @@ -12,6 +12,23 @@ namespace GameClient { public class MainMenuPatches { + [HarmonyPatch(typeof(VersionControl), nameof(VersionControl.DrawInfoInCorner))] + private static class VersionControl_DrawInfoInCorner_Patch + { + private static void Postfix() + { + string toDisplay = $"RimWorld Together v{CommonValues.executableVersion}"; + Vector2 size = Text.CalcSize(toDisplay); + Rect rect = new Rect(10f, 73f, size.x, size.y); + + Text.Font = GameFont.Small; + + GUI.color = Color.white.ToTransparent(0.5f); + Widgets.Label(rect, toDisplay); + GUI.color = Color.white; + } + } + [HarmonyPatch(typeof(MainMenuDrawer), "DoMainMenuControls")] public static class PatchButton { diff --git a/Source/Shared/Misc/CommonValues.cs b/Source/Shared/Misc/CommonValues.cs index dc8721b0..d3c7b974 100644 --- a/Source/Shared/Misc/CommonValues.cs +++ b/Source/Shared/Misc/CommonValues.cs @@ -2,7 +2,7 @@ namespace Shared { public static class CommonValues { - public readonly static string executableVersion = "dev"; + public readonly static string executableVersion = "24.10.6.1"; public readonly static string clientAssemblyName = "GameClient";