Add fix for restricted resource placement circumvention

This commit is contained in:
NGnius (Graham) 2020-12-26 12:31:16 -05:00
parent 4a51207dc6
commit 2cf5e80412

View file

@ -0,0 +1,52 @@
using System.Globalization;
using System.Reflection;
using HarmonyLib;
using UnityEngine;
namespace CLre.Fixes
{
[Bugfix(name = "ExclusionImprovement",
description = "Sync exclusion zone collision check with visual location",
more = "https://trello.com/c/Ue4yIqWQ/11-placing-material-in-restricted-areas",
component = BugfixType.HarmonyPatch, id = 2)]
[HarmonyPatch]
class ExclusionZoneCollisionEngine_TestExclusionZoneCollision_Patch
{
[HarmonyPrefix]
public static void BeforeMethodCall(ref Vector3 structurePosition, ref bool __result)
{
if (ResourcePlacementPreviewEngine_GetLerpPosition_Patch.quantizedPosition != Vector3.zero)
{
structurePosition = ResourcePlacementPreviewEngine_GetLerpPosition_Patch.quantizedPosition;
}
}
[HarmonyTargetMethod]
public static MethodBase Target()
{
return AccessTools.Method("Game.Building.ExclusionZone.ExclusionZoneCollisionEngine:TestExclusionZoneCollision");
}
}
[Bugfix(name = "ExclusionImprovement",
description = "Sync exclusion zone collision check with visual location",
more = "https://trello.com/c/Ue4yIqWQ/11-placing-material-in-restricted-areas",
component = BugfixType.HarmonyPatch, id = 2)]
[HarmonyPatch]
class ResourcePlacementPreviewEngine_GetLerpPosition_Patch
{
internal static Vector3 quantizedPosition = Vector3.zero;
[HarmonyPrefix]
public static void BeforeMethodCall(ref Vector3 voxelWorldPos, ref Vector3 __result)
{
quantizedPosition = voxelWorldPos;
}
[HarmonyTargetMethod]
public static MethodBase Target()
{
return AccessTools.Method("Game.Handhelds.ResourcePlacementPreviewEngine:GetLerpPosition");
}
}
}