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; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace MovingDay; [BepInPlugin("com.drakosdj.movingday", "MovingDay", "1.0.1")] public class MovingDayPlugin : BaseUnityPlugin { [HarmonyPatch(typeof(Player), "UpdatePlacement")] public static class Player_UpdatePlacement_Patch { public static bool Prefix(Player __instance, bool takeInput) { if (m_inMoveMode) { if (takeInput) { UpdateMoveMode(__instance); } 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 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 Piece m_pivotPiece = null; 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 MovingDayPlugin instance; 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_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Expected O, but got Unknown instance = this; configSelectHotkey = ((BaseUnityPlugin)this).Config.Bind("Controls", "SelectHotkey", "G", "Hotkey to select/deselect a hovered piece."); configSelectConnectedHotkey = ((BaseUnityPlugin)this).Config.Bind("Controls", "SelectConnectedHotkey", "H", "Hotkey to select all connected pieces of a structure."); configMoveHotkey = ((BaseUnityPlugin)this).Config.Bind("Controls", "MoveHotkey", "L", "Hotkey to enter Move Mode once pieces are selected."); configModifierKey = ((BaseUnityPlugin)this).Config.Bind("Controls", "TerrainModifierKey", "LeftControl", "Modifier key held during placement to copy and revert terrain modifications. Options: LeftControl, RightControl, LeftShift, RightShift, LeftAlt, RightAlt, None."); 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"); Harmony val = new Harmony("com.drakosdj.movingday"); val.PatchAll(); Debug.Log((object)"[MovingDay] Standalone plugin loaded successfully!"); } private void Update() { PruneRecentlyMoved(); if ((Object)(object)Player.m_localPlayer == (Object)null) { if (m_inMoveMode) { CancelMove(); } MovingDaySelection.ClearSelection(); } else if (!IsHoldingBuildTool(Player.m_localPlayer)) { if (m_inMoveMode) { CancelMove(); } MovingDaySelection.ClearSelection(); } else if (!m_inMoveMode) { HandleSelectionInput(Player.m_localPlayer); } } private static bool IsHoldingBuildTool(Player player) { ItemData rightItem = GetRightItem(player); return rightItem != null && (Object)(object)rightItem.m_shared.m_buildPieces != (Object)null; } private void HandleSelectionInput(Player player) { //IL_0020: 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_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Unknown result type (might be due to invalid IL or missing references) Piece hoveringPiece; if (Enum.TryParse(configSelectHotkey.Value, ignoreCase: true, out KeyCode result) && Input.GetKeyDown(result)) { 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 { ((Character)player).Message((MessageType)2, "No piece hovered to select.", 0, (Sprite)null); } } if (Enum.TryParse(configSelectConnectedHotkey.Value, ignoreCase: true, out KeyCode result2) && Input.GetKeyDown(result2)) { 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 { ((Character)player).Message((MessageType)2, "No piece hovered to select structure.", 0, (Sprite)null); } } if (!Enum.TryParse(configMoveHotkey.Value, ignoreCase: true, out KeyCode result3) || !Input.GetKeyDown(result3)) { 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; } float num = 5f; foreach (Piece selectedPiece2 in MovingDaySelection.m_selectedPieces) { if ((Object)(object)selectedPiece2 != (Object)null) { float num2 = Vector3.Distance(((Component)m_pivotPiece).transform.position, ((Component)selectedPiece2).transform.position); if (num2 > num) { num = num2; } } } m_maxSelectedDistance = num + configTerrainRadiusBuffer.Value; m_inMoveMode = true; m_targetYaw = 0f; m_lastCopyTerrainState = false; float baseHeight = MovingDayTerrain.GetBaseHeight(((Component)m_pivotPiece).transform.position); m_sourceHeightOffset = ((Component)m_pivotPiece).transform.position.y - baseHeight; float num3 = baseHeight; if ((Object)(object)ZoneSystem.instance != (Object)null) { num3 = ZoneSystem.instance.GetGroundHeight(((Component)m_pivotPiece).transform.position); } m_sourceHeightOffsetActual = ((Component)m_pivotPiece).transform.position.y - num3; Debug.Log((object)("[MovingDay] Calculated sourceHeightOffsets: pivotY=" + ((Component)m_pivotPiece).transform.position.y + " baseHeight=" + baseHeight + " actualHeight=" + num3 + " baseOffset=" + m_sourceHeightOffset + " actualOffset=" + m_sourceHeightOffsetActual)); 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_0041: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) 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 val3; if (Physics.Raycast(val, ref val2, 50f, mask)) { val3 = ((RaycastHit)(ref val2)).point; text = (((Object)(object)((RaycastHit)(ref val2)).collider != (Object)null) ? ((Object)((RaycastHit)(ref val2)).collider).name : "NullCollider"); } else { val3 = ((Component)player).transform.position + ((Component)player).transform.forward * 5f; } float y = val3.y; if (IsModifierPressed()) { float baseHeight = MovingDayTerrain.GetBaseHeight(val3); val3.y = baseHeight + m_sourceHeightOffset; } else { val3.y = y + m_sourceHeightOffsetActual; } float axis = Input.GetAxis("Mouse ScrollWheel"); if (axis > 0f) { m_targetYaw += 22.5f; } else if (axis < 0f) { m_targetYaw -= 22.5f; } float y2 = ((Component)player).transform.eulerAngles.y; float num = Mathf.Round(y2 / 22.5f) * 22.5f; Quaternion val4 = Quaternion.Euler(0f, num + m_targetYaw, 0f); MovingDayGhost.UpdateGhosts(val3, val4); ((Character)player).Message((MessageType)2, "BaseOffset: " + m_sourceHeightOffset.ToString("F1") + " | ActOffset: " + m_sourceHeightOffsetActual.ToString("F1") + " | Hit: " + text + " | RawY: " + y.ToString("F1") + " | FinalY: " + val3.y.ToString("F1"), 0, (Sprite)null); bool flag = IsModifierPressed(); if (flag != m_lastCopyTerrainState) { m_lastCopyTerrainState = flag; if (flag) { ((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 (Input.GetMouseButtonDown(0)) { ConfirmMove(player, val3, val4); } else if (Input.GetMouseButtonDown(1) || Input.GetKeyDown((KeyCode)27)) { CancelMove(); ((Character)player).Message((MessageType)2, "Move canceled.", 0, (Sprite)null); } } private static void ConfirmMove(Player player, Vector3 targetPos, Quaternion targetRot) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0759: Unknown result type (might be due to invalid IL or missing references) //IL_076d: 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_0782: Unknown result type (might be due to invalid IL or missing references) //IL_078f: Unknown result type (might be due to invalid IL or missing references) //IL_07bc: Unknown result type (might be due to invalid IL or missing references) //IL_07cd: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0c0e: Unknown result type (might be due to invalid IL or missing references) //IL_0c0f: Unknown result type (might be due to invalid IL or missing references) //IL_0c1b: Unknown result type (might be due to invalid IL or missing references) //IL_0c20: Unknown result type (might be due to invalid IL or missing references) //IL_0c21: Unknown result type (might be due to invalid IL or missing references) //IL_0c26: Unknown result type (might be due to invalid IL or missing references) //IL_0c2b: Unknown result type (might be due to invalid IL or missing references) //IL_0c2d: Unknown result type (might be due to invalid IL or missing references) //IL_0c2e: Unknown result type (might be due to invalid IL or missing references) //IL_0c2f: Unknown result type (might be due to invalid IL or missing references) //IL_0c31: Unknown result type (might be due to invalid IL or missing references) //IL_0c36: Unknown result type (might be due to invalid IL or missing references) //IL_0c3b: Unknown result type (might be due to invalid IL or missing references) //IL_0c44: Unknown result type (might be due to invalid IL or missing references) //IL_0c49: Unknown result type (might be due to invalid IL or missing references) //IL_0c4d: Unknown result type (might be due to invalid IL or missing references) //IL_0c52: Unknown result type (might be due to invalid IL or missing references) //IL_0c56: Unknown result type (might be due to invalid IL or missing references) //IL_0c91: Unknown result type (might be due to invalid IL or missing references) //IL_0c96: 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_0cdf: Unknown result type (might be due to invalid IL or missing references) //IL_0cf3: Unknown result type (might be due to invalid IL or missing references) //IL_0d0a: Unknown result type (might be due to invalid IL or missing references) //IL_0d29: Unknown result type (might be due to invalid IL or missing references) //IL_0d38: Unknown result type (might be due to invalid IL or missing references) //IL_0887: Unknown result type (might be due to invalid IL or missing references) //IL_088c: Unknown result type (might be due to invalid IL or missing references) //IL_0893: Unknown result type (might be due to invalid IL or missing references) //IL_0d87: Unknown result type (might be due to invalid IL or missing references) //IL_0d91: Unknown result type (might be due to invalid IL or missing references) //IL_0940: Unknown result type (might be due to invalid IL or missing references) //IL_0942: Unknown result type (might be due to invalid IL or missing references) //IL_0ae6: Unknown result type (might be due to invalid IL or missing references) //IL_114a: Unknown result type (might be due to invalid IL or missing references) //IL_114b: Unknown result type (might be due to invalid IL or missing references) //IL_115a: Unknown result type (might be due to invalid IL or missing references) //IL_115f: Unknown result type (might be due to invalid IL or missing references) //IL_1160: Unknown result type (might be due to invalid IL or missing references) //IL_1165: Unknown result type (might be due to invalid IL or missing references) //IL_116a: Unknown result type (might be due to invalid IL or missing references) //IL_116c: Unknown result type (might be due to invalid IL or missing references) //IL_116d: Unknown result type (might be due to invalid IL or missing references) //IL_116e: Unknown result type (might be due to invalid IL or missing references) //IL_1170: Unknown result type (might be due to invalid IL or missing references) //IL_1175: Unknown result type (might be due to invalid IL or missing references) //IL_117a: Unknown result type (might be due to invalid IL or missing references) //IL_1186: Unknown result type (might be due to invalid IL or missing references) //IL_118b: Unknown result type (might be due to invalid IL or missing references) //IL_118f: Unknown result type (might be due to invalid IL or missing references) //IL_1194: Unknown result type (might be due to invalid IL or missing references) //IL_1198: Unknown result type (might be due to invalid IL or missing references) //IL_11be: Unknown result type (might be due to invalid IL or missing references) //IL_11c3: Unknown result type (might be due to invalid IL or missing references) //IL_11ca: Unknown result type (might be due to invalid IL or missing references) //IL_11cc: Unknown result type (might be due to invalid IL or missing references) //IL_0f6d: Unknown result type (might be due to invalid IL or missing references) //IL_0f6e: Unknown result type (might be due to invalid IL or missing references) //IL_0f7a: Unknown result type (might be due to invalid IL or missing references) //IL_0f7f: Unknown result type (might be due to invalid IL or missing references) //IL_0f80: Unknown result type (might be due to invalid IL or missing references) //IL_0f85: Unknown result type (might be due to invalid IL or missing references) //IL_0f8a: Unknown result type (might be due to invalid IL or missing references) //IL_0f8c: Unknown result type (might be due to invalid IL or missing references) //IL_0f8d: Unknown result type (might be due to invalid IL or missing references) //IL_0f8e: Unknown result type (might be due to invalid IL or missing references) //IL_0f90: Unknown result type (might be due to invalid IL or missing references) //IL_0f95: Unknown result type (might be due to invalid IL or missing references) //IL_0f9a: Unknown result type (might be due to invalid IL or missing references) //IL_0fa3: Unknown result type (might be due to invalid IL or missing references) //IL_0fa8: Unknown result type (might be due to invalid IL or missing references) //IL_0fac: Unknown result type (might be due to invalid IL or missing references) //IL_0fb1: Unknown result type (might be due to invalid IL or missing references) //IL_0fb5: Unknown result type (might be due to invalid IL or missing references) //IL_0fdb: Unknown result type (might be due to invalid IL or missing references) //IL_0fe0: Unknown result type (might be due to invalid IL or missing references) //IL_1011: Unknown result type (might be due to invalid IL or missing references) //IL_1028: Unknown result type (might be due to invalid IL or missing references) //IL_120c: Unknown result type (might be due to invalid IL or missing references) //IL_1211: Unknown result type (might be due to invalid IL or missing references) //IL_1218: Unknown result type (might be due to invalid IL or missing references) //IL_1295: Unknown result type (might be due to invalid IL or missing references) //IL_129e: Unknown result type (might be due to invalid IL or missing references) //IL_10ac: Unknown result type (might be due to invalid IL or missing references) //IL_10bb: Unknown result type (might be due to invalid IL or missing references) //IL_10e0: Unknown result type (might be due to invalid IL or missing references) //IL_10ea: Unknown result type (might be due to invalid IL or missing references) //IL_10f4: Unknown result type (might be due to invalid IL or missing references) //IL_1101: Unknown result type (might be due to invalid IL or missing references) //IL_1084: Unknown result type (might be due to invalid IL or missing references) //IL_108e: Unknown result type (might be due to invalid IL or missing references) //IL_1363: Unknown result type (might be due to invalid IL or missing references) //IL_1364: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)m_pivotPiece).transform.position; Quaternion rotation = ((Component)m_pivotPiece).transform.rotation; float y = ((Quaternion)(ref rotation)).eulerAngles.y; Quaternion val = Quaternion.Euler(0f, y, 0f); Debug.Log((object)string.Concat("[MovingDay Debug] ConfirmMove triggered! piecesCount=", MovingDaySelection.m_selectedPieces.Count, " oldPivotPos=", position, " 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; Piece val2 = null; foreach (Piece selectedPiece in MovingDaySelection.m_selectedPieces) { if ((Object)(object)selectedPiece != (Object)null) { float num2 = Vector3.Distance(((Component)item).transform.position, ((Component)selectedPiece).transform.position); if (num2 < num) { num = num2; val2 = selectedPiece; } } } string text = (((Object)(object)val2 != (Object)null) ? ((Object)val2).name : "None"); Debug.Log((object)string.Concat("[MovingDay Debug] Character '", ((Object)item).name, "' at ", ((Component)item).transform.position, " | isTamed=", flag, " | closestPiece=", text, " | distance=", ((Object)(object)val2 != (Object)null) ? num.ToString("F1") : "N/A")); 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 (Piece selectedPiece2 in MovingDaySelection.m_selectedPieces) { if ((Object)(object)selectedPiece2 != (Object)null && Vector3.Distance(((Component)item2).transform.position, ((Component)selectedPiece2).transform.position) < 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); } } 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); Debug.LogWarning((object)"[MovingDay Debug] Move aborted: A container is in use."); return; } if (ContainerHasNonTeleportable(component)) { string value3 = configContainerMetalAction.Value; if (value3.Equals("Block", StringComparison.OrdinalIgnoreCase)) { ((Character)player).Message((MessageType)2, "Cannot move: Chest contains non-teleportable items.", 0, (Sprite)null); Debug.LogWarning((object)"[MovingDay Debug] Move aborted: Chest contains metal and ContainerMetalAction=Block."); return; } } } bool flag4 = IsModifierPressed(); Debug.Log((object)("[MovingDay Debug] Modifier Key Check: copyTerrain=" + flag4 + " (Config=" + configModifierKey.Value + " LeftCtrl=" + Input.GetKey((KeyCode)306) + " RightCtrl=" + Input.GetKey((KeyCode)305) + ")")); List list4 = null; HashSet affectedComps = new HashSet(); if (flag4) { ((Character)player).Message((MessageType)2, "Processing terrain updates...", 0, (Sprite)null); list4 = MovingDayTerrain.CaptureTerrain(position, m_maxSelectedDistance, MovingDaySelection.m_selectedPieces); float yawRad = (((Quaternion)(ref targetRot)).eulerAngles.y - y) * ((float)Math.PI / 180f); MovingDayTerrain.ApplyTerrain(position, targetPos, yawRad, list4, ref affectedComps); MovingDayTerrain.ClearTerrain(position, list4, ref affectedComps); MovingDayTerrain.RebuildTerrain(affectedComps); if ((Object)(object)ClutterSystem.instance != (Object)null) { ClutterSystem.instance.ResetGrass(position, m_maxSelectedDistance); ClutterSystem.instance.ResetGrass(targetPos, m_maxSelectedDistance); } } if (configContainerMetalAction.Value.Equals("Drop", StringComparison.OrdinalIgnoreCase)) { Vector3 val3 = 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) { Vector3 position2 = ((Component)selectedPiece4).transform.position; float groundHeight = ZoneSystem.instance.GetGroundHeight(position2); Inventory inventory = component.GetInventory(); List list5 = new List(); foreach (ItemData allItem in inventory.GetAllItems()) { if (allItem != null && !allItem.m_shared.m_teleportable) { list5.Add(allItem); } } int num3 = 0; while (list5.Count > 0 && num3 < 10) { ((Vector3)(ref val3))..ctor(position2.x, groundHeight + 0.5f + (float)num3 * 0.4f, position2.z); GameObject val4 = Object.Instantiate(prefab, val3, Quaternion.identity); Container component2 = val4.GetComponent(); if ((Object)(object)component2 == (Object)null) { Object.Destroy((Object)(object)val4); break; } Inventory inventory2 = component2.GetInventory(); List list6 = new List(); foreach (ItemData item3 in list5) { int stack = item3.m_stack; inventory2.MoveItemToThis(inventory, item3); if (!inventory.ContainsItem(item3) || item3.m_stack < stack) { list6.Add(item3); } } SaveContainer(component2); num3++; list5.Clear(); foreach (ItemData allItem2 in inventory.GetAllItems()) { if (allItem2 != null && !allItem2.m_shared.m_teleportable) { list5.Add(allItem2); } } if (list6.Count == 0) { Debug.LogWarning((object)"[MovingDay Debug] Could not move any more items to CargoCrate. Breaking loop."); break; } } SaveContainer(component); Debug.Log((object)("[MovingDay Debug] Spawned " + num3 + " CargoCrate(s) and dropped all non-teleportable items from chest at " + position2)); } else { Debug.LogWarning((object)"[MovingDay Debug] CargoCrate prefab not found in ZNetScene!"); } } } ((Character)player).Message((MessageType)2, "Moving structure...", 0, (Sprite)null); Debug.Log((object)"[MovingDay Debug] Relocating GameObjects..."); List list7 = new List(); foreach (Piece selectedPiece5 in MovingDaySelection.m_selectedPieces) { if (!((Object)(object)selectedPiece5 == (Object)null)) { WearNTear component3 = ((Component)selectedPiece5).GetComponent(); if ((Object)(object)component3 != (Object)null && ((Behaviour)component3).enabled) { ((Behaviour)component3).enabled = false; list7.Add(component3); } } } int num4 = 0; foreach (Piece selectedPiece6 in MovingDaySelection.m_selectedPieces) { if ((Object)(object)selectedPiece6 == (Object)null) { continue; } Vector3 val5 = Quaternion.Inverse(val) * (((Component)selectedPiece6).transform.position - position); Vector3 val6 = targetPos + targetRot * val5; rotation = ((Component)selectedPiece6).transform.rotation; Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles; float num5 = ((Quaternion)(ref targetRot)).eulerAngles.y - y; float num6 = Mathf.Round((eulerAngles.y + num5) / 22.5f) * 22.5f; Quaternion rotation2 = Quaternion.Euler(eulerAngles.x, num6, eulerAngles.z); Debug.Log((object)string.Concat("[MovingDay Debug] Relocating piece '", ((Object)selectedPiece6).name, "' from pos=", ((Component)selectedPiece6).transform.position, " rot=", eulerAngles, " to pos=", val6, " rot=", ((Quaternion)(ref rotation2)).eulerAngles)); ((Component)selectedPiece6).transform.position = val6; ((Component)selectedPiece6).transform.rotation = rotation2; ZNetView component4 = ((Component)selectedPiece6).GetComponent(); if ((Object)(object)component4 != (Object)null && component4.IsValid()) { component4.ClaimOwnership(); ZDO zDO = component4.GetZDO(); if (zDO != null) { zDO.SetPosition(val6); zDO.SetRotation(rotation2); ZDOMan.instance.ZDOSectorInvalidated(zDO); } } num4++; } Debug.Log((object)("[MovingDay Debug] Relocated " + num4 + " GameObjects. Syncing transforms...")); Physics.SyncTransforms(); foreach (WearNTear item4 in list7) { ResetPieceStabilityCache(item4); } float value4 = Time.time + 5f; foreach (WearNTear item5 in list7) { if ((Object)(object)item5 != (Object)null) { m_recentlyMovedPieces[item5] = value4; } } if ((Object)(object)instance != (Object)null) { ((MonoBehaviour)instance).StartCoroutine(ReenableStabilityDelay(list7)); } else { Debug.LogWarning((object)"[MovingDay Debug] instance is null! Fallback to instant stability re-enable."); foreach (WearNTear item6 in list7) { if ((Object)(object)item6 != (Object)null) { item6.OnPlaced(); ((Behaviour)item6).enabled = true; } } } if (configMoveTamed.Value) { foreach (Character item7 in list3) { if ((Object)(object)item7 == (Object)null) { continue; } Vector3 val5 = Quaternion.Inverse(val) * (((Component)item7).transform.position - position); Vector3 val7 = targetPos + targetRot * val5; rotation = ((Component)item7).transform.rotation; Vector3 eulerAngles2 = ((Quaternion)(ref rotation)).eulerAngles; float num5 = ((Quaternion)(ref targetRot)).eulerAngles.y - y; Quaternion rotation3 = Quaternion.Euler(eulerAngles2.x, eulerAngles2.y + num5, eulerAngles2.z); Debug.Log((object)string.Concat("[MovingDay Debug] Teleporting tamed animal '", ((Object)item7).name, "' from ", ((Component)item7).transform.position, " to ", val7)); ZNetView component4 = ((Component)item7).GetComponent(); if ((Object)(object)component4 != (Object)null && component4.IsValid()) { component4.ClaimOwnership(); ZDO zDO = component4.GetZDO(); if (zDO != null) { zDO.SetPosition(val7); zDO.SetRotation(rotation3); ZDOMan.instance.ZDOSectorInvalidated(zDO); } } ((Component)item7).transform.position = val7; ((Component)item7).transform.rotation = rotation3; Rigidbody component5 = ((Component)item7).GetComponent(); if ((Object)(object)component5 != (Object)null) { component5.position = val7; component5.rotation = rotation3; component5.velocity = Vector3.zero; component5.angularVelocity = Vector3.zero; } } } if (list.Contains(Player.m_localPlayer)) { Vector3 val8 = Quaternion.Inverse(val) * (((Component)Player.m_localPlayer).transform.position - position); Vector3 val9 = targetPos + targetRot * val8; rotation = ((Component)Player.m_localPlayer).transform.rotation; Vector3 eulerAngles3 = ((Quaternion)(ref rotation)).eulerAngles; float num5 = ((Quaternion)(ref targetRot)).eulerAngles.y - y; Quaternion val10 = Quaternion.Euler(eulerAngles3.x, eulerAngles3.y + num5, eulerAngles3.z); ((Character)Player.m_localPlayer).TeleportTo(val9, val10, true); } Vector3 val11 = default(Vector3); foreach (Player item8 in list2) { if (!((Object)(object)item8 == (Object)null)) { Vector3 position3 = ((Component)item8).transform.position; float groundHeight = ZoneSystem.instance.GetGroundHeight(position3); if (position3.y > groundHeight + 0.1f) { ((Character)item8).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("Featherfall"), true, 1, 0f); Debug.Log((object)("[MovingDay Debug] Applied Featherfall status effect to player " + item8.GetPlayerName())); continue; } ((Vector3)(ref val11))..ctor(position3.x, groundHeight + 0.5f, position3.z); ((Character)item8).TeleportTo(val11, ((Component)item8).transform.rotation, true); Debug.Log((object)("[MovingDay Debug] Snapped player " + item8.GetPlayerName() + " to restored ground Y: " + (groundHeight + 0.5f))); } } GameObject prefab2 = ZNetScene.instance.GetPrefab("portal_wood"); if ((Object)(object)prefab2 != (Object)null) { TeleportWorld component6 = prefab2.GetComponent(); if ((Object)(object)component6 != (Object)null && component6.m_connected != null) { component6.m_connected.Create(targetPos, Quaternion.identity, (Transform)null, 1f, -1); } } MovingDayGhost.ClearGhosts(); MovingDaySelection.ClearSelection(); m_inMoveMode = false; m_sourceHeightOffset = 0f; m_sourceHeightOffsetActual = 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 void CancelMove() { MovingDayGhost.ClearGhosts(); m_inMoveMode = false; m_sourceHeightOffset = 0f; m_sourceHeightOffsetActual = 0f; } private static bool IsModifierPressed() { //IL_0174: Unknown result type (might be due to invalid IL or missing references) if (configModifierKey == null || string.IsNullOrEmpty(configModifierKey.Value)) { return Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305); } string text = configModifierKey.Value.Trim(); if (text.Equals("None", StringComparison.OrdinalIgnoreCase)) { return !Input.GetKey((KeyCode)304) && !Input.GetKey((KeyCode)303) && !Input.GetKey((KeyCode)306) && !Input.GetKey((KeyCode)305) && !Input.GetKey((KeyCode)308) && !Input.GetKey((KeyCode)307); } if (text.IndexOf("Shift", StringComparison.OrdinalIgnoreCase) >= 0) { return Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303); } if (text.IndexOf("Control", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Ctrl", StringComparison.OrdinalIgnoreCase) >= 0) { return Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305); } if (text.IndexOf("Alt", StringComparison.OrdinalIgnoreCase) >= 0) { return Input.GetKey((KeyCode)308) || Input.GetKey((KeyCode)307); } if (Enum.TryParse(text, ignoreCase: true, out KeyCode result)) { return Input.GetKey(result); } return Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305); } private static ItemData GetRightItem(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_rightItem", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { return (ItemData)field.GetValue(player); } 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)); } } 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 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); } } } m_selectedPieces.Clear(); } public static void AddToSelection(Piece piece) { if (!((Object)(object)piece == (Object)null) && piece.IsPlacedByPlayer() && m_selectedPieces.Add(piece) && (Object)(object)((Component)piece).GetComponent() == (Object)null) { ((Component)piece).gameObject.AddComponent(); } } public static void RemoveFromSelection(Piece piece) { if (!((Object)(object)piece == (Object)null) && m_selectedPieces.Remove(piece)) { MovingDaySelectionHighlight component = ((Component)piece).GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } } } 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) //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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0134: 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) < 150f) { list.Add(item); } } while (queue.Count > 0) { Piece val = queue.Dequeue(); AddToSelection(val); Vector3 position2 = ((Component)val).transform.position; foreach (Piece item2 in list) { if (!((Object)(object)item2 == (Object)null) && !hashSet.Contains(item2) && item2.IsPlacedByPlayer()) { float num = Vector3.Distance(position2, ((Component)item2).transform.position); if (num <= 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_026e: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0292: 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_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: 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); 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"; 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); } 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) height = 0f; 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, HashSet selectedPieces) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_036c: 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; List list2 = new List(); if (selectedPieces != null) { foreach (Piece selectedPiece in selectedPieces) { if ((Object)(object)selectedPiece != (Object)null) { list2.Add(((Component)selectedPiece).transform.position); } } } 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 item2 in list2) { float num5 = item2.x - val.x; float num6 = item2.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).")); } 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"); 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)); } } } }