using System; using System.Collections; using System.Collections.Generic; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace MovingDay; [BepInPlugin("com.drakosdj.movingday", "MovingDay", "1.0.7")] public class MovingDayPlugin : BaseUnityPlugin { public class SelectedPieceInfo { public Piece piece; public ZDO zdo; public Vector3 relPos; public Quaternion relRot; public string prefabName; } [HarmonyPatch(typeof(Chat), "InputText")] public static class Chat_InputText_Patch { public static bool Prefix(Chat __instance) { string chatText = GetChatText(__instance); if (string.IsNullOrEmpty(chatText)) { return true; } if (chatText.StartsWith("/movingdayclean") || chatText.StartsWith("/mdclean")) { string[] array = chatText.Split(new char[1] { ' ' }); float radius = 150f; if (array.Length > 1 && float.TryParse(array[1], out var result)) { radius = result; } CleanWorldOrigin(radius); object inputField = GetInputField(__instance); if (inputField != null) { PropertyInfo property = inputField.GetType().GetProperty("text"); if (property != null) { property.SetValue(inputField, "", null); } } return false; } return true; } } [HarmonyPatch(typeof(Player), "UpdatePlacement")] public static class Player_UpdatePlacement_Patch { public static bool Prefix() { if (m_inMoveMode) { return false; } return true; } } [HarmonyPatch(typeof(WearNTear), "HaveSupport")] public static class WearNTear_HaveSupport_Patch { public static bool Prefix(WearNTear __instance, ref bool __result) { if (IsRecentlyMoved(__instance)) { __result = true; return false; } return true; } } private delegate bool FindClosestSnapPointsDelegate(Player player, Transform ghost, float maxSnapDistance, out Transform a, out Transform b, List pieces); [HarmonyPatch(typeof(Player), "UpdatePlacementGhost")] public static class Player_UpdatePlacementGhost_Patch { public static bool Prefix() { if (m_inMoveMode) { return false; } return true; } public static void Postfix(Player __instance) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) GameObject field = GetField(__instance, "m_placementGhost"); if ((Object)(object)field == (Object)null) { return; } Transform a = null; Transform b = null; m_myTempPieces.Clear(); if (!FindClosestSnapPoints(__instance, field.transform, 0.5f, out a, out b, m_myTempPieces) || !((Object)(object)a != (Object)null) || !((Object)(object)b != (Object)null) || !(Vector3.Distance(a.position, b.position) < 0.05f)) { return; } Piece componentInParent = ((Component)b).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { Quaternion rotation = ((Component)componentInParent).transform.rotation; float y = ((Quaternion)(ref rotation)).eulerAngles.y; float num = Mathf.Round(y / 22.5f) * 22.5f; float num2 = y - num; if (Mathf.Abs(num2) > 0.01f) { rotation = field.transform.rotation; Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles; Quaternion rotation2 = Quaternion.Euler(eulerAngles.x, eulerAngles.y + num2, eulerAngles.z); field.transform.rotation = rotation2; Vector3 position = b.position - a.position + field.transform.position; field.transform.position = position; } } } } public static ConfigEntry configSelectHotkey; public static ConfigEntry configSelectConnectedHotkey; public static ConfigEntry configMoveHotkey; public static ConfigEntry configModifierKey; public static ConfigEntry configConnectionRadius; public static ConfigEntry configPlayerSafety; public static ConfigEntry configChestSafety; public static ConfigEntry configMoveTamed; public static ConfigEntry configTerrainRadiusBuffer; public static ConfigEntry configContainerMetalAction; public static ConfigEntry configPlayerMetalAction; public static ConfigEntry configHeightUpHotkey; public static ConfigEntry configHeightDownHotkey; public static ConfigEntry configHeightResetHotkey; public static Piece m_pivotPiece = null; public static Vector3 m_oldPivotPos; public static float m_oldPivotYaw; public static bool m_inMoveMode = false; public static float m_targetYaw = 0f; public static float m_maxSelectedDistance = 5f; public static bool m_lastCopyTerrainState = false; public static float m_sourceHeightOffset = 0f; public static float m_sourceHeightOffsetActual = 0f; public static float m_additionalHeightOffset = 0f; public static MovingDayPlugin instance; private static float m_debugLogTimer = 0f; public static List m_selectedPieceInfos = new List(); public static Dictionary m_recentlyMovedPieces = new Dictionary(); private static List m_myTempPieces = new List(); private static FindClosestSnapPointsDelegate m_findClosestSnapPoints = null; public static bool IsRecentlyMoved(WearNTear wear) { if ((Object)(object)wear == (Object)null) { return false; } float time = Time.time; if (m_recentlyMovedPieces.TryGetValue(wear, out var value)) { if (time < value) { return true; } m_recentlyMovedPieces.Remove(wear); } return false; } private static void PruneRecentlyMoved() { float time = Time.time; List list = new List(); foreach (KeyValuePair recentlyMovedPiece in m_recentlyMovedPieces) { if ((Object)(object)recentlyMovedPiece.Key == (Object)null || time >= recentlyMovedPiece.Value) { list.Add(recentlyMovedPiece.Key); } } foreach (WearNTear item in list) { if ((Object)(object)item != (Object)null) { m_recentlyMovedPieces.Remove(item); } } } private void Awake() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_01cd: 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_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Expected O, but got Unknown instance = this; configSelectHotkey = ((BaseUnityPlugin)this).Config.Bind("Keybinds", "SelectHotkey", new KeyboardShortcut((KeyCode)103, (KeyCode[])(object)new KeyCode[0]), "Hotkey to select/deselect a hovered piece."); configSelectConnectedHotkey = ((BaseUnityPlugin)this).Config.Bind("Keybinds", "SelectConnectedHotkey", new KeyboardShortcut((KeyCode)104, (KeyCode[])(object)new KeyCode[0]), "Hotkey to select all connected pieces of a structure."); configMoveHotkey = ((BaseUnityPlugin)this).Config.Bind("Keybinds", "MoveHotkey", new KeyboardShortcut((KeyCode)108, (KeyCode[])(object)new KeyCode[0]), "Hotkey to enter Move Mode once pieces are selected."); configModifierKey = ((BaseUnityPlugin)this).Config.Bind("Keybinds", "TerrainModifierKey", new KeyboardShortcut((KeyCode)306, (KeyCode[])(object)new KeyCode[0]), "Modifier key held during placement to copy and revert terrain modifications."); configConnectionRadius = ((BaseUnityPlugin)this).Config.Bind("General", "ConnectionRadius", 2f, "Maximum distance between pieces to consider them connected in BFS selection."); configPlayerSafety = ((BaseUnityPlugin)this).Config.Bind("Safety", "PlayerSafetyAction", "Block", "Action when other players are in the footprint. Options: Block, Teleport, Ignore"); configChestSafety = ((BaseUnityPlugin)this).Config.Bind("Safety", "ChestSafetyAction", "Block", "Action when containers are in use. Options: Block, Ignore"); configMoveTamed = ((BaseUnityPlugin)this).Config.Bind("Safety", "MoveTamedAnimals", true, "If true, tamed animals inside the building footprint will be moved to the new location."); configTerrainRadiusBuffer = ((BaseUnityPlugin)this).Config.Bind("General", "TerrainRadiusBuffer", 3f, "Extra radius in meters to capture terrain modifications around the structure footprint."); configContainerMetalAction = ((BaseUnityPlugin)this).Config.Bind("Safety", "ContainerMetalAction", "Block", "Controls behavior when chests/carts contain non-teleportable materials. Options: Allow, Block, Drop"); configPlayerMetalAction = ((BaseUnityPlugin)this).Config.Bind("Safety", "PlayerMetalAction", "BlockMove", "Controls behavior if a player is standing inside the structure footprint carrying metals. Options: Allow, BlockMove, LeaveBehind"); configHeightUpHotkey = ((BaseUnityPlugin)this).Config.Bind("Keybinds", "HeightUpHotkey", new KeyboardShortcut((KeyCode)273, (KeyCode[])(object)new KeyCode[0]), "Hotkey to raise the structure height in Move Mode."); configHeightDownHotkey = ((BaseUnityPlugin)this).Config.Bind("Keybinds", "HeightDownHotkey", new KeyboardShortcut((KeyCode)274, (KeyCode[])(object)new KeyCode[0]), "Hotkey to lower the structure height in Move Mode."); configHeightResetHotkey = ((BaseUnityPlugin)this).Config.Bind("Keybinds", "HeightResetHotkey", new KeyboardShortcut((KeyCode)278, (KeyCode[])(object)new KeyCode[0]), "Hotkey to reset structure height adjustment (Home snaps to ground, Shift + Home restores original offset)."); Harmony val = new Harmony("com.drakosdj.movingday"); val.PatchAll(); Debug.Log((object)"[MovingDay] Standalone plugin loaded successfully!"); } private void Start() { TryLinkSharedSelection(); } private void TryLinkSharedSelection() { try { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (!(assembly.GetName().Name == "PrefabHammer")) { continue; } Type type = assembly.GetType("PrefabHammer.PrefabHammerPlugin"); if (type != null) { FieldInfo field = type.GetField("m_selectedPieces", BindingFlags.Static | BindingFlags.Public); if (field != null && field.GetValue(null) is HashSet selectedPieces) { MovingDaySelection.m_selectedPieces = selectedPieces; Debug.Log((object)"[MovingDay] Successfully linked to PrefabHammer selection HashSet!"); } } break; } } catch (Exception ex) { Debug.LogWarning((object)("[MovingDay] Failed to link shared selection with PrefabHammer: " + ex.Message)); } } private void Update() { PruneRecentlyMoved(); if ((Object)(object)Player.m_localPlayer == (Object)null) { if (m_inMoveMode) { Debug.Log((object)"[MovingDay Diag] Update: player is null, canceling Move Mode"); CancelMove(); } MovingDaySelection.ClearSelection(); } else if (m_inMoveMode) { UpdateMoveMode(Player.m_localPlayer); } else if (!IsHoldingBuildTool(Player.m_localPlayer)) { HideSelectionHighlights(); } else { RestoreAndHighlightSelection(Player.m_localPlayer); HandleSelectionInput(Player.m_localPlayer); } } private static void HideSelectionHighlights() { foreach (Piece selectedPiece in MovingDaySelection.m_selectedPieces) { if ((Object)(object)selectedPiece != (Object)null) { MovingDaySelectionHighlight component = ((Component)selectedPiece).GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } Component component2 = ((Component)selectedPiece).GetComponent("PrefabSelectionHighlight"); if ((Object)(object)component2 != (Object)null) { Object.Destroy((Object)(object)component2); } } } MovingDaySelection.m_selectedPieces.Clear(); } private static void RestoreAndHighlightSelection(Player player) { //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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) if (MovingDaySelection.m_selectedZDOIDs.Count == 0) { if (MovingDaySelection.m_selectedPieces.Count > 0) { MovingDaySelection.m_selectedPieces.Clear(); } return; } MovingDaySelection.m_selectedPieces.RemoveWhere((Piece p) => (Object)(object)p == (Object)null); List allPieces = MovingDaySelection.GetAllPieces(); foreach (Piece item in allPieces) { if ((Object)(object)item == (Object)null) { continue; } ZNetView component = ((Component)item).GetComponent(); if (!((Object)(object)component != (Object)null) || !component.IsValid()) { continue; } ZDO zDO = component.GetZDO(); if (zDO == null) { continue; } ZDOID uid = zDO.m_uid; if (MovingDaySelection.m_selectedZDOIDs.Contains(uid)) { if (!MovingDaySelection.m_selectedPieces.Contains(item)) { MovingDaySelection.m_selectedPieces.Add(item); } if ((Object)(object)((Component)item).GetComponent() == (Object)null) { ((Component)item).gameObject.AddComponent(); } } } } private static bool IsHoldingBuildTool(Player player) { ItemData rightItem = GetRightItem(player); return rightItem != null && (Object)(object)rightItem.m_shared.m_buildPieces != (Object)null; } private static GameObject ZNetScene_CreateObject(ZDO zdo) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown if ((Object)(object)ZNetScene.instance == (Object)null) { return null; } MethodInfo method = typeof(ZNetScene).GetMethod("CreateObject", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { return (GameObject)method.Invoke(ZNetScene.instance, new object[1] { zdo }); } return null; } private static bool PlayerCanTakeInput(Player player) { if ((Object)(object)player == (Object)null) { return false; } MethodInfo method = typeof(Character).GetMethod("TakeInput", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { return (bool)method.Invoke(player, null); } return true; } private static bool MyGetKey(KeyCode key) { //IL_0001: 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_002f: Invalid comparison between Unknown and I4 //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Invalid comparison between Unknown and I4 //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Invalid comparison between Unknown and I4 //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Invalid comparison between Unknown and I4 //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Invalid comparison between Unknown and I4 //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Invalid comparison between Unknown and I4 //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Invalid comparison between Unknown and I4 //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Invalid comparison between Unknown and I4 //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Invalid comparison between Unknown and I4 //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Invalid comparison between Unknown and I4 //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Invalid comparison between Unknown and I4 //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Invalid comparison between Unknown and I4 if (ZInput.GetKey(key, true)) { return true; } try { Keyboard current = Keyboard.current; if (current != null) { if ((int)key == 280) { return ((ButtonControl)current.pageUpKey).isPressed; } if ((int)key == 281) { return ((ButtonControl)current.pageDownKey).isPressed; } if ((int)key == 273) { return ((ButtonControl)current.upArrowKey).isPressed; } if ((int)key == 274) { return ((ButtonControl)current.downArrowKey).isPressed; } if ((int)key == 278) { return ((ButtonControl)current.homeKey).isPressed; } if ((int)key == 27) { return ((ButtonControl)current.escapeKey).isPressed; } if ((int)key == 304) { return ((ButtonControl)current.leftShiftKey).isPressed; } if ((int)key == 303) { return ((ButtonControl)current.rightShiftKey).isPressed; } if ((int)key == 306) { return ((ButtonControl)current.leftCtrlKey).isPressed; } if ((int)key == 305) { return ((ButtonControl)current.rightCtrlKey).isPressed; } if ((int)key == 308) { return ((ButtonControl)current.leftAltKey).isPressed; } if ((int)key == 307) { return ((ButtonControl)current.rightAltKey).isPressed; } } } catch (Exception) { } return false; } private static bool MyGetKeyDown(KeyCode key) { //IL_0001: 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_002f: Invalid comparison between Unknown and I4 //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Invalid comparison between Unknown and I4 //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Invalid comparison between Unknown and I4 //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Invalid comparison between Unknown and I4 //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Invalid comparison between Unknown and I4 //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Invalid comparison between Unknown and I4 //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Invalid comparison between Unknown and I4 //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Invalid comparison between Unknown and I4 //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Invalid comparison between Unknown and I4 //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Invalid comparison between Unknown and I4 //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Invalid comparison between Unknown and I4 //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Invalid comparison between Unknown and I4 if (ZInput.GetKeyDown(key, true)) { return true; } try { Keyboard current = Keyboard.current; if (current != null) { if ((int)key == 280) { return ((ButtonControl)current.pageUpKey).wasPressedThisFrame; } if ((int)key == 281) { return ((ButtonControl)current.pageDownKey).wasPressedThisFrame; } if ((int)key == 273) { return ((ButtonControl)current.upArrowKey).wasPressedThisFrame; } if ((int)key == 274) { return ((ButtonControl)current.downArrowKey).wasPressedThisFrame; } if ((int)key == 278) { return ((ButtonControl)current.homeKey).wasPressedThisFrame; } if ((int)key == 27) { return ((ButtonControl)current.escapeKey).wasPressedThisFrame; } if ((int)key == 304) { return ((ButtonControl)current.leftShiftKey).wasPressedThisFrame; } if ((int)key == 303) { return ((ButtonControl)current.rightShiftKey).wasPressedThisFrame; } if ((int)key == 306) { return ((ButtonControl)current.leftCtrlKey).wasPressedThisFrame; } if ((int)key == 305) { return ((ButtonControl)current.rightCtrlKey).wasPressedThisFrame; } if ((int)key == 308) { return ((ButtonControl)current.leftAltKey).wasPressedThisFrame; } if ((int)key == 307) { return ((ButtonControl)current.rightAltKey).wasPressedThisFrame; } } } catch (Exception) { } return false; } private void HandleSelectionInput(Player player) { //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_0032: 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) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: 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_035b: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_04ab: Unknown result type (might be due to invalid IL or missing references) //IL_04b7: Unknown result type (might be due to invalid IL or missing references) //IL_0aa7: Unknown result type (might be due to invalid IL or missing references) //IL_0aac: Unknown result type (might be due to invalid IL or missing references) //IL_0abd: Unknown result type (might be due to invalid IL or missing references) //IL_0ac2: Unknown result type (might be due to invalid IL or missing references) //IL_0ac6: Unknown result type (might be due to invalid IL or missing references) //IL_0ad5: Unknown result type (might be due to invalid IL or missing references) //IL_0ada: Unknown result type (might be due to invalid IL or missing references) //IL_0adc: Unknown result type (might be due to invalid IL or missing references) //IL_0ade: Unknown result type (might be due to invalid IL or missing references) //IL_0ae3: Unknown result type (might be due to invalid IL or missing references) //IL_0aef: Unknown result type (might be due to invalid IL or missing references) //IL_0af4: Unknown result type (might be due to invalid IL or missing references) //IL_0af8: Unknown result type (might be due to invalid IL or missing references) //IL_0b04: Unknown result type (might be due to invalid IL or missing references) //IL_0b06: Unknown result type (might be due to invalid IL or missing references) //IL_0bb2: Unknown result type (might be due to invalid IL or missing references) //IL_0bba: Unknown result type (might be due to invalid IL or missing references) //IL_0bbf: Unknown result type (might be due to invalid IL or missing references) //IL_0bc1: Unknown result type (might be due to invalid IL or missing references) //IL_0bc6: Unknown result type (might be due to invalid IL or missing references) //IL_0bcb: Unknown result type (might be due to invalid IL or missing references) //IL_0bd6: Unknown result type (might be due to invalid IL or missing references) //IL_0bdb: Unknown result type (might be due to invalid IL or missing references) //IL_0bdf: Unknown result type (might be due to invalid IL or missing references) //IL_0bf3: Unknown result type (might be due to invalid IL or missing references) //IL_0bf8: Unknown result type (might be due to invalid IL or missing references) //IL_0bfc: Unknown result type (might be due to invalid IL or missing references) //IL_0c11: Unknown result type (might be due to invalid IL or missing references) //IL_0c16: Unknown result type (might be due to invalid IL or missing references) //IL_0c1a: Unknown result type (might be due to invalid IL or missing references) //IL_0c24: Unknown result type (might be due to invalid IL or missing references) //IL_0c29: Unknown result type (might be due to invalid IL or missing references) //IL_0cc7: Unknown result type (might be due to invalid IL or missing references) //IL_0cd2: Unknown result type (might be due to invalid IL or missing references) //IL_0804: Unknown result type (might be due to invalid IL or missing references) //IL_0809: Unknown result type (might be due to invalid IL or missing references) //IL_0810: Unknown result type (might be due to invalid IL or missing references) //IL_0d77: Unknown result type (might be due to invalid IL or missing references) //IL_0d8d: Unknown result type (might be due to invalid IL or missing references) //IL_0dde: Unknown result type (might be due to invalid IL or missing references) //IL_0e1a: Unknown result type (might be due to invalid IL or missing references) //IL_0dc7: Unknown result type (might be due to invalid IL or missing references) //IL_08bd: Unknown result type (might be due to invalid IL or missing references) //IL_08bf: Unknown result type (might be due to invalid IL or missing references) //IL_0a57: Unknown result type (might be due to invalid IL or missing references) if (!PlayerCanTakeInput(player)) { return; } KeyboardShortcut value; Piece hoveringPiece; if (configSelectHotkey != null) { value = configSelectHotkey.Value; KeyCode mainKey = ((KeyboardShortcut)(ref value)).MainKey; if (MyGetKeyDown(mainKey)) { if (MyGetKey((KeyCode)304) || MyGetKey((KeyCode)303) || MyGetKey((KeyCode)306) || MyGetKey((KeyCode)305)) { if (MovingDaySelection.m_selectedZDOIDs.Count > 0 || MovingDaySelection.m_selectedPieces.Count > 0) { MovingDaySelection.ClearSelection(); ((Character)player).Message((MessageType)2, "Cleared selection.", 0, (Sprite)null); } } else { hoveringPiece = GetHoveringPiece(player); if ((Object)(object)hoveringPiece != (Object)null) { if (!hoveringPiece.IsPlacedByPlayer()) { ((Character)player).Message((MessageType)2, "Cannot select world-generated structures.", 0, (Sprite)null); return; } if (MovingDaySelection.m_selectedPieces.Contains(hoveringPiece)) { MovingDaySelection.RemoveFromSelection(hoveringPiece); ((Character)player).Message((MessageType)2, "Deselected piece (Total: " + MovingDaySelection.m_selectedPieces.Count + ")", 0, (Sprite)null); } else { MovingDaySelection.AddToSelection(hoveringPiece); ((Character)player).Message((MessageType)2, "Selected piece (Total: " + MovingDaySelection.m_selectedPieces.Count + ")", 0, (Sprite)null); } } else if (MovingDaySelection.m_selectedZDOIDs.Count > 0) { MovingDaySelection.ClearSelection(); ((Character)player).Message((MessageType)2, "Cleared selection.", 0, (Sprite)null); } else { ((Character)player).Message((MessageType)2, "No piece hovered to select.", 0, (Sprite)null); } } } } if (configSelectConnectedHotkey != null) { value = configSelectConnectedHotkey.Value; KeyCode mainKey = ((KeyboardShortcut)(ref value)).MainKey; if (MyGetKeyDown(mainKey)) { if (MyGetKey((KeyCode)304) || MyGetKey((KeyCode)303) || MyGetKey((KeyCode)306) || MyGetKey((KeyCode)305)) { if (MovingDaySelection.m_selectedZDOIDs.Count > 0 || MovingDaySelection.m_selectedPieces.Count > 0) { MovingDaySelection.ClearSelection(); ((Character)player).Message((MessageType)2, "Cleared selection.", 0, (Sprite)null); } } else { hoveringPiece = GetHoveringPiece(player); if ((Object)(object)hoveringPiece != (Object)null) { if (!hoveringPiece.IsPlacedByPlayer()) { ((Character)player).Message((MessageType)2, "Cannot select world-generated structures.", 0, (Sprite)null); return; } ((Character)player).Message((MessageType)2, "Selecting structure...", 0, (Sprite)null); MovingDaySelection.SelectConnected(hoveringPiece, configConnectionRadius.Value); ((Character)player).Message((MessageType)2, "Selected structure of " + MovingDaySelection.m_selectedPieces.Count + " pieces.", 0, (Sprite)null); } else if (MovingDaySelection.m_selectedZDOIDs.Count > 0) { MovingDaySelection.ClearSelection(); ((Character)player).Message((MessageType)2, "Cleared selection.", 0, (Sprite)null); } else { ((Character)player).Message((MessageType)2, "No piece hovered to select structure.", 0, (Sprite)null); } } } } if (configMoveHotkey == null) { return; } value = configMoveHotkey.Value; if (!MyGetKeyDown(((KeyboardShortcut)(ref value)).MainKey)) { return; } if (MovingDaySelection.m_selectedPieces.Count == 0) { ((Character)player).Message((MessageType)2, "No pieces selected to move.", 0, (Sprite)null); return; } hoveringPiece = GetHoveringPiece(player); if ((Object)(object)hoveringPiece != (Object)null && MovingDaySelection.m_selectedPieces.Contains(hoveringPiece)) { m_pivotPiece = hoveringPiece; } else { foreach (Piece selectedPiece in MovingDaySelection.m_selectedPieces) { if ((Object)(object)selectedPiece != (Object)null) { m_pivotPiece = selectedPiece; break; } } } if ((Object)(object)m_pivotPiece == (Object)null) { return; } List allPlayers = Player.GetAllPlayers(); foreach (Player item in allPlayers) { if ((Object)(object)item == (Object)null) { continue; } bool flag = false; foreach (Piece selectedPiece2 in MovingDaySelection.m_selectedPieces) { if ((Object)(object)selectedPiece2 != (Object)null && Vector3.Distance(((Component)item).transform.position, ((Component)selectedPiece2).transform.position) < 3f) { flag = true; break; } } if (!flag) { continue; } bool flag2 = PlayerHasNonTeleportable(item); string value2 = configPlayerMetalAction.Value; string value3 = configPlayerSafety.Value; if (flag2 && value2.Equals("BlockMove", StringComparison.OrdinalIgnoreCase)) { if ((Object)(object)item == (Object)(object)Player.m_localPlayer) { ((Character)player).Message((MessageType)2, "Cannot move: You are carrying non-teleportable items.", 0, (Sprite)null); } else { ((Character)player).Message((MessageType)2, "Cannot move: Player '" + item.GetPlayerName() + "' is carrying non-teleportable items.", 0, (Sprite)null); } return; } if ((Object)(object)item == (Object)(object)Player.m_localPlayer && value3.Equals("Block", StringComparison.OrdinalIgnoreCase)) { ((Character)player).Message((MessageType)2, "Cannot move: You are inside the building.", 0, (Sprite)null); return; } if (!((Object)(object)item != (Object)(object)Player.m_localPlayer) || (!value3.Equals("Block", StringComparison.OrdinalIgnoreCase) && !value3.Equals("Teleport", StringComparison.OrdinalIgnoreCase))) { continue; } ((Character)player).Message((MessageType)2, "Cannot move: Player '" + item.GetPlayerName() + "' is inside.", 0, (Sprite)null); return; } foreach (Piece selectedPiece3 in MovingDaySelection.m_selectedPieces) { if ((Object)(object)selectedPiece3 == (Object)null) { continue; } Container component = ((Component)selectedPiece3).GetComponent(); if (!((Object)(object)component != (Object)null)) { continue; } if (configChestSafety.Value.Equals("Block", StringComparison.OrdinalIgnoreCase) && component.IsInUse()) { ((Character)player).Message((MessageType)2, "Cannot move: A container is currently open/in use.", 0, (Sprite)null); return; } if (ContainerHasNonTeleportable(component)) { string value4 = configContainerMetalAction.Value; if (value4.Equals("Block", StringComparison.OrdinalIgnoreCase)) { ((Character)player).Message((MessageType)2, "Cannot move: Chest contains non-teleportable items.", 0, (Sprite)null); return; } } } if (configContainerMetalAction.Value.Equals("Drop", StringComparison.OrdinalIgnoreCase)) { Vector3 val = default(Vector3); foreach (Piece selectedPiece4 in MovingDaySelection.m_selectedPieces) { if ((Object)(object)selectedPiece4 == (Object)null) { continue; } Container component = ((Component)selectedPiece4).GetComponent(); if (!((Object)(object)component != (Object)null) || !ContainerHasNonTeleportable(component)) { continue; } GameObject prefab = ZNetScene.instance.GetPrefab("CargoCrate"); if (!((Object)(object)prefab != (Object)null)) { continue; } Vector3 position = ((Component)selectedPiece4).transform.position; float groundHeight = ZoneSystem.instance.GetGroundHeight(position); Inventory inventory = component.GetInventory(); List list = new List(); foreach (ItemData allItem in inventory.GetAllItems()) { if (allItem != null && !allItem.m_shared.m_teleportable) { list.Add(allItem); } } int num = 0; while (list.Count > 0 && num < 10) { ((Vector3)(ref val))..ctor(position.x, groundHeight + 0.5f + (float)num * 0.4f, position.z); GameObject val2 = Object.Instantiate(prefab, val, Quaternion.identity); Container component2 = val2.GetComponent(); if ((Object)(object)component2 == (Object)null) { Object.Destroy((Object)(object)val2); break; } Inventory inventory2 = component2.GetInventory(); List list2 = new List(); foreach (ItemData item2 in list) { int stack = item2.m_stack; inventory2.MoveItemToThis(inventory, item2); if (!inventory.ContainsItem(item2) || item2.m_stack < stack) { list2.Add(item2); } } SaveContainer(component2); num++; list.Clear(); foreach (ItemData allItem2 in inventory.GetAllItems()) { if (allItem2 != null && !allItem2.m_shared.m_teleportable) { list.Add(allItem2); } } if (list2.Count == 0) { break; } } SaveContainer(component); Debug.Log((object)("[MovingDay Debug] Spawned " + num + " CargoCrate(s) and dropped all non-teleportable items from chest at " + position)); } } m_selectedPieceInfos.Clear(); Vector3 position2 = ((Component)m_pivotPiece).transform.position; Quaternion rotation = ((Component)m_pivotPiece).transform.rotation; Quaternion val3 = Quaternion.Euler(0f, ((Quaternion)(ref rotation)).eulerAngles.y, 0f); Quaternion val4 = Quaternion.Inverse(val3); rotation = ((Component)m_pivotPiece).transform.rotation; float y = ((Quaternion)(ref rotation)).eulerAngles.y; m_oldPivotPos = position2; m_oldPivotYaw = y; foreach (Piece selectedPiece5 in MovingDaySelection.m_selectedPieces) { if (!((Object)(object)selectedPiece5 != (Object)null)) { continue; } ZNetView component3 = ((Component)selectedPiece5).GetComponent(); if ((Object)(object)component3 != (Object)null && component3.IsValid()) { ZDO zDO = component3.GetZDO(); if (zDO != null) { component3.ClaimOwnership(); zDO.SetOwner(ZDOMan.GetSessionID()); SelectedPieceInfo selectedPieceInfo = new SelectedPieceInfo(); selectedPieceInfo.piece = selectedPiece5; selectedPieceInfo.zdo = zDO; selectedPieceInfo.relPos = val4 * (((Component)selectedPiece5).transform.position - position2); rotation = ((Component)selectedPiece5).transform.rotation; float y2 = ((Quaternion)(ref rotation)).eulerAngles.y; rotation = ((Component)selectedPiece5).transform.rotation; float x = ((Quaternion)(ref rotation)).eulerAngles.x; float num2 = y2 - y; rotation = ((Component)selectedPiece5).transform.rotation; selectedPieceInfo.relRot = Quaternion.Euler(x, num2, ((Quaternion)(ref rotation)).eulerAngles.z); selectedPieceInfo.prefabName = ((Object)selectedPiece5).name; m_selectedPieceInfos.Add(selectedPieceInfo); } } } Debug.Log((object)("[MovingDay] Populated m_selectedPieceInfos: count=" + m_selectedPieceInfos.Count)); float num3 = 5f; foreach (Piece selectedPiece6 in MovingDaySelection.m_selectedPieces) { if ((Object)(object)selectedPiece6 != (Object)null) { float num4 = Vector3.Distance(((Component)m_pivotPiece).transform.position, ((Component)selectedPiece6).transform.position); if (num4 > num3) { num3 = num4; } } } m_maxSelectedDistance = num3 + configTerrainRadiusBuffer.Value; m_inMoveMode = true; m_targetYaw = 0f; m_additionalHeightOffset = 0f; m_lastCopyTerrainState = false; GameObject field = GetField(player, "m_placementGhost"); if ((Object)(object)field != (Object)null) { field.SetActive(false); } float baseHeight = MovingDayTerrain.GetBaseHeight(((Component)m_pivotPiece).transform.position); m_sourceHeightOffset = ((Component)m_pivotPiece).transform.position.y - baseHeight; float num5 = baseHeight; if ((Object)(object)ZoneSystem.instance != (Object)null) { num5 = ZoneSystem.instance.GetGroundHeight(((Component)m_pivotPiece).transform.position); } m_sourceHeightOffsetActual = ((Component)m_pivotPiece).transform.position.y - num5; m_additionalHeightOffset = 0f - m_sourceHeightOffsetActual; Debug.Log((object)("[MovingDay] Calculated sourceHeightOffsets: pivotY=" + ((Component)m_pivotPiece).transform.position.y + " baseHeight=" + baseHeight + " actualHeight=" + num5 + " baseOffset=" + m_sourceHeightOffset + " actualOffset=" + m_sourceHeightOffsetActual + " | Initial height adjustment set to: " + m_additionalHeightOffset)); MovingDayGhost.SpawnGhosts(MovingDaySelection.m_selectedPieces, m_pivotPiece); ((Character)player).Message((MessageType)2, "Entered Move Mode. Left Click to place, Right Click/Esc to cancel.", 0, (Sprite)null); } public static void UpdateMoveMode(Player player) { //IL_01b8: 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_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0235: 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_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0562: Unknown result type (might be due to invalid IL or missing references) //IL_0595: Unknown result type (might be due to invalid IL or missing references) //IL_059a: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_05df: Unknown result type (might be due to invalid IL or missing references) //IL_05e1: Unknown result type (might be due to invalid IL or missing references) //IL_05c3: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_06df: Unknown result type (might be due to invalid IL or missing references) //IL_06e1: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || (Object)(object)Camera.main == (Object)null) { Debug.Log((object)("[MovingDay Diag] UpdateMoveMode: early return - player=" + (((Object)(object)player == (Object)null) ? "null" : "ok") + " camera=" + (((Object)(object)Camera.main == (Object)null) ? "null" : "ok"))); return; } m_debugLogTimer += Time.deltaTime; KeyboardShortcut value; if (m_debugLogTimer >= 2f) { m_debugLogTimer = 0f; bool flag = PlayerCanTakeInput(player); int num; if (configHeightUpHotkey == null) { num = 273; } else { value = configHeightUpHotkey.Value; num = (int)((KeyboardShortcut)(ref value)).MainKey; } KeyCode key = (KeyCode)num; int num2; if (configHeightDownHotkey == null) { num2 = 274; } else { value = configHeightDownHotkey.Value; num2 = (int)((KeyboardShortcut)(ref value)).MainKey; } KeyCode key2 = (KeyCode)num2; Debug.Log((object)("[MovingDay Diag] UpdateMoveMode RUNNING: m_inMoveMode=" + m_inMoveMode + " takeInput=" + flag + " heightOffset=" + m_additionalHeightOffset.ToString("F2") + " up=" + MyGetKey(key) + " dn=" + MyGetKey(key2))); } int mask = LayerMask.GetMask(new string[4] { "Default", "static_solid", "piece", "terrain" }); Ray val = default(Ray); ((Ray)(ref val))..ctor(((Component)Camera.main).transform.position, ((Component)Camera.main).transform.forward); string text = "None"; RaycastHit val2 = default(RaycastHit); Vector3 targetPos; if (Physics.Raycast(val, ref val2, 50f, mask)) { targetPos = ((RaycastHit)(ref val2)).point; text = (((Object)(object)((RaycastHit)(ref val2)).collider != (Object)null) ? ((Object)((RaycastHit)(ref val2)).collider).name : "NullCollider"); } else { targetPos = ((Component)player).transform.position + ((Component)player).transform.forward * 5f; } bool flag2 = PlayerCanTakeInput(player); if (flag2) { float num3 = ((MyGetKey((KeyCode)304) || MyGetKey((KeyCode)303)) ? 1f : 5f); int num4; if (configHeightUpHotkey == null) { num4 = 273; } else { value = configHeightUpHotkey.Value; num4 = (int)((KeyboardShortcut)(ref value)).MainKey; } KeyCode key = (KeyCode)num4; int num5; if (configHeightDownHotkey == null) { num5 = 274; } else { value = configHeightDownHotkey.Value; num5 = (int)((KeyboardShortcut)(ref value)).MainKey; } KeyCode key2 = (KeyCode)num5; int num6; if (configHeightResetHotkey == null) { num6 = 278; } else { value = configHeightResetHotkey.Value; num6 = (int)((KeyboardShortcut)(ref value)).MainKey; } KeyCode key3 = (KeyCode)num6; if (MyGetKey(key)) { m_additionalHeightOffset += num3 * Time.deltaTime; Debug.Log((object)("[MovingDay Debug] Height adjustment raise held. New offset: " + m_additionalHeightOffset)); } else if (MyGetKey(key2)) { m_additionalHeightOffset -= num3 * Time.deltaTime; Debug.Log((object)("[MovingDay Debug] Height adjustment lower held. New offset: " + m_additionalHeightOffset)); } else if (MyGetKeyDown(key3)) { if (MyGetKey((KeyCode)304) || MyGetKey((KeyCode)303)) { m_additionalHeightOffset = 0f; ((Character)player).Message((MessageType)2, "Height reset to original structure offset.", 0, (Sprite)null); Debug.Log((object)"[MovingDay Debug] Height adjustment reset to original structure offset (0)."); } else { m_additionalHeightOffset = 0f - m_sourceHeightOffsetActual; ((Character)player).Message((MessageType)2, "Height reset to ground level.", 0, (Sprite)null); Debug.Log((object)"[MovingDay Debug] Height adjustment reset to ground level (-m_sourceHeightOffsetActual)."); } } } float y = targetPos.y; if (IsModifierPressed()) { float baseHeight = MovingDayTerrain.GetBaseHeight(targetPos); targetPos.y = baseHeight + m_sourceHeightOffset; } else { targetPos.y = y + m_sourceHeightOffsetActual; } if (flag2) { float mouseScrollWheel = ZInput.GetMouseScrollWheel(); if (mouseScrollWheel != 0f) { if (MyGetKey((KeyCode)308) || MyGetKey((KeyCode)307)) { float num7 = (MyGetKey((KeyCode)304) ? 0.1f : 0.5f); m_additionalHeightOffset += ((mouseScrollWheel > 0f) ? num7 : (0f - num7)); Debug.Log((object)("[MovingDay Debug] Alt+Scroll detected. Scroll=" + mouseScrollWheel + ", New offset: " + m_additionalHeightOffset)); } else if (mouseScrollWheel > 0f) { m_targetYaw += 22.5f; } else if (mouseScrollWheel < 0f) { m_targetYaw -= 22.5f; } } } float y2 = ((Component)player).transform.eulerAngles.y; float num8 = Mathf.Round(y2 / 22.5f) * 22.5f; Quaternion val3 = Quaternion.Euler(0f, num8 + m_targetYaw, 0f); if (!MyGetKey((KeyCode)304) && !MyGetKey((KeyCode)303)) { FindAndApplySnapping(ref targetPos, val3); } targetPos.y += m_additionalHeightOffset; MovingDayGhost.UpdateGhosts(targetPos, val3); ((Character)player).Message((MessageType)2, "BaseOffset: " + m_sourceHeightOffset.ToString("F1") + " | ActOffset: " + m_sourceHeightOffsetActual.ToString("F1") + " | HeightAdj: " + m_additionalHeightOffset.ToString("F1") + " | FinalY: " + targetPos.y.ToString("F1"), 0, (Sprite)null); bool flag3 = IsModifierPressed(); if (flag3 != m_lastCopyTerrainState) { m_lastCopyTerrainState = flag3; if (flag3) { ((Character)player).Message((MessageType)2, "Terrain Modification: COPY/REVERT ENABLED", 0, (Sprite)null); } else { ((Character)player).Message((MessageType)2, "Terrain Modification: COPY/REVERT DISABLED", 0, (Sprite)null); } } if (flag2) { if (ZInput.GetMouseButtonDown(0)) { ConfirmMove(player, targetPos, val3); } else if (ZInput.GetMouseButtonDown(1) || MyGetKeyDown((KeyCode)27)) { CancelMove(); ((Character)player).Message((MessageType)2, "Move canceled.", 0, (Sprite)null); } } } private static void ConfirmMove(Player player, Vector3 targetPos, Quaternion targetRot) { //IL_0032: 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) //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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0515: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_0297: 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_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015c: 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_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_05ba: Unknown result type (might be due to invalid IL or missing references) //IL_05bb: Unknown result type (might be due to invalid IL or missing references) //IL_05be: Unknown result type (might be due to invalid IL or missing references) //IL_05c3: Unknown result type (might be due to invalid IL or missing references) //IL_05c8: Unknown result type (might be due to invalid IL or missing references) //IL_05f3: Unknown result type (might be due to invalid IL or missing references) //IL_0604: Unknown result type (might be due to invalid IL or missing references) //IL_0618: Unknown result type (might be due to invalid IL or missing references) //IL_0619: Unknown result type (might be due to invalid IL or missing references) //IL_0626: Unknown result type (might be due to invalid IL or missing references) //IL_0653: Unknown result type (might be due to invalid IL or missing references) //IL_0664: Unknown result type (might be due to invalid IL or missing references) //IL_06d6: Unknown result type (might be due to invalid IL or missing references) //IL_06d7: Unknown result type (might be due to invalid IL or missing references) //IL_06da: Unknown result type (might be due to invalid IL or missing references) //IL_06df: Unknown result type (might be due to invalid IL or missing references) //IL_06e4: Unknown result type (might be due to invalid IL or missing references) //IL_06e9: Unknown result type (might be due to invalid IL or missing references) //IL_06eb: Unknown result type (might be due to invalid IL or missing references) //IL_06ee: Unknown result type (might be due to invalid IL or missing references) //IL_06f3: Unknown result type (might be due to invalid IL or missing references) //IL_06f8: Unknown result type (might be due to invalid IL or missing references) //IL_06fc: Unknown result type (might be due to invalid IL or missing references) //IL_071b: Unknown result type (might be due to invalid IL or missing references) //IL_0729: Unknown result type (might be due to invalid IL or missing references) //IL_0733: Unknown result type (might be due to invalid IL or missing references) //IL_0738: Unknown result type (might be due to invalid IL or missing references) //IL_073a: Unknown result type (might be due to invalid IL or missing references) //IL_073c: Unknown result type (might be due to invalid IL or missing references) //IL_0741: Unknown result type (might be due to invalid IL or missing references) //IL_076b: Unknown result type (might be due to invalid IL or missing references) //IL_0781: Unknown result type (might be due to invalid IL or missing references) //IL_08b6: Unknown result type (might be due to invalid IL or missing references) //IL_08c5: Unknown result type (might be due to invalid IL or missing references) //IL_08eb: Unknown result type (might be due to invalid IL or missing references) //IL_0800: Unknown result type (might be due to invalid IL or missing references) //IL_0814: Unknown result type (might be due to invalid IL or missing references) //IL_0859: Unknown result type (might be due to invalid IL or missing references) //IL_0868: Unknown result type (might be due to invalid IL or missing references) //IL_088e: Unknown result type (might be due to invalid IL or missing references) //IL_0ca2: Unknown result type (might be due to invalid IL or missing references) //IL_0ca3: Unknown result type (might be due to invalid IL or missing references) //IL_0cb2: Unknown result type (might be due to invalid IL or missing references) //IL_0cb7: Unknown result type (might be due to invalid IL or missing references) //IL_0cb8: Unknown result type (might be due to invalid IL or missing references) //IL_0cbd: Unknown result type (might be due to invalid IL or missing references) //IL_0cc2: Unknown result type (might be due to invalid IL or missing references) //IL_0cc4: Unknown result type (might be due to invalid IL or missing references) //IL_0cc5: Unknown result type (might be due to invalid IL or missing references) //IL_0cc6: Unknown result type (might be due to invalid IL or missing references) //IL_0cc8: Unknown result type (might be due to invalid IL or missing references) //IL_0ccd: Unknown result type (might be due to invalid IL or missing references) //IL_0cd2: Unknown result type (might be due to invalid IL or missing references) //IL_0cde: Unknown result type (might be due to invalid IL or missing references) //IL_0ce3: Unknown result type (might be due to invalid IL or missing references) //IL_0ce7: Unknown result type (might be due to invalid IL or missing references) //IL_0cec: Unknown result type (might be due to invalid IL or missing references) //IL_0cf0: Unknown result type (might be due to invalid IL or missing references) //IL_0d16: Unknown result type (might be due to invalid IL or missing references) //IL_0d1b: Unknown result type (might be due to invalid IL or missing references) //IL_0d1d: Unknown result type (might be due to invalid IL or missing references) //IL_0d1f: Unknown result type (might be due to invalid IL or missing references) //IL_0d24: Unknown result type (might be due to invalid IL or missing references) //IL_0d2b: Unknown result type (might be due to invalid IL or missing references) //IL_0d2d: Unknown result type (might be due to invalid IL or missing references) //IL_0abc: Unknown result type (might be due to invalid IL or missing references) //IL_0abd: Unknown result type (might be due to invalid IL or missing references) //IL_0ac9: Unknown result type (might be due to invalid IL or missing references) //IL_0ace: Unknown result type (might be due to invalid IL or missing references) //IL_0acf: Unknown result type (might be due to invalid IL or missing references) //IL_0ad4: Unknown result type (might be due to invalid IL or missing references) //IL_0ad9: Unknown result type (might be due to invalid IL or missing references) //IL_0adb: Unknown result type (might be due to invalid IL or missing references) //IL_0adc: Unknown result type (might be due to invalid IL or missing references) //IL_0add: Unknown result type (might be due to invalid IL or missing references) //IL_0adf: Unknown result type (might be due to invalid IL or missing references) //IL_0ae4: Unknown result type (might be due to invalid IL or missing references) //IL_0ae9: Unknown result type (might be due to invalid IL or missing references) //IL_0af2: Unknown result type (might be due to invalid IL or missing references) //IL_0af7: Unknown result type (might be due to invalid IL or missing references) //IL_0afb: Unknown result type (might be due to invalid IL or missing references) //IL_0b00: Unknown result type (might be due to invalid IL or missing references) //IL_0b04: Unknown result type (might be due to invalid IL or missing references) //IL_0b2a: Unknown result type (might be due to invalid IL or missing references) //IL_0b2f: Unknown result type (might be due to invalid IL or missing references) //IL_0b31: Unknown result type (might be due to invalid IL or missing references) //IL_0b33: Unknown result type (might be due to invalid IL or missing references) //IL_0b38: Unknown result type (might be due to invalid IL or missing references) //IL_0b69: Unknown result type (might be due to invalid IL or missing references) //IL_0b80: Unknown result type (might be due to invalid IL or missing references) //IL_0d6d: Unknown result type (might be due to invalid IL or missing references) //IL_0d72: Unknown result type (might be due to invalid IL or missing references) //IL_0d79: Unknown result type (might be due to invalid IL or missing references) //IL_0df6: Unknown result type (might be due to invalid IL or missing references) //IL_0dff: Unknown result type (might be due to invalid IL or missing references) //IL_0c04: Unknown result type (might be due to invalid IL or missing references) //IL_0c13: Unknown result type (might be due to invalid IL or missing references) //IL_0c38: Unknown result type (might be due to invalid IL or missing references) //IL_0c42: Unknown result type (might be due to invalid IL or missing references) //IL_0c4c: Unknown result type (might be due to invalid IL or missing references) //IL_0c59: Unknown result type (might be due to invalid IL or missing references) //IL_0bdc: Unknown result type (might be due to invalid IL or missing references) //IL_0be6: Unknown result type (might be due to invalid IL or missing references) //IL_0ec4: Unknown result type (might be due to invalid IL or missing references) //IL_0ec5: Unknown result type (might be due to invalid IL or missing references) if (m_selectedPieceInfos.Count == 0) { ((Character)player).Message((MessageType)2, "Move aborted: No cached pieces to move.", 0, (Sprite)null); CancelMove(); return; } Vector3 oldPivotPos = m_oldPivotPos; float oldPivotYaw = m_oldPivotYaw; Quaternion val = Quaternion.Euler(0f, oldPivotYaw, 0f); Debug.Log((object)string.Concat("[MovingDay Debug] ConfirmMove triggered! piecesCount=", m_selectedPieceInfos.Count, " oldPivotPos=", oldPivotPos, " targetPos=", targetPos)); List allPlayers = Player.GetAllPlayers(); List list = new List(); List list2 = new List(); List list3 = new List(); if (configMoveTamed.Value) { List allCharacters = Character.GetAllCharacters(); Debug.Log((object)("[MovingDay Debug] Scanning " + allCharacters.Count + " total active characters for tamed animals...")); foreach (Character item in allCharacters) { if ((Object)(object)item == (Object)null) { continue; } bool flag = item.IsTamed(); float num = float.MaxValue; foreach (SelectedPieceInfo selectedPieceInfo in m_selectedPieceInfos) { Vector3 val2 = oldPivotPos + val * selectedPieceInfo.relPos; float num2 = Vector3.Distance(((Component)item).transform.position, val2); if (num2 < num) { num = num2; } } if (flag && num < 6f) { list3.Add(item); Debug.Log((object)("[MovingDay Debug] -> Added " + ((Object)item).name + " to teleport list (distance: " + num.ToString("F1") + "m).")); } } } foreach (Player item2 in allPlayers) { if ((Object)(object)item2 == (Object)null) { continue; } bool flag2 = false; foreach (SelectedPieceInfo selectedPieceInfo2 in m_selectedPieceInfos) { Vector3 val2 = oldPivotPos + val * selectedPieceInfo2.relPos; if (Vector3.Distance(((Component)item2).transform.position, val2) < 3f) { flag2 = true; break; } } if (!flag2) { continue; } bool flag3 = PlayerHasNonTeleportable(item2); string value = configPlayerMetalAction.Value; string value2 = configPlayerSafety.Value; if (flag3 && value.Equals("BlockMove", StringComparison.OrdinalIgnoreCase)) { if ((Object)(object)item2 == (Object)(object)Player.m_localPlayer) { ((Character)player).Message((MessageType)2, "Cannot move: You are carrying non-teleportable items.", 0, (Sprite)null); } else { ((Character)player).Message((MessageType)2, "Cannot move: Player '" + item2.GetPlayerName() + "' is carrying non-teleportable items.", 0, (Sprite)null); } Debug.LogWarning((object)"[MovingDay Debug] Move aborted: Player carrying metal when PlayerMetalAction=BlockMove."); return; } if ((Object)(object)item2 == (Object)(object)Player.m_localPlayer) { if (value2.Equals("Block", StringComparison.OrdinalIgnoreCase)) { ((Character)player).Message((MessageType)2, "Cannot move: You are inside the building.", 0, (Sprite)null); Debug.LogWarning((object)"[MovingDay Debug] Move aborted: Local player is inside and PlayerSafetyAction=Block."); return; } if (value2.Equals("Teleport", StringComparison.OrdinalIgnoreCase)) { if (flag3 && value.Equals("LeaveBehind", StringComparison.OrdinalIgnoreCase)) { list2.Add(item2); } else { list.Add(item2); } } else { list2.Add(item2); } } else { if (value2.Equals("Block", StringComparison.OrdinalIgnoreCase) || value2.Equals("Teleport", StringComparison.OrdinalIgnoreCase)) { ((Character)player).Message((MessageType)2, "Cannot move: Player '" + item2.GetPlayerName() + "' is inside.", 0, (Sprite)null); Debug.LogWarning((object)("[MovingDay Debug] Move aborted: Other player is inside and PlayerSafetyAction=" + value2)); return; } list2.Add(item2); } } bool flag4 = IsModifierPressed(); Debug.Log((object)string.Concat("[MovingDay Debug] Modifier Key Check: copyTerrain=", flag4, " (Config=", configModifierKey.Value, " LeftCtrl=", ZInput.GetKey((KeyCode)306, true), " RightCtrl=", ZInput.GetKey((KeyCode)305, true), ")")); List list4 = null; HashSet affectedComps = new HashSet(); if (flag4) { ((Character)player).Message((MessageType)2, "Processing terrain updates...", 0, (Sprite)null); List list5 = new List(); foreach (SelectedPieceInfo selectedPieceInfo3 in m_selectedPieceInfos) { list5.Add(oldPivotPos + val * selectedPieceInfo3.relPos); } list4 = MovingDayTerrain.CaptureTerrain(oldPivotPos, m_maxSelectedDistance, list5); float yawRad = (((Quaternion)(ref targetRot)).eulerAngles.y - oldPivotYaw) * ((float)Math.PI / 180f); MovingDayTerrain.ApplyTerrain(oldPivotPos, targetPos, yawRad, list4, ref affectedComps); MovingDayTerrain.ClearTerrain(oldPivotPos, list4, ref affectedComps); MovingDayTerrain.RebuildTerrain(affectedComps); if ((Object)(object)ClutterSystem.instance != (Object)null) { ClutterSystem.instance.ResetGrass(oldPivotPos, m_maxSelectedDistance); ClutterSystem.instance.ResetGrass(targetPos, m_maxSelectedDistance); } } ((Character)player).Message((MessageType)2, "Moving structure...", 0, (Sprite)null); Debug.Log((object)"[MovingDay Debug] Relocating GameObjects..."); List list6 = new List(); int num3 = 0; foreach (SelectedPieceInfo selectedPieceInfo4 in m_selectedPieceInfos) { if (selectedPieceInfo4.zdo == null || !selectedPieceInfo4.zdo.IsValid()) { continue; } Vector3 val3 = targetPos + targetRot * selectedPieceInfo4.relPos; Quaternion val4 = targetRot * selectedPieceInfo4.relRot; float num4 = Mathf.Round(((Quaternion)(ref val4)).eulerAngles.y / 22.5f) * 22.5f; val4 = Quaternion.Euler(((Quaternion)(ref val4)).eulerAngles.x, num4, ((Quaternion)(ref val4)).eulerAngles.z); val4 = NormalizeQuaternion(val4); Debug.Log((object)string.Concat("[MovingDay Debug] Relocating piece '", selectedPieceInfo4.prefabName, "' to pos=", val3, " rot=", ((Quaternion)(ref val4)).eulerAngles)); if ((Object)(object)selectedPieceInfo4.piece != (Object)null) { WearNTear component = ((Component)selectedPieceInfo4.piece).GetComponent(); if ((Object)(object)component != (Object)null && ((Behaviour)component).enabled) { ((Behaviour)component).enabled = false; list6.Add(component); } ((Component)selectedPieceInfo4.piece).transform.position = val3; ((Component)selectedPieceInfo4.piece).transform.rotation = val4; ZNetView component2 = ((Component)selectedPieceInfo4.piece).GetComponent(); if ((Object)(object)component2 != (Object)null && component2.IsValid()) { component2.ClaimOwnership(); } selectedPieceInfo4.zdo.SetPosition(val3); selectedPieceInfo4.zdo.SetRotation(val4); ZDOMan.instance.ZDOSectorInvalidated(selectedPieceInfo4.zdo); ZDOMan.instance.ClientChanged(selectedPieceInfo4.zdo.m_uid); } else { selectedPieceInfo4.zdo.SetOwner(ZDOMan.GetSessionID()); selectedPieceInfo4.zdo.SetPosition(val3); selectedPieceInfo4.zdo.SetRotation(val4); ZDOMan.instance.ZDOSectorInvalidated(selectedPieceInfo4.zdo); ZDOMan.instance.ClientChanged(selectedPieceInfo4.zdo.m_uid); } num3++; } Debug.Log((object)("[MovingDay Debug] Relocated " + num3 + " GameObjects. Syncing transforms...")); Physics.SyncTransforms(); foreach (WearNTear item3 in list6) { ResetPieceStabilityCache(item3); } float value3 = Time.time + 5f; foreach (WearNTear item4 in list6) { if ((Object)(object)item4 != (Object)null) { m_recentlyMovedPieces[item4] = value3; } } if ((Object)(object)instance != (Object)null) { ((MonoBehaviour)instance).StartCoroutine(ReenableStabilityDelay(list6)); } else { Debug.LogWarning((object)"[MovingDay Debug] instance is null! Fallback to instant stability re-enable."); foreach (WearNTear item5 in list6) { if ((Object)(object)item5 != (Object)null) { item5.OnPlaced(); ((Behaviour)item5).enabled = true; } } } Quaternion rotation; if (configMoveTamed.Value) { foreach (Character item6 in list3) { if ((Object)(object)item6 == (Object)null) { continue; } Vector3 val5 = Quaternion.Inverse(val) * (((Component)item6).transform.position - oldPivotPos); Vector3 val6 = targetPos + targetRot * val5; rotation = ((Component)item6).transform.rotation; Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles; float num5 = ((Quaternion)(ref targetRot)).eulerAngles.y - oldPivotYaw; Quaternion q = Quaternion.Euler(eulerAngles.x, eulerAngles.y + num5, eulerAngles.z); q = NormalizeQuaternion(q); Debug.Log((object)string.Concat("[MovingDay Debug] Teleporting tamed animal '", ((Object)item6).name, "' from ", ((Component)item6).transform.position, " to ", val6)); ZNetView component2 = ((Component)item6).GetComponent(); if ((Object)(object)component2 != (Object)null && component2.IsValid()) { component2.ClaimOwnership(); ZDO zDO = component2.GetZDO(); if (zDO != null) { zDO.SetPosition(val6); zDO.SetRotation(q); ZDOMan.instance.ZDOSectorInvalidated(zDO); } } ((Component)item6).transform.position = val6; ((Component)item6).transform.rotation = q; Rigidbody component3 = ((Component)item6).GetComponent(); if ((Object)(object)component3 != (Object)null) { component3.position = val6; component3.rotation = q; component3.velocity = Vector3.zero; component3.angularVelocity = Vector3.zero; } } } if (list.Contains(Player.m_localPlayer)) { Vector3 val7 = Quaternion.Inverse(val) * (((Component)Player.m_localPlayer).transform.position - oldPivotPos); Vector3 val8 = targetPos + targetRot * val7; rotation = ((Component)Player.m_localPlayer).transform.rotation; Vector3 eulerAngles2 = ((Quaternion)(ref rotation)).eulerAngles; float num5 = ((Quaternion)(ref targetRot)).eulerAngles.y - oldPivotYaw; Quaternion q2 = Quaternion.Euler(eulerAngles2.x, eulerAngles2.y + num5, eulerAngles2.z); q2 = NormalizeQuaternion(q2); ((Character)Player.m_localPlayer).TeleportTo(val8, q2, true); } Vector3 val9 = default(Vector3); foreach (Player item7 in list2) { if (!((Object)(object)item7 == (Object)null)) { Vector3 position = ((Component)item7).transform.position; float groundHeight = ZoneSystem.instance.GetGroundHeight(position); if (position.y > groundHeight + 0.1f) { ((Character)item7).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("Featherfall"), true, 1, 0f); Debug.Log((object)("[MovingDay Debug] Applied Featherfall status effect to player " + item7.GetPlayerName())); continue; } ((Vector3)(ref val9))..ctor(position.x, groundHeight + 0.5f, position.z); ((Character)item7).TeleportTo(val9, ((Component)item7).transform.rotation, true); Debug.Log((object)("[MovingDay Debug] Snapped player " + item7.GetPlayerName() + " to restored ground Y: " + (groundHeight + 0.5f))); } } GameObject prefab = ZNetScene.instance.GetPrefab("portal_wood"); if ((Object)(object)prefab != (Object)null) { TeleportWorld component4 = prefab.GetComponent(); if ((Object)(object)component4 != (Object)null && component4.m_connected != null) { component4.m_connected.Create(targetPos, Quaternion.identity, (Transform)null, 1f, -1); } } GameObject field = GetField(player, "m_placementGhost"); if ((Object)(object)field != (Object)null) { field.SetActive(true); } MovingDayGhost.ClearGhosts(); MovingDaySelection.ClearSelection(); m_selectedPieceInfos.Clear(); m_inMoveMode = false; m_sourceHeightOffset = 0f; m_sourceHeightOffsetActual = 0f; m_additionalHeightOffset = 0f; ((Character)player).Message((MessageType)2, "Structure moved successfully!", 0, (Sprite)null); } private static void ResetPieceStabilityCache(WearNTear wear) { if ((Object)(object)wear == (Object)null) { return; } try { Heightmap field = GetField(wear, "m_connectedHeightMap"); if ((Object)(object)field != (Object)null) { MethodInfo method = typeof(Heightmap).GetMethod("remove_m_clearConnectedWearNTearCache", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { MethodInfo method2 = typeof(WearNTear).GetMethod("ClearCachedSupport", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method2 != null) { Action action = (Action)Delegate.CreateDelegate(typeof(Action), wear, method2); method.Invoke(field, new object[1] { action }); } } } SetField(wear, "m_connectedHeightMap", null); SetField(wear, "m_heightmap", null); SetField(wear, "m_biome", 0); SetField(wear, "m_groundDist", 0f); SetField(wear, "m_haveRoof", false); SetField(wear, "m_haveAshRoof", false); SetField(wear, "m_updateCoverTimer", 0f); GetField>(wear, "m_supportColliders")?.Clear(); GetField>(wear, "m_supportPositions")?.Clear(); GetField>(wear, "m_supportValue")?.Clear(); MethodInfo method3 = typeof(WearNTear).GetMethod("SetupColliders", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method3 != null) { method3.Invoke(wear, null); } MethodInfo method4 = typeof(WearNTear).GetMethod("GetMaxSupport", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method4 != null) { float num = (float)method4.Invoke(wear, null); SetField(wear, "m_support", num); } MethodInfo method5 = typeof(WearNTear).GetMethod("Start", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method5 != null) { method5.Invoke(wear, null); } } catch (Exception ex) { Debug.LogWarning((object)("[MovingDay Debug] Error resetting stability cache: " + ex.Message)); } } private static IEnumerator ReenableStabilityDelay(List wnts) { yield return null; yield return null; List sortedWnts = new List(); foreach (WearNTear wnt in wnts) { if ((Object)(object)wnt != (Object)null) { sortedWnts.Add(wnt); } } sortedWnts.Sort(delegate(WearNTear a, WearNTear b) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) float y = ((Component)a).transform.position.y; return y.CompareTo(((Component)b).transform.position.y); }); Debug.Log((object)("[MovingDay Debug] Re-enabling stability for " + sortedWnts.Count + " pieces in ground-up order.")); foreach (WearNTear item in sortedWnts) { item.OnPlaced(); ((Behaviour)item).enabled = true; } MethodInfo updateSupportMethod = typeof(WearNTear).GetMethod("UpdateSupport", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (updateSupportMethod != null) { int num = 0; foreach (WearNTear item2 in sortedWnts) { if (!((Object)(object)item2 == (Object)null)) { try { updateSupportMethod.Invoke(item2, null); num++; } catch (Exception ex) { Debug.LogWarning((object)("[MovingDay Debug] UpdateSupport failed on " + ((Object)item2).name + ": " + ex.Message)); } } } Debug.Log((object)("[MovingDay Debug] Synchronously propagated support for " + num + " pieces.")); } else { Debug.LogWarning((object)"[MovingDay Debug] UpdateSupport method not found via reflection!"); } } private static void SetField(object obj, string name, object val) { if (obj != null) { FieldInfo field = obj.GetType().GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { field.SetValue(obj, val); } } } private static T GetField(object obj, string name) { if (obj == null) { return default(T); } FieldInfo field = obj.GetType().GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); return (field != null) ? ((T)field.GetValue(obj)) : default(T); } private static Quaternion NormalizeQuaternion(Quaternion q) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Sqrt(q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w); if (num > 1E-05f) { return new Quaternion(q.x / num, q.y / num, q.z / num, q.w / num); } return Quaternion.identity; } private static void FindAndApplySnapping(ref Vector3 targetPos, Quaternion targetRot) { //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_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_009a: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0266: 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_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) List list = new List(); foreach (GhostPiece activeGhost in MovingDayGhost.m_activeGhosts) { if (activeGhost == null || (Object)(object)activeGhost.gameObject == (Object)null) { continue; } for (int i = 0; i < activeGhost.gameObject.transform.childCount; i++) { Transform child = activeGhost.gameObject.transform.GetChild(i); if ((Object)(object)child != (Object)null && ((Component)child).CompareTag("snappoint")) { Vector3 item = targetPos + targetRot * (activeGhost.relPos + activeGhost.relRot * child.localPosition); list.Add(item); } } } if (list.Count == 0) { return; } List list2 = new List(); List allPieces = MovingDaySelection.GetAllPieces(); float num = m_maxSelectedDistance + 10f; foreach (Piece item2 in allPieces) { if ((Object)(object)item2 == (Object)null || MovingDaySelection.m_selectedPieces.Contains(item2) || Vector3.Distance(((Component)item2).transform.position, targetPos) > num) { continue; } for (int i = 0; i < ((Component)item2).transform.childCount; i++) { Transform child = ((Component)item2).transform.GetChild(i); if ((Object)(object)child != (Object)null && ((Component)child).CompareTag("snappoint")) { list2.Add(child.position); } } } if (list2.Count == 0) { return; } float num2 = 1f; Vector3 val = Vector3.zero; Vector3 val2 = Vector3.zero; bool flag = false; foreach (Vector3 item3 in list) { foreach (Vector3 item4 in list2) { float num3 = Vector3.Distance(item3, item4); if (num3 < num2) { num2 = num3; val = item3; val2 = item4; flag = true; } } } if (flag) { Vector3 val3 = val2 - val; targetPos += val3; } } private static void CancelMove() { if ((Object)(object)Player.m_localPlayer != (Object)null) { GameObject field = GetField(Player.m_localPlayer, "m_placementGhost"); if ((Object)(object)field != (Object)null) { field.SetActive(true); } } MovingDayGhost.ClearGhosts(); m_inMoveMode = false; m_sourceHeightOffset = 0f; m_sourceHeightOffsetActual = 0f; m_additionalHeightOffset = 0f; m_selectedPieceInfos.Clear(); } private static bool IsModifierPressed() { //IL_0019: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Invalid comparison between Unknown and I4 //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (configModifierKey == null) { return false; } KeyboardShortcut value = configModifierKey.Value; KeyCode mainKey = ((KeyboardShortcut)(ref value)).MainKey; if ((int)mainKey == 0) { return false; } return MyGetKey(mainKey); } private static ItemData GetRightItem(Player player) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown if ((Object)(object)player == (Object)null) { return null; } Type type = ((object)player).GetType(); while (type != null) { FieldInfo field = type.GetField("m_rightItem", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { return (ItemData)field.GetValue(player); } type = type.BaseType; } return null; } private static Piece GetHoveringPiece(Player player) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown if ((Object)(object)player == (Object)null) { return null; } FieldInfo field = typeof(Player).GetField("m_hoveringPiece", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { return (Piece)field.GetValue(player); } return null; } private static bool PlayerHasNonTeleportable(Player player) { if ((Object)(object)player == (Object)null) { return false; } foreach (ItemData allItem in ((Humanoid)player).GetInventory().GetAllItems()) { if (allItem != null && !allItem.m_shared.m_teleportable) { return true; } } return false; } private static bool ContainerHasNonTeleportable(Container c) { if ((Object)(object)c == (Object)null) { return false; } foreach (ItemData allItem in c.GetInventory().GetAllItems()) { if (allItem != null && !allItem.m_shared.m_teleportable) { return true; } } return false; } private static void SaveContainer(Container c) { if ((Object)(object)c == (Object)null) { return; } try { MethodInfo method = typeof(Container).GetMethod("Save", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { method.Invoke(c, null); } } catch (Exception ex) { Debug.LogWarning((object)("[MovingDay Debug] Error saving container: " + ex.Message)); } } public static object GetInputField(Chat chat) { if ((Object)(object)chat == (Object)null) { return null; } FieldInfo field = typeof(Chat).GetField("m_input", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { return field.GetValue(chat); } return null; } public static string GetChatText(Chat chat) { object inputField = GetInputField(chat); if (inputField == null) { return null; } PropertyInfo property = inputField.GetType().GetProperty("text"); if (property != null) { return (string)property.GetValue(inputField, null); } return null; } public static void CleanWorldOrigin(float radius = 150f) { //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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) if (ZDOMan.instance == null) { return; } int num = 0; try { FieldInfo field = typeof(ZDOMan).GetField("m_objectsByID", BindingFlags.Instance | BindingFlags.NonPublic); if (field == null) { Debug.LogWarning((object)"[MovingDay] Failed to find m_objectsByID field in ZDOMan"); return; } Dictionary dictionary = (Dictionary)field.GetValue(ZDOMan.instance); if (dictionary == null) { return; } List list = new List(); foreach (KeyValuePair item in dictionary) { ZDO value = item.Value; if (value != null && value.IsValid()) { Vector3 position = value.GetPosition(); float num2 = Vector2.Distance(new Vector2(position.x, position.z), Vector2.zero); if (num2 <= radius && Mathf.Abs(position.y) < 2f && value.GetPrefab() != 0) { list.Add(value); } } } foreach (ZDO item2 in list) { item2.SetOwner(ZDOMan.GetSessionID()); ZDOMan.instance.DestroyZDO(item2); num++; } string text = "MovingDay: Cleaned " + num + " ZDO(s) near world origin (0,0,0)."; Debug.Log((object)("[MovingDay] " + text)); if ((Object)(object)Player.m_localPlayer != (Object)null) { ((Character)Player.m_localPlayer).Message((MessageType)2, text, 0, (Sprite)null); } } catch (Exception ex) { Debug.LogWarning((object)("[MovingDay] Error cleaning world origin: " + ex)); } } private static bool FindClosestSnapPoints(Player player, Transform ghost, float maxSnapDistance, out Transform a, out Transform b, List pieces) { //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Expected O, but got Unknown //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Expected O, but got Unknown a = null; b = null; try { if (m_findClosestSnapPoints == null) { MethodInfo method = typeof(Player).GetMethod("FindClosestSnapPoints", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { m_findClosestSnapPoints = (FindClosestSnapPointsDelegate)Delegate.CreateDelegate(typeof(FindClosestSnapPointsDelegate), null, method); } } if (m_findClosestSnapPoints != null) { return m_findClosestSnapPoints(player, ghost, maxSnapDistance, out a, out b, pieces); } } catch (Exception ex) { Debug.LogWarning((object)("[MovingDay Debug] Error calling FindClosestSnapPoints via delegate: " + ex.Message)); } try { MethodInfo method = typeof(Player).GetMethod("FindClosestSnapPoints", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { object[] array = new object[5] { ghost, maxSnapDistance, null, null, pieces }; bool result = (bool)method.Invoke(player, array); a = (Transform)array[2]; b = (Transform)array[3]; return result; } } catch (Exception ex) { Debug.LogWarning((object)("[MovingDay Debug] Error calling FindClosestSnapPoints: " + ex.Message)); } return false; } } public class MovingDaySelection { public static HashSet m_selectedPieces = new HashSet(); public static HashSet m_selectedZDOIDs = new HashSet(); public static List GetAllPieces() { FieldInfo field = typeof(Piece).GetField("s_allPieces", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { return (List)field.GetValue(null); } return new List(); } public static void ClearSelection() { foreach (Piece selectedPiece in m_selectedPieces) { if ((Object)(object)selectedPiece != (Object)null) { MovingDaySelectionHighlight component = ((Component)selectedPiece).GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } Component component2 = ((Component)selectedPiece).GetComponent("PrefabSelectionHighlight"); if ((Object)(object)component2 != (Object)null) { Object.Destroy((Object)(object)component2); } } } m_selectedPieces.Clear(); m_selectedZDOIDs.Clear(); } public static void AddToSelection(Piece piece) { //IL_0084: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)piece == (Object)null) && piece.IsPlacedByPlayer()) { if (m_selectedPieces.Add(piece) && (Object)(object)((Component)piece).GetComponent() == (Object)null) { ((Component)piece).gameObject.AddComponent(); } ZNetView component = ((Component)piece).GetComponent(); if ((Object)(object)component != (Object)null && component.IsValid() && component.GetZDO() != null) { m_selectedZDOIDs.Add(component.GetZDO().m_uid); } } } public static void RemoveFromSelection(Piece piece) { //IL_009e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)piece == (Object)null) { return; } if (m_selectedPieces.Remove(piece)) { MovingDaySelectionHighlight component = ((Component)piece).GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } Component component2 = ((Component)piece).GetComponent("PrefabSelectionHighlight"); if ((Object)(object)component2 != (Object)null) { Object.Destroy((Object)(object)component2); } } ZNetView component3 = ((Component)piece).GetComponent(); if ((Object)(object)component3 != (Object)null && component3.IsValid() && component3.GetZDO() != null) { m_selectedZDOIDs.Remove(component3.GetZDO().m_uid); } } private static Bounds GetPieceBounds(Piece piece, out bool success) { //IL_000b: 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_007b: 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_0058: 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_004d: Unknown result type (might be due to invalid IL or missing references) Collider[] componentsInChildren = ((Component)piece).GetComponentsInChildren(true); Bounds result = default(Bounds); success = false; Collider[] array = componentsInChildren; foreach (Collider val in array) { if ((Object)(object)val != (Object)null && !val.isTrigger) { if (!success) { result = val.bounds; success = true; } else { ((Bounds)(ref result)).Encapsulate(val.bounds); } } } return result; } private static float GetBoundsDistance(Bounds b1, Bounds b2) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(0f, Mathf.Abs(((Bounds)(ref b1)).center.x - ((Bounds)(ref b2)).center.x) - (((Bounds)(ref b1)).extents.x + ((Bounds)(ref b2)).extents.x)); float num2 = Mathf.Max(0f, Mathf.Abs(((Bounds)(ref b1)).center.y - ((Bounds)(ref b2)).center.y) - (((Bounds)(ref b1)).extents.y + ((Bounds)(ref b2)).extents.y)); float num3 = Mathf.Max(0f, Mathf.Abs(((Bounds)(ref b1)).center.z - ((Bounds)(ref b2)).center.z) - (((Bounds)(ref b1)).extents.z + ((Bounds)(ref b2)).extents.z)); return Mathf.Sqrt(num * num + num2 * num2 + num3 * num3); } private static float GetPieceDistance(Piece p1, Piece p2) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) bool success; Bounds pieceBounds = GetPieceBounds(p1, out success); bool success2; Bounds pieceBounds2 = GetPieceBounds(p2, out success2); if (success && success2) { return GetBoundsDistance(pieceBounds, pieceBounds2); } return Vector3.Distance(((Component)p1).transform.position, ((Component)p2).transform.position); } public static void SelectConnected(Piece startPiece, float maxDistance) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)startPiece == (Object)null || !startPiece.IsPlacedByPlayer()) { return; } ClearSelection(); List allPieces = GetAllPieces(); Queue queue = new Queue(); HashSet hashSet = new HashSet(); queue.Enqueue(startPiece); hashSet.Add(startPiece); List list = new List(); Vector3 position = ((Component)startPiece).transform.position; foreach (Piece item in allPieces) { if ((Object)(object)item != (Object)null && Vector3.Distance(((Component)item).transform.position, position) < 250f) { list.Add(item); } } while (queue.Count > 0) { Piece val = queue.Dequeue(); AddToSelection(val); foreach (Piece item2 in list) { if (!((Object)(object)item2 == (Object)null) && !hashSet.Contains(item2) && item2.IsPlacedByPlayer()) { float pieceDistance = GetPieceDistance(val, item2); if (pieceDistance <= maxDistance) { hashSet.Add(item2); queue.Enqueue(item2); } } } } } } public class MovingDaySelectionHighlight : MonoBehaviour { private GameObject m_highlightRoot; private Material m_material; private float m_time; private List m_renderers = new List(); private void Awake() { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Expected O, but got Unknown //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Expected O, but got Unknown //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) Shader val = Shader.Find("Legacy Shaders/Transparent/Diffuse"); if ((Object)(object)val == (Object)null) { val = Shader.Find("Transparent/Diffuse"); } if ((Object)(object)val == (Object)null) { val = Shader.Find("UI/Default"); } if ((Object)(object)val == (Object)null) { val = Shader.Find("Standard"); } if ((Object)(object)val != (Object)null) { m_material = new Material(val); } else { m_material = new Material(Shader.Find("Sprites/Default")); } if (m_material.HasProperty("_Color")) { m_material.color = new Color(0.1f, 0.9f, 0.5f, 0.35f); } m_highlightRoot = new GameObject("MovingDaySelectionHighlightRoot"); m_highlightRoot.transform.SetParent(((Component)this).transform, false); m_highlightRoot.transform.localPosition = Vector3.zero; m_highlightRoot.transform.localRotation = Quaternion.identity; m_highlightRoot.transform.localScale = Vector3.one; MeshFilter[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); MeshFilter[] array = componentsInChildren; foreach (MeshFilter val2 in array) { if ((Object)(object)val2 == (Object)null || (Object)(object)val2.sharedMesh == (Object)null) { continue; } Renderer component = ((Component)val2).GetComponent(); if (!((Object)(object)component == (Object)null) && component.enabled && ((Component)component).gameObject.activeInHierarchy) { string text = ((Object)((Component)val2).gameObject).name.ToLower(); if (!text.Contains("collision") && !text.Contains("collider") && !text.Contains("trigger") && !text.Contains("preview") && !text.Contains("ghost") && !text.Contains("helper") && !text.Contains("dummy")) { GameObject val3 = new GameObject(((Object)((Component)val2).gameObject).name + "_Highlight"); val3.transform.SetParent(m_highlightRoot.transform, false); val3.transform.position = ((Component)val2).transform.position; val3.transform.rotation = ((Component)val2).transform.rotation; val3.transform.localScale = ((Component)val2).transform.lossyScale; MeshFilter val4 = val3.AddComponent(); val4.sharedMesh = val2.sharedMesh; MeshRenderer val5 = val3.AddComponent(); ((Renderer)val5).sharedMaterial = m_material; m_renderers.Add(val5); } } } } private void Update() { //IL_0071: Unknown result type (might be due to invalid IL or missing references) m_time += Time.deltaTime; float num = 0.2f + 0.2f * Mathf.Sin(m_time * 5f); if ((Object)(object)m_material != (Object)null && m_material.HasProperty("_Color")) { m_material.color = new Color(0.1f, 0.9f, 0.5f, num); } } private void OnDestroy() { if ((Object)(object)m_highlightRoot != (Object)null) { Object.Destroy((Object)(object)m_highlightRoot); } if ((Object)(object)m_material != (Object)null) { Object.Destroy((Object)(object)m_material); } } } public class GhostPiece { public GameObject gameObject; public Vector3 relPos; public Quaternion relRot; } public class MovingDayGhost { public static List m_activeGhosts = new List(); private static Material m_ghostMaterial; private static void CreateGhostMaterial() { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)m_ghostMaterial != (Object)null)) { Shader val = Shader.Find("Legacy Shaders/Transparent/Diffuse"); if ((Object)(object)val == (Object)null) { val = Shader.Find("Transparent/Diffuse"); } if ((Object)(object)val == (Object)null) { val = Shader.Find("UI/Default"); } if ((Object)(object)val == (Object)null) { val = Shader.Find("Standard"); } if ((Object)(object)val != (Object)null) { m_ghostMaterial = new Material(val); } else { m_ghostMaterial = new Material(Shader.Find("Sprites/Default")); } if (m_ghostMaterial.HasProperty("_Color")) { m_ghostMaterial.color = new Color(0.1f, 0.7f, 1f, 0.4f); } } } public static void ClearGhosts() { foreach (GhostPiece activeGhost in m_activeGhosts) { if (activeGhost != null && (Object)(object)activeGhost.gameObject != (Object)null) { Object.Destroy((Object)(object)activeGhost.gameObject); } } m_activeGhosts.Clear(); } public static void SpawnGhosts(HashSet selectedPieces, Piece pivotPiece) { //IL_0037: 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_0043: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_027d: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) ClearGhosts(); CreateGhostMaterial(); if (selectedPieces == null || selectedPieces.Count == 0 || (Object)(object)pivotPiece == (Object)null) { return; } Vector3 position = ((Component)pivotPiece).transform.position; Quaternion rotation = ((Component)pivotPiece).transform.rotation; float y = ((Quaternion)(ref rotation)).eulerAngles.y; Quaternion val = Quaternion.Euler(0f, y, 0f); ZNetView.m_forceDisableInit = true; try { foreach (Piece selectedPiece in selectedPieces) { if ((Object)(object)selectedPiece == (Object)null) { continue; } string text = ((Object)((Component)selectedPiece).gameObject).name.Replace("(Clone)", "").Trim(); GameObject val2 = ZNetScene.instance.GetPrefab(text); ZNetView component = ((Component)selectedPiece).GetComponent(); if ((Object)(object)val2 == (Object)null && (Object)(object)component != (Object)null && component.IsValid()) { int prefab = component.GetZDO().GetPrefab(); val2 = ZNetScene.instance.GetPrefab(prefab); } if ((Object)(object)val2 == (Object)null) { val2 = ((Component)selectedPiece).gameObject; } GameObject val3 = Object.Instantiate(val2); ((Object)val3).name = text + "_MovingDayGhost"; Object.DontDestroyOnLoad((Object)(object)val3); int num = LayerMask.NameToLayer("Ignore Raycast"); if (num != -1) { Transform[] componentsInChildren = val3.GetComponentsInChildren(true); foreach (Transform val4 in componentsInChildren) { if ((Object)(object)val4 != (Object)null) { ((Component)val4).gameObject.layer = num; } } } Component[] componentsInChildren2 = val3.GetComponentsInChildren(true); Component[] array = componentsInChildren2; foreach (Component val5 in array) { if (!((Object)(object)val5 == (Object)null) && !(val5 is Transform) && !(val5 is MeshFilter) && !(val5 is MeshRenderer)) { Object.DestroyImmediate((Object)(object)val5); } } Renderer[] componentsInChildren3 = val3.GetComponentsInChildren(true); Renderer[] array2 = componentsInChildren3; foreach (Renderer val6 in array2) { if ((Object)(object)val6 != (Object)null) { val6.sharedMaterial = m_ghostMaterial; } } Vector3 relPos = Quaternion.Inverse(val) * (((Component)selectedPiece).transform.position - position); rotation = ((Component)selectedPiece).transform.rotation; Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles; Quaternion relRot = Quaternion.Euler(eulerAngles.x, eulerAngles.y - y, eulerAngles.z); GhostPiece ghostPiece = new GhostPiece(); ghostPiece.gameObject = val3; ghostPiece.relPos = relPos; ghostPiece.relRot = relRot; m_activeGhosts.Add(ghostPiece); } } finally { ZNetView.m_forceDisableInit = false; } Debug.Log((object)("[MovingDay] Spawned " + m_activeGhosts.Count + " ghost preview pieces.")); } public static void UpdateGhosts(Vector3 targetPivotPos, Quaternion targetPivotRot) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) foreach (GhostPiece activeGhost in m_activeGhosts) { if (activeGhost != null && !((Object)(object)activeGhost.gameObject == (Object)null)) { activeGhost.gameObject.transform.position = targetPivotPos + targetPivotRot * activeGhost.relPos; activeGhost.gameObject.transform.rotation = targetPivotRot * activeGhost.relRot; } } } } public class TerrainPoint { public float relX; public float relZ; public float levelDelta; public float smoothDelta; public Color paintMask; public bool modifiedHeight; public bool modifiedPaint; public float oldBaseHeight; } public class MovingDayTerrain { private static T GetField(object obj, string name) { if (obj == null) { return default(T); } FieldInfo field = obj.GetType().GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); return (field != null) ? ((T)field.GetValue(obj)) : default(T); } private static void CallMethod(object obj, string name, params object[] args) { if (obj != null) { MethodInfo method = obj.GetType().GetMethod(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { method.Invoke(obj, args); } else { Debug.LogWarning((object)("[MovingDay] CallMethod: method '" + name + "' not found on " + obj.GetType().Name)); } } } private static bool GetWorldBaseHeightReflection(Heightmap hmap, Vector3 pos, out float height) { //IL_001d: 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_00ab: Unknown result type (might be due to invalid IL or missing references) height = pos.y; Heightmap val = hmap; if ((Object)(object)val == (Object)null) { val = Heightmap.FindHeightmap(pos); } if ((Object)(object)val == (Object)null) { return false; } MethodInfo method = typeof(Heightmap).GetMethod("GetWorldBaseHeight", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { object[] array = new object[2] { pos, 0f }; bool flag = (bool)method.Invoke(val, array); height = (float)array[1]; if (!flag) { Heightmap val2 = Heightmap.FindHeightmap(pos); if ((Object)(object)val2 != (Object)null && (Object)(object)val2 != (Object)(object)val) { flag = (bool)method.Invoke(val2, array); height = (float)array[1]; } } return flag; } return false; } public static float GetBaseHeight(Vector3 pos) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) float height = pos.y; if (GetWorldBaseHeightReflection(null, pos, out height)) { return height; } return pos.y; } public static TerrainComp GetOrCreateTerrainComp(Vector3 pos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_008a: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) TerrainComp val = TerrainComp.FindTerrainCompiler(pos); if ((Object)(object)val != (Object)null) { return val; } Heightmap val2 = Heightmap.FindHeightmap(pos); if ((Object)(object)val2 == (Object)null) { Debug.LogWarning((object)("[MovingDay] GetOrCreateTerrainComp: heightmap not found at " + pos)); return null; } MethodInfo method = typeof(Heightmap).GetMethod("GetAndCreateTerrainCompiler", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { val = (TerrainComp)method.Invoke(val2, null); Debug.Log((object)string.Concat("[MovingDay] Created new TerrainComp for zone at ", pos, ": ", ((Object)(object)val != (Object)null) ? ((Object)val).name : "null")); return val; } Debug.LogWarning((object)"[MovingDay] GetOrCreateTerrainComp: GetAndCreateTerrainCompiler reflection failed!"); return null; } public static TerrainComp GetOrCreateCompilerForHeightmap(Heightmap hmap) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown if ((Object)(object)hmap == (Object)null) { return null; } MethodInfo method = typeof(Heightmap).GetMethod("GetAndCreateTerrainCompiler", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { return (TerrainComp)method.Invoke(hmap, null); } return null; } public static List CaptureTerrain(Vector3 pivotPos, float radius, List piecePositions) { //IL_0022: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_0130: 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_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) List list = new List(); int num = Mathf.CeilToInt(radius); Debug.Log((object)string.Concat("[MovingDay] CaptureTerrain: pivot=", pivotPos, " radius=", radius)); HashSet hashSet = new HashSet(); float num2 = 0.5f; if (piecePositions == null) { piecePositions = new List(); } int num7 = default(int); int num8 = default(int); for (float num3 = -num; num3 <= (float)num; num3 += num2) { for (float num4 = -num; num4 <= (float)num; num4 += num2) { if (num3 * num3 + num4 * num4 > radius * radius) { continue; } Vector3 val = pivotPos + new Vector3(num3, 0f, num4); bool flag = false; foreach (Vector3 piecePosition in piecePositions) { float num5 = piecePosition.x - val.x; float num6 = piecePosition.z - val.z; if (num5 * num5 + num6 * num6 < 6.25f) { flag = true; break; } } TerrainComp orCreateTerrainComp = GetOrCreateTerrainComp(val); if ((Object)(object)orCreateTerrainComp == (Object)null) { continue; } Heightmap field = GetField(orCreateTerrainComp, "m_hmap"); if ((Object)(object)field == (Object)null) { continue; } field.WorldToVertex(val, ref num7, ref num8); int field2 = GetField(orCreateTerrainComp, "m_width"); int num9 = field2 + 1; if (num7 < 0 || num7 > field2 || num8 < 0 || num8 > field2) { continue; } int num10 = num8 * num9 + num7; long item = (long)((Object)orCreateTerrainComp).GetInstanceID() * 100000L + num10; if (!hashSet.Contains(item)) { hashSet.Add(item); bool[] field3 = GetField(orCreateTerrainComp, "m_modifiedHeight"); bool[] field4 = GetField(orCreateTerrainComp, "m_modifiedPaint"); bool flag2 = field3 != null && num10 < field3.Length && field3[num10]; bool flag3 = field4 != null && num10 < field4.Length && field4[num10]; if (flag2 || flag3 || flag) { float[] field5 = GetField(orCreateTerrainComp, "m_levelDelta"); float[] field6 = GetField(orCreateTerrainComp, "m_smoothDelta"); Color[] field7 = GetField(orCreateTerrainComp, "m_paintMask"); float height = 0f; GetWorldBaseHeightReflection(field, val, out height); TerrainPoint terrainPoint = new TerrainPoint(); terrainPoint.relX = num3; terrainPoint.relZ = num4; terrainPoint.levelDelta = ((field5 != null && num10 < field5.Length) ? field5[num10] : 0f); terrainPoint.smoothDelta = ((field6 != null && num10 < field6.Length) ? field6[num10] : 0f); terrainPoint.paintMask = ((field7 != null && num10 < field7.Length) ? field7[num10] : Color.clear); terrainPoint.modifiedHeight = flag2 || flag; terrainPoint.modifiedPaint = flag3; terrainPoint.oldBaseHeight = height; list.Add(terrainPoint); } } } } Debug.Log((object)("[MovingDay] Captured " + list.Count + " modified/footprint terrain vertices.")); return list; } public static void ApplyTerrain(Vector3 oldPivotPos, Vector3 targetPivotPos, float yawRad, List snapshot, ref HashSet affectedComps) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) if (snapshot == null || snapshot.Count == 0) { return; } float num = Mathf.Cos(yawRad); float num2 = Mathf.Sin(yawRad); Debug.Log((object)string.Concat("[MovingDay] ApplyTerrain: oldPivot=", oldPivotPos, " targetPivot=", targetPivotPos, " yawRad=", yawRad, " snapshotCount=", snapshot.Count)); int num3 = 0; List list = new List(); foreach (TerrainPoint item in snapshot) { float num4 = item.relX * num + item.relZ * num2; float num5 = (0f - item.relX) * num2 + item.relZ * num; Vector3 val = targetPivotPos + new Vector3(num4, 0f, num5); list.Clear(); Heightmap.FindHeightmap(val, 0.1f, list); foreach (Heightmap item2 in list) { if ((Object)(object)item2 == (Object)null) { continue; } TerrainComp orCreateCompilerForHeightmap = GetOrCreateCompilerForHeightmap(item2); if ((Object)(object)orCreateCompilerForHeightmap == (Object)null) { continue; } affectedComps.Add(orCreateCompilerForHeightmap); int num6 = 0; int num7 = 0; item2.WorldToVertex(val, ref num6, ref num7); int field = GetField(orCreateCompilerForHeightmap, "m_width"); int num8 = field + 1; if (num6 < 0 || num6 > field || num7 < 0 || num7 > field) { continue; } int num9 = num7 * num8 + num6; float num10 = item.oldBaseHeight + item.levelDelta + item.smoothDelta; float num11 = num10 - oldPivotPos.y; float num12 = targetPivotPos.y + num11; float height = 0f; GetWorldBaseHeightReflection(item2, val, out height); float num13 = num12 - height; num13 = Mathf.Clamp(num13, -8f, 8f); float[] field2 = GetField(orCreateCompilerForHeightmap, "m_levelDelta"); float[] field3 = GetField(orCreateCompilerForHeightmap, "m_smoothDelta"); bool[] field4 = GetField(orCreateCompilerForHeightmap, "m_modifiedHeight"); if (item.modifiedHeight) { if (field2 != null && num9 < field2.Length) { field2[num9] = num13; } if (field3 != null && num9 < field3.Length) { field3[num9] = 0f; } if (field4 != null && num9 < field4.Length) { field4[num9] = true; } } if (item.modifiedPaint) { Color[] field5 = GetField(orCreateCompilerForHeightmap, "m_paintMask"); bool[] field6 = GetField(orCreateCompilerForHeightmap, "m_modifiedPaint"); if (field5 != null && num9 < field5.Length) { ref Color reference = ref field5[num9]; reference = item.paintMask; } if (field6 != null && num9 < field6.Length) { field6[num9] = true; } } num3++; } } Debug.Log((object)("[MovingDay] ApplyTerrain applied " + num3 + " vertices to destination (including overlaps).")); } public static void ClearTerrain(Vector3 oldPivotPos, List snapshot, ref HashSet affectedComps) { //IL_003e: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) if (snapshot == null || snapshot.Count == 0) { return; } int num = 0; List list = new List(); foreach (TerrainPoint item in snapshot) { Vector3 val = oldPivotPos + new Vector3(item.relX, 0f, item.relZ); list.Clear(); Heightmap.FindHeightmap(val, 0.1f, list); foreach (Heightmap item2 in list) { if ((Object)(object)item2 == (Object)null) { continue; } TerrainComp orCreateCompilerForHeightmap = GetOrCreateCompilerForHeightmap(item2); if ((Object)(object)orCreateCompilerForHeightmap == (Object)null) { continue; } affectedComps.Add(orCreateCompilerForHeightmap); int num2 = 0; int num3 = 0; item2.WorldToVertex(val, ref num2, ref num3); int field = GetField(orCreateCompilerForHeightmap, "m_width"); int num4 = field + 1; if (num2 < 0 || num2 > field || num3 < 0 || num3 > field) { continue; } int num5 = num3 * num4 + num2; if (item.modifiedHeight) { float[] field2 = GetField(orCreateCompilerForHeightmap, "m_levelDelta"); float[] field3 = GetField(orCreateCompilerForHeightmap, "m_smoothDelta"); bool[] field4 = GetField(orCreateCompilerForHeightmap, "m_modifiedHeight"); if (field2 != null && num5 < field2.Length) { field2[num5] = 0f; } if (field3 != null && num5 < field3.Length) { field3[num5] = 0f; } if (field4 != null && num5 < field4.Length) { field4[num5] = false; } } if (item.modifiedPaint) { Color[] field5 = GetField(orCreateCompilerForHeightmap, "m_paintMask"); bool[] field6 = GetField(orCreateCompilerForHeightmap, "m_modifiedPaint"); if (field5 != null && num5 < field5.Length) { ref Color reference = ref field5[num5]; reference = Color.clear; } if (field6 != null && num5 < field6.Length) { field6[num5] = false; } } num++; } } Debug.Log((object)("[MovingDay] Reverted " + num + " terrain vertices at source location (including overlaps).")); } private static void SetField(object obj, string name, object val) { if (obj != null) { FieldInfo field = obj.GetType().GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { field.SetValue(obj, val); } } } private static void ForceSaveTerrainComp(TerrainComp tc) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) ZNetView field = GetField(tc, "m_nview"); if ((Object)(object)field == (Object)null || !field.IsValid()) { return; } ZDO zDO = field.GetZDO(); if (zDO == null) { return; } try { if (zDO.GetOwner() != ZDOMan.GetSessionID()) { zDO.SetOwner(ZDOMan.GetSessionID()); } ZPackage val = new ZPackage(); val.Write(1); val.Write(GetField(tc, "m_operations")); val.Write(GetField(tc, "m_lastOpPoint")); val.Write(GetField(tc, "m_lastOpRadius")); bool[] field2 = GetField(tc, "m_modifiedHeight"); float[] field3 = GetField(tc, "m_levelDelta"); float[] field4 = GetField(tc, "m_smoothDelta"); if (field2 != null) { val.Write(field2.Length); for (int i = 0; i < field2.Length; i++) { val.Write(field2[i]); if (field2[i]) { val.Write((field3 != null && i < field3.Length) ? field3[i] : 0f); val.Write((field4 != null && i < field4.Length) ? field4[i] : 0f); } } } else { val.Write(0); } bool[] field5 = GetField(tc, "m_modifiedPaint"); Color[] field6 = GetField(tc, "m_paintMask"); if (field5 != null) { val.Write(field5.Length); for (int i = 0; i < field5.Length; i++) { val.Write(field5[i]); if (field5[i]) { Color val2 = ((field6 != null && i < field6.Length) ? field6[i] : Color.clear); val.Write(val2.r); val.Write(val2.g); val.Write(val2.b); val.Write(val2.a); } } } else { val.Write(0); } byte[] array = val.GetArray(); byte[] array2 = Utils.Compress(array); FieldInfo field7 = typeof(ZDOVars).GetField("s_TCData", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); int num = ((field7 != null) ? ((int)field7.GetValue(null)) : StringExtensionMethods.GetStableHashCode("TCData")); zDO.Set(num, array2); uint dataRevision = zDO.DataRevision; SetField(tc, "m_lastDataRevision", dataRevision); Debug.Log((object)("[MovingDay] Force-saved TerrainComp " + ((Object)tc).name + " to ZDO directly. Revision=" + dataRevision)); } catch (Exception ex) { Debug.LogError((object)("[MovingDay] Error in ForceSaveTerrainComp: " + ex.Message)); } } public static void RebuildTerrain(HashSet affectedComps) { if (affectedComps == null || affectedComps.Count == 0) { return; } foreach (TerrainComp affectedComp in affectedComps) { if ((Object)(object)affectedComp == (Object)null) { continue; } try { ZNetView field = GetField(affectedComp, "m_nview"); if ((Object)(object)field != (Object)null && field.IsValid() && !field.IsOwner()) { field.ClaimOwnership(); } Heightmap field2 = GetField(affectedComp, "m_hmap"); if ((Object)(object)field2 != (Object)null) { field2.Regenerate(); field2.Poke(true); } CallMethod(affectedComp, "Save"); uint field3 = GetField(affectedComp, "m_lastDataRevision"); uint num = 0u; if ((Object)(object)field != (Object)null && field.IsValid()) { ZDO zDO = field.GetZDO(); if (zDO != null) { num = zDO.DataRevision; } } if (field3 != num) { ForceSaveTerrainComp(affectedComp); } Debug.Log((object)("[MovingDay] Rebuilt and saved terrain zone: " + ((Object)affectedComp).name)); } catch (Exception ex) { Debug.LogError((object)("[MovingDay] Error rebuilding terrain zone: " + ex.Message)); } } } }