Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of FineTunedPlacement v1.0.0
plugins/FineTunedPlacement/FineTunedPlacement.dll
Decompiled 13 hours agousing System; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: AssemblyCompany("FineTunedPlacement")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+50bae53a95fb309e590b3f7af5cb60286cb85d29")] [assembly: AssemblyProduct("FineTunedPlacement")] [assembly: AssemblyTitle("FineTunedPlacement")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace FineTunedPlacement { [HarmonyPatch] public static class PlacementLock { private sealed class Move { public ConfigEntry<string> Key; public int F; public int R; public int U; } private sealed class Hotkey { public KeyCode Key; public bool Ctrl; public bool Alt; public bool Shift; public bool IsSet => (int)Key > 0; public static Hotkey Parse(string s) { //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) Hotkey hotkey = new Hotkey(); if (string.IsNullOrEmpty(s)) { return hotkey; } string[] array = s.Split(new char[1] { '+' }); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.Length == 0) { continue; } if (text.Equals("Ctrl", StringComparison.OrdinalIgnoreCase) || text.Equals("Control", StringComparison.OrdinalIgnoreCase) || text.Equals("LeftControl", StringComparison.OrdinalIgnoreCase)) { hotkey.Ctrl = true; continue; } if (text.Equals("Alt", StringComparison.OrdinalIgnoreCase)) { hotkey.Alt = true; continue; } if (text.Equals("Shift", StringComparison.OrdinalIgnoreCase)) { hotkey.Shift = true; continue; } try { hotkey.Key = (KeyCode)Enum.Parse(typeof(KeyCode), text, ignoreCase: true); } catch { } } return hotkey; } private bool ModsHeld() { bool flag = Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305); bool flag2 = Input.GetKey((KeyCode)308) || Input.GetKey((KeyCode)307); bool flag3 = Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303); if (Ctrl == flag && Alt == flag2) { return Shift == flag3; } return false; } public bool Down() { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (IsSet && Input.GetKeyDown(Key)) { return ModsHeld(); } return false; } public bool HeldNow() { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (IsSet && Input.GetKey(Key)) { return ModsHeld(); } return false; } public string Display() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Invalid comparison between Unknown and I4 //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected I4, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Invalid comparison between Unknown and I4 //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Invalid comparison between Unknown and I4 //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected I4, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Invalid comparison between Unknown and I4 //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Invalid comparison between Unknown and I4 if (!IsSet) { return ""; } KeyCode key = Key; string text; if ((int)key <= 61) { switch (key - 44) { case 1: goto IL_00d1; case 2: goto IL_00f9; case 0: goto IL_0101; } if ((int)key != 59) { if ((int)key != 61) { goto IL_0131; } text = "="; } else { text = ";"; } } else if ((int)key <= 93) { if ((int)key != 91) { if ((int)key != 93) { goto IL_0131; } text = "]"; } else { text = "["; } } else if ((int)key != 127) { switch (key - 269) { case 1: break; case 0: goto IL_00b6; case 11: goto IL_00c1; case 12: goto IL_00c9; case 4: goto IL_0109; case 5: goto IL_0111; case 7: goto IL_0119; case 6: goto IL_0121; default: goto IL_0131; } text = "+"; } else { text = "Delete"; } goto IL_0143; IL_00f9: text = "."; goto IL_0143; IL_0101: text = ","; goto IL_0143; IL_00d1: text = "-"; goto IL_0143; IL_0143: return (Ctrl ? "Ctrl+" : "") + (Alt ? "Alt+" : "") + (Shift ? "Shift+" : "") + text; IL_0131: text = ((object)Unsafe.As<KeyCode, KeyCode>(ref Key)/*cast due to .constrained prefix*/).ToString(); goto IL_0143; IL_00b6: text = "-"; goto IL_0143; IL_00c9: text = "Page Down"; goto IL_0143; IL_0109: text = "Up"; goto IL_0143; IL_0111: text = "Down"; goto IL_0143; IL_0121: text = "Right"; goto IL_0143; IL_0119: text = "Left"; goto IL_0143; IL_00c1: text = "Page Up"; goto IL_0143; } } public const float ReachMargin = 2f; private const float RepeatDelay = 0.35f; private const float RepeatEvery = 0.07f; private static ConfigEntry<string> _lockKey; private static ConfigEntry<string> _fwd; private static ConfigEntry<string> _back; private static ConfigEntry<string> _left; private static ConfigEntry<string> _right; private static ConfigEntry<string> _up; private static ConfigEntry<string> _down; private static ConfigEntry<string> _stepUp; private static ConfigEntry<string> _stepDown; private static ConfigEntry<string> _steps; private static ConfigEntry<float> _step; private static ConfigEntry<bool> _keepLock; private static ConfigEntry<bool> _enabled; private static readonly FieldRef<Player, GameObject> Ghost = AccessTools.FieldRefAccess<Player, GameObject>("m_placementGhost"); private static readonly FieldRef<Player, PlacementStatus> Status = AccessTools.FieldRefAccess<Player, PlacementStatus>("m_placementStatus"); private static readonly FieldRef<Player, GameObject> Marker = AccessTools.FieldRefAccess<Player, GameObject>("m_placementMarkerInstance"); private static readonly FieldRef<Player, int> PlaceRotation = AccessTools.FieldRefAccess<Player, int>("m_placeRotation"); private static readonly FieldRef<Player, float> PlaceRotationDegrees = AccessTools.FieldRefAccess<Player, float>("m_placeRotationDegrees"); private static readonly FieldRef<Player, float> MaxPlaceDistance = AccessTools.FieldRefAccess<Player, float>("m_maxPlaceDistance"); private static readonly MethodInfo SetGhostValid = AccessTools.Method(typeof(Player), "SetPlacementGhostValid", (Type[])null, (Type[])null); private static bool _locked; private static GameObject _lockedGhost; private static string _lockedPiece; private static Vector3 _anchor; private static Vector3 _offset; private static PlacementStatus _lockedStatus; private static string _held; private static float _nextRepeat; private static Text _readout; private static Canvas _canvas; private static Move[] _moves; private static bool On { get { if (_enabled != null) { return _enabled.Value; } return true; } } private static float Step { get { if (_step == null) { return 0.1f; } return _step.Value; } } public static void Bind(ConfigFile config) { _enabled = config.Bind<bool>("General", "Enabled", true, "Turn the lock-and-nudge placement on or off."); _lockKey = config.Bind<string>("Keys", "PlaceLock", "Delete", "Lock the piece you are placing where it stands, so you can move it by steps (again: unlock)."); _fwd = config.Bind<string>("Keys", "NudgeForward", "UpArrow", "Piece locked: move it one step away from you (along the world's axis closest to where you look)."); _back = config.Bind<string>("Keys", "NudgeBack", "DownArrow", "Piece locked: move it one step towards you."); _left = config.Bind<string>("Keys", "NudgeLeft", "LeftArrow", "Piece locked: move it one step to the left."); _right = config.Bind<string>("Keys", "NudgeRight", "RightArrow", "Piece locked: move it one step to the right."); _up = config.Bind<string>("Keys", "NudgeUp", "PageUp", "Piece locked: move it one step up."); _down = config.Bind<string>("Keys", "NudgeDown", "PageDown", "Piece locked: move it one step down."); _stepUp = config.Bind<string>("Keys", "NudgeStepUp", "KeypadPlus", "A bigger step for moving a locked piece."); _stepDown = config.Bind<string>("Keys", "NudgeStepDown", "KeypadMinus", "A smaller step for moving a locked piece."); _steps = config.Bind<string>("Building", "NudgeSteps", "1,0.5,0.25,0.1,0.05,0.01", "The steps (m) a locked piece moves by; the step keys go through them."); _step = config.Bind<float>("Building", "NudgeStep", 0.1f, "The step (m) a locked piece moves by now (remembered; one of NudgeSteps)."); _keepLock = config.Bind<bool>("Building", "KeepLockAfterPlace", false, "Keep the piece locked after placing it, to line up the next one from the same spot."); } private static float[] Steps() { float result; float[] array = (from f in (from s in (_steps?.Value ?? "").Split(new char[1] { ',' }) select (!float.TryParse(s.Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out result)) ? 0f : result into f where f > 0.0005f && f <= 10f select f).Distinct() orderby f descending select f).ToArray(); if (array.Length == 0) { return new float[6] { 1f, 0.5f, 0.25f, 0.1f, 0.05f, 0.01f }; } return array; } private static void ChangeStep(bool bigger) { float[] array = Steps(); float step = Step; int num = 0; for (int i = 0; i < array.Length; i++) { if (Mathf.Abs(array[i] - step) < Mathf.Abs(array[num] - step)) { num = i; } } num = Mathf.Clamp(num + ((!bigger) ? 1 : (-1)), 0, array.Length - 1); _step.Value = array[num]; } private static void Unlock() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) _locked = false; _lockedGhost = null; _lockedPiece = null; _offset = Vector3.zero; _held = null; ShowReadout(null); } private static bool Lock(Player p) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) GameObject val = (((Object)(object)p != (Object)null) ? Ghost.Invoke(p) : null); if ((Object)(object)val == (Object)null || !val.activeSelf) { return false; } _locked = true; _lockedGhost = val; _lockedPiece = Utils.GetPrefabName(val); _anchor = val.transform.position; _offset = Vector3.zero; _lockedStatus = Status.Invoke(p); return true; } private static void Nudge(Vector3 cameraFlat, int forward, int right, int up) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Mathf.Abs(cameraFlat.x) > Mathf.Abs(cameraFlat.z)) ? new Vector3(Mathf.Sign(cameraFlat.x), 0f, 0f) : new Vector3(0f, 0f, Mathf.Sign(cameraFlat.z))); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(val.z, 0f, 0f - val.x); _offset += (val * (float)forward + val2 * (float)right + Vector3.up * (float)up) * Step; } [HarmonyPatch(typeof(Player), "UpdatePlacementGhost")] [HarmonyPostfix] [HarmonyPriority(800)] private static void Player_UpdatePlacementGhost(Player __instance) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Expected I4, but got Unknown //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Invalid comparison between Unknown and I4 //IL_0125: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return; } if (!On) { if (_locked) { Unlock(); } return; } GameObject val = Ghost.Invoke(__instance); if (_locked && val != _lockedGhost) { if ((Object)(object)val != (Object)null && Utils.GetPrefabName(val) == _lockedPiece) { _lockedGhost = val; } else { Unlock(); } } Keys(__instance, val); if (_locked) { val.SetActive(true); val.transform.position = _anchor + _offset; val.transform.rotation = Quaternion.Euler(0f, PlaceRotationDegrees.Invoke(__instance) * (float)PlaceRotation.Invoke(__instance), 0f); GameObject val2 = Marker.Invoke(__instance); if ((Object)(object)val2 != (Object)null) { val2.SetActive(false); } PlacementStatus val3 = _lockedStatus; float num = MaxPlaceDistance.Invoke(__instance) + 2f; bool flag = Vector3.Distance(((Component)__instance).transform.position, val.transform.position) > num; if (flag) { val3 = (PlacementStatus)1; } Status.Invoke(__instance) = (PlacementStatus)(int)val3; SetGhostValid.Invoke(__instance, new object[1] { (int)val3 == 0 }); ShowReadout(Readout(flag)); } } private static bool Blocked() { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Invalid comparison between Unknown and I4 if ((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus()) { return true; } if (Console.IsVisible() || Menu.IsVisible() || InventoryGui.IsVisible()) { return true; } if (TextInput.IsVisible()) { return true; } if ((Object)(object)Hud.instance != (Object)null && (Object)(object)Hud.instance.m_pieceSelectionWindow != (Object)null && Hud.instance.m_pieceSelectionWindow.activeSelf) { return true; } if ((Object)(object)Minimap.instance != (Object)null && (int)Minimap.instance.m_mode == 2) { return true; } return false; } private static void Keys(Player p, GameObject ghost) { //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) if (Blocked()) { return; } if (Hotkey.Parse(_lockKey.Value).Down()) { if (_locked) { Unlock(); ((Character)p).Message((MessageType)1, "Piece unlocked", 0, (Sprite)null, false); } else if (Lock(p)) { ((Character)p).Message((MessageType)1, "Piece locked: move it with " + Label(_fwd) + " " + Label(_left) + " " + Label(_back) + " " + Label(_right) + ", " + Label(_up) + " " + Label(_down), 0, (Sprite)null, false); } return; } if (Hotkey.Parse(_stepUp.Value).Down()) { ChangeStep(bigger: true); } if (Hotkey.Parse(_stepDown.Value).Down()) { ChangeStep(bigger: false); } if (!_locked || (Object)(object)ghost == (Object)null) { return; } Move[] array = Moves(); foreach (Move move in array) { ConfigEntry<string> key = move.Key; Hotkey hotkey = Hotkey.Parse(key.Value); bool flag = hotkey.Down(); bool flag2 = hotkey.HeldNow(); if (flag || (flag2 && _held == ((ConfigEntryBase)key).Definition.Key && Time.unscaledTime >= _nextRepeat)) { _nextRepeat = Time.unscaledTime + (flag ? 0.35f : 0.07f); _held = ((ConfigEntryBase)key).Definition.Key; Vector3 val = (((Object)(object)GameCamera.instance != (Object)null) ? ((Component)GameCamera.instance).transform.forward : ((Component)p).transform.forward); Nudge(new Vector3(val.x, 0f, val.z), move.F, move.R, move.U); } } } private static Move[] Moves() { object obj = _moves; if (obj == null) { obj = new Move[6] { new Move { Key = _fwd, F = 1 }, new Move { Key = _back, F = -1 }, new Move { Key = _right, R = 1 }, new Move { Key = _left, R = -1 }, new Move { Key = _up, U = 1 }, new Move { Key = _down, U = -1 } }; _moves = (Move[])obj; } return (Move[])obj; } private static string Label(ConfigEntry<string> key) { if (key != null) { return Hotkey.Parse(key.Value).Display(); } return ""; } [HarmonyPatch(typeof(Player), "TryPlacePiece")] [HarmonyPostfix] private static void Player_TryPlacePiece(Player __instance, bool __result) { if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && __result && _locked && (_keepLock == null || !_keepLock.Value)) { Unlock(); } } private static string Readout(bool tooFar) { string text = ((Step >= 0.1f) ? (Step.ToString("0.##", CultureInfo.InvariantCulture) + " m") : (Mathf.RoundToInt(Step * 100f) + " cm")); string text2 = ((((Vector3)(ref _offset)).sqrMagnitude < 1E-05f) ? "not moved" : ("x " + M(_offset.x) + " y " + M(_offset.y) + " z " + M(_offset.z))); return "<color=#e0b85c>Locked</color> step " + text + " (" + Label(_stepDown) + " " + Label(_stepUp) + ") " + text2 + (tooFar ? " <color=#ff6050>too far: walk closer</color>" : ""); static string M(float v) { return ((v >= 0f) ? "+" : "") + v.ToString("0.00", CultureInfo.InvariantCulture); } } private static void EnsureReadout() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_readout != (Object)null)) { _canvas = new GameObject("FineTunedPlacement_Canvas").AddComponent<Canvas>(); _canvas.renderMode = (RenderMode)0; _canvas.sortingOrder = 1000; Object.DontDestroyOnLoad((Object)(object)((Component)_canvas).gameObject); GameObject val = new GameObject("FineTunedPlacement_Readout"); val.transform.SetParent(((Component)_canvas).transform, false); _readout = val.AddComponent<Text>(); _readout.font = Font.CreateDynamicFontFromOSFont(new string[3] { "Arial", "Liberation Sans", "Helvetica" }, 18); _readout.fontSize = 18; _readout.fontStyle = (FontStyle)1; _readout.alignment = (TextAnchor)4; _readout.supportRichText = true; _readout.horizontalOverflow = (HorizontalWrapMode)1; _readout.verticalOverflow = (VerticalWrapMode)1; ((Graphic)_readout).color = new Color(0.92f, 0.92f, 0.92f, 1f); RectTransform rectTransform = ((Graphic)_readout).rectTransform; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0.5f, 0.5f); rectTransform.anchorMax = val2; rectTransform.anchorMin = val2; rectTransform.pivot = new Vector2(0.5f, 0.5f); rectTransform.anchoredPosition = new Vector2(0f, -110f); rectTransform.sizeDelta = new Vector2(900f, 28f); Shadow obj = val.AddComponent<Shadow>(); obj.effectColor = new Color(0f, 0f, 0f, 0.85f); obj.effectDistance = new Vector2(1.5f, -1.5f); } } private static void ShowReadout(string text) { if (text == null) { if ((Object)(object)_readout != (Object)null) { ((Component)_readout).gameObject.SetActive(false); } return; } EnsureReadout(); if (!((Object)(object)_readout == (Object)null)) { if (!((Component)_readout).gameObject.activeSelf) { ((Component)_readout).gameObject.SetActive(true); } if (_readout.text != text) { _readout.text = text; } } } } [BepInPlugin("com.valheimmmo.finetunedplacement", "FineTunedPlacement", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string Guid = "com.valheimmmo.finetunedplacement"; public const string Name = "FineTunedPlacement"; public const string Version = "1.0.0"; private Harmony _harmony; private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown PlacementLock.Bind(((BaseUnityPlugin)this).Config); _harmony = new Harmony("com.valheimmmo.finetunedplacement"); _harmony.PatchAll(typeof(PlacementLock)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"FineTunedPlacement 1.0.0 loaded"); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } }