Skip to content

Commit

Permalink
Back to basics
Browse files Browse the repository at this point in the history
  • Loading branch information
LocoNeko committed Apr 29, 2020
1 parent c524034 commit 2fd1f39
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 74 deletions.
65 changes: 5 additions & 60 deletions Source/HarmonyPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -327,70 +327,15 @@ public static void Postfix(List<TransferableOneWay> transferables, ref Transfera
}
}

// This was just a test : it confirmed setting WaterCovered to false allows roads on water, unfortunately all roads
[HarmonyPatch(typeof(Tile), "WaterCovered" , MethodType.Getter)]
public static class Patch_Tile_WaterCovered
// ALl Tiles can now have roads
[HarmonyPatch(typeof(Tile), "Roads" , MethodType.Getter)]
public static class Patch_Tile_Roads
{
[HarmonyPostfix]
public static void Postfix (ref bool __result)
public static void Postfix(Tile __instance , ref List<Tile.RoadLink> __result)
{
StackTrace stackTrace = new StackTrace();
RoadsOfTheRim.DebugLog("WaterCovered called by "+stackTrace.GetFrame(1).GetMethod().Name);
// __result = false;
__result = __instance.potentialRoads;
}
}

/*
[HarmonyPatch(typeof(WorldLayer_Roads))]
[HarmonyPatch("Regenerate")]
public static class Patch_WorldLayer_Roads_Regenerate
{
static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
// I need to remove :
// IL_014f: callvirt instance bool RimWorld.Planet.Tile::get_WaterCovered()
// IL_0154: brtrue IL_02cb
RoadsOfTheRim.DebugLog("RotR - TRANSPILING");
bool foundWaterCovered = false;
int startIndex = -1, endIndex = -1;
var codes = new List<CodeInstruction>(instructions);
for (int i = 0; i < codes.Count; i++)
{
RoadsOfTheRim.DebugLog("Transpiler code=" + codes[i].ToString());
if (codes[i].opcode == OpCodes.Ret)
{
if (foundWaterCovered)
{
//Log.Error("END " + i);
endIndex = i; // include current 'ret'
break;
}
else
{
//Log.Error("START " + (i + 1));
startIndex = i + 1; // exclude current 'ret'
for (int j = startIndex; j < codes.Count; j++)
{
if (codes[j].opcode == OpCodes.Ret)
break;
var strOperand = codes[j].operand as String;
if (strOperand == "get_WaterCovered")
{
foundWaterCovered = true;
RoadsOfTheRim.DebugLog("Transpiler found Water Covered");
break;
}
}
}
}
}
return codes.AsEnumerable();
}
}
*/
}
Binary file modified v1.1/Assemblies/RoadsOfTheRim.dll
Binary file not shown.
14 changes: 0 additions & 14 deletions v1.1/Patches/patches.xml
Original file line number Diff line number Diff line change
Expand Up @@ -168,19 +168,5 @@
</value>
</match>
</Operation>

<Operation Class="PatchOperationReplace">
<xpath>/Defs/BiomeDef[defName = "Ocean"]/allowRoads</xpath>
<value>
<allowRoads>true</allowRoads>
</value>
</Operation>

<Operation Class="PatchOperationReplace">
<xpath>/Defs/BiomeDef[defName = "Lake"]/allowRoads</xpath>
<value>
<allowRoads>true</allowRoads>
</value>
</Operation>

</Patch>

0 comments on commit 2fd1f39

Please sign in to comment.