diff --git a/1.3/Assemblies/CameraPlus.dll b/1.3/Assemblies/CameraPlus.dll index 85cb8a1..7551b08 100644 Binary files a/1.3/Assemblies/CameraPlus.dll and b/1.3/Assemblies/CameraPlus.dll differ diff --git a/About/Manifest.xml b/About/Manifest.xml index adf2c20..1ce961f 100644 --- a/About/Manifest.xml +++ b/About/Manifest.xml @@ -1,7 +1,7 @@  net.pardeike.rimworld.mod.cameraplus - 2.2.1.0 + 2.2.2.0
  • 1.0.0
  • 1.1.0
  • diff --git a/Source/CameraPlus.csproj b/Source/CameraPlus.csproj index 73936da..67dadc5 100644 --- a/Source/CameraPlus.csproj +++ b/Source/CameraPlus.csproj @@ -10,7 +10,7 @@ ..\1.3\Assemblies\ true false - 2.2.1.0 + 2.2.2.0 Copyright Andreas Pardeike @@ -30,9 +30,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Source/Main.cs b/Source/Main.cs index 7b2ddf5..257f703 100644 --- a/Source/Main.cs +++ b/Source/Main.cs @@ -1,5 +1,6 @@ using HarmonyLib; using RimWorld; +using RimWorld.Planet; using System; using System.Collections.Generic; using System.Linq; @@ -385,6 +386,68 @@ public static IEnumerable Transpiler(ILGenerator generator, IEn } } + [HarmonyPatch] + static class SaveOurShip2BackgroundPatch + { + public static bool Prepare() => TargetMethod() != null; + public static MethodBase TargetMethod() { return AccessTools.Method("SaveOurShip2.MeshRecalculateHelper:RecalculateMesh"); } + public static readonly MethodInfo mCenter = AccessTools.PropertyGetter(AccessTools.TypeByName("SaveOurShip2.SectionThreadManager"), "Center"); + + public static IEnumerable Transpiler(IEnumerable instructions) + { + var state = 0; + foreach (var code in instructions) + { + switch (state) + { + case 0: + if (code.opcode == OpCodes.Ldsflda && code.operand is MethodInfo method && method == mCenter) + state = 1; + break; + case 1: + if (code.opcode == OpCodes.Sub) + state = 2; + break; + case 2: + state = 3; + break; + case 3: + yield return new CodeInstruction(OpCodes.Ldc_R4, 4f); + yield return new CodeInstruction(OpCodes.Mul); + state = 0; + break; + } + yield return code; + } + } + } + + [HarmonyPatch(typeof(Map))] + [HarmonyPatch(nameof(Map.MapUpdate))] + static class Map_MapUpdate_Patch + { + static bool done = false; + static void FixSoSMaterial() + { + done = true; + var type = AccessTools.TypeByName("SaveOurShip2.RenderPlanetBehindMap"); + if (type != null) + { + var mat = Traverse.Create(type).Field("PlanetMaterial").GetValue(); + mat.mainTextureOffset = new Vector2(0.3f, 0.3f); + mat.mainTextureScale = new Vector2(0.4f, 0.4f); + } + } + + static void Postfix(Map __instance) + { + if (done) return; + if (WorldRendererUtility.WorldRenderedNow) return; + if (Find.CurrentMap != __instance) return; + FixSoSMaterial(); + } + } + /*[HarmonyPatch(typeof(TickManager), nameof(TickManager.TickRateMultiplier), MethodType.Getter)] static class TickManager_TickRateMultiplier_Patch {