Skip to content

Commit

Permalink
v2.2.3 minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
pardeike committed Feb 24, 2022
1 parent 8c142ce commit a0f8187
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 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.2.0</version>
<version>2.2.3.0</version>
<targetVersions>
<li>1.0.0</li>
<li>1.1.0</li>
Expand Down
2 changes: 1 addition & 1 deletion 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.2.0</Version>
<Version>2.2.3.0</Version>
<Copyright>Copyright Andreas Pardeike</Copyright>
</PropertyGroup>

Expand Down
28 changes: 16 additions & 12 deletions Source/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,21 +282,25 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
[HarmonyPatch(typeof(CameraDriver), nameof(CameraDriver.CurrentZoom), MethodType.Getter)]
static class CameraDriver_CurrentZoom_Patch
{
public static bool Prefix(ref CameraZoomRange __result, float ___rootSize)
{
// these values are from vanilla
// we remap them to the range 30 - 60
var sizes = new[] { 12f, 13.8f, 42f, 57f }
// these values are from vanilla
// we remap them to the range 30 - 60
static readonly float[] sizes = new[] { 12f, 13.8f, 42f, 57f }
.Select(f => Tools.LerpDoubleSafe(12, 57, 30, 60, f))
.ToArray();

__result = CameraZoomRange.Furthest;
for (var i = 0; i < 4; i++)
if (Tools.LerpRootSize(___rootSize) < sizes[i])
{
__result = (CameraZoomRange)i;
break;
}
public static bool Prefix(ref CameraZoomRange __result, float ___rootSize)
{
var lerped = Tools.LerpRootSize(___rootSize);
if (lerped < sizes[0])
__result = CameraZoomRange.Closest;
else if (lerped < sizes[1])
__result = CameraZoomRange.Close;
else if (lerped < sizes[2])
__result = CameraZoomRange.Middle;
else if (lerped < sizes[3])
__result = CameraZoomRange.Far;
else
__result = CameraZoomRange.Furthest;
return false;
}
}
Expand Down

0 comments on commit a0f8187

Please sign in to comment.