Decompiled source of PerfectPlacement v1.1.8
PerfectPlacement.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using PerfectPlacement; using PerfectPlacement.Patches.Compatibility.WardIsLove; using ServerSync; using TMPro; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("PerfectPlacement")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyProduct("PerfectPlacement")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("E3FE707A-B402-4C69-8C3D-E9C0C709715D")] [assembly: AssemblyFileVersion("1.1.8")] [assembly: AssemblyCompany("Azumatt_and_ValheimPlusDevs")] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.8.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<927abd1e-fecd-41f0-82d0-833528de020f>Embedded] internal sealed class <927abd1e-fecd-41f0-82d0-833528de020f>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [<927abd1e-fecd-41f0-82d0-833528de020f>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class <fa36b506-5f27-4c75-9256-d48dbb1c433a>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <fa36b506-5f27-4c75-9256-d48dbb1c433a>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <fa36b506-5f27-4c75-9256-d48dbb1c433a>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [<927abd1e-fecd-41f0-82d0-833528de020f>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class <c44312b6-f40f-41ca-bd8b-4eba4cc9a976>NullableContextAttribute : Attribute { public readonly byte Flag; public <c44312b6-f40f-41ca-bd8b-4eba4cc9a976>NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace AllManagersModTemplate { [HarmonyPatch(typeof(ZNet), "OnNewConnection")] public static class RegisterAndCheckVersion { [<c44312b6-f40f-41ca-bd8b-4eba4cc9a976>NullableContext(1)] private static void Prefix(ZNetPeer peer, ref ZNet __instance) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown PerfectPlacementPlugin.PerfectPlacementLogger.LogDebug((object)"Registering version RPC handler"); peer.m_rpc.Register<ZPackage>("PerfectPlacement_VersionCheck", (Action<ZRpc, ZPackage>)RpcHandlers.RPC_AllManagersModTemplate_Version); PerfectPlacementPlugin.PerfectPlacementLogger.LogDebug((object)"Invoking version check"); ZPackage val = new ZPackage(); val.Write("1.1.8"); val.Write(RpcHandlers.ComputeHashForMod().Replace("-", "")); peer.m_rpc.Invoke("PerfectPlacement_VersionCheck", new object[1] { val }); } } [<fa36b506-5f27-4c75-9256-d48dbb1c433a>Nullable(0)] [HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")] [<c44312b6-f40f-41ca-bd8b-4eba4cc9a976>NullableContext(1)] public static class VerifyClient { private static bool Prefix(ZRpc rpc, ZPackage pkg, ref ZNet __instance) { if (!__instance.IsServer() || RpcHandlers.ValidatedPeers.Contains(rpc)) { return true; } PerfectPlacementPlugin.PerfectPlacementLogger.LogWarning((object)("Peer (" + rpc.m_socket.GetHostName() + ") never sent version or couldn't due to previous disconnect, disconnecting")); rpc.Invoke("Error", new object[1] { 3 }); return false; } private static void Postfix(ZNet __instance) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "PerfectPlacementRequestAdminSync", new object[1] { (object)new ZPackage() }); } } [HarmonyPatch(typeof(FejdStartup), "ShowConnectError")] public class ShowConnectionError { [<c44312b6-f40f-41ca-bd8b-4eba4cc9a976>NullableContext(1)] private static void Postfix(FejdStartup __instance) { if (__instance.m_connectionFailedPanel.activeSelf) { TMP_Text connectionFailedError = __instance.m_connectionFailedError; connectionFailedError.text = connectionFailedError.text + "\n" + PerfectPlacementPlugin.ConnectionError; } } } [HarmonyPatch(typeof(ZNet), "Disconnect")] public static class RemoveDisconnectedPeerFromVerified { [<c44312b6-f40f-41ca-bd8b-4eba4cc9a976>NullableContext(1)] private static void Prefix(ZNetPeer peer, ref ZNet __instance) { if (__instance.IsServer()) { PerfectPlacementPlugin.PerfectPlacementLogger.LogInfo((object)("Peer (" + peer.m_rpc.m_socket.GetHostName() + ") disconnected, removing from validated list")); RpcHandlers.ValidatedPeers.Remove(peer.m_rpc); } } } [<c44312b6-f40f-41ca-bd8b-4eba4cc9a976>NullableContext(1)] [<fa36b506-5f27-4c75-9256-d48dbb1c433a>Nullable(0)] public static class RpcHandlers { public static readonly List<ZRpc> ValidatedPeers = new List<ZRpc>(); public static void RPC_AllManagersModTemplate_Version(ZRpc rpc, ZPackage pkg) { string text = pkg.ReadString(); string text2 = pkg.ReadString(); string text3 = ComputeHashForMod().Replace("-", ""); PerfectPlacementPlugin.PerfectPlacementLogger.LogInfo((object)("Version check, local: 1.1.8, remote: " + text)); if (text2 != text3 || text != "1.1.8") { PerfectPlacementPlugin.ConnectionError = "PerfectPlacement Installed: 1.1.8 " + text3 + "\n Needed: " + text + " " + text2; if (ZNet.instance.IsServer()) { PerfectPlacementPlugin.PerfectPlacementLogger.LogWarning((object)("Peer (" + rpc.m_socket.GetHostName() + ") has incompatible version, disconnecting...")); rpc.Invoke("Error", new object[1] { 3 }); } } else if (!ZNet.instance.IsServer()) { PerfectPlacementPlugin.PerfectPlacementLogger.LogInfo((object)"Received same version from server!"); } else { PerfectPlacementPlugin.PerfectPlacementLogger.LogInfo((object)("Adding peer (" + rpc.m_socket.GetHostName() + ") to validated list")); ValidatedPeers.Add(rpc); } } public static string ComputeHashForMod() { using SHA256 sHA = SHA256.Create(); byte[] array = sHA.ComputeHash(File.ReadAllBytes(Assembly.GetExecutingAssembly().Location)); StringBuilder stringBuilder = new StringBuilder(); byte[] array2 = array; foreach (byte b in array2) { stringBuilder.Append(b.ToString("X2")); } return stringBuilder.ToString(); } } } namespace PerfectPlacement { [<fa36b506-5f27-4c75-9256-d48dbb1c433a>Nullable(0)] [BepInPlugin("Azumatt_and_ValheimPlusDevs.PerfectPlacement", "PerfectPlacement", "1.1.8")] [<c44312b6-f40f-41ca-bd8b-4eba4cc9a976>NullableContext(1)] public class PerfectPlacementPlugin : BaseUnityPlugin { [<c44312b6-f40f-41ca-bd8b-4eba4cc9a976>NullableContext(0)] public enum Toggle { On = 1, Off = 0 } [<c44312b6-f40f-41ca-bd8b-4eba4cc9a976>NullableContext(0)] internal class PlayerData { public Vector3 PlaceRotation = Vector3.zero; public bool Opposite; [<fa36b506-5f27-4c75-9256-d48dbb1c433a>Nullable(1)] public Piece LastPiece; public KeyCode LastKeyCode; } [<c44312b6-f40f-41ca-bd8b-4eba4cc9a976>NullableContext(0)] private class ConfigurationManagerAttributes { [UsedImplicitly] public int? Order; [UsedImplicitly] public bool? Browsable; [<fa36b506-5f27-4c75-9256-d48dbb1c433a>Nullable(2)] [UsedImplicitly] public string Category; [<fa36b506-5f27-4c75-9256-d48dbb1c433a>Nullable(new byte[] { 2, 1 })] [UsedImplicitly] public Action<ConfigEntryBase> CustomDrawer; } internal const string ModName = "PerfectPlacement"; internal const string ModVersion = "1.1.8"; internal const string Author = "Azumatt_and_ValheimPlusDevs"; private const string ModGUID = "Azumatt_and_ValheimPlusDevs.PerfectPlacement"; private static string ConfigFileName = "Azumatt_and_ValheimPlusDevs.PerfectPlacement.cfg"; private static string ConfigFileFullPath; internal static string ConnectionError; private readonly Harmony _harmony = new Harmony("Azumatt_and_ValheimPlusDevs.PerfectPlacement"); public static readonly ManualLogSource PerfectPlacementLogger; private static readonly ConfigSync ConfigSync; internal static readonly Dictionary<Player, PlayerData> PlayersData; private static ConfigEntry<Toggle> _serverConfigLocked; internal static ConfigEntry<Toggle> fpmIsEnabled; internal static ConfigEntry<KeyCode> fpmrotateY; internal static ConfigEntry<KeyCode> fpmrotateX; internal static ConfigEntry<KeyCode> fpmrotateZ; internal static ConfigEntry<KeyCode> fpmcopyRotationParallel; internal static ConfigEntry<KeyCode> fpmcopyRotationPerpendicular; internal static ConfigEntry<Toggle> abmIsEnabled; internal static ConfigEntry<KeyCode> abmenterAdvancedBuildingMode; internal static ConfigEntry<KeyCode> abmexitAdvancedBuildingMode; internal static ConfigEntry<KeyCode> abmcopyObjectRotation; internal static ConfigEntry<KeyCode> abmpasteObjectRotation; internal static ConfigEntry<KeyCode> abmincreaseScrollSpeed; internal static ConfigEntry<KeyCode> abmdecreaseScrollSpeed; internal static ConfigEntry<Toggle> aemIsEnabled; internal static ConfigEntry<KeyCode> aementerAdvancedEditingMode; internal static ConfigEntry<KeyCode> aemresetAdvancedEditingMode; internal static ConfigEntry<KeyCode> aemabortAndExitAdvancedEditingMode; internal static ConfigEntry<KeyCode> aemconfirmPlacementOfAdvancedEditingMode; internal static ConfigEntry<KeyCode> aemcopyObjectRotation; internal static ConfigEntry<KeyCode> aempasteObjectRotation; internal static ConfigEntry<KeyCode> aemincreaseScrollSpeed; internal static ConfigEntry<KeyCode> aemdecreaseScrollSpeed; internal static ConfigEntry<Toggle> gridAlignmentEnabled; internal static ConfigEntry<KeyCode> alignToGrid; internal static ConfigEntry<KeyCode> alignToggle; internal static ConfigEntry<KeyCode> changeDefaultAlignment; public void Awake() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Expected O, but got Unknown //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Expected O, but got Unknown //IL_0380: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Expected O, but got Unknown _serverConfigLocked = config("1 - General", "Lock Configuration", Toggle.On, new ConfigDescription("If on, the configuration is locked and can be changed by server admins only.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 5 } })); ConfigSync.AddLockingConfigEntry<Toggle>(_serverConfigLocked); fpmIsEnabled = config("1 - General", "Enable Free Placement Rotation", Toggle.On, new ConfigDescription("If on, Free Placement Rotation is enabled. Everything in section 2 will be affected.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 1 } })); fpmrotateY = config<KeyCode>("2 - Free Placement Rotation", "Rotate Y", (KeyCode)308, "The key to rotate the object you are placing on the Y axis, Rotates placement marker by 1 degree with keep ability to attach to nearly pieces.", synchronizedSetting: false); fpmrotateX = config<KeyCode>("2 - Free Placement Rotation", "Rotate X", (KeyCode)99, "The key to rotate the object you are placing on the X axis, Rotates placement marker by 1 degree with keep ability to attach to nearly pieces.", synchronizedSetting: false); fpmrotateZ = config<KeyCode>("2 - Free Placement Rotation", "Rotate Z", (KeyCode)118, "The key to rotate the object you are placing on the Z axis, Rotates placement marker by 1 degree with keep ability to attach to nearly pieces.", synchronizedSetting: false); fpmcopyRotationParallel = config<KeyCode>("2 - Free Placement Rotation", "Copy Rotation Parallel", (KeyCode)102, "Copy rotation of placement marker from target piece in front of you.", synchronizedSetting: false); fpmcopyRotationPerpendicular = config<KeyCode>("2 - Free Placement Rotation", "Copy Rotation Perpendicular", (KeyCode)103, "Set rotation to be perpendicular to piece in front of you.", synchronizedSetting: false); abmIsEnabled = config("1 - General", "Enable Advanced Building Mode", Toggle.On, new ConfigDescription("If on, Advanced Building Mode is enabled. Everything in section 3 will be affected.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 2 } })); abmenterAdvancedBuildingMode = config<KeyCode>("3 - Advanced Building Mode", "Enter Advanced Building Mode", (KeyCode)282, "The key to enter Advanced Building Mode when building", synchronizedSetting: false); abmexitAdvancedBuildingMode = config<KeyCode>("3 - Advanced Building Mode", "Exit Advanced Building Mode", (KeyCode)284, "The key to exit Advanced Building Mode when building", synchronizedSetting: false); abmcopyObjectRotation = config<KeyCode>("3 - Advanced Building Mode", "Copy Object Rotation", (KeyCode)263, "Copy the object rotation of the currently selected object in ABM", synchronizedSetting: false); abmpasteObjectRotation = config<KeyCode>("3 - Advanced Building Mode", "Paste Object Rotation", (KeyCode)264, "Apply the copied object rotation to the currently selected object in ABM", synchronizedSetting: false); abmincreaseScrollSpeed = config<KeyCode>("3 - Advanced Building Mode", "Increase Scroll Speed", (KeyCode)270, "Increases the amount an object rotates and moves. Holding Shift will increase in increments of 10 instead of 1.", synchronizedSetting: false); abmdecreaseScrollSpeed = config<KeyCode>("3 - Advanced Building Mode", "Decrease Scroll Speed", (KeyCode)269, "Decreases the amount an object rotates and moves. Holding Shift will decrease in increments of 10 instead of 1.", synchronizedSetting: false); aemIsEnabled = config("1 - General", "Enable Advanced Editing Mode", Toggle.On, new ConfigDescription("If on, Advanced Editing Mode is enabled. Everything in section 4 will be affected.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 3 } })); aementerAdvancedEditingMode = config<KeyCode>("4 - Advanced Editing Mode", "Enter Advanced Editing Mode", (KeyCode)256, "The key to enter Advanced Editing Mode", synchronizedSetting: false); aemresetAdvancedEditingMode = config<KeyCode>("4 - Advanced Editing Mode", "Reset Advanced Editing Mode", (KeyCode)288, "The key to reset the object to its original position and rotation", synchronizedSetting: false); aemabortAndExitAdvancedEditingMode = config<KeyCode>("4 - Advanced Editing Mode", "Abort and Exit Advanced Editing Mode", (KeyCode)289, "The key to abort and exit Advanced Editing Mode and reset the object", synchronizedSetting: false); aemconfirmPlacementOfAdvancedEditingMode = config<KeyCode>("4 - Advanced Editing Mode", "Confirm Placement of Advanced Editing Mode", (KeyCode)271, "The key to confirm the placement of the object and place it", synchronizedSetting: false); aemcopyObjectRotation = config<KeyCode>("4 - Advanced Editing Mode", "Copy Object Rotation", (KeyCode)263, "The key to copy the object rotation of the currently selected object in AEM", synchronizedSetting: false); aempasteObjectRotation = config<KeyCode>("4 - Advanced Editing Mode", "Paste Object Rotation", (KeyCode)264, "The key to apply the copied object rotation to the currently selected object in AEM", synchronizedSetting: false); aemincreaseScrollSpeed = config<KeyCode>("4 - Advanced Editing Mode", "Increase Scroll Speed", (KeyCode)270, "The key to increase the scroll speed. Increases the amount an object rotates and moves. Holding Shift will increase in increments of 10 instead of 1.", synchronizedSetting: false); aemdecreaseScrollSpeed = config<KeyCode>("4 - Advanced Editing Mode", "Decrease Scroll Speed", (KeyCode)269, "The key to decrease the scroll speed. Decreases the amount an object rotates and moves. Holding Shift will increase in increments of 10 instead of 1.", synchronizedSetting: false); gridAlignmentEnabled = config("1 - General", "Enable Grid Alignment", Toggle.Off, new ConfigDescription("If off, Grid Alignment is disabled overall, all code for it will be skipped. Everything in section 5 will be affected.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 4 } })); alignToGrid = config<KeyCode>("5 - Grid Alignment", "Align to Grid", (KeyCode)308, "The key to enable grid alignment while building", synchronizedSetting: false); alignToggle = config<KeyCode>("5 - Grid Alignment", "Align Toggle", (KeyCode)288, "The key to toggle grid alignment while building", synchronizedSetting: false); changeDefaultAlignment = config<KeyCode>("5 - Grid Alignment", "Change Default Alignment", (KeyCode)287, "The key to change the default alignment", synchronizedSetting: false); Assembly executingAssembly = Assembly.GetExecutingAssembly(); _harmony.PatchAll(executingAssembly); SetupWatcher(); } private void Start() { AutoDoc(); } internal void AutoDoc() { } private void OnDestroy() { ((BaseUnityPlugin)this).Config.Save(); } private void SetupWatcher() { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName); fileSystemWatcher.Changed += ReadConfigValues; fileSystemWatcher.Created += ReadConfigValues; fileSystemWatcher.Renamed += ReadConfigValues; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; } private void ReadConfigValues(object sender, FileSystemEventArgs e) { if (!File.Exists(ConfigFileFullPath)) { return; } try { PerfectPlacementLogger.LogDebug((object)"ReadConfigValues called"); ((BaseUnityPlugin)this).Config.Reload(); } catch { PerfectPlacementLogger.LogError((object)("There was an issue loading your " + ConfigFileName)); PerfectPlacementLogger.LogError((object)"Please check your config entries for spelling and format!"); } } private ConfigEntry<T> config<[<fa36b506-5f27-4c75-9256-d48dbb1c433a>Nullable(2)] T>(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown ConfigDescription val = new ConfigDescription(description.Description + (synchronizedSetting ? " [Synced with Server]" : " [Not Synced with Server]"), description.AcceptableValues, description.Tags); ConfigEntry<T> val2 = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, val); ConfigSync.AddConfigEntry<T>(val2).SynchronizedConfig = synchronizedSetting; return val2; } private ConfigEntry<T> config<[<fa36b506-5f27-4c75-9256-d48dbb1c433a>Nullable(2)] T>(string group, string name, T value, string description, bool synchronizedSetting = true) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting); } static PerfectPlacementPlugin() { string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName; ConnectionError = ""; PerfectPlacementLogger = Logger.CreateLogSource("PerfectPlacement"); ConfigSync = new ConfigSync("Azumatt_and_ValheimPlusDevs.PerfectPlacement") { DisplayName = "PerfectPlacement", CurrentVersion = "1.1.8", MinimumRequiredVersion = "1.1.8" }; PlayersData = new Dictionary<Player, PlayerData>(); _serverConfigLocked = null; fpmIsEnabled = null; fpmrotateY = null; fpmrotateX = null; fpmrotateZ = null; fpmcopyRotationParallel = null; fpmcopyRotationPerpendicular = null; abmIsEnabled = null; abmenterAdvancedBuildingMode = null; abmexitAdvancedBuildingMode = null; abmcopyObjectRotation = null; abmpasteObjectRotation = null; abmincreaseScrollSpeed = null; abmdecreaseScrollSpeed = null; aemIsEnabled = null; aementerAdvancedEditingMode = null; aemresetAdvancedEditingMode = null; aemabortAndExitAdvancedEditingMode = null; aemconfirmPlacementOfAdvancedEditingMode = null; aemcopyObjectRotation = null; aempasteObjectRotation = null; aemincreaseScrollSpeed = null; aemdecreaseScrollSpeed = null; gridAlignmentEnabled = null; alignToGrid = null; alignToggle = null; changeDefaultAlignment = null; } } } namespace PerfectPlacement.Patches { public class Util { internal static Vector3 ClampAngles(Vector3 angles) { //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_0016: 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) return new Vector3(ClampAngle(angles.x), ClampAngle(angles.y), ClampAngle(angles.z)); } internal static int ClampPlaceRotation(int index) { if (index < 0) { index = 16 + index; } else if (index >= 16) { index -= 16; } return index; } private static float ClampAngle(float angle) { if (angle < 0f) { angle = 360f + angle; } else if (angle >= 360f) { angle -= 360f; } return angle; } [<c44312b6-f40f-41ca-bd8b-4eba4cc9a976>NullableContext(1)] public static Character getPlayerCharacter(Player __instance) { return (Character)(object)__instance; } } [<fa36b506-5f27-4c75-9256-d48dbb1c433a>Nullable(0)] [<c44312b6-f40f-41ca-bd8b-4eba4cc9a976>NullableContext(1)] internal class ABM { public static bool isActive; private static Player PlayerInstance; private static bool controlFlag; private static bool shiftFlag; private static bool altFlag; public static bool exitOnNextIteration; private static bool blockDefaultFunction; private static Piece component; private const float BASE_TRANSLATION_DISTANCE = 0.1f; private const float BASE_ROTATION_ANGLE_DEGREES = 3f; private static float currentModificationSpeed = 1f; private const float MIN_MODIFICATION_SPEED = 1f; private const float MAX_MODIFICATION_SPEED = 30f; private static Quaternion savedRotation; public static void Run(ref Player __instance) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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) PlayerInstance = __instance; if (AEM.isActive) { if (isActive) { exitMode(); } return; } if (Input.GetKeyDown(PerfectPlacementPlugin.abmexitAdvancedBuildingMode.Value)) { if (isActive) { exitMode(); } return; } if (exitOnNextIteration) { isActive = false; blockDefaultFunction = false; exitOnNextIteration = false; component = null; } if (isActive && (Object)(object)component == (Object)null) { exitMode(); } else if ((Object)(object)selectedPrefab() == (Object)null || (Object)(object)PlayerInstance.m_placementGhost == (Object)null) { if (isActive) { exitMode(); } } else if (isInBuildMode() && IsHoeOrTerrainTool(selectedPrefab())) { if (isActive) { exitMode(); } } else if (isActive) { if (Vector3.Distance(((Component)PlayerInstance).transform.position, ((Component)component).transform.position) > PlayerInstance.m_maxPlaceDistance) { exitMode(); } isRunning(); listenToHotKeysAndDoWork(); } else if (Input.GetKeyDown(PerfectPlacementPlugin.abmenterAdvancedBuildingMode.Value)) { startMode(); } } private static void listenToHotKeysAndDoWork() { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_040e: Unknown result type (might be due to invalid IL or missing references) float num = 0f; float num2 = 0f; float num3 = 0f; if (Input.GetKeyDown((KeyCode)306)) { controlFlag = true; } if (Input.GetKeyUp((KeyCode)306)) { controlFlag = false; } if (Input.GetKeyDown((KeyCode)304)) { shiftFlag = true; } if (Input.GetKeyUp((KeyCode)304)) { shiftFlag = false; } if (Input.GetKeyDown((KeyCode)308)) { altFlag = true; } if (Input.GetKeyUp((KeyCode)308)) { altFlag = false; } changeModificationSpeed(); if (Input.GetKeyUp(PerfectPlacementPlugin.abmcopyObjectRotation.Value)) { savedRotation = ((Component)component).transform.rotation; } if (Input.GetKeyUp(PerfectPlacementPlugin.abmpasteObjectRotation.Value)) { ((Component)component).transform.rotation = savedRotation; } float num4 = 3f * currentModificationSpeed; if (Input.GetAxis("Mouse ScrollWheel") > 0f) { Quaternion rotation; if (controlFlag) { num += 1f; rotation = Quaternion.Euler(((Component)component).transform.eulerAngles.x + num4 * num, ((Component)component).transform.eulerAngles.y, ((Component)component).transform.eulerAngles.z); } else if (altFlag) { num2 += 1f; rotation = Quaternion.Euler(((Component)component).transform.eulerAngles.x, ((Component)component).transform.eulerAngles.y, ((Component)component).transform.eulerAngles.z + num4 * num2); } else { num3 += 1f; rotation = Quaternion.Euler(((Component)component).transform.eulerAngles.x, ((Component)component).transform.eulerAngles.y + num4 * num3, ((Component)component).transform.eulerAngles.z); } ((Component)component).transform.rotation = rotation; } if (Input.GetAxis("Mouse ScrollWheel") < 0f) { Quaternion rotation2; if (controlFlag) { num -= 1f; rotation2 = Quaternion.Euler(((Component)component).transform.eulerAngles.x + num4 * num, ((Component)component).transform.eulerAngles.y, ((Component)component).transform.eulerAngles.z); } else if (altFlag) { num2 -= 1f; rotation2 = Quaternion.Euler(((Component)component).transform.eulerAngles.x, ((Component)component).transform.eulerAngles.y, ((Component)component).transform.eulerAngles.z + num4 * num2); } else { num3 -= 1f; rotation2 = Quaternion.Euler(((Component)component).transform.eulerAngles.x, ((Component)component).transform.eulerAngles.y + num4 * num3, ((Component)component).transform.eulerAngles.z); } ((Component)component).transform.rotation = rotation2; } float num5 = 0.1f * currentModificationSpeed; if (Input.GetKeyDown((KeyCode)273)) { if (controlFlag) { ((Component)component).transform.Translate(Vector3.up * num5); } else { ((Component)component).transform.Translate(Vector3.forward * num5); } } if (Input.GetKeyDown((KeyCode)274)) { if (controlFlag) { ((Component)component).transform.Translate(Vector3.down * num5); } else { ((Component)component).transform.Translate(Vector3.back * num5); } } if (Input.GetKeyDown((KeyCode)276)) { ((Component)component).transform.Translate(Vector3.left * num5); } if (Input.GetKeyDown((KeyCode)275)) { ((Component)component).transform.Translate(Vector3.right * num5); } try { isValidPlacement(); } catch { } } private static void isValidPlacement() { //IL_0006: 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_00c3: 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_0128: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_013a: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: 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) PlayerInstance.m_placementStatus = (PlacementStatus)0; if (component.m_groundOnly || component.m_groundPiece || component.m_cultivatedGroundOnly) { PlayerInstance.m_placementMarkerInstance.SetActive(false); } StationExtension val = ((Component)component).GetComponent<StationExtension>(); if ((Object)(object)val != (Object)null) { CraftingStation val2 = val.FindClosestStationInRange(((Component)component).transform.position); if (Object.op_Implicit((Object)(object)val2)) { val.StartConnectionEffect(val2, 1f); } else { val.StopConnectionEffect(); PlayerInstance.m_placementStatus = (PlacementStatus)7; } if (val.OtherExtensionInRange(component.m_spaceRequirement)) { PlayerInstance.m_placementStatus = (PlacementStatus)5; } } if (component.m_onlyInTeleportArea && !Object.op_Implicit((Object)(object)EffectArea.IsPointInsideArea(((Component)component).transform.position, (Type)16, 0f))) { PlayerInstance.m_placementStatus = (PlacementStatus)6; } if (!component.m_allowedInDungeons && ((Component)component).transform.position.y > 3000f) { PlayerInstance.m_placementStatus = (PlacementStatus)11; } if (Location.IsInsideNoBuildLocation(PlayerInstance.m_placementGhost.transform.position)) { PlayerInstance.m_placementStatus = (PlacementStatus)3; } float num = (Object.op_Implicit((Object)(object)((Component)component).GetComponent<PrivateArea>()) ? ((Component)component).GetComponent<PrivateArea>().m_radius : 0f); if (!PrivateArea.CheckAccess(PlayerInstance.m_placementGhost.transform.position, num, true, false)) { PlayerInstance.m_placementStatus = (PlacementStatus)4; } if (WardIsLovePlugin.IsLoaded() && WardIsLovePlugin.WardEnabled().Value && WardMonoscript.CheckInWardMonoscript(PlayerInstance.m_placementGhost.transform.position) && !WardMonoscript.CheckAccess(PlayerInstance.m_placementGhost.transform.position, num)) { PlayerInstance.m_placementStatus = (PlacementStatus)4; } if ((int)PlayerInstance.m_placementStatus != 0) { component.SetInvalidPlacementHeightlight(true); } else { component.SetInvalidPlacementHeightlight(false); } } private static void startMode() { notifyUser("Starting ABM", (MessageType)1); isActive = true; blockDefaultFunction = true; component = PlayerInstance.m_placementGhost.GetComponent<Piece>(); } private static void exitMode() { notifyUser("Exiting ABM", (MessageType)1); exitOnNextIteration = true; isActive = false; component = null; } private static bool isInBuildMode() { return ((Character)PlayerInstance).InPlaceMode(); } private static GameObject selectedPrefab() { if ((Object)(object)PlayerInstance.m_buildPieces != (Object)null) { try { return PlayerInstance.m_buildPieces.GetSelectedPrefab(); } catch { return null; } } return null; } private static bool IsHoeOrTerrainTool(GameObject selectedPrefab) { string[] source = new string[4] { "paved_road", "mud_road", "raise", "path" }; string[] source2 = new string[2] { "cultivate", "replant" }; if (((Object)selectedPrefab).name.ToLower().Contains("sapling")) { return true; } if (source.Contains(((Object)selectedPrefab).name) || source2.Contains(((Object)selectedPrefab).name)) { return true; } return false; } private static void notifyUser(string Message, MessageType position = 1) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) MessageHud.instance.ShowMessage(position, "ABM: " + Message, 0, (Sprite)null); } private static void isRunning() { if (isActive) { MessageHud.instance.ShowMessage((MessageType)2, "ABM is active", 0, (Sprite)null); } } private static void changeModificationSpeed() { //IL_0018: 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) float num = 1f; if (shiftFlag) { num = 10f; } if (Input.GetKeyDown(PerfectPlacementPlugin.abmincreaseScrollSpeed.Value)) { currentModificationSpeed = Mathf.Clamp(currentModificationSpeed + num, 1f, 30f); notifyUser("Modification Speed: " + currentModificationSpeed, (MessageType)1); } if (Input.GetKeyDown(PerfectPlacementPlugin.abmdecreaseScrollSpeed.Value)) { currentModificationSpeed = Mathf.Clamp(currentModificationSpeed - num, 1f, 30f); notifyUser("Modification Speed: " + currentModificationSpeed, (MessageType)1); } } } [<c44312b6-f40f-41ca-bd8b-4eba4cc9a976>NullableContext(1)] [<fa36b506-5f27-4c75-9256-d48dbb1c433a>Nullable(0)] internal class AEM { public static bool isActive; public static Player PlayerInstance; private static bool controlFlag; private static bool shiftFlag; private static bool altFlag; public static Vector3 HitPoint; public static Vector3 HitNormal; public static Piece HitPiece; public static GameObject HitObject; public static Heightmap HitHeightmap; private static Quaternion InitialRotation; private static Vector3 InitialPosition; private static bool isInExistence; private const float BASE_TRANSLATION_DISTANCE = 0.1f; private const float BASE_ROTATION_ANGLE_DEGREES = 3f; private static float currentModificationSpeed = 1f; private const float MIN_MODIFICATION_SPEED = 1f; private const float MAX_MODIFICATION_SPEED = 30f; private static Quaternion savedRotation; public static bool forceExitNextIteration; public static bool ExecuteRayCast(Player playerInstance) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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) //IL_0070: 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_0089: 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_00d7: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) int placeRayMask = playerInstance.m_placeRayMask; RaycastHit val = default(RaycastHit); if (Physics.Raycast(((Component)GameCamera.instance).transform.position, ((Component)GameCamera.instance).transform.forward, ref val, 50f, placeRayMask) && Object.op_Implicit((Object)(object)((RaycastHit)(ref val)).collider) && !Object.op_Implicit((Object)(object)((RaycastHit)(ref val)).collider.attachedRigidbody) && Vector3.Distance(Util.getPlayerCharacter(playerInstance).m_eye.position, ((RaycastHit)(ref val)).point) < playerInstance.m_maxPlaceDistance) { HitPoint = ((RaycastHit)(ref val)).point; HitNormal = ((RaycastHit)(ref val)).normal; HitPiece = ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<Piece>(); HitObject = ((Component)((RaycastHit)(ref val)).collider).gameObject; HitHeightmap = ((Component)((RaycastHit)(ref val)).collider).GetComponent<Heightmap>(); InitialRotation = ((Component)HitPiece).transform.rotation; InitialPosition = ((Component)HitPiece).transform.position; return isValidRayCastTarget(); } resetObjectInfo(); return false; } public static bool checkForObject() { if ((Object)(object)PlayerInstance == (Object)null) { return false; } if (!ExecuteRayCast(PlayerInstance)) { return false; } return true; } public static void run() { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) if (forceExitNextIteration) { forceExitNextIteration = false; resetObjectInfo(); isActive = false; return; } if (isInBuildMode()) { if (isActive) { exitMode(); resetObjectTransform(); } return; } if (ABM.isActive) { if (isActive) { exitMode(); resetObjectTransform(); } return; } if (!isActive && Input.GetKeyDown(PerfectPlacementPlugin.aementerAdvancedEditingMode.Value)) { if (checkForObject()) { startMode(); } return; } if (Input.GetKeyDown(PerfectPlacementPlugin.aemabortAndExitAdvancedEditingMode.Value)) { exitMode(); resetObjectTransform(); } if (!isActive) { return; } if (hitPieceStillExists()) { try { if ((Object)(object)((Component)HitPiece).GetComponent<ZNetView>() == (Object)null) { PerfectPlacementPlugin.PerfectPlacementLogger.LogInfo((object)"AEM: Error, network object empty. Code: 2."); exitMode(); return; } } catch { PerfectPlacementPlugin.PerfectPlacementLogger.LogInfo((object)"AEM: Error, network object empty. Code: 3."); exitMode(); } isRunning(); listenToHotKeysAndDoWork(); } else { exitMode(); } } private static void listenToHotKeysAndDoWork() { //IL_0017: 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_005c: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_04ae: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Unknown result type (might be due to invalid IL or missing references) //IL_0491: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_043e: Unknown result type (might be due to invalid IL or missing references) //IL_0448: Unknown result type (might be due to invalid IL or missing references) //IL_044d: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_0459: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Unknown result type (might be due to invalid IL or missing references) //IL_0520: Unknown result type (might be due to invalid IL or missing references) //IL_04f2: Unknown result type (might be due to invalid IL or missing references) //IL_04f9: Unknown result type (might be due to invalid IL or missing references) //IL_04d5: Unknown result type (might be due to invalid IL or missing references) //IL_04dc: Unknown result type (might be due to invalid IL or missing references) //IL_0540: Unknown result type (might be due to invalid IL or missing references) //IL_0547: Unknown result type (might be due to invalid IL or missing references) float num = 0f; float num2 = 0f; float num3 = 0f; if (Input.GetKeyDown(PerfectPlacementPlugin.aemresetAdvancedEditingMode.Value)) { resetObjectTransform(); } if (Input.GetKeyDown(PerfectPlacementPlugin.aemconfirmPlacementOfAdvancedEditingMode.Value)) { if (isContainer()) { dropContainerContents(); } GameObject val = Object.Instantiate<GameObject>(((Component)HitPiece).gameObject, ((Component)HitPiece).transform.position, ((Component)HitPiece).transform.rotation); HitPiece.m_placeEffect.Create(((Component)HitPiece).transform.position, ((Component)HitPiece).transform.rotation, val.transform, 1f, -1); ZNetView component = ((Component)HitPiece).GetComponent<ZNetView>(); if ((Object)(object)component == (Object)null) { PerfectPlacementPlugin.PerfectPlacementLogger.LogInfo((object)"AEM: Error, network object empty."); resetObjectTransform(); exitMode(); } else { component.ClaimOwnership(); ZNetScene.instance.Destroy(((Component)HitPiece).gameObject); PerfectPlacementPlugin.PerfectPlacementLogger.LogInfo((object)"AEM: Executed."); exitMode(); } return; } if (Input.GetKeyDown((KeyCode)306)) { controlFlag = true; } if (Input.GetKeyUp((KeyCode)306)) { controlFlag = false; } if (Input.GetKeyDown((KeyCode)304)) { shiftFlag = true; } if (Input.GetKeyUp((KeyCode)304)) { shiftFlag = false; } if (Input.GetKeyDown((KeyCode)308)) { altFlag = true; } if (Input.GetKeyUp((KeyCode)308)) { altFlag = false; } changeModificationSpeed(); if (Input.GetKeyUp(PerfectPlacementPlugin.aemcopyObjectRotation.Value)) { savedRotation = ((Component)HitPiece).transform.rotation; } if (Input.GetKeyUp(PerfectPlacementPlugin.aempasteObjectRotation.Value)) { ((Component)HitPiece).transform.rotation = savedRotation; } if (Vector3.Distance(((Component)PlayerInstance).transform.position, ((Component)HitPiece).transform.position) > PlayerInstance.m_maxPlaceDistance) { resetObjectTransform(); exitMode(); } float num4 = 3f * currentModificationSpeed; if (Input.GetAxis("Mouse ScrollWheel") > 0f) { Quaternion rotation; if (controlFlag) { num += 1f; rotation = Quaternion.Euler(((Component)HitPiece).transform.eulerAngles.x + num4 * num, ((Component)HitPiece).transform.eulerAngles.y, ((Component)HitPiece).transform.eulerAngles.z); } else if (altFlag) { num2 += 1f; rotation = Quaternion.Euler(((Component)HitPiece).transform.eulerAngles.x, ((Component)HitPiece).transform.eulerAngles.y, ((Component)HitPiece).transform.eulerAngles.z + num4 * num2); } else { num3 += 1f; rotation = Quaternion.Euler(((Component)HitPiece).transform.eulerAngles.x, ((Component)HitPiece).transform.eulerAngles.y + num4 * num3, ((Component)HitPiece).transform.eulerAngles.z); } ((Component)HitPiece).transform.rotation = rotation; } if (Input.GetAxis("Mouse ScrollWheel") < 0f) { Quaternion rotation2; if (controlFlag) { num -= 1f; rotation2 = Quaternion.Euler(((Component)HitPiece).transform.eulerAngles.x + num4 * num, ((Component)HitPiece).transform.eulerAngles.y, ((Component)HitPiece).transform.eulerAngles.z); } else if (altFlag) { num2 -= 1f; rotation2 = Quaternion.Euler(((Component)HitPiece).transform.eulerAngles.x, ((Component)HitPiece).transform.eulerAngles.y, ((Component)HitPiece).transform.eulerAngles.z + num4 * num2); } else { num3 -= 1f; rotation2 = Quaternion.Euler(((Component)HitPiece).transform.eulerAngles.x, ((Component)HitPiece).transform.eulerAngles.y + num4 * num3, ((Component)HitPiece).transform.eulerAngles.z); } ((Component)HitPiece).transform.rotation = rotation2; } float num5 = 0.1f * currentModificationSpeed; if (Input.GetKeyDown((KeyCode)273)) { if (controlFlag) { ((Component)HitPiece).transform.Translate(Vector3.up * num5); } else { ((Component)HitPiece).transform.Translate(Vector3.forward * num5); } } if (Input.GetKeyDown((KeyCode)274)) { if (controlFlag) { ((Component)HitPiece).transform.Translate(Vector3.down * num5); } else { ((Component)HitPiece).transform.Translate(Vector3.back * num5); } } if (Input.GetKeyDown((KeyCode)276)) { ((Component)HitPiece).transform.Translate(Vector3.left * num5); } if (Input.GetKeyDown((KeyCode)275)) { ((Component)HitPiece).transform.Translate(Vector3.right * num5); } } private static bool hitPieceStillExists() { try { if (isActive) { isInExistence = true; } } catch { isInExistence = false; } return isInExistence; } private static bool isValidRayCastTarget() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) bool result = true; if (HitPiece.m_onlyInTeleportArea && !Object.op_Implicit((Object)(object)EffectArea.IsPointInsideArea(((Component)HitPiece).transform.position, (Type)16, 0f))) { result = false; } if (!HitPiece.m_allowedInDungeons && ((Component)HitPiece).transform.position.y > 3000f) { result = false; } if (Location.IsInsideNoBuildLocation(((Component)HitPiece).transform.position)) { result = false; } float num = (Object.op_Implicit((Object)(object)((Component)HitPiece).GetComponent<PrivateArea>()) ? ((Component)HitPiece).GetComponent<PrivateArea>().m_radius : 0f); if (!PrivateArea.CheckAccess(((Component)HitPiece).transform.position, num, true, false)) { result = false; } if (WardIsLovePlugin.IsLoaded() && WardIsLovePlugin.WardEnabled().Value && WardMonoscript.CheckInWardMonoscript(((Component)HitPiece).transform.position) && !WardMonoscript.CheckAccess(((Component)HitPiece).transform.position, num)) { result = false; } return result; } private static bool isInBuildMode() { return ((Character)PlayerInstance).InPlaceMode(); } private static void resetObjectTransform() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)HitPiece == (Object)null)) { notifyUser("Object has been reset to initial position & rotation.", (MessageType)1); ((Component)HitPiece).transform.position = InitialPosition; ((Component)HitPiece).transform.rotation = InitialRotation; } } private static void resetObjectInfo() { //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) //IL_002b: 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) HitPoint = Vector3.zero; HitNormal = Vector3.zero; HitObject = null; HitPiece = null; HitHeightmap = null; InitialRotation = default(Quaternion); InitialPosition = default(Vector3); } private static void startMode() { notifyUser("Entering AEM", (MessageType)1); isActive = true; } private static void exitMode() { notifyUser("Exiting AEM", (MessageType)1); forceExitNextIteration = true; } private static void notifyUser(string Message, MessageType position = 1) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) MessageHud.instance.ShowMessage(position, "AEM: " + Message, 0, (Sprite)null); } private static void isRunning() { if (isActive) { MessageHud.instance.ShowMessage((MessageType)2, "AEM is active", 0, (Sprite)null); } } private static bool isContainer() { return (Object)(object)((Component)HitPiece).GetComponent<Container>() != (Object)null; } private static void dropContainerContents() { ((Component)HitPiece).GetComponent<Container>().DropAllItems(); } private static void changeModificationSpeed() { //IL_0018: 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) float num = 1f; if (shiftFlag) { num = 10f; } if (Input.GetKeyDown(PerfectPlacementPlugin.aemincreaseScrollSpeed.Value)) { currentModificationSpeed = Mathf.Clamp(currentModificationSpeed + num, 1f, 30f); notifyUser("Modification Speed: " + currentModificationSpeed, (MessageType)1); } if (Input.GetKeyDown(PerfectPlacementPlugin.aemdecreaseScrollSpeed.Value)) { currentModificationSpeed = Mathf.Clamp(currentModificationSpeed - num, 1f, 30f); notifyUser("Modification Speed: " + currentModificationSpeed, (MessageType)1); } } } [HarmonyPatch(typeof(GameCamera), "UpdateCamera")] public static class BlockCameraScrollInAEM { [<c44312b6-f40f-41ca-bd8b-4eba4cc9a976>NullableContext(1)] private static void Prefix(GameCamera __instance) { if (AEM.isActive) { __instance.m_maxDistance = __instance.m_distance; __instance.m_minDistance = __instance.m_distance; } else { __instance.m_maxDistance = 6f; } } } [<c44312b6-f40f-41ca-bd8b-4eba4cc9a976>NullableContext(1)] [<fa36b506-5f27-4c75-9256-d48dbb1c433a>Nullable(0)] [HarmonyPatch(typeof(Player), "Update")] public static class Player_Update_Patch { private static GameObject timeObj = null; private static double savedEnvMinutes = -1.0; private static void Postfix(ref Player __instance, ref Vector3 ___m_moveDir, ref Vector3 ___m_lookDir, ref GameObject ___m_placementGhost, Transform ___m_eye) { if (((Character)__instance).m_nview.IsValid() && ((Character)__instance).m_nview.IsOwner()) { if (PerfectPlacementPlugin.aemIsEnabled.Value == PerfectPlacementPlugin.Toggle.On) { AEM.PlayerInstance = __instance; AEM.run(); } if (PerfectPlacementPlugin.abmIsEnabled.Value == PerfectPlacementPlugin.Toggle.On) { ABM.Run(ref __instance); } } } } [<c44312b6-f40f-41ca-bd8b-4eba4cc9a976>NullableContext(1)] [<fa36b506-5f27-4c75-9256-d48dbb1c433a>Nullable(0)] [HarmonyPatch(typeof(Player), "UpdatePlacementGhost")] public static class Player_UpdatePlacementGhost_Transpile { private static MethodInfo method_Quaternion_Euler = AccessTools.Method(typeof(Quaternion), "Euler", new Type[3] { typeof(float), typeof(float), typeof(float) }, (Type[])null); private static MethodInfo method_GetRotation = AccessTools.Method(typeof(Player_UpdatePlacementGhost_Transpile), "GetRotation", (Type[])null, (Type[])null); [HarmonyTranspiler] public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown if (PerfectPlacementPlugin.fpmIsEnabled.Value == PerfectPlacementPlugin.Toggle.Off) { return instructions; } List<CodeInstruction> list = instructions.ToList(); for (int i = 0; i < list.Count; i++) { if (CodeInstructionExtensions.Calls(list[i], method_Quaternion_Euler)) { list[i - 1] = new CodeInstruction(OpCodes.Ldarg_0, (object)null); list[i] = new CodeInstruction(OpCodes.Call, (object)method_GetRotation); list.RemoveRange(i - 8, 7); break; } } return list.AsEnumerable(); } public static Quaternion GetRotation(Player __instance) { //IL_001f: 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_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) //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (ABM.isActive) { return Quaternion.Euler(0f, __instance.m_placeRotationDegrees * (float)__instance.m_placeRotation, 0f); } PerfectPlacementPlugin.PlayerData value; return Quaternion.Euler(PerfectPlacementPlugin.PlayersData.TryGetValue(__instance, out value) ? value.PlaceRotation : ((float)__instance.m_placeRotation * 22.5f * Vector3.up)); } } [<c44312b6-f40f-41ca-bd8b-4eba4cc9a976>NullableContext(1)] [<fa36b506-5f27-4c75-9256-d48dbb1c433a>Nullable(0)] [HarmonyPatch(typeof(Player), "UpdatePlacement")] public static class ModifyPUpdatePlacement { private static void Postfix(Player __instance, bool takeInput, float dt) { //IL_0053: 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) if (PerfectPlacementPlugin.fpmIsEnabled.Value != 0 && !ABM.isActive && ((Character)__instance).InPlaceMode() && takeInput && !Hud.IsPieceSelectionVisible()) { if (!PerfectPlacementPlugin.PlayersData.ContainsKey(__instance)) { PerfectPlacementPlugin.PlayersData[__instance] = new PerfectPlacementPlugin.PlayerData(); } RotateWithWheel(__instance); SyncRotationWithTargetInFront(__instance, PerfectPlacementPlugin.fpmcopyRotationParallel.Value, perpendicular: false); SyncRotationWithTargetInFront(__instance, PerfectPlacementPlugin.fpmcopyRotationPerpendicular.Value, perpendicular: true); } } private static void RotateWithWheel(Player __instance) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0061: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) float axis = Input.GetAxis("Mouse ScrollWheel"); PerfectPlacementPlugin.PlayerData playerData = PerfectPlacementPlugin.PlayersData[__instance]; if (!axis.Equals(0f) || ZInput.GetButton("JoyRotate")) { if (Input.GetKey(PerfectPlacementPlugin.fpmrotateY.Value)) { playerData.PlaceRotation += Vector3.up * Mathf.Sign(axis); __instance.m_placeRotation = (int)(playerData.PlaceRotation.y / 22.5f); } else if (Input.GetKey(PerfectPlacementPlugin.fpmrotateX.Value)) { playerData.PlaceRotation += Vector3.right * Mathf.Sign(axis); } else if (Input.GetKey(PerfectPlacementPlugin.fpmrotateZ.Value)) { playerData.PlaceRotation += Vector3.forward * Mathf.Sign(axis); } else { __instance.m_placeRotation = Util.ClampPlaceRotation(__instance.m_placeRotation); playerData.PlaceRotation = new Vector3(0f, (float)__instance.m_placeRotation * 22.5f, 0f); } playerData.PlaceRotation = Util.ClampAngles(playerData.PlaceRotation); } } private static void SyncRotationWithTargetInFront(Player __instance, KeyCode keyCode, bool perpendicular) { //IL_000f: 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) //IL_004c: 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_0071: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_008a: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) Vector3 val = default(Vector3); Vector3 placeRotation = default(Vector3); Piece val2 = default(Piece); Heightmap val3 = default(Heightmap); Collider val4 = default(Collider); if (!((Object)(object)__instance.m_placementGhost == (Object)null) && Input.GetKeyUp(keyCode) && __instance.PieceRayTest(ref val, ref placeRotation, ref val2, ref val3, ref val4, false) && !((Object)(object)val2 == (Object)null)) { PerfectPlacementPlugin.PlayerData playerData = PerfectPlacementPlugin.PlayersData[__instance]; Quaternion val5 = ((Component)val2).transform.rotation; if (perpendicular) { val5 *= Quaternion.Euler(0f, 90f, 0f); } if (playerData.LastKeyCode != keyCode || (Object)(object)playerData.LastPiece != (Object)(object)val2) { playerData.Opposite = false; } playerData.LastKeyCode = keyCode; playerData.LastPiece = val2; if (playerData.Opposite) { val5 *= Quaternion.Euler(0f, 180f, 0f); } playerData.Opposite = !playerData.Opposite; playerData.PlaceRotation = ((Quaternion)(ref val5)).eulerAngles; ManualLogSource perfectPlacementLogger = PerfectPlacementPlugin.PerfectPlacementLogger; placeRotation = playerData.PlaceRotation; perfectPlacementLogger.LogInfo((object)("Sync Angle " + ((object)(Vector3)(ref placeRotation)).ToString())); } } } [<c44312b6-f40f-41ca-bd8b-4eba4cc9a976>NullableContext(1)] [<fa36b506-5f27-4c75-9256-d48dbb1c433a>Nullable(0)] [HarmonyPatch(typeof(Player), "UpdatePlacementGhost")] public static class Player_UpdatePlacementGhost_Patch { private static Vector3? ghostPosition; private static Quaternion? ghostRotation; private static Vector3? markerPosition; private static Quaternion? markerRotation; private static void Prefix(ref Player __instance, bool flashGuardStone) { //IL_0024: 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) //IL_002e: 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_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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) if (ABM.isActive) { if (Object.op_Implicit((Object)(object)__instance.m_placementGhost)) { ghostPosition = __instance.m_placementGhost.transform.position + Vector3.zero; ghostRotation = __instance.m_placementGhost.transform.rotation * Quaternion.identity; } if (Object.op_Implicit((Object)(object)__instance.m_placementMarkerInstance)) { markerPosition = __instance.m_placementMarkerInstance.transform.position + Vector3.zero; markerRotation = __instance.m_placementMarkerInstance.transform.rotation * Quaternion.identity; } } } private static void Postfix(ref Player __instance) { //IL_001b: 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_0067: 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) if (ABM.isActive) { __instance.m_placementGhost.transform.position = ghostPosition.Value; __instance.m_placementGhost.transform.rotation = ghostRotation.Value; ghostPosition = null; ghostRotation = null; __instance.m_placementMarkerInstance.transform.position = markerPosition.Value; __instance.m_placementMarkerInstance.transform.rotation = markerRotation.Value; markerPosition = null; markerRotation = null; if (Object.op_Implicit((Object)(object)__instance.m_placementMarkerInstance)) { __instance.m_placementMarkerInstance.SetActive(false); } } if (ABM.exitOnNextIteration) { try { if (Object.op_Implicit((Object)(object)__instance.m_placementMarkerInstance)) { __instance.m_placementMarkerInstance.SetActive(false); } } catch { } } if (PerfectPlacementPlugin.gridAlignmentEnabled.Value == PerfectPlacementPlugin.Toggle.On && (GridAlignment.AlignPressed ^ GridAlignment.AlignToggled)) { GridAlignment.UpdatePlacementGhost(__instance); } } } [<c44312b6-f40f-41ca-bd8b-4eba4cc9a976>NullableContext(1)] [<fa36b506-5f27-4c75-9256-d48dbb1c433a>Nullable(0)] [HarmonyPatch(typeof(Player), "Update")] public static class GridAlignment { public static int DefaultAlignment = 100; public static bool AlignPressed = false; public static bool AlignToggled = false; private static void Postfix(ref Player __instance) { //IL_001c: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) if (!((Character)__instance).IsPlayer() || PerfectPlacementPlugin.gridAlignmentEnabled.Value == PerfectPlacementPlugin.Toggle.Off) { return; } if (Input.GetKeyDown(PerfectPlacementPlugin.alignToGrid.Value)) { AlignPressed = true; } if (Input.GetKeyUp(PerfectPlacementPlugin.alignToGrid.Value)) { AlignPressed = false; } if (Input.GetKeyDown(PerfectPlacementPlugin.changeDefaultAlignment.Value)) { if (DefaultAlignment == 50) { DefaultAlignment = 100; } else if (DefaultAlignment == 100) { DefaultAlignment = 200; } else if (DefaultAlignment == 200) { DefaultAlignment = 400; } else { DefaultAlignment = 50; } MessageHud.instance.ShowMessage((MessageType)1, "Default grid alignment set to " + (float)DefaultAlignment / 100f, 0, (Sprite)null); } if (Input.GetKeyDown(PerfectPlacementPlugin.alignToggle.Value)) { AlignToggled = !AlignToggled; MessageHud.instance.ShowMessage((MessageType)1, "Grid alignment by default " + (AlignToggled ? "enabled" : "disabled"), 0, (Sprite)null); } } private static float FixAlignment(float f) { int num = (int)Mathf.Round(f * 100f); if (num <= 0) { return (float)DefaultAlignment / 100f; } if (num <= 50) { return 0.5f; } if (num <= 100) { return 1f; } if (num <= 200) { return 2f; } return 4f; } public static void GetAlignment(Piece piece, out Vector3 alignment, out Vector3 offset) { //IL_0018: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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) List<Transform> list = new List<Transform>(); piece.GetSnapPoints(list); if (list.Count != 0) { Vector3 val = Vector3.positiveInfinity; Vector3 val2 = Vector3.negativeInfinity; foreach (Transform item in list) { Vector3 localPosition = item.localPosition; val = Vector3.Min(val, localPosition); val2 = Vector3.Max(val2, localPosition); } alignment = val2 - val; alignment.x = FixAlignment(alignment.x); alignment.y = FixAlignment(alignment.y); alignment.z = FixAlignment(alignment.z); offset = val2; string name = ((Object)piece).name; if ((name == "iron_grate" || name == "wood_gate") ? true : false) { offset.y = val.y; } if (((Object)piece).name == "wood_gate") { alignment.x = 4f; } } else if (piece.m_notOnFloor || ((Object)piece).name == "sign" || ((Object)piece).name == "itemstand") { alignment = new Vector3(0.5f, 0.5f, 0f); offset = new Vector3(0f, 0f, 0f); if (((Object)piece).name == "sign") { alignment.y = 0.25f; } } else if (((Object)piece).name == "piece_walltorch") { alignment = new Vector3(0f, 0.5f, 0.5f); offset = new Vector3(0f, 0f, 0f); } else { alignment = new Vector3(0.5f, 0f, 0.5f); offset = new Vector3(0f, 0f, 0f); } } public static float Align(float value, out float alpha) { float num = Mathf.Round(value); alpha = value - num; return num; } public static void UpdatePlacementGhost(Player player) { //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) //IL_0056: 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_0060: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_0079: 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_007e: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_009e: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017e: 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_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_019d: 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_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player.m_placementGhost == (Object)null || !((Character)player).IsPlayer() || ABM.isActive) { return; } bool num = ZInput.GetButton("AltPlace") || ZInput.GetButton("JoyAltPlace"); Piece component = player.m_placementGhost.GetComponent<Piece>(); Vector3 val = ((Component)component).transform.position; val = Quaternion.Inverse(((Component)component).transform.rotation) * val; GetAlignment(component, out var alignment, out var offset); val += offset; Vector3 val2 = val; ((Vector3)(ref val))..ctor(val.x / alignment.x, val.y / alignment.y, val.z / alignment.z); ((Vector3)(ref val))..ctor(Align(val.x, out var alpha), Align(val.y, out var alpha2), Align(val.z, out var alpha3)); if (num) { float num2 = 0.2f; if (Mathf.Abs(alpha) >= num2 && Mathf.Abs(alpha) >= Mathf.Abs(alpha2) && Mathf.Abs(alpha) >= Mathf.Abs(alpha3)) { val.x += Mathf.Sign(alpha); } else if (Mathf.Abs(alpha2) >= num2 && Mathf.Abs(alpha2) >= Mathf.Abs(alpha3)) { val.y += Mathf.Sign(alpha2); } else if (Mathf.Abs(alpha3) >= num2) { val.z += Mathf.Sign(alpha3); } } ((Vector3)(ref val))..ctor(val.x * alignment.x, val.y * alignment.y, val.z * alignment.z); if (alignment.x <= 0f) { val.x = val2.x; } if (alignment.y <= 0f) { val.y = val2.y; } if (alignment.z <= 0f) { val.z = val2.z; } val -= offset; val = ((Component)component).transform.rotation * val; ((Component)component).transform.position = val; } } } namespace PerfectPlacement.Patches.Compatibility { [<c44312b6-f40f-41ca-bd8b-4eba4cc9a976>NullableContext(1)] [<fa36b506-5f27-4c75-9256-d48dbb1c433a>Nullable(0)] public class ModCompat { public static T InvokeMethod<[<fa36b506-5f27-4c75-9256-d48dbb1c433a>Nullable(2)] T>(Type type, object instance, string methodName, object[] parameter) { return (T)(type.GetMethod(methodName)?.Invoke(instance, parameter)); } public static T GetField<[<fa36b506-5f27-4c75-9256-d48dbb1c433a>Nullable(2)] T>(Type type, object instance, string fieldName) { return (T)(type.GetField(fieldName)?.GetValue(instance)); } } } namespace PerfectPlacement.Patches.Compatibility.WardIsLove { public class CustomCheck : ModCompat { [<c44312b6-f40f-41ca-bd8b-4eba4cc9a976>NullableContext(1)] public static Type ClassType() { return Type.GetType("WardIsLove.Util.CustomCheck, WardIsLove"); } public static bool CheckAccess(long playerID, Vector3 point, float radius = 0f, bool flash = true) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) return ModCompat.InvokeMethod<bool>(ClassType(), null, "CheckAccess", new object[4] { playerID, point, radius, flash }); } } [<fa36b506-5f27-4c75-9256-d48dbb1c433a>Nullable(0)] [<c44312b6-f40f-41ca-bd8b-4eba4cc9a976>NullableContext(1)] public class WardIsLovePlugin : ModCompat { private const string GUID = "Azumatt.WardIsLove"; private static readonly Version MinVersion = new Version(2, 3, 3); public static Type ClassType() { return Type.GetType("WardIsLove.WardIsLovePlugin, WardIsLove"); } public static bool IsLoaded() { if (Chainloader.PluginInfos.ContainsKey("Azumatt.WardIsLove")) { return Chainloader.PluginInfos["Azumatt.WardIsLove"].Metadata.Version >= MinVersion; } return false; } public static ConfigEntry<bool> WardEnabled() { return ModCompat.GetField<ConfigEntry<bool>>(ClassType(), null, "WardEnabled"); } } [<c44312b6-f40f-41ca-bd8b-4eba4cc9a976>NullableContext(1)] [<fa36b506-5f27-4c75-9256-d48dbb1c433a>Nullable(0)] public class WardMonoscript : ModCompat { public object targetScript; public static Type ClassType() { return Type.GetType("WardIsLove.Util.WardMonoscript, WardIsLove"); } public WardMonoscript(object targetScript) { this.targetScript = targetScript; } public static bool CheckInWardMonoscript(Vector3 point, bool flash = false) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) return ModCompat.InvokeMethod<bool>(ClassType(), null, "CheckInWardMonoscript", new object[2] { point, flash }); } public static bool CheckAccess(Vector3 point, float radius = 0f, bool flash = true, bool wardCheck = false) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) return ModCompat.InvokeMethod<bool>(ClassType(), null, "CheckAccess", new object[4] { point, radius, flash, wardCheck }); } public ZNetView GetZNetView() { if (targetScript == null) { return null; } return ModCompat.GetField<ZNetView>(ClassType(), targetScript, "m_nview"); } public ZDO GetZDO() { ZNetView zNetView = GetZNetView(); if (!((Object)(object)zNetView != (Object)null) || !Object.op_Implicit((Object)(object)zNetView) || !zNetView.IsValid()) { return null; } return zNetView.GetZDO(); } } [<fa36b506-5f27-4c75-9256-d48dbb1c433a>Nullable(0)] [<c44312b6-f40f-41ca-bd8b-4eba4cc9a976>NullableContext(1)] public static class WardMonoscriptExt { public static Type ClassType() { return Type.GetType("WardIsLove.Extensions.WardMonoscriptExt, WardIsLove"); } public static WardMonoscript GetWardMonoscript(Vector3 pos) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) return new WardMonoscript(ModCompat.InvokeMethod<object>(ClassType(), null, "GetWardMonoscript", new object[1] { pos })); } public static float GetWardRadius(this WardMonoscript wrapper) { return ModCompat.InvokeMethod<float>(ClassType(), null, "GetWardRadius", new object[1] { wrapper.targetScript }); } public static bool GetDoorInteractOn(this WardMonoscript wrapper) { return ModCompat.InvokeMethod<bool>(ClassType(), null, "GetDoorInteractOn", new object[1] { wrapper.targetScript }); } } } namespace Microsoft.CodeAnalysis { [Microsoft.CodeAnalysis.Embedded] [CompilerGenerated] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] [Microsoft.CodeAnalysis.Embedded] [CompilerGenerated] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] [Microsoft.CodeAnalysis.Embedded] [CompilerGenerated] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] [Microsoft.CodeAnalysis.Embedded] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ServerSync { [PublicAPI] internal abstract class OwnConfigEntryBase { public object? LocalBaseValue; public bool SynchronizedConfig = true; public abstract ConfigEntryBase BaseConfig { get; } } [PublicAPI] internal class SyncedConfigEntry<T> : OwnConfigEntryBase { public readonly ConfigEntry<T> SourceConfig; public override ConfigEntryBase BaseConfig => (ConfigEntryBase)(object)SourceConfig; public T Value { get { return SourceConfig.Value; } set { SourceConfig.Value = value; } } public SyncedConfigEntry(ConfigEntry<T> sourceConfig) { SourceConfig = sourceConfig; } public void AssignLocalValue(T value) { if (LocalBaseValue == null) { Value = value; } else { LocalBaseValue = value; } } } internal abstract class CustomSyncedValueBase { public object? LocalBaseValue; public readonly string Identifier; public readonly Type Type; private object? boxedValue; protected bool localIsOwner; public readonly int Priority; public object? BoxedValue { get { return boxedValue; } set { boxedValue = value; this.ValueChanged?.Invoke(); } } public event Action? ValueChanged; protected CustomSyncedValueBase(ConfigSync configSync, string identifier, Type type, int priority) { Priority = priority; Identifier = identifier; Type = type; configSync.AddCustomValue(this); localIsOwner = configSync.IsSourceOfTruth; configSync.SourceOfTruthChanged += delegate(bool truth) { localIsOwner = truth; }; } } [PublicAPI] internal sealed class CustomSyncedValue<T> : CustomSyncedValueBase { public T Value { get { return (T)base.BoxedValue; } set { base.BoxedValue = value; } } public CustomSyncedValue(ConfigSync configSync, string identifier, T value = default(T), int priority = 0) : base(configSync, identifier, typeof(T), priority) { Value = value; } public void AssignLocalValue(T value) { if (localIsOwner) { Value = value; } else { LocalBaseValue = value; } } } internal class ConfigurationManagerAttributes { [UsedImplicitly] public bool? ReadOnly = false; } [PublicAPI] internal class ConfigSync { [HarmonyPatch(typeof(ZRpc), "HandlePackage")] private static class SnatchCurrentlyHandlingRPC { public static ZRpc? currentRpc; [HarmonyPrefix] private static void Prefix(ZRpc __instance) { currentRpc = __instance; } } [HarmonyPatch(typeof(ZNet), "Awake")] internal static class RegisterRPCPatch { [HarmonyPostfix] private static void Postfix(ZNet __instance) { isServer = __instance.IsServer(); foreach (ConfigSync configSync2 in configSyncs) { ZRoutedRpc.instance.Register<ZPackage>(configSync2.Name + " ConfigSync", (Action<long, ZPackage>)configSync2.RPC_FromOtherClientConfigSync); if (isServer) { configSync2.InitialSyncDone = true; Debug.Log((object)("Registered '" + configSync2.Name + " ConfigSync' RPC - waiting for incoming connections")); } } if (isServer) { ((MonoBehaviour)__instance).StartCoroutine(WatchAdminListChanges()); } static void SendAdmin(List<ZNetPeer> peers, bool isAdmin) { ZPackage package = ConfigsToPackage(null, null, new PackageEntry[1] { new PackageEntry { section = "Internal", key = "lockexempt", type = typeof(bool), value = isAdmin } }); ConfigSync configSync = configSyncs.First(); if (configSync != null) { ((MonoBehaviour)ZNet.instance).StartCoroutine(configSync.sendZPackage(peers, package)); } } static IEnumerator WatchAdminListChanges() { MethodInfo listContainsId = AccessTools.DeclaredMethod(typeof(ZNet), "ListContainsId", (Type[])null, (Type[])null); SyncedList adminList = (SyncedList)AccessTools.DeclaredField(typeof(ZNet), "m_adminList").GetValue(ZNet.instance); List<string> CurrentList = new List<string>(adminList.GetList()); while (true) { yield return (object)new WaitForSeconds(30f); if (!adminList.GetList().SequenceEqual(CurrentList)) { CurrentList = new List<string>(adminList.GetList()); List<ZNetPeer> adminPeer = ZNet.instance.GetPeers().Where(delegate(ZNetPeer p) { string hostName = p.m_rpc.GetSocket().GetHostName(); return ((object)listContainsId == null) ? adminList.Contains(hostName) : ((bool)listContainsId.Invoke(ZNet.instance, new object[2] { adminList, hostName })); }).ToList(); List<ZNetPeer> nonAdminPeer = ZNet.instance.GetPeers().Except(adminPeer).ToList(); SendAdmin(nonAdminPeer, isAdmin: false); SendAdmin(adminPeer, isAdmin: true); } } } } } [HarmonyPatch(typeof(ZNet), "OnNewConnection")] private static class RegisterClientRPCPatch { [HarmonyPostfix] private static void Postfix(ZNet __instance, ZNetPeer peer) { if (__instance.IsServer()) { return; } foreach (ConfigSync configSync in configSyncs) { peer.m_rpc.Register<ZPackage>(configSync.Name + " ConfigSync", (Action<ZRpc, ZPackage>)configSync.RPC_FromServerConfigSync); } } } private class ParsedConfigs { public readonly Dictionary<OwnConfigEntryBase, object?> configValues = new Dictionary<OwnConfigEntryBase, object>(); public readonly Dictionary<CustomSyncedValueBase, object?> customValues = new Dictionary<CustomSyncedValueBase, object>(); } [HarmonyPatch(typeof(ZNet), "Shutdown")] private class ResetConfigsOnShutdown { [HarmonyPostfix] private static void Postfix() { ProcessingServerUpdate = true; foreach (ConfigSync configSync in configSyncs) { configSync.resetConfigsFromServer(); configSync.IsSourceOfTruth = true; configSync.InitialSyncDone = false; } ProcessingServerUpdate = false; } } [HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")] private class SendConfigsAfterLogin { private class BufferingSocket : ISocket { public volatile bool finished = false; public volatile int versionMatchQueued = -1; public readonly List<ZPackage> Package = new List<ZPackage>(); public readonly ISocket Original; public BufferingSocket(ISocket original) { Original = original; } public bool IsConnected() { return Original.IsConnected(); } public ZPackage Recv() { return Original.Recv(); } public int GetSendQueueSize() { return Original.GetSendQueueSize(); } public int GetCurrentSendRate() { return Original.GetCurrentSendRate(); } public bool IsHost() { return Original.IsHost(); } public void Dispose() { Original.Dispose(); } public bool GotNewData() { return Original.GotNewData(); } public void Close() { Original.Close(); } public string GetEndPointString() { return Original.GetEndPointString(); } public void GetAndResetStats(out int totalSent, out int totalRecv) { Original.GetAndResetStats(ref totalSent, ref totalRecv); } public void GetConnectionQuality(out float localQuality, out float remoteQuality, out int ping, out float outByteSec, out float inByteSec) { Original.GetConnectionQuality(ref localQuality, ref remoteQuality, ref ping, ref outByteSec, ref inByteSec); } public ISocket Accept() { return Original.Accept(); } public int GetHostPort() { return Original.GetHostPort(); } public bool Flush() { return Original.Flush(); } public string GetHostName() { return Original.GetHostName(); } public void VersionMatch() { if (finished) { Original.VersionMatch(); } else { versionMatchQueued = Package.Count; } } public void Send(ZPackage pkg) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown int pos = pkg.GetPos(); pkg.SetPos(0); int num = pkg.ReadInt(); if ((num == StringExtensionMethods.GetStableHashCode("PeerInfo") || num == StringExtensionMethods.GetStableHashCode("RoutedRPC") || num == StringExtensionMethods.GetStableHashCode("ZDOData")) && !finished) { ZPackage val = new ZPackage(pkg.GetArray()); val.SetPos(pos); Package.Add(val); } else { pkg.SetPos(pos); Original.Send(pkg); } } } [HarmonyPriority(800)] [HarmonyPrefix] private static void Prefix(ref Dictionary<Assembly, BufferingSocket>? __state, ZNet __instance, ZRpc rpc) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Invalid comparison between Unknown and I4 if (__instance.IsServer()) { BufferingSocket value = new BufferingSocket(rpc.GetSocket()); AccessTools.DeclaredField(typeof(ZRpc), "m_socket").SetValue(rpc, value); object? obj = AccessTools.DeclaredMethod(typeof(ZNet), "GetPeer", new Type[1] { typeof(ZRpc) }, (Type[])null).Invoke(__instance, new object[1] { rpc }); ZNetPeer val = (ZNetPeer)((obj is ZNetPeer) ? obj : null); if (val != null && (int)ZNet.m_onlineBackend > 0) { AccessTools.DeclaredField(typeof(ZNetPeer), "m_socket").SetValue(val, value); } if (__state == null) { __state = new Dictionary<Assembly, BufferingSocket>(); } __state[Assembly.GetExecutingAssembly()] = value; } } [HarmonyPostfix] private static void Postfix(Dictionary<Assembly, BufferingSocket> __state, ZNet __instance, ZRpc rpc) { ZRpc rpc2 = rpc; ZNet __instance2 = __instance; Dictionary<Assembly, BufferingSocket> __state2 = __state; ZNetPeer peer; if (__instance2.IsServer()) { object obj = AccessTools.DeclaredMethod(typeof(ZNet), "GetPeer", new Type[1] { typeof(ZRpc) }, (Type[])null).Invoke(__instance2, new object[1] { rpc2 }); peer = (ZNetPeer)((obj is ZNetPeer) ? obj : null); if (peer == null) { SendBufferedData(); } else { ((MonoBehaviour)__instance2).StartCoroutine(sendAsync()); } } void SendBufferedData() { if (rpc2.GetSocket() is BufferingSocket bufferingSocket) { AccessTools.DeclaredField(typeof(ZRpc), "m_socket").SetValue(rpc2, bufferingSocket.Original); object? obj2 = AccessTools.DeclaredMethod(typeof(ZNet), "GetPeer", new Type[1] { typeof(ZRpc) }, (Type[])null).Invoke(__instance2, new object[1] { rpc2 }); ZNetPeer val = (ZNetPeer)((obj2 is ZNetPeer) ? obj2 : null); if (val != null) { AccessTools.DeclaredField(typeof(ZNetPeer), "m_socket").SetValue(val, bufferingSocket.Original); } } BufferingSocket bufferingSocket2 = __state2[Assembly.GetExecutingAssembly()]; bufferingSocket2.finished = true; for (int i = 0; i < bufferingSocket2.Package.Count; i++) { if (i == bufferingSocket2.versionMatchQueued) { bufferingSocket2.Original.VersionMatch(); } bufferingSocket2.Original.Send(bufferingSocket2.Package[i]); } if (bufferingSocket2.Package.Count == bufferingSocket2.versionMatchQueued)