Skip to content

Commit

Permalink
v2.2.2 adds support for SoS2
Browse files Browse the repository at this point in the history
  • Loading branch information
pardeike committed Feb 21, 2022
1 parent f25a6c8 commit 8c142ce
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 5 deletions.
Binary file modified 1.3/Assemblies/CameraPlus.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion About/Manifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Manifest>
<identifier>net.pardeike.rimworld.mod.cameraplus</identifier>
<version>2.2.1.0</version>
<version>2.2.2.0</version>
<targetVersions>
<li>1.0.0</li>
<li>1.1.0</li>
Expand Down
8 changes: 4 additions & 4 deletions Source/CameraPlus.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<OutputPath>..\1.3\Assemblies\</OutputPath>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<Version>2.2.1.0</Version>
<Version>2.2.2.0</Version>
<Copyright>Copyright Andreas Pardeike</Copyright>
</PropertyGroup>

Expand All @@ -30,9 +30,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Krafs.Rimworld.Ref" Version="1.3.3117" />
<PackageReference Include="Lib.Harmony" Version="2.1.1" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.NETCore.Platforms" Version="5.0.4" />
<PackageReference Include="Krafs.Rimworld.Ref" Version="1.3.3200" GeneratePathProperty="true" />
<PackageReference Include="Lib.Harmony" Version="2.2.0" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.NETCore.Platforms" Version="6.0.1" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net472" Version="1.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
63 changes: 63 additions & 0 deletions Source/Main.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using HarmonyLib;
using RimWorld;
using RimWorld.Planet;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -385,6 +386,68 @@ public static IEnumerable<CodeInstruction> 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<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> 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<Material>();
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
{
Expand Down

0 comments on commit 8c142ce

Please sign in to comment.