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 AnyAngle v0.1.0
plugins/AnyAngle/AnyAngle.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("AnyAngle")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0+c6b0c707e59e12f439ddced9a21a632d20ad3d0b")] [assembly: AssemblyProduct("AnyAngle")] [assembly: AssemblyTitle("AnyAngle")] [assembly: AssemblyVersion("0.1.0.0")] namespace AnyAngle; internal static class Nudge { internal const string OffsetKey = "vbb_off"; internal const string RotKey = "vbb_rot"; internal static bool Applied; internal static Vector3 PreSnapPos; internal static Piece SnapTarget; internal static Piece HitPiece; internal static Vector3 HitPoint; internal static bool Ready { get { if (Plugin.Enabled.Value) { return PlacementAdjust.Active; } return false; } } internal static void CameraAxes(Player player, out Vector3 right, out Vector3 fwd) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) Transform val = (((Object)(object)GameCamera.instance != (Object)null) ? ((Component)GameCamera.instance).transform : ((Component)player).transform); fwd = Vector3.ProjectOnPlane(val.forward, Vector3.up); if (((Vector3)(ref fwd)).sqrMagnitude < 0.0001f) { fwd = ((Component)player).transform.forward; } ((Vector3)(ref fwd)).Normalize(); right = Vector3.Cross(Vector3.up, fwd); } internal static void Rotate(Transform ghost) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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) //IL_001c: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) Quaternion rotation = ghost.rotation; Quaternion val = rotation * Quaternion.Euler(PlacementAdjust.Euler); Vector3 val2 = Quaternion.Inverse(rotation) * (HitPoint - ghost.position); ghost.rotation = val; ghost.position = HitPoint - val * val2; } internal static Vector3 OffsetOf(Piece piece) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) ZDO val = ZdoOf(piece); if (val == null) { return Vector3.zero; } return val.GetVec3("vbb_off", Vector3.zero); } internal static ZDO ZdoOf(Piece piece) { ZNetView val = (((Object)(object)piece != (Object)null) ? ((Component)piece).GetComponent<ZNetView>() : null); if (!((Object)(object)val != (Object)null) || !val.IsValid()) { return null; } return val.GetZDO(); } } [HarmonyPatch(typeof(Player), "UpdatePlacementGhost")] internal static class GhostPatch { 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 MethodInfo SetValid = AccessTools.Method(typeof(Player), "SetPlacementGhostValid", (Type[])null, (Type[])null); private static void Prefix() { Nudge.Applied = false; Nudge.SnapTarget = null; Nudge.HitPiece = null; } private static void Postfix(Player __instance) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Expected I4, but got Unknown //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Invalid comparison between Unknown and I4 //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Invalid comparison between Unknown and I4 //IL_014b: Unknown result type (might be due to invalid IL or missing references) GameObject val = Ghost.Invoke(__instance); PlacementAdjust.Building = (Object)(object)val != (Object)null && (Object)(object)__instance == (Object)(object)Player.m_localPlayer; if (!PlacementAdjust.Building || !Nudge.Ready || !val.activeSelf) { return; } Vector3 offset = PlacementAdjust.Offset; if (!Nudge.Applied) { Nudge.Rotate(val.transform); Transform transform = val.transform; transform.position += offset - Nudge.OffsetOf(Nudge.HitPiece); } else { Vector3 val2 = val.transform.position - Nudge.PreSnapPos; if (((Vector3)(ref val2)).sqrMagnitude > 1E-06f) { Transform transform2 = val.transform; transform2.position += offset - Nudge.OffsetOf(Nudge.SnapTarget); } } PlacementStatus val3 = Status.Invoke(__instance); Vector3 position = val.transform.position; Piece component = val.GetComponent<Piece>(); PrivateArea val4 = (((Object)(object)component != (Object)null) ? ((Component)component).GetComponent<PrivateArea>() : null); if (Location.IsInsideNoBuildLocation(position)) { val3 = (PlacementStatus)3; } else if (!PrivateArea.CheckAccess(position, Object.op_Implicit((Object)(object)val4) ? val4.m_radius : 0f, false, (Object)(object)val4 != (Object)null)) { val3 = (PlacementStatus)4; } else if (Plugin.IgnoreInvalid.Value && (int)val3 == 1) { val3 = (PlacementStatus)0; } Status.Invoke(__instance) = (PlacementStatus)(int)val3; SetValid.Invoke(__instance, new object[1] { (int)val3 == 0 }); } } [HarmonyPatch(typeof(Player), "PieceRayTest")] internal static class RayPatch { private static void Postfix(bool __result, Piece piece, Vector3 point) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) Nudge.HitPiece = (__result ? piece : null); Nudge.HitPoint = point; } } [HarmonyPatch(typeof(Player), "FindClosestSnapPoints")] internal static class SnapPatch { private static void Prefix(Transform ghost) { //IL_001d: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) if (Nudge.Ready && !((Object)(object)Player.m_localPlayer == (Object)null)) { Nudge.Rotate(ghost); ghost.position += PlacementAdjust.Offset - Nudge.OffsetOf(Nudge.HitPiece); Nudge.PreSnapPos = ghost.position; Nudge.Applied = true; } } private static void Postfix(bool __result, Transform b) { if (__result && (Object)(object)b != (Object)null) { Nudge.SnapTarget = ((Component)b).GetComponentInParent<Piece>(); } } } [HarmonyPatch(typeof(Player), "PlacePiece")] internal static class PlacePatch { internal static bool Placing; private static void Prefix() { Placing = Nudge.Ready; } private static void Postfix() { Placing = false; if (Plugin.ResetAfterPlace.Value) { PlacementAdjust.Reset(); } } } [HarmonyPatch(typeof(Piece), "SetCreator")] internal static class StoreNudgePatch { private static void Postfix(Piece __instance) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (PlacePatch.Placing) { ZDO val = Nudge.ZdoOf(__instance); if (val != null) { val.Set("vbb_off", PlacementAdjust.Offset); val.Set("vbb_rot", PlacementAdjust.Euler); } } } } internal class PlacementAdjust : MonoBehaviour { internal static Vector3 Offset; internal static Vector3 Euler; internal static bool Building; private static readonly float[] PosSteps = new float[4] { 0.01f, 0.05f, 0.25f, 1f }; private static readonly float[] RotSteps = new float[4] { 1f, 5f, 15f, 45f }; private static readonly string[] StepNames = new string[4] { "fine", "medium", "coarse", "large" }; private static int step = 1; private const float RepeatDelay = 0.4f; private const float RepeatRate = 0.05f; private float nextRepeat; private KeyCode held; private static Texture2D panelTex; private static Texture2D chipTex; private static GUIStyle titleStyle; private static GUIStyle labelStyle; private static GUIStyle chipStyle; private static GUIStyle footStyle; internal static bool Active { get { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (!(Offset != Vector3.zero)) { return Euler != Vector3.zero; } return true; } } internal static void Reset() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) Offset = Vector3.zero; Euler = Vector3.zero; } private void Update() { //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_0052: 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_00a4: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Enabled.Value || !Building || !InputFree()) { held = (KeyCode)0; return; } if (Input.GetKeyDown(Plugin.CycleStep.Value)) { step = (step + 1) % PosSteps.Length; } if (Input.GetKeyDown(Plugin.ResetKey.Value)) { Reset(); } KeyboardShortcut value = Plugin.CopyKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { CopyFromTarget(); } float p = PosSteps[step]; float r = RotSteps[step]; Try(Plugin.Forward.Value, delegate { Move(0f, 0f, p); }); Try(Plugin.Back.Value, delegate { Move(0f, 0f, 0f - p); }); Try(Plugin.Right.Value, delegate { Move(p, 0f, 0f); }); Try(Plugin.Left.Value, delegate { Move(0f - p, 0f, 0f); }); Try(Plugin.Up.Value, delegate { Move(0f, p, 0f); }); Try(Plugin.Down.Value, delegate { Move(0f, 0f - p, 0f); }); Try(Plugin.PitchUp.Value, delegate { Euler.x += r; }); Try(Plugin.PitchDown.Value, delegate { Euler.x -= r; }); Try(Plugin.YawRight.Value, delegate { Euler.y += r; }); Try(Plugin.YawLeft.Value, delegate { Euler.y -= r; }); Try(Plugin.RollRight.Value, delegate { Euler.z -= r; }); Try(Plugin.RollLeft.Value, delegate { Euler.z += r; }); float value2 = Plugin.MaxOffset.Value; if (((Vector3)(ref Offset)).magnitude > value2) { Offset = ((Vector3)(ref Offset)).normalized * value2; } Offset = new Vector3(Round(Offset.x), Round(Offset.y), Round(Offset.z)); } private static void Move(float right, float up, float fwd) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { Nudge.CameraAxes(localPlayer, out var right2, out var fwd2); Offset += right2 * right + Vector3.up * up + fwd2 * fwd; } } private static void CopyFromTarget() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || (Object)(object)GameCamera.instance == (Object)null) { return; } Transform transform = ((Component)GameCamera.instance).transform; RaycastHit val = default(RaycastHit); if (Physics.Raycast(transform.position, transform.forward, ref val, 50f, LayerMask.GetMask(new string[2] { "piece", "piece_nonsolid" }))) { ZDO val2 = Nudge.ZdoOf(((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<Piece>()); if (val2 != null) { Offset = val2.GetVec3("vbb_off", Vector3.zero); Euler = val2.GetVec3("vbb_rot", Vector3.zero); ((Character)localPlayer).Message((MessageType)1, "Offset and rotation copied", 0, (Sprite)null, false); } } } private void Try(KeyCode key, Action act) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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) if ((int)key != 0) { if (Input.GetKeyDown(key)) { held = key; nextRepeat = Time.unscaledTime + 0.4f; act(); } else if (held == key && Input.GetKey(key) && Time.unscaledTime >= nextRepeat) { nextRepeat = Time.unscaledTime + 0.05f; act(); } } } private static float Round(float v) { return Mathf.Round(v * 1000f) / 1000f; } private static bool InputFree() { if ((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus()) { return false; } if (!Console.IsVisible() && !TextInput.IsVisible() && !Menu.IsVisible() && !InventoryGui.IsVisible()) { return !Hud.IsPieceSelectionVisible(); } return false; } private static Texture2D Solid(Color c) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown Texture2D val = new Texture2D(1, 1); val.SetPixel(0, 0, c); val.Apply(); return val; } private static void InitStyles() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown //IL_0102: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)panelTex != (Object)null)) { panelTex = Solid(new Color(0.08f, 0.07f, 0.06f, 0.78f)); chipTex = Solid(new Color(0.93f, 0.89f, 0.8f, 0.95f)); titleStyle = new GUIStyle(GUI.skin.label) { fontStyle = (FontStyle)1, richText = true }; labelStyle = new GUIStyle(GUI.skin.label) { richText = true }; footStyle = new GUIStyle(GUI.skin.label) { richText = true }; chipStyle = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)4, fontStyle = (FontStyle)1, wordWrap = false }; chipStyle.normal.background = chipTex; chipStyle.normal.textColor = new Color(0.12f, 0.1f, 0.08f); } } private unsafe static string Name(KeyCode k) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected I4, but got Unknown if ((int)k != 0) { switch (k - 269) { case 4: return "Up"; case 5: return "Down"; case 7: return "Left"; case 6: return "Right"; case 11: return "PgUp"; case 12: return "PgDn"; case 1: return "Num +"; case 0: return "Num -"; default: { string text = ((object)(*(KeyCode*)(&k))/*cast due to .constrained prefix*/).ToString(); if (!text.StartsWith("Keypad")) { return text; } return "Num " + text.Substring(6); } } } return "-"; } private static string Pair(KeyCode a, KeyCode b) { //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) return Name(a) + " / " + Name(b); } private void OnGUI() { //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_0482: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.ShowHud.Value || !Plugin.Enabled.Value || !Building) { return; } InitStyles(); float num = Mathf.Clamp((float)Screen.height / 1080f, 0.7f, 2f); int num2 = Mathf.RoundToInt(15f * num); GUIStyle obj = titleStyle; GUIStyle obj2 = labelStyle; GUIStyle obj3 = chipStyle; int num3 = (footStyle.fontSize = num2); int num5 = (obj3.fontSize = num3); int fontSize = (obj2.fontSize = num5); obj.fontSize = fontSize; titleStyle.normal.textColor = new Color(1f, 0.82f, 0.35f); labelStyle.normal.textColor = Color.white; footStyle.normal.textColor = new Color(0.8f, 0.8f, 0.8f); List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>> { new KeyValuePair<string, string>(Pair(Plugin.Forward.Value, Plugin.Back.Value), "Move forward / back"), new KeyValuePair<string, string>(Pair(Plugin.Left.Value, Plugin.Right.Value), "Move left / right"), new KeyValuePair<string, string>(Pair(Plugin.Up.Value, Plugin.Down.Value), "Move up / down"), new KeyValuePair<string, string>(Pair(Plugin.PitchUp.Value, Plugin.PitchDown.Value), "Tilt"), new KeyValuePair<string, string>(Pair(Plugin.RollLeft.Value, Plugin.RollRight.Value), "Roll"), new KeyValuePair<string, string>(Pair(Plugin.YawLeft.Value, Plugin.YawRight.Value), "Turn"), new KeyValuePair<string, string>(Name(Plugin.CycleStep.Value), "Step size: " + StepNames[step]), new KeyValuePair<string, string>(Name(Plugin.ResetKey.Value), "Reset"), new KeyValuePair<string, string>(((object)Plugin.CopyKey.Value/*cast due to .constrained prefix*/).ToString().Replace(" + ", "+"), "Copy from piece") }; float num8 = 28f * num; float num9 = 12f * num; float num10 = 130f * num; float num11 = 360f * num; float num12 = num9 * 2f + num8 * (float)(list.Count + 2); Rect val = default(Rect); ((Rect)(ref val))..ctor((float)Screen.width - num11 - 24f * num, (float)Screen.height - num12 - 110f * num, num11, num12); GUI.DrawTexture(val, (Texture)(object)panelTex); Piece val2 = SelectedPiece(); string text = (((Object)(object)val2 != (Object)null) ? Localization.instance.Localize(val2.m_name) : "Build"); float num13 = ((Rect)(ref val)).y + num9; GUI.Label(new Rect(((Rect)(ref val)).x + num9, num13, num11 - num9 * 2f, num8), text, titleStyle); num13 += num8; foreach (KeyValuePair<string, string> item in list) { GUI.Label(new Rect(((Rect)(ref val)).x + num9, num13, num10, num8 - 4f * num), item.Key, chipStyle); GUI.Label(new Rect(((Rect)(ref val)).x + num9 * 2f + num10, num13 - 2f * num, num11 - num10 - num9 * 3f, num8), item.Value, labelStyle); num13 += num8; } object[] obj4 = new object[5] { Offset.y, null, null, null, null }; Vector2 val3 = new Vector2(Offset.x, Offset.z); obj4[1] = ((Vector2)(ref val3)).magnitude; obj4[2] = Euler.x; obj4[3] = Euler.y; obj4[4] = Euler.z; string text2 = string.Format("Offset up {0:0.00} side {1:0.00} m Rot {2:0.#} / {3:0.#} / {4:0.#}", obj4); GUI.Label(new Rect(((Rect)(ref val)).x + num9, num13 + 2f * num, num11 - num9 * 2f, num8), text2, footStyle); } private static Piece SelectedPiece() { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return null; } GameObject val = AccessTools_Ghost(localPlayer); if (!((Object)(object)val != (Object)null)) { return null; } return val.GetComponent<Piece>(); } private static GameObject AccessTools_Ghost(Player p) { return AccessTools.FieldRefAccess<Player, GameObject>("m_placementGhost").Invoke(p); } } [BepInPlugin("com.morda.anyangle", "AnyAngle", "0.1.0")] public class Plugin : BaseUnityPlugin { public const string ModGuid = "com.morda.anyangle"; public const string ModName = "AnyAngle"; public const string ModVersion = "0.1.0"; internal static ManualLogSource Log; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<bool> IgnoreInvalid; internal static ConfigEntry<bool> ResetAfterPlace; internal static ConfigEntry<bool> ShowHud; internal static ConfigEntry<float> MaxOffset; internal static ConfigEntry<KeyCode> Forward; internal static ConfigEntry<KeyCode> Back; internal static ConfigEntry<KeyCode> Left; internal static ConfigEntry<KeyCode> Right; internal static ConfigEntry<KeyCode> Up; internal static ConfigEntry<KeyCode> Down; internal static ConfigEntry<KeyCode> PitchUp; internal static ConfigEntry<KeyCode> PitchDown; internal static ConfigEntry<KeyCode> RollLeft; internal static ConfigEntry<KeyCode> RollRight; internal static ConfigEntry<KeyCode> YawLeft; internal static ConfigEntry<KeyCode> YawRight; internal static ConfigEntry<KeyCode> CycleStep; internal static ConfigEntry<KeyCode> ResetKey; internal static ConfigEntry<KeyboardShortcut> CopyKey; private void Awake() { //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Allow nudging and rotating the build ghost before placing."); IgnoreInvalid = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "IgnoreInvalid", true, "While a nudge/rotation is active, a ghost that Valheim marks invalid (clipping, slope, ...) can still be placed. Ward zones and no-build zones are always respected."); ResetAfterPlace = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ResetAfterPlace", false, "Reset offset and rotation after each placed piece. Off = the same offset/rotation stays for the next pieces, which still snap to the (nudged) pieces already built."); MaxOffset = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MaxOffset", 3f, "Maximum distance in meters the ghost can be moved away from its normal spot."); ShowHud = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowHud", true, "Show offset/rotation/step on screen while building."); Forward = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keys (hold to repeat)", "Forward", (KeyCode)273, "Move the piece away from you."); Back = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keys (hold to repeat)", "Back", (KeyCode)274, "Move the piece towards you."); Left = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keys (hold to repeat)", "Left", (KeyCode)276, "Move the piece left."); Right = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keys (hold to repeat)", "Right", (KeyCode)275, "Move the piece right."); Up = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keys (hold to repeat)", "Up", (KeyCode)280, "Move the piece up."); Down = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keys (hold to repeat)", "Down", (KeyCode)281, "Move the piece down."); PitchUp = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keys (hold to repeat)", "PitchUp", (KeyCode)258, "Tilt the piece forward."); PitchDown = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keys (hold to repeat)", "PitchDown", (KeyCode)264, "Tilt the piece back."); RollLeft = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keys (hold to repeat)", "RollLeft", (KeyCode)260, "Roll the piece to the left."); RollRight = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keys (hold to repeat)", "RollRight", (KeyCode)262, "Roll the piece to the right."); YawLeft = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keys (hold to repeat)", "YawLeft", (KeyCode)263, "Extra turn left (on top of the vanilla mouse wheel)."); YawRight = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keys (hold to repeat)", "YawRight", (KeyCode)265, "Extra turn right."); CycleStep = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keys (hold to repeat)", "CycleStep", (KeyCode)270, "Switch between the fine / medium / coarse / large step sizes."); ResetKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keys (hold to repeat)", "Reset", (KeyCode)261, "Reset offset and rotation."); CopyKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keys (hold to repeat)", "CopyNudge", new KeyboardShortcut((KeyCode)99, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }), "Look at a piece you built with this mod and press this to take over its offset and rotation."); ((Component)this).gameObject.AddComponent<PlacementAdjust>(); new Harmony("com.morda.anyangle").PatchAll(Assembly.GetExecutingAssembly()); ((BaseUnityPlugin)this).Logger.LogInfo((object)"AnyAngle v0.1.0 loaded."); } }