Skip to content

Commit

Permalink
removed obsolete transpilers, removing trigger colliders from gear items
Browse files Browse the repository at this point in the history
  • Loading branch information
WulfMarius committed Jan 19, 2019
1 parent b1841b2 commit 70b2570
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 68 deletions.
4 changes: 2 additions & 2 deletions VisualStudio/Properties/AssemblyInfo.cs
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.0.1")]
[assembly: AssemblyFileVersion("3.0.1")]
[assembly: AssemblyVersion("3.0.2")]
[assembly: AssemblyFileVersion("3.0.2")]
11 changes: 10 additions & 1 deletion VisualStudio/src/BetterPlacing.cs
Expand Up @@ -58,12 +58,21 @@ internal static void FixBoxCollider(GameObject gameObject)
return;
}

Renderer renderer = Utils.GetLargestBoundsRenderer(gameObject.gameObject);
Renderer renderer = Utils.GetLargestBoundsRenderer(gameObject);
if (renderer == null)
{
return;
}

BoxCollider[] boxColliders = gameObject.GetComponentsInChildren<BoxCollider>();
foreach (BoxCollider eachBoxCollider in boxColliders) {
if (eachBoxCollider.isTrigger)
{
Log("Removing " + eachBoxCollider + " because it is a trigger.");
Object.Destroy(eachBoxCollider);
}
}

BoxCollider boxCollider = gameObject.GetComponentInChildren<BoxCollider>();
if (boxCollider == null)
{
Expand Down
66 changes: 1 addition & 65 deletions VisualStudio/src/Patches.cs
Expand Up @@ -35,70 +35,6 @@ private static bool Prefix(BreakDown __instance, string text)

return false;
}

private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
var codes = new List<CodeInstruction>(instructions);

for (int i = 0; i < codes.Count; i++)
{
if (codes[i].opcode != OpCodes.Call)
{
continue;
}

MethodInfo methodInfo = codes[i].operand as MethodInfo;
if (methodInfo == null || methodInfo.Name != "DeserializeObject" || methodInfo.DeclaringType != typeof(Utils) || !methodInfo.IsGenericMethod)
{
continue;
}

System.Type[] genericArguments = methodInfo.GetGenericArguments();
if (genericArguments.Length != 1 || genericArguments[0] != typeof(BreakDownSaveData))
{
continue;
}

methodInfo = methodInfo.GetBaseDefinition().MakeGenericMethod(typeof(ModBreakDownSaveData));
codes[i].operand = methodInfo;
}

return codes;
}
}

[HarmonyPatch(typeof(BreakDown), "DeserializeAll")]
internal class BreakDown_DeserializeAll
{
internal static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
var codes = new List<CodeInstruction>(instructions);

for (int i = 0; i < codes.Count; i++)
{
if (codes[i].opcode != OpCodes.Call)
{
continue;
}

MethodInfo methodInfo = codes[i].operand as MethodInfo;
if (methodInfo == null || methodInfo.Name != "DeserializeObject" || methodInfo.DeclaringType != typeof(Utils) || !methodInfo.IsGenericMethod)
{
continue;
}

System.Type[] genericArguments = methodInfo.GetGenericArguments();
if (genericArguments.Length != 1 || genericArguments[0] != typeof(BreakDownSaveData))
{
continue;
}

methodInfo = methodInfo.GetBaseDefinition().MakeGenericMethod(typeof(ModBreakDownSaveData));
codes[i].operand = methodInfo;
}

return codes;
}
}

[HarmonyPatch(typeof(BreakDown), "ProcessInteraction")]
Expand Down Expand Up @@ -198,7 +134,7 @@ internal static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruct

if (methodInfo.Name == "set_layer" && methodInfo.DeclaringType == typeof(GameObject) && methodInfo.GetParameters().Length == 1)
{
codeInstructions[i - 1].operand = vp_Layer.NPC;
codeInstructions[i - 1].operand = (sbyte)vp_Layer.NPC;
break;
}
}
Expand Down

0 comments on commit 70b2570

Please sign in to comment.