From 8700c82fde0f21eaf11be42dbccd437a28a1aff9 Mon Sep 17 00:00:00 2001 From: SirWilliam <93367389+SirrWilliam@users.noreply.github.com> Date: Mon, 18 Aug 2025 00:44:10 +0300 Subject: [PATCH 1/3] FactionSidebar Fix +Krafs.Rimworld.Ref updated to latest version + Replaced direct Find.WorldCameraDriver.JumpTo with reflection to avoid TypeLoadException + Odyssey random site selection added --- Source/Client/Factions/FactionSidebar.cs | 23 +++++++++++++++++++++-- Source/Client/Multiplayer.csproj | 2 +- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Source/Client/Factions/FactionSidebar.cs b/Source/Client/Factions/FactionSidebar.cs index 5acf8eb55..d397c894e 100644 --- a/Source/Client/Factions/FactionSidebar.cs +++ b/Source/Client/Factions/FactionSidebar.cs @@ -3,8 +3,10 @@ using Multiplayer.Common; using RimWorld; using RimWorld.Planet; +using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Text; using UnityEngine; using Verse; @@ -341,8 +343,25 @@ private static void DrawFactionCreator(Rect inRect) if (Widgets.ButtonText(selectRandomSiteRect, "MpSelectRandomSite".Translate())) { SoundDefOf.Click.PlayOneShotOnCamera(null); - Find.WorldInterface.SelectedTile = TileFinder.RandomStartingTile(); - Find.WorldCameraDriver.JumpTo(Find.WorldGrid.GetTileCenter(Find.WorldInterface.SelectedTile)); + if (ModsConfig.OdysseyActive && Rand.Bool) + { + Find.WorldInterface.SelectedTile = TileFinder.RandomSettlementTileFor(Find.WorldGrid.Surface, Faction.OfPlayer, true, (PlanetTile x) => x.Tile.Landmark != null); + } + else + { + Find.WorldInterface.SelectedTile = TileFinder.RandomStartingTile(); + } + Vector3 selectedTileCenter = Find.WorldGrid.GetTileCenter(Find.WorldInterface.SelectedTile); + PropertyInfo worldCameraDriver = typeof(Find).GetProperty("WorldCameraDriver", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); + object worldCam = worldCameraDriver?.GetValue(null); + if (worldCam != null) + { + MethodInfo jumpMethod = worldCam.GetType().GetMethod("JumpTo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[] { typeof(Vector3) }, null); + if (jumpMethod != null) + { + jumpMethod.Invoke(worldCam, new object[] { selectedTileCenter }); + } + } } Rect worldFactionsRect = new Rect( diff --git a/Source/Client/Multiplayer.csproj b/Source/Client/Multiplayer.csproj index e85cad9d1..a8e7a9cad 100644 --- a/Source/Client/Multiplayer.csproj +++ b/Source/Client/Multiplayer.csproj @@ -32,7 +32,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + From 826d3ad7c7c8612acd4c0686d5a6037d0126391d Mon Sep 17 00:00:00 2001 From: SirWilliam <93367389+SirrWilliam@users.noreply.github.com> Date: Mon, 18 Aug 2025 01:07:03 +0300 Subject: [PATCH 2/3] Removed reflection --- Source/Client/Factions/FactionSidebar.cs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/Source/Client/Factions/FactionSidebar.cs b/Source/Client/Factions/FactionSidebar.cs index d397c894e..03bc5b3cb 100644 --- a/Source/Client/Factions/FactionSidebar.cs +++ b/Source/Client/Factions/FactionSidebar.cs @@ -350,18 +350,8 @@ private static void DrawFactionCreator(Rect inRect) else { Find.WorldInterface.SelectedTile = TileFinder.RandomStartingTile(); - } - Vector3 selectedTileCenter = Find.WorldGrid.GetTileCenter(Find.WorldInterface.SelectedTile); - PropertyInfo worldCameraDriver = typeof(Find).GetProperty("WorldCameraDriver", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); - object worldCam = worldCameraDriver?.GetValue(null); - if (worldCam != null) - { - MethodInfo jumpMethod = worldCam.GetType().GetMethod("JumpTo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[] { typeof(Vector3) }, null); - if (jumpMethod != null) - { - jumpMethod.Invoke(worldCam, new object[] { selectedTileCenter }); - } - } + } + CameraJumper.TryJumpAndSelect(new GlobalTargetInfo(Find.WorldInterface.SelectedTile), CameraJumper.MovementMode.Pan); } Rect worldFactionsRect = new Rect( From e837a32137723e5b10a141cdbbfed3bcdb260013 Mon Sep 17 00:00:00 2001 From: SirWilliam <93367389+SirrWilliam@users.noreply.github.com> Date: Mon, 18 Aug 2025 01:13:41 +0300 Subject: [PATCH 3/3] Removed unused using directives --- Source/Client/Factions/FactionSidebar.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Source/Client/Factions/FactionSidebar.cs b/Source/Client/Factions/FactionSidebar.cs index 03bc5b3cb..6c09e7af0 100644 --- a/Source/Client/Factions/FactionSidebar.cs +++ b/Source/Client/Factions/FactionSidebar.cs @@ -3,10 +3,8 @@ using Multiplayer.Common; using RimWorld; using RimWorld.Planet; -using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; using System.Text; using UnityEngine; using Verse;