Browse Source

Add fix for restricted resource placement circumvention

tags/v0.0.1
NGnius (Graham) 4 years ago
parent
commit
2cf5e80412
1 changed files with 52 additions and 0 deletions
  1. +52
    -0
      CLre/Fixes/ExclusionImprovement.cs

+ 52
- 0
CLre/Fixes/ExclusionImprovement.cs 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");
}
}
}

Loading…
Cancel
Save