Add fix for restricted resource placement circumvention
This commit is contained in:
parent
4a51207dc6
commit
2cf5e80412
1 changed files with 52 additions and 0 deletions
52
CLre/Fixes/ExclusionImprovement.cs
Normal file
52
CLre/Fixes/ExclusionImprovement.cs
Normal 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…
Reference in a new issue