Skip to content

Commit

Permalink
Fix incompatibility with Zetrith's Prepatcher.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Byass committed Nov 25, 2020
1 parent 31b303d commit bb89067
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Binary file modified 1.1-1.2/Assemblies/BetterLoading.dll
Binary file not shown.
11 changes: 10 additions & 1 deletion Source/BetterLoadingMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using RimWorld.Planet;
using UnityEngine;
using Verse;
using Object = UnityEngine.Object;

namespace BetterLoading
{
Expand Down Expand Up @@ -78,8 +79,16 @@ public BetterLoadingMain(ModContentPack content) : base(content)

if (DllPathsThatFailedToLoad.Count == 0)
{
//Prepatcher re-launches the game...
var alreadyCreatedLoadScreens = Object.FindObjectsOfType<Component>().Where(c => c.GetType().FullName.Contains("LoadingScreen")).ToList();
if (alreadyCreatedLoadScreens.Count > 0)
{
Log.Warning("[BetterLoading] [Warning] Loading screen already appears to have been injected. Are we running with prepatcher perchance? Destroying old one and re-making.");
alreadyCreatedLoadScreens.ForEach(Object.Destroy);
LoadingScreen = null;
}
Log.Message("[BetterLoading] Injecting into main UI.");
LoadingScreen = UnityEngine.Object.FindObjectOfType<Root_Entry>().gameObject.AddComponent<LoadingScreen>();
LoadingScreen = Object.FindObjectOfType<Root_Entry>().gameObject.AddComponent<LoadingScreen>();
try
{
LoadingScreen.Background = typeof(UI_BackgroundMain).GetField("BGPlanet", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null) as Texture2D;
Expand Down

0 comments on commit bb89067

Please sign in to comment.