using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using Fusion; using HarmonyLib; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.Injection; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Il2CppSystem.Reflection; using Microsoft.CodeAnalysis; using SSSGame; using SSSGame.Controllers; using SSSGame.InputContext; using SSSGame.Network; using SSSGame.Render; using SSSGame.UI; using SandSailorStudio.Localization; using SandSailorStudio.UI; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("AskaMovingDay")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.1")] [assembly: AssemblyInformationalVersion("1.0.1+be397203888b23b18914a97a2fda0759900b5994")] [assembly: AssemblyProduct("Aska Moving Day")] [assembly: AssemblyTitle("AskaMovingDay")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace AskaMovingDay { internal static class AnnexOverlay { private enum ClearSample { Resolved, Rejected, Unavailable } private sealed class Clone { internal GameObject Object; internal Renderer Renderer; internal Il2CppReferenceArray Natural; internal Il2CppReferenceArray Blocked; } private sealed class Box { internal GameObject Object; internal Renderer Renderer; internal List Clones; } private const string Prefix = "[MovingDay][overlay]"; private const string BoxNamePrefix = "MovingDayAnnexGhost:"; private const string CloneNamePrefix = "MovingDayAnnexGhost:mesh:"; private const string InvalidMaterialMarker = "InvalidPlacement"; private static readonly Color ClearTint = new Color(0.15f, 0.85f, 0.25f, 1f); private static readonly Color BlockedTint = new Color(1f, 0.2f, 0.15f, 0.42f); private static readonly string[] ColourProperties = new string[5] { "_BaseColor", "_Color", "_TintColor", "_UnlitColor", "_MainColor" }; private static readonly List Boxes = new List(); private static Material _clearMaterial; private static Material _blockedMaterial; private static Transform _parent; private static Transform _structureRoot; private static GameObject _preview; private static bool _clearPending; private static int _lastClearAttemptFrame = -1; private static string _clearOrigin = ""; private static string _blockedOrigin = ""; private static int _previewLayer = -1; private static int _materialSourceLayer = -1; private static string _materialSourceObject = ""; private static bool _failureLogged; private static bool _sampleFailureLogged; private static bool _lodFailOpenLogged; private static bool _fallbackLogged; internal static bool IsReady { get; private set; } internal static bool Begin(GameObject preview) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown Reset(); try { if ((Object)(object)preview == (Object)null) { return false; } Transform transform = preview.transform; if ((Object)(object)transform == (Object)null) { return false; } _previewLayer = ReadLayer(preview); _structureRoot = ResolveStructureRoot(); if (!TryResolveMaterials(preview)) { return false; } _parent = transform; IsReady = true; return true; } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(118, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][overlay]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" the annex overlay could not be started ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") - no annex boxes are drawn on this move, and the move itself is unaffected."); } log.LogWarning(val); Reset(); return false; } } internal static void Add(string name, GameObject annexRoot, Vector3 localPosition, Quaternion localRotation, Vector3 localScale) { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) Box box = new Box(); Boxes.Add(box); if (!IsReady) { return; } try { if (BuildClones(box, name, annexRoot) > 0) { ApplyCloneMaterials(box, blocked: false); return; } } catch (Exception ex) { ReportFailure($"cloning the geometry of annex '{name}' threw ({ex.Message}); it falls back to a plain box"); DestroyClones(box); } AddCube(box, name, localPosition, localRotation, localScale); } private static void AddCube(Box box, string name, Vector3 localPosition, Quaternion localRotation, Vector3 localScale) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) GameObject val = null; try { val = GameObject.CreatePrimitive((PrimitiveType)3); if ((Object)(object)val == (Object)null) { ReportFailure("a primitive cube could not be created"); return; } if (!StripColliders(val)) { Object.DestroyImmediate((Object)(object)val); return; } ((Object)val).name = "MovingDayAnnexGhost:" + (name ?? ""); ApplyLayer(val); Transform transform = val.transform; transform.SetParent(_parent, false); transform.localPosition = localPosition; transform.localRotation = localRotation; transform.localScale = localScale; Renderer component = (Renderer)(object)val.GetComponent(); if ((Object)(object)component == (Object)null) { ReportFailure("the cube for annex '" + name + "' has no MeshRenderer"); Object.DestroyImmediate((Object)(object)val); return; } ApplyMaterial(component, blocked: false); component.shadowCastingMode = (ShadowCastingMode)0; component.receiveShadows = false; component.lightProbeUsage = (LightProbeUsage)0; component.reflectionProbeUsage = (ReflectionProbeUsage)0; box.Object = val; box.Renderer = component; } catch (Exception ex) { ReportFailure($"building the box for annex '{name}' threw ({ex.Message})"); try { if ((Object)(object)val != (Object)null) { Object.DestroyImmediate((Object)(object)val); } } catch { } box.Object = null; box.Renderer = null; } } private static int BuildClones(Box box, string name, GameObject annexRoot) { if ((Object)(object)annexRoot == (Object)null) { NoteNoGeometry(name, "the annex has no live GameObject to read geometry from"); return 0; } if ((Object)(object)_structureRoot == (Object)null) { NoteNoGeometry(name, "the moving structure's root transform could not be resolved, so no clone could be posed"); return 0; } Il2CppArrayBase componentsInChildren = annexRoot.GetComponentsInChildren(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { NoteNoGeometry(name, "it has no MeshRenderer anywhere under it"); return 0; } HashSet hashSet = BuildLodRejectSet(annexRoot, name); int length = componentsInChildren.Length; int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; int num5 = 0; int num6 = 0; int num7 = 0; int num8 = 0; for (int i = 0; i < length; i++) { try { MeshRenderer val = componentsInChildren[i]; if ((Object)(object)val == (Object)null) { num8++; continue; } if (!((Renderer)val).enabled) { num2++; continue; } GameObject gameObject = ((Component)val).gameObject; if ((Object)(object)gameObject == (Object)null || !gameObject.activeInHierarchy) { num3++; continue; } if (hashSet.Contains(((Il2CppObjectBase)val).Pointer)) { num4++; continue; } MeshFilter component = gameObject.GetComponent(); if ((Object)(object)component == (Object)null) { num5++; continue; } Mesh sharedMesh = component.sharedMesh; if ((Object)(object)sharedMesh == (Object)null) { num6++; continue; } Il2CppReferenceArray sharedMaterials = ((Renderer)val).sharedMaterials; if (sharedMaterials == null || ((Il2CppArrayBase)(object)sharedMaterials).Length == 0) { num7++; continue; } Clone clone = BuildClone(name, val, gameObject, sharedMesh, sharedMaterials); if (clone != null) { if (box.Clones == null) { box.Clones = new List(length); } box.Clones.Add(clone); num++; } } catch (Exception ex) { num8++; ReportFailure($"cloning one renderer of annex '{name}' threw ({ex.Message}); that part is not drawn"); } } if (num == 0) { NoteNoGeometry(name, $"all {length} of its MeshRenderer(s) were refused - {num2} disabled, {num3} inactive, {num4} on a non-zero LOD level, {num5} with no MeshFilter, {num6} with a null sharedMesh, {num7} with no materials, {num8} unreadable"); } return num; } private static Clone BuildClone(string annexName, MeshRenderer source, GameObject owner, Mesh mesh, Il2CppReferenceArray natural) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) GameObject val = null; try { Transform transform = ((Component)source).transform; if ((Object)(object)transform == (Object)null) { return null; } val = new GameObject("MovingDayAnnexGhost:mesh:" + (annexName ?? "") + ":" + SafeName((Object)(object)owner)); if ((Object)(object)val == (Object)null) { return null; } MeshFilter val2 = AddComponent(val); if ((Object)(object)val2 == (Object)null) { ReportFailure("a MeshFilter could not be added to a geometry clone of annex '" + annexName + "'"); Object.DestroyImmediate((Object)(object)val); return null; } MeshRenderer val3 = AddComponent(val); if ((Object)(object)val3 == (Object)null) { ReportFailure("a MeshRenderer could not be added to a geometry clone of annex '" + annexName + "'"); Object.DestroyImmediate((Object)(object)val); return null; } val2.sharedMesh = mesh; ApplyLayer(val); Transform transform2 = val.transform; transform2.SetParent(_parent, false); Matrix4x4 val4 = _structureRoot.worldToLocalMatrix * transform.localToWorldMatrix; Vector4 column = ((Matrix4x4)(ref val4)).GetColumn(3); transform2.localPosition = new Vector3(column.x, column.y, column.z); transform2.localRotation = ((Matrix4x4)(ref val4)).rotation; transform2.localScale = ((Matrix4x4)(ref val4)).lossyScale; ((Renderer)val3).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val3).receiveShadows = false; ((Renderer)val3).lightProbeUsage = (LightProbeUsage)0; ((Renderer)val3).reflectionProbeUsage = (ReflectionProbeUsage)0; return new Clone { Object = val, Renderer = (Renderer)(object)val3, Natural = natural, Blocked = BuildBlockedMaterials(((Il2CppArrayBase)(object)natural).Length) }; } catch (Exception ex) { ReportFailure($"building a geometry clone for annex '{annexName}' threw ({ex.Message}); that part is not drawn"); try { if ((Object)(object)val != (Object)null) { Object.DestroyImmediate((Object)(object)val); } } catch { } return null; } } private static Il2CppReferenceArray BuildBlockedMaterials(int slots) { Material blockedMaterial = _blockedMaterial; if ((Object)(object)blockedMaterial == (Object)null || slots <= 0) { return null; } Il2CppReferenceArray val = new Il2CppReferenceArray((long)slots); for (int i = 0; i < slots; i++) { ((Il2CppArrayBase)(object)val)[i] = blockedMaterial; } return val; } private static HashSet BuildLodRejectSet(GameObject annexRoot, string annexName) { HashSet hashSet = new HashSet(); try { Il2CppArrayBase componentsInChildren = annexRoot.GetComponentsInChildren(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { return hashSet; } for (int i = 0; i < componentsInChildren.Length; i++) { try { LODGroup val = componentsInChildren[i]; if ((Object)(object)val == (Object)null) { continue; } Il2CppReferenceArray lODs = val.GetLODs(); if (lODs == null || ((Il2CppArrayBase)(object)lODs).Length == 0) { NoteLodFailOpen(annexName, "LODGroup.GetLODs() described no levels"); continue; } for (int j = 1; j < ((Il2CppArrayBase)(object)lODs).Length; j++) { LOD val2 = ((Il2CppArrayBase)(object)lODs)[j]; if (val2 == null) { continue; } Il2CppReferenceArray renderers = val2.renderers; if (renderers == null) { continue; } for (int k = 0; k < ((Il2CppArrayBase)(object)renderers).Length; k++) { Renderer val3 = ((Il2CppArrayBase)(object)renderers)[k]; if ((Object)(object)val3 != (Object)null) { hashSet.Add(((Il2CppObjectBase)val3).Pointer); } } } } catch (Exception ex) { NoteLodFailOpen(annexName, "reading one LODGroup threw (" + ex.Message + ")"); } } return hashSet; } catch (Exception ex2) { NoteLodFailOpen(annexName, "walking the LODGroups threw (" + ex2.Message + ")"); return new HashSet(); } } private static T AddComponent(GameObject host) where T : Object { try { Component val = host.AddComponent(Il2CppType.Of()); return ((Object)(object)val == (Object)null) ? default(T) : ((Il2CppObjectBase)val).TryCast(); } catch (Exception ex) { ReportFailure($"adding a {typeof(T).Name} to a geometry clone threw ({ex.Message})"); return default(T); } } private static void ApplyCloneMaterials(Box box, bool blocked) { List clones = box.Clones; if (clones == null) { return; } for (int i = 0; i < clones.Count; i++) { Clone clone = clones[i]; if (clone == null) { continue; } Renderer renderer = clone.Renderer; if ((Object)(object)renderer == (Object)null) { continue; } Il2CppReferenceArray val = (blocked ? clone.Blocked : clone.Natural); if (val == null || ((Il2CppArrayBase)(object)val).Length == 0) { if (renderer.enabled) { renderer.enabled = false; } continue; } Material val2 = ((Il2CppArrayBase)(object)val)[0]; Material sharedMaterial = renderer.sharedMaterial; bool num; if (!((Object)(object)sharedMaterial == (Object)null)) { if (!((Object)(object)val2 != (Object)null)) { goto IL_00ac; } num = ((Il2CppObjectBase)sharedMaterial).Pointer == ((Il2CppObjectBase)val2).Pointer; } else { num = (Object)(object)val2 == (Object)null; } if (!num) { goto IL_00ac; } goto IL_00b4; IL_00ac: renderer.sharedMaterials = val; goto IL_00b4; IL_00b4: if (!renderer.enabled) { renderer.enabled = true; } } } private static void DestroyClones(Box box) { List clones = box.Clones; box.Clones = null; if (clones == null) { return; } for (int i = 0; i < clones.Count; i++) { Clone clone = clones[i]; if (clone != null) { GameObject obj = clone.Object; clone.Object = null; clone.Renderer = null; clone.Natural = null; clone.Blocked = null; DestroyOverlayObject(obj, "an annex geometry clone"); } } } private static Transform ResolveStructureRoot() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown try { MoveSession activeSession = MovingDayTool.ActiveSession; if (activeSession == null) { return null; } Structure target = activeSession.Target; if ((Object)(object)target == (Object)null) { return null; } return ((Component)target).transform; } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(112, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][overlay]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" the moving structure's root transform could not be read ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") - the annexes fall back to plain boxes on this move."); } log.LogWarning(val); return null; } } private static void NoteNoGeometry(string annexName, string reason) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown if (!_fallbackLogged) { _fallbackLogged = true; ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(195, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][overlay]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" annex '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(annexName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' yielded no drawable geometry ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(reason); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("), so it falls back to a plain box. A degraded box is better than an invisible annex. Validation and the move itself are unaffected (logged once per move)."); } log.LogInfo(val); } } private static void NoteLodFailOpen(string annexName, string reason) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown if (!_lodFailOpenLogged) { _lodFailOpenLogged = true; ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(233, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][overlay]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" the LOD filter could not read the LODGroups of annex '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(annexName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(reason); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") - it FAILS OPEN, so every renderer under that group is drawn and the annex may be drawn with its lower LOD levels stacked on top of it. Cosmetic only (logged once per move)."); } log.LogInfo(val); } } internal static void SetBlocked(int index, bool blocked) { if (index < 0 || index >= Boxes.Count) { return; } if (_clearPending) { RetryClearMaterial(); } Box box = Boxes[index]; if (box == null) { return; } try { if (box.Clones != null && box.Clones.Count > 0) { ApplyCloneMaterials(box, blocked); return; } Renderer renderer = box.Renderer; if (!((Object)(object)renderer == (Object)null)) { ApplyMaterial(renderer, blocked); } } catch (Exception ex) { ReportFailure("recolouring an annex box threw (" + ex.Message + ")"); } } private static void ApplyMaterial(Renderer renderer, bool blocked) { Material val = (blocked ? _blockedMaterial : _clearMaterial); if ((Object)(object)val == (Object)null) { if (renderer.enabled) { renderer.enabled = false; } return; } Material sharedMaterial = renderer.sharedMaterial; if ((Object)(object)sharedMaterial == (Object)null || ((Il2CppObjectBase)sharedMaterial).Pointer != ((Il2CppObjectBase)val).Pointer) { renderer.sharedMaterial = val; } if (!renderer.enabled) { renderer.enabled = true; } } private static void RetryClearMaterial() { try { int frameCount = Time.frameCount; if (frameCount != _lastClearAttemptFrame) { _lastClearAttemptFrame = frameCount; if (TryResolveClearMaterial() == ClearSample.Resolved) { _clearPending = false; } } } catch { } } internal static void Reset() { for (int i = 0; i < Boxes.Count; i++) { Box box = Boxes[i]; if (box != null) { DestroyClones(box); GameObject obj = box.Object; box.Object = null; box.Renderer = null; DestroyOverlayObject(obj, "an annex box"); } } Boxes.Clear(); DestroyMaterial(ref _clearMaterial); DestroyMaterial(ref _blockedMaterial); _parent = null; _preview = null; _structureRoot = null; _clearPending = false; _lastClearAttemptFrame = -1; _clearOrigin = ""; _blockedOrigin = ""; _previewLayer = -1; _materialSourceLayer = -1; _materialSourceObject = ""; IsReady = false; _failureLogged = false; _sampleFailureLogged = false; _lodFailOpenLogged = false; _fallbackLogged = false; } private static bool TryResolveMaterials(GameObject preview) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Expected O, but got Unknown //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Expected O, but got Unknown //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Expected O, but got Unknown //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Expected O, but got Unknown //IL_01eb: 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) _preview = preview; Material ghostValidationMaterial = GhostSession.GhostValidationMaterial; if ((Object)(object)ghostValidationMaterial != (Object)null) { string value = DescribeSource(ghostValidationMaterial); _blockedMaterial = new Material(ghostValidationMaterial); if ((Object)(object)_blockedMaterial == (Object)null) { _blockedOrigin = " - copying the game's validation material produced nothing. Blocked annexes draw no box."; } else { _blockedOrigin = $"a copy of the game's OWN ValidationPlacementTool.validationMaterial '{SafeName((Object)(object)ghostValidationMaterial)}' (shader '{SafeShaderName(ghostValidationMaterial)}'), used UNTINTED - it is the game's invalid-placement material and already carries its own colour.{value}"; } } else { _blockedOrigin = " - ValidationPlacementTool.validationMaterial was not reachable. Blocked annexes draw no box."; } ClearSample clearSample = TryResolveClearMaterial(); _clearPending = clearSample != ClearSample.Resolved; switch (clearSample) { case ClearSample.Rejected: _clearOrigin = "DEFERRED - the ghost is showing the game's invalid-placement material right now, and sampling it would make every legal annex red. Retried on later frames. Until then a clear annex draws no box."; break; case ClearSample.Unavailable: _clearOrigin = "not resolved - the preview offered no material to sample. Retried on later frames, and until then a clear annex draws no box."; break; } if ((Object)(object)_blockedMaterial != (Object)null || (Object)(object)_clearMaterial != (Object)null || clearSample == ClearSample.Rejected) { LogSources(); return true; } string found; Shader val = FindFallbackShader(out found); bool flag = default(bool); if ((Object)(object)val == (Object)null) { ManualLogSource log = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(228, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][overlay]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" no material could be built for the annex boxes (the preview's own renderers, the game's validation material and every fallback shader were all unreachable) - NO annex boxes are drawn on this move. The move itself is unaffected."); } log.LogWarning(val2); return false; } _clearMaterial = new Material(val); _blockedMaterial = new Material(val); if ((Object)(object)_clearMaterial == (Object)null || (Object)(object)_blockedMaterial == (Object)null) { DestroyMaterial(ref _clearMaterial); DestroyMaterial(ref _blockedMaterial); ManualLogSource log2 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(117, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][overlay]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" a material could not be built from shader '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(found); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' - NO annex boxes are drawn on this move. The move itself is unaffected."); } log2.LogWarning(val2); return false; } string value2 = DescribeSource(_clearMaterial); string value3 = Prepare(_clearMaterial, ClearTint); string text = Prepare(_blockedMaterial, BlockedTint); _clearPending = false; _clearOrigin = $"a fallback shader found by name, '{found}', TINTED green (neither the game's validation material nor the preview's own renderers were reachable). {value3}{value2}"; _blockedOrigin = "a fallback shader found by name, '" + found + "', TINTED red (same source as the clear material). " + text; LogSources(); return true; } private static ClearSample TryResolveClearMaterial() { //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown try { GameObject preview = _preview; if ((Object)(object)preview == (Object)null) { return ClearSample.Unavailable; } Material val = TakePreviewMaterial(preview); if ((Object)(object)val == (Object)null) { return ClearSample.Unavailable; } if (IsInvalidPlacementMaterial(val)) { return ClearSample.Rejected; } Material val2 = new Material(val); if ((Object)(object)val2 == (Object)null) { return ClearSample.Unavailable; } _clearMaterial = val2; _clearOrigin = $"a copy of the ghost preview's OWN natural material '{SafeName((Object)(object)val)}' (shader '{SafeShaderName(val)}', from '{_materialSourceObject}'), used UNTINTED so a clear annex reads in the structure's own natural colour, as the game's own main ghost does.{DescribeSource(val)}"; return ClearSample.Resolved; } catch (Exception ex) { if (!_sampleFailureLogged) { _sampleFailureLogged = true; ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(153, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted("[MovingDay][overlay]"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" resolving the annex overlay's clear material threw ("); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(") - clear annexes draw no box (logged once per move). Validation and the move itself are unaffected."); } log.LogWarning(val3); } return ClearSample.Unavailable; } } private static bool IsInvalidPlacementMaterial(Material sampled) { try { if ((Object)(object)sampled == (Object)null) { return false; } string text = SafeName((Object)(object)sampled); if (!string.IsNullOrEmpty(text) && text.IndexOf("InvalidPlacement", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } Material ghostValidationMaterial = GhostSession.GhostValidationMaterial; if ((Object)(object)ghostValidationMaterial != (Object)null && ((Il2CppObjectBase)sampled).Pointer == ((Il2CppObjectBase)ghostValidationMaterial).Pointer) { return true; } return false; } catch { return true; } } private static void LogSources() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][overlay]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" annex box CLEAR material: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_clearOrigin); } log.LogInfo(val); ManualLogSource log2 = Plugin.Log; val = new BepInExInfoLogInterpolatedStringHandler(29, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][overlay]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" annex box BLOCKED material: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_blockedOrigin); } log2.LogInfo(val); ManualLogSource log3 = Plugin.Log; val = new BepInExInfoLogInterpolatedStringHandler(82, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][overlay]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" annex box layers: preview root layer="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(LayerText(_previewLayer)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", material source renderer layer="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(LayerText(_materialSourceLayer)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (from '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_materialSourceObject); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("')."); } log3.LogInfo(val); } private static string DescribeSource(Material material) { return string.Empty; } private static Material TakePreviewMaterial(GameObject preview) { //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown _materialSourceLayer = -1; _materialSourceObject = ""; try { if ((Object)(object)preview == (Object)null) { return null; } Il2CppArrayBase componentsInChildren = preview.GetComponentsInChildren(true); if (componentsInChildren == null) { return null; } for (int i = 0; i < componentsInChildren.Length; i++) { Renderer val = componentsInChildren[i]; if ((Object)(object)val == (Object)null || !val.enabled) { continue; } GameObject gameObject = ((Component)val).gameObject; if ((Object)(object)gameObject == (Object)null || !gameObject.activeInHierarchy) { continue; } string text = SafeName((Object)(object)gameObject); if (string.IsNullOrEmpty(text) || !text.StartsWith("MovingDayAnnexGhost:", StringComparison.Ordinal)) { Material sharedMaterial = val.sharedMaterial; if (!((Object)(object)sharedMaterial == (Object)null)) { _materialSourceLayer = gameObject.layer; _materialSourceObject = text; return sharedMaterial; } } } } catch (Exception ex) { if (!_sampleFailureLogged) { _sampleFailureLogged = true; ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(118, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][overlay]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" reading a material off the ghost preview's own renderers threw ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(") - clear annexes draw no box (logged once per move)."); } log.LogWarning(val2); } } return null; } private static Shader FindFallbackShader(out string found) { string[] array = new string[5] { "Sprites/Default", "Hidden/Internal-Colored", "Legacy Shaders/Transparent/Diffuse", "Universal Render Pipeline/Unlit", "Unlit/Color" }; for (int i = 0; i < array.Length; i++) { try { Shader val = Shader.Find(array[i]); if ((Object)(object)val != (Object)null) { found = array[i]; return val; } } catch { } } found = null; return null; } private static string Prepare(Material material, Color colour) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) List list = new List(); List list2 = new List(); try { for (int i = 0; i < ColourProperties.Length; i++) { if (!material.HasProperty(ColourProperties[i])) { list2.Add(ColourProperties[i]); continue; } material.SetColor(ColourProperties[i], colour); list.Add(ColourProperties[i]); } if (list.Count == 0) { material.color = colour; } } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(110, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][overlay]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" tinting an annex box material threw ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") - the boxes are drawn in whatever colour the material already carried."); } log.LogWarning(val); return "colour probe threw (" + ex.Message + ")."; } if (list.Count == 0) { return "NO colour property exists on this material (absent: " + Join(list2) + ") - it CANNOT show green versus red, and Material.color was the only thing left to try. If the boxes draw but are all one colour, this line is the reason."; } return $"colour properties set: {Join(list)}; absent: {Join(list2)}."; } private static string Join(List names) { if (names.Count != 0) { return string.Join(", ", names); } return ""; } private static void DestroyMaterial(ref Material material) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown Material val = material; material = null; if ((Object)(object)val == (Object)null) { return; } try { Object.Destroy((Object)(object)val); } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(43, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][overlay]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" destroying an annex box material threw ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")."); } log.LogWarning(val2); } } private static void ApplyLayer(GameObject cube) { try { if (!((Object)(object)cube == (Object)null) && _previewLayer >= 0) { SetLayerRecursively(cube.transform, _previewLayer); } } catch { } } private static void SetLayerRecursively(Transform transform, int layer) { if (!((Object)(object)transform == (Object)null)) { ((Component)transform).gameObject.layer = layer; for (int i = 0; i < transform.childCount; i++) { SetLayerRecursively(transform.GetChild(i), layer); } } } private static int ReadLayer(GameObject obj) { try { return ((Object)(object)obj == (Object)null) ? (-1) : obj.layer; } catch { return -1; } } private static string LayerText(int layer) { if (layer < 0) { return ""; } try { string value = LayerMask.LayerToName(layer); return string.IsNullOrEmpty(value) ? $"{layer} ('')" : $"{layer} ('{value}')"; } catch { return layer.ToString(); } } private static bool StripColliders(GameObject cube) { try { Il2CppArrayBase components = cube.GetComponents(); if (components != null) { for (int i = 0; i < components.Length; i++) { Collider val = components[i]; if ((Object)(object)val != (Object)null) { Object.DestroyImmediate((Object)(object)val); } } } Il2CppArrayBase components2 = cube.GetComponents(); if (components2 != null && components2.Length > 0) { ReportFailure($"{components2.Length} collider(s) could not be removed from an annex box"); return false; } return true; } catch (Exception ex) { ReportFailure("removing the collider from an annex box threw (" + ex.Message + ")"); return false; } } private static void DestroyOverlayObject(GameObject obj, string what) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown if ((Object)(object)obj == (Object)null) { return; } try { obj.SetActive(false); obj.transform.SetParent((Transform)null, false); Object.Destroy((Object)(object)obj); } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(75, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][overlay]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" destroying "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(what); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" threw ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") - it may stay visible until the preview is despawned."); } log.LogWarning(val); } } private static void ReportFailure(string reason) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown if (!_failureLogged) { _failureLogged = true; ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(111, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][overlay]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(reason); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" - that annex is not drawn in the ghost. Validation and the move itself are unaffected (logged once per move)."); } log.LogWarning(val); } } private static string SafeName(Object obj) { try { return (obj == (Object)null) ? "" : obj.name; } catch { return ""; } } private static string SafeShaderName(Material material) { try { if ((Object)(object)material == (Object)null) { return ""; } Shader shader = material.shader; return ((Object)(object)shader == (Object)null) ? "" : ((Object)shader).name; } catch { return ""; } } } internal static class ArmingReport { internal static int Armed; internal static int Attempted; internal static bool TryPatch(Harmony harmony, MethodBase target, string label, HarmonyMethod prefix = null, HarmonyMethod postfix = null) { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown Attempted++; bool flag = default(bool); if (target == null) { ManualLogSource log = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(36, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[arm-fail] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(label); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": target method not found"); } log.LogWarning(val); return false; } try { harmony.Patch(target, prefix, postfix, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Armed++; ManualLogSource log2 = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(8, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[armed] "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(label); } log2.LogInfo(val2); return true; } catch (Exception ex) { ManualLogSource log3 = Plugin.Log; bool flag2 = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(13, 2, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[arm-fail] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(label); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log3.LogWarning(val); return false; } } internal static void LogTotal() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(28, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] armed "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(Armed); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(Attempted); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" patches."); } log.LogInfo(val); } } public static class CharacterSpawnPatch { private static bool _attachFailureLogged; internal static Character LocalCharacter { get; private set; } public static void Spawned(Character __instance) { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown bool flag = default(bool); try { if (!__instance.IsPlayer() || ((NetworkBehaviour)__instance).GetLocalAuthorityMask() != 1) { return; } LocalCharacter = __instance; if (!((Object)(object)((Component)__instance).GetComponentInChildren() != (Object)null)) { GameObject val = new GameObject("MovingDay_Tool"); val.transform.SetParent(((Component)__instance).gameObject.transform, false); val.AddComponent(); ManualLogSource log = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(45, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[MovingDay] tool attached to local player '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(((Object)((Component)__instance).gameObject).name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'."); } log.LogInfo(val2); } } catch (Exception ex) { if (!_attachFailureLogged) { _attachFailureLogged = true; ManualLogSource log2 = Plugin.Log; BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(154, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[MovingDay] attaching the tool to the local player threw - Moving Day will do nothing this session, and this is reported once rather than once per spawn: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex); } log2.LogError(val3); } } } } internal static class CommitEngine { private const string Prefix = "[MovingDay][commit]"; internal static bool TryMove(MoveSession session, Vector3 position, Quaternion rotation, out string failReason) { //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Expected O, but got Unknown //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_042d: Expected O, but got Unknown //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Expected O, but got Unknown //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Expected O, but got Unknown //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_021f: 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_0311: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Expected O, but got Unknown //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Expected O, but got Unknown //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Expected O, but got Unknown //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03ea: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_047b: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Unknown result type (might be due to invalid IL or missing references) //IL_0481: Unknown result type (might be due to invalid IL or missing references) //IL_0486: Unknown result type (might be due to invalid IL or missing references) //IL_0492: Unknown result type (might be due to invalid IL or missing references) //IL_0499: Expected O, but got Unknown //IL_051f: Unknown result type (might be due to invalid IL or missing references) //IL_0526: Expected O, but got Unknown //IL_04e4: Unknown result type (might be due to invalid IL or missing references) //IL_04ff: Unknown result type (might be due to invalid IL or missing references) //IL_0544: Unknown result type (might be due to invalid IL or missing references) //IL_057d: Unknown result type (might be due to invalid IL or missing references) bool flag = default(bool); if (session == null) { failReason = "the move was lost before it could be applied"; ManualLogSource log = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(35, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][commit]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" refused: there is no move session."); } log.LogWarning(val); return false; } string displayName = session.DisplayName; if (!session.IsTargetAlive()) { failReason = "the structure no longer exists"; ManualLogSource log2 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(60, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][commit]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" refused for '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(displayName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': the target is gone, dismantled or inactive."); } log2.LogWarning(val); return false; } if (!SessionGate.IsLocalPlayerMaster(out var reason)) { failReason = reason; ManualLogSource log3 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(18, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][commit]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" refused for '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(displayName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(reason); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log3.LogWarning(val); return false; } if (!PoseMath.IsUsable(position)) { failReason = "the confirmed position could not be used"; ManualLogSource log4 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(63, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][commit]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" refused for '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(displayName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': the confirmed position "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(Fmt(position)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is not a finite point."); } log4.LogWarning(val); return false; } if (!PoseMath.IsUsable(rotation)) { failReason = "the confirmed rotation could not be used"; ManualLogSource log5 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(73, 6, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][commit]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" refused for '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(displayName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': the confirmed rotation ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(rotation.x); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(","); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(rotation.y); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(","); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(rotation.z); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(","); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(rotation.w); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") is not a usable quaternion."); } log5.LogWarning(val); return false; } Structure target = session.Target; Transform transform; try { transform = ((Component)target).transform; } catch (Exception ex) { failReason = "the structure could not be read"; ManualLogSource log6 = Plugin.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(29, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][commit]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" reading '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(displayName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' transform threw: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex); } log6.LogError(val2); return false; } bool flag2 = default(bool); if ((Object)(object)transform == (Object)null) { failReason = "the structure could not be read"; ManualLogSource log7 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(37, 2, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][commit]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" refused for '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(displayName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': it has no transform."); } log7.LogWarning(val); return false; } Vector3 val3 = SafeTransformPosition(transform); ManualLogSource log8 = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(62, 5, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted("[MovingDay][commit]"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" moving '"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(displayName); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("': before GetPosition()="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(SafeStructurePosition(target)); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(", transform.position="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(Fmt(val3)); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(", euler="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(Fmt(SafeEuler(transform))); } log8.LogInfo(val4); ManualLogSource log9 = Plugin.Log; val4 = new BepInExInfoLogInterpolatedStringHandler(26, 3, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted("[MovingDay][commit]"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" target pose: pos="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(Fmt(position)); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(", euler="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(Fmt(((Quaternion)(ref rotation)).eulerAngles)); } log9.LogInfo(val4); List occupants = Occupants.Collect(target, displayName); try { transform.SetPositionAndRotation(position, rotation); } catch (Exception ex2) { failReason = "the game refused the new position"; ManualLogSource log10 = Plugin.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(37, 3, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][commit]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" SetPositionAndRotation on '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(displayName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' threw: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex2); } log10.LogError(val2); return false; } Vector3 val5 = SafeTransformPosition(transform); Vector3 val6 = val5 - val3; ManualLogSource log11 = Plugin.Log; val4 = new BepInExInfoLogInterpolatedStringHandler(60, 5, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted("[MovingDay][commit]"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" moved '"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(displayName); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("': after GetPosition()="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(SafeStructurePosition(target)); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(", transform.position="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(Fmt(val5)); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(", euler="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(Fmt(SafeEuler(transform))); } log11.LogInfo(val4); ManualLogSource log12 = Plugin.Log; val4 = new BepInExInfoLogInterpolatedStringHandler(37, 4, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted("[MovingDay][commit]"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" delta="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(Fmt(val6)); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" (distance "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(((Vector3)(ref val6)).magnitude, "F2"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("m, height change "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(val6.y, "F2"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("m)"); } log12.LogInfo(val4); Occupants.Reseat(occupants, displayName); failReason = null; return true; } private static Vector3 SafeTransformPosition(Transform transform) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0048: 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_0045: Unknown result type (might be due to invalid IL or missing references) try { return transform.position; } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(35, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][commit]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" reading transform.position threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); return Vector3.zero; } } private static Vector3 SafeEuler(Transform transform) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0051: 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) try { Quaternion rotation = transform.rotation; return ((Quaternion)(ref rotation)).eulerAngles; } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(39, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][commit]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" reading the transform rotation threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); return Vector3.zero; } } private static string SafeStructurePosition(Structure structure) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) try { return Fmt(structure.GetPosition()); } catch (Exception ex) { return ""; } } private static string Fmt(Vector3 v) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) return $"({v.x:F2},{v.y:F2},{v.z:F2})"; } } internal static class ConfirmDialog { private const string ConfirmCaptionKey = "common.confirm"; private const string CancelCaptionKey = "common.cancel"; private const string Prefix = "[MovingDay][dialog]"; private const float VanishGraceSeconds = 5f; private static Action _confirmHandler; private static Action _cancelHandler; private static Action _onConfirm; private static Action _onCancel; private static Menu _menu; private static bool _tracking; private static float _lastAliveAt; internal static bool TryOpen(string title, string message, Structure prefabSource, Action onConfirm, Action onCancel) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Expected O, but got Unknown //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Expected O, but got Unknown //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_0103: 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_0115: 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_0124: Expected O, but got Unknown //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Expected O, but got Unknown //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Expected O, but got Unknown //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Expected O, but got Unknown Close(); if (onConfirm == null || onCancel == null) { return false; } MenuManager instance; try { instance = MenuManager.Instance; } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(37, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][dialog]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" reading MenuManager.Instance threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); return false; } bool flag2 = default(bool); if ((Object)(object)instance == (Object)null) { ManualLogSource log2 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(68, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][dialog]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" there is no MenuManager - the confirmation dialog cannot be opened."); } log2.LogWarning(val2); return false; } ConfirmActionMenu val3 = ResolvePrefab(instance, prefabSource); if ((Object)(object)val3 == (Object)null) { ManualLogSource log3 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(90, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][dialog]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" no ConfirmActionMenu prefab could be resolved - the confirmation dialog cannot be opened."); } log3.LogWarning(val2); return false; } ConfirmActionMenuParameters val4; try { val4 = new ConfirmActionMenuParameters { Title = title, Message = message, ConfirmMessage = "common.confirm", CancelMessage = "common.cancel", CloseOnConfirm = true, HideCancelButton = false, DontCloseOnEscape = false }; } catch (Exception ex2) { ManualLogSource log4 = Plugin.Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(45, 2, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][dialog]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" building the confirmation parameters threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex2); } log4.LogError(val); return false; } _onConfirm = onConfirm; _onCancel = onCancel; _confirmHandler = HandleConfirm; _cancelHandler = HandleCancel; try { val4.OnConfirm = DelegateSupport.ConvertDelegate>((Delegate)_confirmHandler); val4.OnCancel = DelegateSupport.ConvertDelegate>((Delegate)_cancelHandler); } catch (Exception ex3) { ManualLogSource log5 = Plugin.Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(48, 2, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][dialog]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" converting the confirm/cancel callbacks threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex3); } log5.LogError(val); Forget(); return false; } Menu val5; try { val5 = instance.OpenMenuPrefab((Menu)(object)val3, (MenuParameters)(object)val4); } catch (Exception ex4) { ManualLogSource log6 = Plugin.Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(40, 2, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][dialog]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" opening the confirmation dialog threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex4); } log6.LogError(val); Forget(); return false; } if ((Object)(object)val5 == (Object)null) { ManualLogSource log7 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(72, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][dialog]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" OpenMenuPrefab returned nothing - the confirmation dialog did not open."); } log7.LogWarning(val2); Forget(); return false; } _menu = val5; _tracking = true; _lastAliveAt = SafeNow(); ManualLogSource log8 = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val6 = new BepInExInfoLogInterpolatedStringHandler(30, 3, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted("[MovingDay][dialog]"); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(" opened: title='"); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted(title); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("', message='"); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted(message); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("'."); } log8.LogInfo(val6); if (!RawTextRenders(title)) { ManualLogSource log9 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(156, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][dialog]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" the localizer does not pass unknown keys through, so the dialog's own title and message may not read as written - repeating the question as a notification."); } log9.LogWarning(val2); Hud.Notify(message); } return true; } internal static bool HasVanished() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown if (!_tracking) { return false; } float num = SafeNow(); bool flag; try { flag = (Object)(object)_menu != (Object)null && _menu.IsActive; } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag2 = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(35, 2, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][dialog]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" reading the dialog's state threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); flag = false; } if (flag) { _lastAliveAt = num; return false; } return num - _lastAliveAt > 5f; } internal static void Forget() { _tracking = false; _menu = null; _onConfirm = null; _onCancel = null; } internal static void Close() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown if (!_tracking) { Forget(); return; } Menu menu = _menu; Forget(); if ((Object)(object)menu == (Object)null) { return; } try { MenuManager instance = MenuManager.Instance; if ((Object)(object)instance != (Object)null) { instance.CloseMenu(menu); } } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(40, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][dialog]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" closing the confirmation dialog threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } } private static void HandleConfirm(ConfirmActionMenu menu) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown Action onConfirm = _onConfirm; Forget(); bool flag = default(bool); try { ManualLogSource log = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(25, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][dialog]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" confirmed by the player."); } log.LogInfo(val); onConfirm?.Invoke(); } catch (Exception ex) { ManualLogSource log2 = Plugin.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(34, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][dialog]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" handling the confirmation threw: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex); } log2.LogError(val2); } } private static void HandleCancel(ConfirmActionMenu menu) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown Action onCancel = _onCancel; Forget(); bool flag = default(bool); try { ManualLogSource log = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(24, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][dialog]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" declined by the player."); } log.LogInfo(val); onCancel?.Invoke(); } catch (Exception ex) { ManualLogSource log2 = Plugin.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(34, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][dialog]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" handling the cancellation threw: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex); } log2.LogError(val2); } } private static ConfirmActionMenu ResolvePrefab(MenuManager manager, Structure prefabSource) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown bool flag = default(bool); try { ConfirmActionMenu prefab = manager.GetPrefab(); if ((Object)(object)prefab != (Object)null) { return prefab; } ManualLogSource log = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(111, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][dialog]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" MenuManager has no registered ConfirmActionMenu prefab - falling back to the structure's own dismantle dialog."); } log.LogInfo(val); } catch (Exception ex) { ManualLogSource log2 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(109, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][dialog]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" MenuManager.GetPrefab() failed ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(") - falling back to the structure's own dismantle dialog."); } log2.LogWarning(val2); } try { if ((Object)(object)prefabSource != (Object)null) { ConfirmActionMenu confirmDismantleMenu = prefabSource._confirmDismantleMenu; if ((Object)(object)confirmDismantleMenu != (Object)null) { return confirmDismantleMenu; } } } catch (Exception ex2) { ManualLogSource log3 = Plugin.Log; BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(56, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted("[MovingDay][dialog]"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" reading the structure's dismantle dialog prefab threw: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex2); } log3.LogError(val3); } return null; } private static bool RawTextRenders(string sample) { //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown if (string.IsNullOrEmpty(sample)) { return true; } bool flag3 = default(bool); try { LocalizationManager instance = LocalizationManager.Instance; BepInExInfoLogInterpolatedStringHandler val; if ((Object)(object)instance == (Object)null) { ManualLogSource log = Plugin.Log; bool flag = default(bool); val = new BepInExInfoLogInterpolatedStringHandler(108, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][dialog]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" there is no LocalizationManager to check raw-text rendering against - assuming the text renders as written."); } log.LogInfo(val); return true; } string text = instance.Loc(sample, false); bool flag2 = string.Equals(text, sample, StringComparison.Ordinal); ManualLogSource log2 = Plugin.Log; val = new BepInExInfoLogInterpolatedStringHandler(54, 4, ref flag3); if (flag3) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][dialog]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" raw-text check: Loc(\""); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(sample); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\") -> \""); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\" (renders as written: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(flag2 ? "yes" : "NO"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")."); } log2.LogInfo(val); return flag2; } catch (Exception ex) { ManualLogSource log3 = Plugin.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(27, 2, ref flag3); if (flag3) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][dialog]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" the raw-text check threw: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex); } log3.LogError(val2); return true; } } private static float SafeNow() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown try { return Time.unscaledTime; } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(26, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][dialog]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" reading the clock threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); return 0f; } } } internal static class GhostSession { private sealed class PendingInjection { internal ICollection Collection { get; } internal List Added { get; } internal PendingInjection(ICollection collection, List added) { Collection = collection; Added = added; } } private static readonly Collider[] NoColliders = (Collider[])(object)new Collider[0]; private static PlayerBuilder _builder; private static bool _live; private static bool _starting; private static bool _ending; private static bool _gameLeftBuildMode; private static Collider[] _exempt = NoColliders; private static readonly HashSet _exemptPointers = new HashSet(); private static bool _injectionFailureLogged; private static bool _injectionCapLogged; private static readonly List _pendingInjections = new List(); private const int MaxPendingInjections = 32; private static float _seedYaw; private static bool _haveSeedYaw; private static bool _seedApplied; private static int _seedWaitFrames; private const int MaxSeedWaitFrames = 30; private static float _seedWritten; private static bool _seedVerifyPending; private static AnchorPointPlacementTool _seededTool; private static float _priorAngle; private static AnchorPointPlacement _seededPlacement; private static Quaternion _priorPlacementRotation; private const float SeedDriftTolerance = 1f; internal static bool IsLive => _live; internal static StructurePreviewData GhostPreviewData { get { if (!_live) { return null; } try { PlayerBuilder builder = _builder; return ((Object)(object)builder == (Object)null) ? null : builder.previewData; } catch { return null; } } } internal static Material GhostValidationMaterial { get { if (!_live) { return null; } try { PlayerBuilder builder = _builder; PlacementTool val = (((Object)(object)builder == (Object)null) ? null : builder._placementTool); if ((Object)(object)val == (Object)null) { return null; } ValidationPlacementTool val2 = ((Il2CppObjectBase)val).TryCast(); return ((Object)(object)val2 == (Object)null) ? null : val2.validationMaterial; } catch { return null; } } } internal static bool Begin(MoveSession session) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Expected O, but got Unknown //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Expected O, but got Unknown //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Expected O, but got Unknown //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Invalid comparison between Unknown and I4 //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Expected O, but got Unknown //IL_01cd: 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_023c: 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_0282: Invalid comparison between Unknown and I4 //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Expected O, but got Unknown //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Expected O, but got Unknown //IL_02a7: Unknown result type (might be due to invalid IL or missing references) if (_live) { Plugin.Log.LogWarning((object)"[MovingDay] a ghost placement session was already live - ending it before starting another."); End(); } _gameLeftBuildMode = false; if (session == null) { return false; } Structure target = session.Target; if ((Object)(object)target == (Object)null) { Plugin.Log.LogWarning((object)"[MovingDay] the move target is gone - ghost placement cannot start."); return false; } StructureTemplate template; try { template = target.Template; } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(54, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] reading the move target's template threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); return false; } if ((Object)(object)template == (Object)null) { Plugin.Log.LogWarning((object)"[MovingDay] the move target has no build template - ghost placement cannot start."); return false; } PlayerBuilder val2 = ResolveBuilder(); if ((Object)(object)val2 == (Object)null) { return false; } bool flag2 = default(bool); BepInExInfoLogInterpolatedStringHandler val3; try { State currentState = val2.CurrentState; if ((int)currentState != 0) { ManualLogSource log2 = Plugin.Log; val3 = new BepInExInfoLogInterpolatedStringHandler(91, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[MovingDay] the player is already in build state "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(currentState); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" - not starting a ghost placement session."); } log2.LogInfo(val3); return false; } } catch (Exception ex2) { ManualLogSource log3 = Plugin.Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(54, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] reading the player builder's state threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex2); } log3.LogError(val); return false; } CaptureExemptColliders(session); ShellValidation.CaptureAtGhostStart(target); CaptureRotationSeed(target); _builder = val2; _live = true; _starting = true; try { ((StructureBuilder)val2).StructureTemplate = template; State currentState2 = val2.CurrentState; if ((int)currentState2 == 1) { Plugin.Log.LogInfo((object)"[MovingDay] template setter entered placement itself - skipping explicit _StartBuilding()."); } else if ((int)currentState2 == 0) { Plugin.Log.LogInfo((object)"[MovingDay] template setter did not change state - calling _StartBuilding()."); val2._StartBuilding(); } else { ManualLogSource log4 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(110, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[MovingDay] the template setter left the player builder in state "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(currentState2); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" - not calling _StartBuilding() on top of it."); } log4.LogWarning(val4); } } catch (Exception ex3) { ManualLogSource log5 = Plugin.Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(57, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] starting the game's placement session threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex3); } log5.LogError(val); _starting = false; Abandon(val2); return false; } _starting = false; State currentState3; try { currentState3 = val2.CurrentState; } catch (Exception ex4) { ManualLogSource log6 = Plugin.Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(57, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] re-reading the player builder's state threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex4); } log6.LogError(val); Abandon(val2); return false; } if ((int)currentState3 != 1) { ManualLogSource log7 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(115, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[MovingDay] _StartBuilding() left the player builder in state "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(currentState3); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(", expected PLACEMENT - ghost placement did not start."); } log7.LogWarning(val4); Abandon(val2); return false; } ManualLogSource log8 = Plugin.Log; val3 = new BepInExInfoLogInterpolatedStringHandler(83, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[MovingDay] ghost placement started ("); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(_exemptPointers.Count); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" collider(s) exempt from the footprint check)."); } log8.LogInfo(val3); return true; } internal static void End() { if (_ending) { return; } _ending = true; try { bool gameLeftBuildMode = _gameLeftBuildMode; _gameLeftBuildMode = false; if (!_live) { _builder = null; _starting = false; ClearExemptColliders(); return; } _live = false; _starting = false; PlayerBuilder builder = _builder; _builder = null; ClearExemptColliders(); if (gameLeftBuildMode) { Plugin.Log.LogInfo((object)"[MovingDay] ghost placement ended by the game's own build-mode exit."); } else { EndBuilding(builder); } RepairLeakedInputContext(builder); } finally { _ending = false; } } internal static void NoteBuildModeLeftByGame() { _gameLeftBuildMode = true; } internal static void Tick() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown if (!_live || _starting) { return; } try { VerifyRotationSeed(); ApplyRotationSeed(); } catch (Exception ex) { _seedApplied = true; _seedVerifyPending = false; ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(98, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] seeding the ghost's opening rotation threw - the ghost keeps the game's own rotation: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } } private static void CaptureRotationSeed(Structure target) { //IL_0006: 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_0034: Expected O, but got Unknown try { _seedYaw = ((Component)target).transform.eulerAngles.y; _haveSeedYaw = true; } catch (Exception ex) { _haveSeedYaw = false; ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(100, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] the move target's yaw could not be read, so the ghost opens at the game's own rotation: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); } } private static void ApplyRotationSeed() { //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown if (_seedApplied || !_haveSeedYaw) { return; } PlayerBuilder builder = _builder; AnchorPointPlacementTool val = (((Object)(object)builder == (Object)null) ? null : ResolveAnchorTool(builder)); bool flag = default(bool); if ((Object)(object)val == (Object)null) { if (++_seedWaitFrames >= 30) { _seedApplied = true; ManualLogSource log = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(124, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[MovingDay] no AnchorPointPlacementTool was readable within "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(30); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" frames of the ghost opening - it keeps the game's own rotation."); } log.LogWarning(val2); } return; } _seedApplied = true; float seedYaw = _seedYaw; _priorAngle = val._angle; _seededTool = val; val._angle = seedYaw; AnchorPointPlacement pointPlacement = val._pointPlacement; if (pointPlacement != null) { Quaternion rotation = ((PointPlacement)pointPlacement).rotation; Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles; _priorPlacementRotation = ((PointPlacement)pointPlacement).rotation; _seededPlacement = pointPlacement; ((PointPlacement)pointPlacement).rotation = Quaternion.Euler(eulerAngles.x, seedYaw, eulerAngles.z); } _seedWritten = seedYaw; _seedVerifyPending = true; ManualLogSource log2 = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(100, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[MovingDay] the ghost's opening rotation was seeded to the structure's yaw "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(seedYaw, "F2"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" on its first live frame."); } log2.LogInfo(val3); } private static void VerifyRotationSeed() { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown if (!_seedVerifyPending) { return; } _seedVerifyPending = false; PlayerBuilder builder = _builder; AnchorPointPlacementTool val = (((Object)(object)builder == (Object)null) ? null : ResolveAnchorTool(builder)); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)"[MovingDay] the seeded ghost rotation could not be checked - the placement tool was no longer readable a frame later."); return; } float angle = val._angle; float num = Mathf.Abs(Mathf.DeltaAngle(_seedWritten, angle)); if (num <= 1f) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(88, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[MovingDay] the seeded ghost rotation HELD: _angle reads "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(angle, "F2"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" one frame after being set to "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(_seedWritten, "F2"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } log.LogInfo(val2); } else { Plugin.Log.LogWarning((object)($"[MovingDay] the seeded ghost rotation did NOT hold: _angle was set to {_seedWritten:F2} and reads {angle:F2} one frame later ({num:F2} degrees off). " + "The game's placement reset happens later than the ghost's first live frame, so the seed needs to be applied later still.")); } } private static AnchorPointPlacementTool ResolveAnchorTool(PlayerBuilder builder) { PlacementTool placementTool = builder._placementTool; if (!((Object)(object)placementTool == (Object)null)) { return ((Il2CppObjectBase)placementTool).TryCast(); } return null; } private static void ResetRotationSeed() { RestoreRotationSeed(); _seedYaw = 0f; _haveSeedYaw = false; _seedApplied = false; _seedWaitFrames = 0; _seedWritten = 0f; _seedVerifyPending = false; } private static void RestoreRotationSeed() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) AnchorPointPlacementTool seededTool = _seededTool; AnchorPointPlacement seededPlacement = _seededPlacement; _seededTool = null; _seededPlacement = null; if ((Object)(object)seededTool == (Object)null && seededPlacement == null) { return; } try { if ((Object)(object)seededTool != (Object)null) { seededTool._angle = _priorAngle; } if (seededPlacement != null) { ((PointPlacement)seededPlacement).rotation = _priorPlacementRotation; } } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(135, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] the build tool's own rotation could not be put back after the move, so build mode may open at the moved structure's angle: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); } } internal static bool IsOurBuilder(PlayerBuilder builder) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown if (!_live || _starting) { return false; } if (builder == null || _builder == null) { return false; } if (MovingDayTool.ActiveSession == null) { return false; } try { return ((Il2CppObjectBase)builder).Pointer == ((Il2CppObjectBase)_builder).Pointer; } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(57, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] comparing the player builder identity threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); return false; } } internal static bool IsExemptCollider(Collider collider) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown if (!_live || _exemptPointers.Count == 0 || collider == null) { return false; } if (MovingDayTool.ActiveSession == null) { return false; } try { return _exemptPointers.Contains(((Il2CppObjectBase)collider).Pointer); } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(116, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] reading a collider's native identity threw, so it is treated as belonging to the structure being moved: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); return true; } } internal static bool TryGetCandidatePose(out Vector3 position, out Quaternion rotation) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_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_004f: 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) position = Vector3.zero; rotation = Quaternion.identity; if (!_live) { return false; } try { PlayerBuilder builder = _builder; if ((Object)(object)builder == (Object)null) { return false; } Placement buildPlacement = ((StructureBuilder)builder).BuildPlacement; if (buildPlacement == null) { return false; } position = buildPlacement.GetPivotPosition(); rotation = buildPlacement.GetPivotRotation(); return true; } catch { return false; } } internal static List AddExemptColliders(ICollection toIgnore) { //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown if (!_live || _exempt.Length == 0 || toIgnore == null) { return null; } if (MovingDayTool.ActiveSession == null) { return null; } bool flag = default(bool); if (_pendingInjections.Count >= 32) { if (!_injectionCapLogged) { _injectionCapLogged = true; ManualLogSource log = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(173, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(32); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" footprint ignore-list injections are still outstanding, so the matching cleanup is not running - no more will be made. The per-collider exemption still applies."); } log.LogWarning(val); } return null; } List list = null; try { for (int i = 0; i < _exempt.Length; i++) { Collider val2 = _exempt[i]; if (val2 != null && !toIgnore.Contains(val2)) { toIgnore.Add(val2); (list ?? (list = new List(_exempt.Length))).Add(val2); } } } catch (Exception ex) { if (!_injectionFailureLogged) { _injectionFailureLogged = true; ManualLogSource log2 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(129, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] adding the move target's colliders to the footprint ignore list failed ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") - the per-collider exemption still applies."); } log2.LogWarning(val); } } if (list != null) { _pendingInjections.Add(new PendingInjection(toIgnore, list)); } return list; } internal static void RemoveExemptColliders(ICollection toIgnore, List added) { if (added == null || added.Count == 0) { return; } for (int num = _pendingInjections.Count - 1; num >= 0; num--) { if (_pendingInjections[num].Added == added) { _pendingInjections.RemoveAt(num); break; } } RemoveInjected(toIgnore, added); } private static void RemoveInjected(ICollection toIgnore, List added) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown if (toIgnore == null || added == null) { return; } try { for (int i = 0; i < added.Count; i++) { Collider val = added[i]; if (val != null) { toIgnore.Remove(val); } } } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(85, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[MovingDay] removing the move target's colliders from a footprint ignore list threw: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex); } log.LogError(val2); } } private static void ReleaseInjections() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown if (_pendingInjections.Count > 0) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(107, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_pendingInjections.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" footprint ignore-list injection(s) outlived their validation call - removing them on teardown."); } log.LogWarning(val); for (int i = 0; i < _pendingInjections.Count; i++) { RemoveInjected(_pendingInjections[i].Collection, _pendingInjections[i].Added); } _pendingInjections.Clear(); } _injectionFailureLogged = false; _injectionCapLogged = false; } private static void Abandon(PlayerBuilder builder) { _live = false; _starting = false; _builder = null; ClearExemptColliders(); EndBuilding(builder); RepairLeakedInputContext(builder); } private static void RepairLeakedInputContext(PlayerBuilder builder) { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown if ((Object)(object)builder == (Object)null) { return; } bool flag = default(bool); try { PlayerBuilder_NewController val = ((Il2CppObjectBase)builder).TryCast(); if ((Object)(object)val == (Object)null) { return; } Context buildingContext = val.buildingContext; if ((Object)(object)buildingContext == (Object)null) { return; } InputManager inputManager = builder._inputManager; if (!((Object)(object)inputManager == (Object)null) && inputManager.HasContext(buildingContext)) { inputManager.RemoveContext(buildingContext); ManualLogSource log = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(234, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[MovingDay] the game's building input context ('"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(((Object)buildingContext).name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("') was still on the input stack after the ghost session ended - removed it. Left in place it silently kills the menu shortcut keys ('b', Esc, inventory, map) until the game is restarted."); } log.LogWarning(val2); } } catch (Exception ex) { ManualLogSource log2 = Plugin.Log; BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(76, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[MovingDay] checking the input context stack after the ghost session threw: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex); } log2.LogError(val3); } } private static void EndBuilding(PlayerBuilder builder) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_000c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)builder == (Object)null) { return; } try { if ((int)builder.CurrentState != 0) { builder._EndBuilding(); Plugin.Log.LogInfo((object)"[MovingDay] ghost placement ended."); } } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(55, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] ending the game's placement session threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } } private static void CaptureExemptColliders(MoveSession session) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown ClearExemptColliders(); IReadOnlyList targetColliders = session.TargetColliders; if (targetColliders == null || targetColliders.Count == 0) { return; } List list = new List(targetColliders.Count); bool flag = default(bool); for (int i = 0; i < targetColliders.Count; i++) { Collider val = targetColliders[i]; if (val == null) { continue; } try { _exemptPointers.Add(((Il2CppObjectBase)val).Pointer); list.Add(val); } catch (Exception ex) { ManualLogSource log = Plugin.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(68, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[MovingDay] reading a move-target collider's native identity threw: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex); } log.LogError(val2); } } _exempt = ((list.Count == 0) ? NoColliders : list.ToArray()); } private static void ClearExemptColliders() { ReleaseInjections(); _exempt = NoColliders; _exemptPointers.Clear(); ShellValidation.Reset(); ResetRotationSeed(); } private static PlayerBuilder ResolveBuilder() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown try { Character localCharacter = CharacterSpawnPatch.LocalCharacter; if ((Object)(object)localCharacter != (Object)null) { PlayerBuilder componentInChildren = ((Component)localCharacter).GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { return componentInChildren; } componentInChildren = ((Component)localCharacter).GetComponentInParent(); if ((Object)(object)componentInChildren != (Object)null) { return componentInChildren; } } PlayerBuilder obj = Object.FindObjectOfType(); if ((Object)(object)obj == (Object)null) { Plugin.Log.LogWarning((object)"[MovingDay] no PlayerBuilder could be found - ghost placement cannot start."); } return obj; } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(48, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] resolving the player builder threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); return null; } } } public static class HeavyAttackPatch { private const string TargetMethodName = "_HandleAttackHeavy"; private const string TargetLabel = "SSSGame.Controllers.PlayerDrive._HandleAttackHeavy"; private static bool _suppressionFailureLogged; internal static void Arm(Harmony harmony) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(PlayerDrive), "_HandleAttackHeavy", (Type[])null, (Type[])null); if (methodInfo == null) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(114, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("SSSGame.Controllers.PlayerDrive._HandleAttackHeavy"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" was not found - moving still works, but starting or cancelling a move will also swing a heavy attack."); } log.LogInfo(val); } else { ArmingReport.TryPatch(harmony, methodInfo, "SSSGame.Controllers.PlayerDrive._HandleAttackHeavy", new HarmonyMethod(typeof(HeavyAttackPatch), "HandleAttackHeavyPrefix", (Type[])null)); } } public static bool HandleAttackHeavyPrefix() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown try { return !MovingDayTool.OwnsRightClick(); } catch (Exception ex) { if (!_suppressionFailureLogged) { _suppressionFailureLogged = true; ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(152, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] deciding whether to suppress the heavy attack threw - the attack was allowed through, and this is reported once rather than once per swing: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } return true; } } } internal static class Hud { private static string _selectionName; internal static void ShowSelection(string displayName) { string text = (string.IsNullOrWhiteSpace(displayName) ? "this structure" : displayName); if (!(_selectionName == text)) { _selectionName = text; Display((NotificationType)0, "Moving: " + text); } } internal static void Clear() { _selectionName = null; } internal static void Notify(string message) { Display((NotificationType)0, message); } internal static void Warn(string message) { Display((NotificationType)1, message); } private static void Display(NotificationType type, string message) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_000c: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(message)) { return; } try { string text = message; NotificationMenu.Display(type, ref text, false); } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(47, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] showing the notification '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } } } internal sealed class MoveSession { private static readonly Collider[] NoColliders = (Collider[])(object)new Collider[0]; private bool _tornDown; internal Structure Target { get; private set; } internal IReadOnlyList TargetColliders { get; private set; } internal string DisplayName { get; } private MoveSession(Structure target, Collider[] colliders, string displayName) { Target = target; TargetColliders = colliders; DisplayName = displayName; } internal static MoveSession TryCreate(Structure target) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown if ((Object)(object)target == (Object)null) { return null; } try { return new MoveSession(target, CollectColliders(target), ResolveDisplayName(target)); } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(45, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] creating the move session threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); return null; } } internal bool IsTargetAlive() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown if (_tornDown) { return false; } try { if ((Object)(object)Target == (Object)null) { return false; } return Target.IsActive && !Target.Dismantled; } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(47, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] re-checking the move target threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); return false; } } internal void Teardown() { if (!_tornDown) { _tornDown = true; Target = null; TargetColliders = NoColliders; } } private static Collider[] CollectColliders(Structure target) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown try { Il2CppArrayBase componentsInChildren = ((Component)target).GetComponentsInChildren(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { Plugin.Log.LogWarning((object)"[MovingDay] the move target has no colliders - the self-overlap exemption will have nothing to ignore."); return NoColliders; } List list = new List(componentsInChildren.Length); for (int i = 0; i < componentsInChildren.Length; i++) { if ((Object)(object)componentsInChildren[i] != (Object)null) { list.Add(componentsInChildren[i]); } } return list.ToArray(); } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(53, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] collecting the target's colliders threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); return NoColliders; } } private static string ResolveDisplayName(Structure target) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown bool flag = default(bool); try { string customName = target.GetCustomName(); if (!string.IsNullOrWhiteSpace(customName)) { return customName; } } catch (Exception ex) { ManualLogSource log = Plugin.Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(52, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] reading the target's custom name threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } try { string structureName = target.StructureName; if (!string.IsNullOrWhiteSpace(structureName)) { return structureName; } } catch (Exception ex2) { ManualLogSource log2 = Plugin.Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(55, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] reading the target's structure name threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex2); } log2.LogError(val); } return "this structure"; } } internal enum MoveState { IDLE, PROMPTING, GHOST, CONFIRMING } public class MovingDayTool : MonoBehaviour { private static IntPtr _aimedPick = IntPtr.Zero; private static bool _aimedEligibilityFailureLogged; private static bool _notMasterLogged; private static bool _pendingConfirm; private static bool _pendingLost; private static Vector3 _confirmedPosition; private static Quaternion _confirmedRotation; private static bool _dialogOpen; private static bool _pendingDialogConfirm; private static bool _pendingDialogCancel; internal static MoveState CurrentState { get; private set; } = MoveState.IDLE; internal static MoveSession ActiveSession { get; private set; } internal static bool HasEligibleTargetAimed { get; private set; } private void Start() { ForceIdle(); Plugin.Log.LogInfo((object)"[MovingDay] tool ready."); } private void OnDestroy() { if (CurrentState != MoveState.IDLE) { Plugin.Log.LogInfo((object)"[MovingDay] the tool was destroyed with a move in progress - cancelling."); } ForceIdle(); } private void Update() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown GhostSession.Tick(); RefreshAimedEligibility(); try { PollInput(); } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(44, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] move-mode input handling threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); ForceIdle(); } } private static void PollInput() { if (_pendingLost) { _pendingLost = false; _pendingConfirm = false; Cancel("the confirmed placement could not be read", "The move was cancelled - the placement could not be read.", warn: true); } else if (_pendingConfirm) { _pendingConfirm = false; CompleteConfirmation(); } else if (_pendingDialogCancel) { _pendingDialogCancel = false; _pendingDialogConfirm = false; Cancel("the move was not confirmed"); } else if (_pendingDialogConfirm) { _pendingDialogConfirm = false; EnterGhost("the move was confirmed"); } else if (_dialogOpen) { if (Input.GetKeyDown((KeyCode)27)) { Plugin.Log.LogInfo((object)"[MovingDay] Escape was pressed while the confirmation dialog was open - cancelling the move."); Cancel("cancelled by the player"); } else if (ActiveSession == null || !ActiveSession.IsTargetAlive()) { Cancel("the target structure no longer exists", "The structure you were moving is gone.", warn: true); } else if (ConfirmDialog.HasVanished()) { Plugin.Log.LogWarning((object)"[MovingDay] the confirmation dialog went away without answering - treating it as a decline."); _dialogOpen = false; ConfirmDialog.Close(); Cancel("the confirmation dialog went away"); } } else if (CurrentState == MoveState.IDLE) { if (Input.GetKeyDown((KeyCode)324)) { TryStartMove(); } } else if (Input.GetKeyDown((KeyCode)324) || Input.GetKeyDown((KeyCode)27)) { Cancel("cancelled by the player"); } else if (ActiveSession != null && !ActiveSession.IsTargetAlive()) { Cancel("the target structure no longer exists", "The structure you were moving is gone."); } } internal static bool OwnsRightClick() { if (CurrentState == MoveState.IDLE) { return HasEligibleTargetAimed; } return true; } private static void RefreshAimedEligibility() { //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown bool flag2 = default(bool); try { if (CurrentState != MoveState.IDLE) { _aimedPick = IntPtr.Zero; HasEligibleTargetAimed = false; return; } Targeting.TryGetPickedPointer(out var pointer); if (pointer == _aimedPick) { return; } _aimedPick = pointer; Targeting.TryGetPickedStructure(out var structure); bool flag = false; if ((Object)(object)structure != (Object)null) { flag = SessionGate.IsLocalPlayerMaster(out var reason); if (!flag && !_notMasterLogged) { _notMasterLogged = true; ManualLogSource log = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(140, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] a structure is aimed at but this player cannot move it ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(reason); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("), so the right-click stays with the game's heavy attack. Reported once."); } log.LogInfo(val); } } HasEligibleTargetAimed = flag && Targeting.IsEligible(Targeting.ResolveRoot(structure), out var _); } catch (Exception ex) { _aimedPick = IntPtr.Zero; HasEligibleTargetAimed = false; if (!_aimedEligibilityFailureLogged) { _aimedEligibilityFailureLogged = true; ManualLogSource log2 = Plugin.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(114, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[MovingDay] working out whether a movable structure is aimed at threw - reported once rather than once per frame: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex); } log2.LogError(val2); } } } private static void TryStartMove() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Expected O, but got Unknown Targeting.TryGetPickedStructure(out var structure); if ((Object)(object)structure == (Object)null) { return; } structure = Targeting.ResolveRoot(structure); bool flag = default(bool); if (!Targeting.IsEligible(structure, out var reason)) { ManualLogSource log = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(32, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] selection refused: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(reason); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogInfo(val); Hud.Warn("Can't move this: " + reason + "."); return; } if (!SessionGate.IsLocalPlayerMaster(out var reason2)) { ManualLogSource log2 = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] move refused: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(reason2); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log2.LogInfo(val); Hud.Warn("Can't move this: " + reason2 + "."); return; } MoveSession moveSession = MoveSession.TryCreate(structure); if (moveSession == null) { Hud.Warn("Can't move this: its state could not be read."); return; } ActiveSession = moveSession; if (!Plugin.ConfigRequireConfirmation.Value) { EnterGhost("RequireConfirmation is off"); return; } CurrentState = MoveState.PROMPTING; _dialogOpen = true; string message = "Are you sure you want to move this? (" + moveSession.DisplayName + ")"; if (ConfirmDialog.TryOpen("Moving Day", message, moveSession.Target, OnDialogConfirmed, OnDialogDeclined)) { Hud.Clear(); ManualLogSource log3 = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(80, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] state IDLE -> PROMPTING: confirming the move of '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(moveSession.DisplayName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' before placement."); } log3.LogInfo(val); } else { _dialogOpen = false; Cancel("the confirmation dialog could not be opened", "The move was cancelled - the confirmation dialog could not be opened. Set RequireConfirmation to false to move without one.", warn: true); } } private static void EnterGhost(string reason) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown MoveSession activeSession = ActiveSession; if (activeSession == null || !activeSession.IsTargetAlive()) { Cancel("the target structure no longer exists", "The structure you were moving is gone.", warn: true); return; } MoveState currentState = CurrentState; CurrentState = MoveState.GHOST; if (!GhostSession.Begin(activeSession)) { Cancel("the ghost placement session could not be started", "Can't move this: the build preview could not be started.", warn: true); return; } Hud.ShowSelection(activeSession.DisplayName); Hud.Notify("Aim and left-click to place it, or right-click to cancel."); ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(98, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] state "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(currentState); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" -> GHOST: holding '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(activeSession.DisplayName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(activeSession.TargetColliders.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" collider(s) captured for the self-overlap exemption) - "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(reason); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogInfo(val); } internal static void OnPlacementConfirmed(Vector3 position, Quaternion rotation) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_00ee: 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) if (CurrentState == MoveState.GHOST && ActiveSession != null) { _confirmedPosition = position; _confirmedRotation = rotation; _pendingConfirm = true; CurrentState = MoveState.CONFIRMING; Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles; Plugin.Log.LogInfo((object)($"[MovingDay] state GHOST -> CONFIRMING: placement confirmed for '{ActiveSession.DisplayName}' at pos=({position.x:F2},{position.y:F2},{position.z:F2}) rot=({eulerAngles.x:F1},{eulerAngles.y:F1},{eulerAngles.z:F1}) " + "- the game's own build was suppressed, nothing was spawned or spent.")); } } internal static void OnPlacementLost() { if (CurrentState == MoveState.GHOST || CurrentState == MoveState.CONFIRMING) { _pendingLost = true; } } internal static void OnBuildModeExited() { if (!_pendingConfirm && !_pendingLost && CurrentState != MoveState.CONFIRMING) { Cancel("the game left build mode"); } } private static void CompleteConfirmation() { if (ActiveSession == null) { Cancel("the move session was gone by the time the placement was acted on", "The move was cancelled - it was lost before it could be applied.", warn: true); return; } ReleaseGhost(); Commit(); } private static void OnDialogConfirmed() { if (_dialogOpen) { _dialogOpen = false; _pendingDialogConfirm = true; } } private static void OnDialogDeclined() { if (_dialogOpen) { _dialogOpen = false; _pendingDialogCancel = true; } } private static void Commit() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown MoveSession activeSession = ActiveSession; MoveState currentState = CurrentState; string text = "the structure"; bool flag = false; bool flag2 = false; string failReason = null; bool flag3 = default(bool); try { if (activeSession != null) { text = activeSession.DisplayName; } flag = CommitEngine.TryMove(activeSession, _confirmedPosition, _confirmedRotation, out failReason); } catch (Exception ex) { ManualLogSource log = Plugin.Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(45, 2, ref flag3); if (flag3) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] committing the move of '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); flag2 = true; flag = false; failReason = "something went wrong applying it - check whether the structure moved"; } finally { ForceIdle(); if (flag) { ManualLogSource log2 = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(41, 2, ref flag3); if (flag3) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[MovingDay] state "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(currentState); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" -> IDLE: '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' was moved."); } log2.LogInfo(val2); Hud.Notify("Moved " + text + "."); } else { string text2 = (flag2 ? string.Empty : " - the original is untouched"); ManualLogSource log3 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(48, 4, ref flag3); if (flag3) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[MovingDay] state "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(currentState); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" -> IDLE: '"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' was NOT moved ("); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(failReason); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(")"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(text2); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("."); } log3.LogWarning(val3); Hud.Warn($"Couldn't move {text}: {failReason}."); } } } private static void ReleaseGhost() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown try { GhostSession.End(); } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(54, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] ending the ghost placement session threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } } private static void Cancel(string reason, string notice = "Move cancelled.", bool warn = false) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown if (CurrentState != MoveState.IDLE || ActiveSession != null) { MoveState currentState = CurrentState; ForceIdle(); if (warn) { Hud.Warn(notice); } else { Hud.Notify(notice); } ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(30, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] state "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(currentState); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" -> IDLE ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(reason); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")."); } log.LogInfo(val); } } private static void ForceIdle() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown MoveSession activeSession = ActiveSession; ActiveSession = null; CurrentState = MoveState.IDLE; _pendingConfirm = false; _pendingLost = false; _dialogOpen = false; _pendingDialogConfirm = false; _pendingDialogCancel = false; bool flag = default(bool); try { ConfirmDialog.Close(); } catch (Exception ex) { ManualLogSource log = Plugin.Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(51, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] closing the confirmation dialog threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } ReleaseGhost(); if (activeSession != null) { try { activeSession.Teardown(); } catch (Exception ex2) { ManualLogSource log2 = Plugin.Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(49, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] tearing down the move session threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex2); } log2.LogError(val); } } Hud.Clear(); } } internal static class Occupants { internal enum ReseatPath { Anchor, Delta } internal sealed class Occupant { internal Villager Villager { get; } internal string VillagerName { get; } internal string InteractionTypeName { get; } internal string OwnerName { get; } internal ReseatPath Path { get; } internal string PathName { get { if (Path != ReseatPath.Anchor) { return "delta"; } return "anchor"; } } internal Transform Anchor { get; } internal Transform Root { get; } internal Vector3 LocalPosition { get; } internal Quaternion LocalRotation { get; } private Occupant(Villager villager, string villagerName, string interactionTypeName, string ownerName, ReseatPath path, Transform anchor, Transform root, Vector3 localPosition, Quaternion localRotation) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) Villager = villager; VillagerName = villagerName; InteractionTypeName = interactionTypeName; OwnerName = ownerName; Path = path; Anchor = anchor; Root = root; LocalPosition = localPosition; LocalRotation = localRotation; } internal static Occupant OnAnchor(Villager villager, string villagerName, string interactionTypeName, string ownerName, Transform anchor) { //IL_0008: 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) return new Occupant(villager, villagerName, interactionTypeName, ownerName, ReseatPath.Anchor, anchor, null, Vector3.zero, Quaternion.identity); } internal static Occupant OnDelta(Villager villager, string villagerName, string interactionTypeName, string ownerName, Transform root, Vector3 localPosition, Quaternion localRotation) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) return new Occupant(villager, villagerName, interactionTypeName, ownerName, ReseatPath.Delta, null, root, localPosition, localRotation); } } private const string Prefix = "[MovingDay][commit][occupants]"; internal static List Collect(Structure root, string structureName) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Expected O, but got Unknown //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Expected O, but got Unknown List list = new List(); bool flag = default(bool); if ((Object)(object)root == (Object)null) { ManualLogSource log = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(62, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][commit][occupants]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(structureName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': no structure to scan - anyone inside will be left behind."); } log.LogWarning(val); return list; } Transform transform; try { transform = ((Component)root).transform; } catch (Exception ex) { ManualLogSource log2 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(102, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][commit][occupants]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(structureName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': reading the root transform threw ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") - the move goes ahead, but anyone inside will be left behind."); } log2.LogWarning(val); return list; } if ((Object)(object)transform == (Object)null) { ManualLogSource log3 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(92, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][commit][occupants]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(structureName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': the root has no transform - the move goes ahead, but anyone inside will be left behind."); } log3.LogWarning(val); return list; } int num = 0; int occupiedCount = 0; try { num = Sweep(root, transform, list, out occupiedCount); } catch (Exception ex2) { ManualLogSource log4 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(155, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][commit][occupants]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(structureName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': scanning for occupants failed after "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(list.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" were collected ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex2.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") - the move goes ahead and those are still re-seated, but any others inside will be left behind."); } log4.LogWarning(val); return list; } ManualLogSource log5 = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(98, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][commit][occupants]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(structureName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("': scanned "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" Interaction component(s), "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(occupiedCount); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" holding an active session, found "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(list.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" occupant(s) to re-seat."); } log5.LogInfo(val2); return list; } internal static void Reseat(List occupants, string structureName) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown if (occupants == null || occupants.Count == 0) { return; } bool flag = default(bool); for (int i = 0; i < occupants.Count; i++) { Occupant occupant = occupants[i]; if (occupant == null) { continue; } try { ReseatOne(occupant, structureName); } catch (Exception ex) { ManualLogSource log = Plugin.Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(26, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][commit][occupants]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(structureName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': re-seating '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(occupant.VillagerName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } } } private static int Sweep(Structure root, Transform rootTransform, List occupants, out int occupiedCount) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Expected O, but got Unknown occupiedCount = 0; Il2CppArrayBase componentsInChildren = ((Component)root).GetComponentsInChildren(true); if (componentsInChildren == null) { return 0; } HashSet seen = new HashSet(); bool flag = default(bool); for (int i = 0; i < componentsInChildren.Length; i++) { Interaction val; try { val = componentsInChildren[i]; } catch (Exception ex) { ManualLogSource log = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(45, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][commit][occupants]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" reading Interaction["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(i); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] threw: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" - skipping it."); } log.LogWarning(val2); continue; } if ((Object)(object)val == (Object)null) { continue; } List activeSessions; try { activeSessions = val._activeSessions; } catch (Exception ex2) { ManualLogSource log2 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(69, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][commit][occupants]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" reading _activeSessions on Interaction["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(i); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] ('"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(SafeName((Object)(object)val)); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("') threw: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex2.Message); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" - skipping it."); } log2.LogWarning(val2); continue; } if (activeSessions == null || activeSessions.Count == 0) { continue; } occupiedCount++; try { CollectFromInteraction(val, activeSessions, rootTransform, occupants, seen); } catch (Exception ex3) { ManualLogSource log3 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(78, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][commit][occupants]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" reading the occupied Interaction["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(i); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] ('"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(SafeName((Object)(object)val)); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("', runtime type "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(TypeNameOf((Object)(object)val)); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(") threw: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex3.Message); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" - skipping it."); } log3.LogWarning(val2); } } return componentsInChildren.Length; } private static void CollectFromInteraction(Interaction interaction, List sessions, Transform rootTransform, List occupants, HashSet seen) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Expected O, but got Unknown string text = TypeNameOf((Object)(object)interaction); string text2 = SafeName((Object)(object)interaction); bool flag = default(bool); for (int i = 0; i < sessions.Count; i++) { InteractionSession val; try { val = sessions[i]; } catch (Exception ex) { ManualLogSource log = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(55, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][commit][occupants]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("): reading active session["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(i); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] threw: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" - skipping it."); } log.LogWarning(val2); continue; } if (val == null) { continue; } IInteractionAgent agent = val.Agent; if (agent == null) { continue; } Villager val3 = ((Il2CppObjectBase)agent).TryCast(); if ((Object)(object)val3 == (Object)null || !seen.Add(((Il2CppObjectBase)val3).Pointer)) { continue; } try { CollectOne(val3, text, text2, rootTransform, occupants); } catch (Exception ex2) { ManualLogSource log2 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(78, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][commit][occupants]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("): collecting the villager in session["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(i); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] threw: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex2.Message); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" - it will be left behind."); } log2.LogWarning(val2); } } } private static void CollectOne(Villager villager, string typeName, string ownerName, Transform rootTransform, List occupants) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Expected O, but got Unknown //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_033d: 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_02a4: Expected O, but got Unknown //IL_025e: 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) //IL_0381: Expected O, but got Unknown //IL_0407: Unknown result type (might be due to invalid IL or missing references) string text = SafeVillagerName(villager); Transform val; bool flag = default(bool); try { val = villager._mtTarget; } catch (Exception ex) { ManualLogSource log = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(73, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][commit][occupants]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" occupant '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' on '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ownerName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(typeName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("): reading _mtTarget threw: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" - taking the delta path."); } log.LogWarning(val2); val = null; } bool flag2 = false; if ((Object)(object)val != (Object)null) { try { flag2 = val.IsChildOf(rootTransform); } catch (Exception ex2) { ManualLogSource log2 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(81, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][commit][occupants]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" occupant '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' on '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ownerName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(typeName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("): _mtTarget.IsChildOf(root) threw: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex2.Message); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" - taking the delta path."); } log2.LogWarning(val2); flag2 = false; } } string text2 = $"IsSleeping={IsSleepingText(villager)}, _mtActive={MtActiveText(villager)}, _mtForceRotation={MtForceRotationText(villager)}"; BepInExInfoLogInterpolatedStringHandler val3; if (flag2) { occupants.Add(Occupant.OnAnchor(villager, text, typeName, ownerName, val)); ManualLogSource log3 = Plugin.Log; val3 = new BepInExInfoLogInterpolatedStringHandler(104, 7, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted("[MovingDay][commit][occupants]"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" occupant '"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' on '"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ownerName); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' ("); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(typeName); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("): path=anchor, "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(text2); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", _mtTarget='"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(SafeName((Object)(object)val)); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' at "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(FmtFull(SafePosition(val))); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" (a child of the move root, so it rides the move)."); } log3.LogInfo(val3); return; } Transform transform = ((Component)villager).transform; if ((Object)(object)transform == (Object)null) { ManualLogSource log4 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(90, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][commit][occupants]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" occupant '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' on '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ownerName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(typeName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("): no transform to read a pre-move pose from - it will be left behind."); } log4.LogWarning(val2); return; } Vector3 position = transform.position; Quaternion rotation = transform.rotation; Vector3 localPosition = rootTransform.InverseTransformPoint(position); Quaternion localRotation = Quaternion.Inverse(rootTransform.rotation) * rotation; occupants.Add(Occupant.OnDelta(villager, text, typeName, ownerName, rootTransform, localPosition, localRotation)); string text3 = (((Object)(object)val == (Object)null) ? "_mtTarget=" : ("_mtTarget='" + SafeName((Object)(object)val) + "' but NOT a child of the move root")); ManualLogSource log5 = Plugin.Log; val3 = new BepInExInfoLogInterpolatedStringHandler(100, 7, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted("[MovingDay][commit][occupants]"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" occupant '"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' on '"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ownerName); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' ("); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(typeName); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("): path=delta, "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(text2); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(text3); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" - carrying its pre-move pose "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(FmtFull(position)); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" through the root's own movement."); } log5.LogInfo(val3); } private static void ReseatOne(Occupant occupant, string structureName) { //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Expected O, but got Unknown //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Expected O, but got Unknown //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03ff: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0286: 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_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_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Expected O, but got Unknown //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Expected O, but got Unknown Villager villager = occupant.Villager; bool flag = default(bool); if ((Object)(object)villager == (Object)null) { ManualLogSource log = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(48, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][commit][occupants]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(structureName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': skipping '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(occupant.VillagerName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(occupant.PathName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" path) - the villager is gone."); } log.LogWarning(val); return; } Transform transform = ((Component)villager).transform; if ((Object)(object)transform == (Object)null) { ManualLogSource log2 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(57, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][commit][occupants]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(structureName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': skipping '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(occupant.VillagerName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(occupant.PathName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" path) - the villager has no transform."); } log2.LogWarning(val); return; } Vector3 position = transform.position; Vector3 val2; Quaternion val3; string text; if (occupant.Path == ReseatPath.Anchor) { Transform anchor = occupant.Anchor; if ((Object)(object)anchor == (Object)null) { ManualLogSource log3 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(47, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][commit][occupants]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(structureName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': skipping '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(occupant.VillagerName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' - the anchor on '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(occupant.OwnerName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(occupant.InteractionTypeName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") is gone."); } log3.LogWarning(val); return; } val2 = anchor.position; val3 = anchor.rotation; text = ", anchor '" + SafeName((Object)(object)anchor) + "' " + FmtFull(val2); } else { Transform root = occupant.Root; if ((Object)(object)root == (Object)null) { ManualLogSource log4 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(78, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][commit][occupants]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(structureName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': skipping '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(occupant.VillagerName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' - the move root is gone, so its pose cannot be reconstructed."); } log4.LogWarning(val); return; } val2 = root.TransformPoint(occupant.LocalPosition); val3 = root.rotation * occupant.LocalRotation; text = ", no anchor - pose reconstructed from the root's own movement"; } try { villager.AbortMatchTarget(); } catch (Exception ex) { ManualLogSource log5 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(103, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][commit][occupants]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(structureName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': AbortMatchTarget() on '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(occupant.VillagerName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" - re-seating anyway, but a running match-target may pull it back."); } log5.LogWarning(val); } transform.SetPositionAndRotation(val2, val3); Vector3 position2 = transform.position; ManualLogSource log6 = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(59, 9, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted("[MovingDay][commit][occupants]"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" '"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(structureName); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("': re-seated '"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(occupant.VillagerName); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("' on '"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(occupant.OwnerName); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("' ("); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(occupant.InteractionTypeName); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(") via the "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(occupant.PathName); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" path: before "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(FmtFull(position)); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" -> after "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(FmtFull(position2)); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(text); } log6.LogInfo(val4); } private static string TypeNameOf(Object obj) { if (obj == null) { return ""; } try { return ((MemberInfo)obj.GetIl2CppType()).Name; } catch (Exception ex) { return ""; } } private static string SafeVillagerName(Villager villager) { try { return ((Character)villager).GetName() ?? ""; } catch (Exception ex) { return ""; } } private static string IsSleepingText(Villager villager) { try { VillagerSurvival survival = villager.GetSurvival(); if ((Object)(object)survival == (Object)null) { return ""; } return survival.IsSleeping.ToString(); } catch (Exception ex) { return ""; } } private static string MtActiveText(Villager villager) { try { return villager._mtActive.ToString(); } catch (Exception ex) { return ""; } } private static string MtForceRotationText(Villager villager) { try { return villager._mtForceRotation.ToString(); } catch (Exception ex) { return ""; } } private static Vector3 SafePosition(Transform transform) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) try { return transform.position; } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(37, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][commit][occupants]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" reading a transform position threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); return Vector3.zero; } } private static string SafeName(Object obj) { try { return (obj != (Object)null) ? obj.name : ""; } catch (Exception ex) { return ""; } } private static string FmtFull(Vector3 v) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) return $"({v.x:R},{v.y:R},{v.z:R})"; } } public static class PlacementPatches { private static readonly Type[] BuildArgs = new Type[2] { typeof(Settlement), typeof(Structure) }; internal static void Arm(Harmony harmony) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_00d3: Expected O, but got Unknown //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Expected O, but got Unknown //IL_0133: Expected O, but got Unknown //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Expected O, but got Unknown //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Expected O, but got Unknown HarmonyMethod prefix = new HarmonyMethod(typeof(PlacementPatches), "BuildPrefix", (Type[])null); HarmonyMethod postfix = new HarmonyMethod(typeof(PlacementPatches), "EndBuildingPostfix", (Type[])null); ArmDeclared(harmony, typeof(PlayerBuilder), "Build", BuildArgs, required: true, prefix); ArmDeclared(harmony, typeof(PlayerBuilder_NewController), "Build", BuildArgs, required: false, prefix); ArmDeclared(harmony, typeof(FootprintValidator), "_CheckValidFootprint", new Type[3] { typeof(BoxCollider), typeof(Il2CppReferenceArray), typeof(ICollection) }, required: true, new HarmonyMethod(typeof(PlacementPatches), "CheckFootprintIgnorePrefix", (Type[])null), new HarmonyMethod(typeof(PlacementPatches), "CheckFootprintIgnorePostfix", (Type[])null)); ArmDeclared(harmony, typeof(StructureLogic), "ValidateFootprint", new Type[2] { typeof(LayerMask), typeof(ICollection) }, required: true, new HarmonyMethod(typeof(PlacementPatches), "ValidateFootprintPrefix", (Type[])null), new HarmonyMethod(typeof(PlacementPatches), "ValidateFootprintPostfix", (Type[])null)); ArmDeclared(harmony, typeof(FootprintValidator), "_CheckValidFootprint", new Type[2] { typeof(BoxCollider), typeof(Collider) }, required: true, new HarmonyMethod(typeof(PlacementPatches), "CheckValidFootprintPrefix", (Type[])null)); ArmDeclared(harmony, typeof(PlayerBuilder), "_EndBuilding", Type.EmptyTypes, required: true, null, postfix); ArmDeclared(harmony, typeof(PlayerBuilder_NewController), "_EndBuilding", Type.EmptyTypes, required: false, null, postfix); ArmDeclared(harmony, typeof(PlayerBuilder_Invector), "_EndBuilding", Type.EmptyTypes, required: false, null, postfix); ArmDeclared(harmony, typeof(PlayerBuilder_Naughty), "_EndBuilding", Type.EmptyTypes, required: false, null, postfix); HarmonyMethod postfix2 = new HarmonyMethod(typeof(ShellValidation), "ValidateFootprintShellPostfix", (Type[])null); ArmDeclared(harmony, typeof(StructureLogic), "ValidateFootprint", new Type[2] { typeof(LayerMask), typeof(ICollection) }, required: true, null, postfix2); ArmDeclared(harmony, typeof(StructureLogic), "ValidateFootprint", new Type[2] { typeof(LayerMask), typeof(Collider) }, required: true, null, postfix2); } public static bool BuildPrefix(PlayerBuilder __instance) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) if (!GhostSession.IsOurBuilder(__instance)) { return true; } try { Placement buildPlacement = ((StructureBuilder)__instance).BuildPlacement; if (buildPlacement == null) { Plugin.Log.LogWarning((object)"[MovingDay] the confirmed placement could not be read - abandoning the move rather than guessing where it goes."); MovingDayTool.OnPlacementLost(); } else { Vector3 pivotPosition = buildPlacement.GetPivotPosition(); Quaternion pivotRotation = buildPlacement.GetPivotRotation(); MovingDayTool.OnPlacementConfirmed(pivotPosition, pivotRotation); } } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(53, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] capturing the confirmed placement threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); MovingDayTool.OnPlacementLost(); } return false; } public static bool CheckValidFootprintPrefix(Collider colliderToTest, ref bool __result) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown try { if (!GhostSession.IsExemptCollider(colliderToTest)) { return true; } __result = true; return false; } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(124, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] the footprint exemption check threw, so this collider is answered as valid rather than handed back to the game: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); __result = true; return false; } } public static void ValidateFootprintPrefix(ICollection toIgnoreFromOverlap, out List __state) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown __state = null; try { __state = GhostSession.AddExemptColliders(toIgnoreFromOverlap); } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(55, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] the footprint ignore-list injection threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } } public static void ValidateFootprintPostfix(ICollection toIgnoreFromOverlap, List __state) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown try { GhostSession.RemoveExemptColliders(toIgnoreFromOverlap, __state); } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(53, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] the footprint ignore-list cleanup threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } } public static void CheckFootprintIgnorePrefix(ICollection collidersToIgnore, out List __state) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown __state = null; try { __state = GhostSession.AddExemptColliders(collidersToIgnore); } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(55, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] the footprint ignore-list injection threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } } public static void CheckFootprintIgnorePostfix(ICollection collidersToIgnore, List __state) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown try { GhostSession.RemoveExemptColliders(collidersToIgnore, __state); } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(53, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] the footprint ignore-list cleanup threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } } public static void EndBuildingPostfix(PlayerBuilder __instance) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown try { if (GhostSession.IsOurBuilder(__instance)) { GhostSession.NoteBuildModeLeftByGame(); MovingDayTool.OnBuildModeExited(); } } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(55, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] handling the game's build-mode exit threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } } private static void ArmDeclared(Harmony harmony, Type type, string name, Type[] parameters, bool required, HarmonyMethod prefix = null, HarmonyMethod postfix = null) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.DeclaredMethod(type, name, parameters, (Type[])null); if (methodInfo == null && !required) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(81, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(type.Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is not overridden here - the patched base implementation covers it."); } log.LogInfo(val); } else { ArmingReport.TryPatch(harmony, methodInfo, type.FullName + "." + name, prefix, postfix); } } } [BepInPlugin("smithio.aska.movingday", "Aska Moving Day", "1.0.1")] public class Plugin : BasePlugin { public const string PluginGuid = "smithio.aska.movingday"; public const string PluginName = "Aska Moving Day"; public const string PluginVersion = "1.0.1"; internal static ManualLogSource Log; internal static ConfigEntry ConfigRequireConfirmation; public override void Load() { //IL_0035: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown //IL_0071: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_007d: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown Log = ((BasePlugin)this).Log; ConfigRequireConfirmation = ((BasePlugin)this).Config.Bind("MovingDay", "RequireConfirmation", true, "Ask for confirmation before a structure is actually moved."); ClassInjector.RegisterTypeInIl2Cpp(); Harmony val = new Harmony("smithio.aska.movingday"); ArmingReport.TryPatch(val, AccessTools.Method(typeof(Character), "Spawned", (Type[])null, (Type[])null), "SSSGame.Character.Spawned", null, new HarmonyMethod(typeof(CharacterSpawnPatch), "Spawned", (Type[])null)); PlacementPatches.Arm(val); HeavyAttackPatch.Arm(val); ArmingReport.LogTotal(); ManualLogSource log = Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(10, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("Aska Moving Day"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" v"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("1.0.1"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" loaded."); } log.LogInfo(val2); } } internal static class PoseMath { internal static bool IsUsable(Vector3 v) { //IL_0000: 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_001a: Unknown result type (might be due to invalid IL or missing references) if (IsFinite(v.x) && IsFinite(v.y)) { return IsFinite(v.z); } return false; } internal static bool IsUsable(Quaternion q) { //IL_0000: 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_001a: 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_0036: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) if (!IsFinite(q.x) || !IsFinite(q.y) || !IsFinite(q.z) || !IsFinite(q.w)) { return false; } return q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w > 1E-06f; } internal static bool IsFinite(float f) { if (!float.IsNaN(f)) { return !float.IsInfinity(f); } return false; } } internal static class SessionGate { private static NetworkSession _session; internal static bool IsLocalPlayerMaster(out string reason) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown try { NetworkSession session = GetSession(); if ((Object)(object)session == (Object)null) { reason = "the network session could not be found"; return false; } if (!session.isMaster) { reason = "only the host can move structures"; return false; } } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(47, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] reading the network session threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); reason = "the network session could not be read"; return false; } reason = null; return true; } private static NetworkSession GetSession() { if ((Object)(object)_session == (Object)null) { _session = Object.FindObjectOfType(); } return _session; } } internal static class ShellValidation { private sealed class Annex { internal Structure Structure { get; } internal string Name { get; } internal StructureLogic Logic { get; } internal BoxCollider Footprint { get; } internal Vector3 OffsetInRoot { get; } internal Quaternion RotationInRoot { get; } internal Vector3 HalfExtents { get; } internal bool BlockedThisFrame { get; set; } internal string ObstacleThisFrame { get; set; } internal Annex(Structure structure, string name, StructureLogic logic, BoxCollider footprint, Vector3 offsetInRoot, Quaternion rotationInRoot, Vector3 halfExtents) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) Structure = structure; Name = name; Logic = logic; Footprint = footprint; OffsetInRoot = offsetInRoot; RotationInRoot = rotationInRoot; HalfExtents = halfExtents; } } private const string Prefix = "[MovingDay][shell]"; private const int GhostResolveRetryInterval = 5; private static readonly List Annexes = new List(); private static readonly List Candidates = new List(); private static readonly Collider[] SingleCandidate = (Collider[])(object)new Collider[1]; private static int _maskValue; private static bool _maskCaptured; private static bool _failureLogged; private static bool _delegationFailureLogged; private static bool _overlayFailureLogged; private static bool _footprintDecisionLogged; private static ICollection _ignoreCollection; private static bool _verdictSeen; private static string _verdictText; private static string _notifiedObstacleName; private static bool _notifyFailureLogged; private static StructureLogic _ghostLogic; private static IntPtr _ghostLogicPointer; private static GameObject _ghostPreview; private static int _ghostResolveCountdown; private static readonly string[] RawPrefabPrefixes = new string[3] { "House_", "Building", "Structure_" }; internal static bool IsBlocked { get; private set; } internal static string BlockingObstacleName { get; private set; } internal static void CaptureAtGhostStart(Structure root) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown Reset(); bool flag = default(bool); if ((Object)(object)root == (Object)null) { ManualLogSource log = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(93, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" no root structure - the annexes of this building are NOT validated, only its root footprint."); } log.LogWarning(val); return; } try { Collect(root); } catch (Exception ex) { ManualLogSource log2 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(144, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" classifying the building's annexes failed after "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(Annexes.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" were collected ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") - the move goes ahead and those are still validated, but any others are not."); } log2.LogWarning(val); } if (Annexes.Count > 0) { ResolveDelegatedRule(); } } private static void ResolveDelegatedRule() { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown bool flag = default(bool); try { _ignoreCollection = ((Il2CppObjectBase)new List()).TryCast>(); if (_ignoreCollection == null) { ManualLogSource log = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(180, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" the game's own footprint rule is NOT available (an Il2Cpp ICollection could not be obtained) - NO annex is validated on this move and nothing here can block a placement."); } log.LogWarning(val); } else { ManualLogSource log2 = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(178, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" annex hits are judged by the game's own rule: FootprintValidator._CheckValidFootprint(BoxCollider, Collider[], ICollection), called on each annex's own StructureLogic."); } log2.LogInfo(val2); } } catch (Exception ex) { _ignoreCollection = null; ManualLogSource log3 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(127, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" the game's own footprint rule is NOT available ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") - NO annex is validated on this move and nothing here can block a placement."); } log3.LogWarning(val); } } internal static void Reset() { AnnexOverlay.Reset(); Annexes.Clear(); Candidates.Clear(); SingleCandidate[0] = null; _maskValue = 0; _maskCaptured = false; _failureLogged = false; _delegationFailureLogged = false; _overlayFailureLogged = false; _footprintDecisionLogged = false; _ignoreCollection = null; _verdictSeen = false; _verdictText = null; _notifiedObstacleName = null; _notifyFailureLogged = false; _ghostLogic = null; _ghostLogicPointer = IntPtr.Zero; _ghostPreview = null; _ghostResolveCountdown = 0; IsBlocked = false; BlockingObstacleName = null; } public static void ValidateFootprintShellPostfix(StructureLogic __instance, LayerMask objectsMask, ref bool __result) { //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown //IL_0074: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) try { if (__instance == null || MovingDayTool.CurrentState != MoveState.GHOST || MovingDayTool.ActiveSession == null || !GhostSession.IsLive || Annexes.Count == 0 || !IsGhostLogic(__instance)) { return; } int num = (_maskCaptured ? _maskValue : ((LayerMask)(ref objectsMask)).value); if (num != 0 && GhostSession.TryGetCandidatePose(out var position, out var rotation) && PoseMath.IsUsable(position) && PoseMath.IsUsable(rotation)) { Annex blockingAnnex; Collider blockingCollider; bool num2 = Evaluate(num, position, rotation, out blockingAnnex, out blockingCollider); RecordVerdict(num2 ? blockingAnnex : null, blockingCollider); if (num2) { __result = false; } SyncOverlay(); } } catch (Exception ex) { if (!_failureLogged) { _failureLogged = true; ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(100, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" the annex footprint check threw - the game's own verdict is left untouched (logged once per move): "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } } } private static void Collect(Structure root) { //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Expected O, but got Unknown //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Expected O, but got Unknown Transform transform = ((Component)root).transform; bool flag = default(bool); if ((Object)(object)transform == (Object)null) { ManualLogSource log = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(101, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" the root has no transform - the annexes of this building are NOT validated, only its root footprint."); } log.LogWarning(val); return; } CaptureMask(root); ModularBuilding modularBuilding = root.GetModularBuilding(); BepInExInfoLogInterpolatedStringHandler val2; if ((Object)(object)modularBuilding == (Object)null) { ManualLogSource log2 = Plugin.Log; val2 = new BepInExInfoLogInterpolatedStringHandler(135, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(SafeName((Object)(object)root)); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("': root.GetModularBuilding() is null, so no descendant can be confirmed as one of its modules - only the root footprint is validated."); } log2.LogInfo(val2); return; } Il2CppArrayBase componentsInChildren = ((Component)root).GetComponentsInChildren(true); if (componentsInChildren == null) { ManualLogSource log3 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(99, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(SafeName((Object)(object)root)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': GetComponentsInChildren(true) returned null - only the root footprint is validated."); } log3.LogWarning(val); return; } IntPtr pointer = ((Il2CppObjectBase)root).Pointer; int length = componentsInChildren.Length; for (int i = 0; i < length; i++) { try { Structure val3 = componentsInChildren[i]; if (!((Object)(object)val3 == (Object)null) && !(((Il2CppObjectBase)val3).Pointer == pointer)) { CollectOne(val3, modularBuilding, transform); } } catch (Exception ex) { ManualLogSource log4 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(65, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" descendant["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(i); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("]: reading it threw ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") - its volume is NOT validated."); } log4.LogWarning(val); } } ManualLogSource log5 = Plugin.Log; val2 = new BepInExInfoLogInterpolatedStringHandler(122, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(SafeName((Object)(object)root)); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("': walked "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(length); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" descendant Structure component(s) (the root is one of them), classified "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(Annexes.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" as structural annex(es) to validate."); } log5.LogInfo(val2); } private static void CollectOne(Structure child, ModularBuilding rootBuilding, Transform rootTransform) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Expected O, but got Unknown //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Expected O, but got Unknown //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Expected O, but got Unknown //IL_0288: 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_0291: 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_029c: 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_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: 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_02d4: 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_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Expected O, but got Unknown //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Expected O, but got Unknown //IL_030f: 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_037e: 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_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Expected O, but got Unknown //IL_0456: Unknown result type (might be due to invalid IL or missing references) //IL_0470: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Unknown result type (might be due to invalid IL or missing references) //IL_04b9: Unknown result type (might be due to invalid IL or missing references) BuildingModule module = child.GetModule(); if ((Object)(object)module == (Object)null) { return; } string text = SafeName((Object)(object)child); bool isActive = child.IsActive; bool dismantled = child.Dismantled; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val; if (!isActive) { ManualLogSource log = Plugin.Log; val = new BepInExInfoLogInterpolatedStringHandler(168, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" skipped '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': Structure.IsActive is false, so it does not stand in the world (an unfinished or superseded structure left in the hierarchy) - its volume is NOT validated."); } log.LogInfo(val); return; } if (dismantled) { ManualLogSource log2 = Plugin.Log; val = new BepInExInfoLogInterpolatedStringHandler(110, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" skipped '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': Structure.Dismantled is true, so it is on its way out of the world - its volume is NOT validated."); } log2.LogInfo(val); return; } if (!rootBuilding.HasModule(module)) { ManualLogSource log3 = Plugin.Log; val = new BepInExInfoLogInterpolatedStringHandler(114, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" skipped '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': it has a BuildingModule but the root's ModularBuilding does not own it - its volume is NOT validated."); } log3.LogInfo(val); return; } StructureTemplate template = child.Template; if ((Object)(object)template != (Object)null && template.ignoreCollisionValidation) { ManualLogSource log4 = Plugin.Log; val = new BepInExInfoLogInterpolatedStringHandler(112, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" skipped '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': its template sets ignoreCollisionValidation - the game does not collision-check this volume either."); } log4.LogInfo(val); return; } StructureLogic componentInChildren = ((Component)child).GetComponentInChildren(true); if ((Object)(object)componentInChildren == (Object)null) { ManualLogSource log5 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(106, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" skipped '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("': no StructureLogic on it, so it has no footprint volume to test - its volume is NOT validated."); } log5.LogWarning(val2); return; } BoxCollider footprintCollider = componentInChildren.FootprintCollider; if ((Object)(object)footprintCollider == (Object)null) { ManualLogSource log6 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(87, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" skipped '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("': its StructureLogic has no FootprintCollider - its volume is NOT validated."); } log6.LogWarning(val2); return; } Transform transform = ((Component)footprintCollider).transform; if ((Object)(object)transform == (Object)null) { ManualLogSource log7 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(82, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" skipped '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("': its FootprintCollider has no transform - its volume is NOT validated."); } log7.LogWarning(val2); return; } Vector3 size = footprintCollider.size; Vector3 lossyScale = transform.lossyScale; Vector3 val3 = transform.TransformPoint(footprintCollider.center); Quaternion rotation = transform.rotation; Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(Mathf.Abs(size.x * lossyScale.x) * 0.5f, Mathf.Abs(size.y * lossyScale.y) * 0.5f, Mathf.Abs(size.z * lossyScale.z) * 0.5f); if (!PoseMath.IsUsable(val3) || !PoseMath.IsUsable(val4) || !PoseMath.IsUsable(rotation)) { ManualLogSource log8 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(119, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" skipped '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("': its footprint box does not read as a finite volume (centre "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(Fmt(val3)); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", half extents "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(Fmt(val4)); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(") - its volume is NOT validated."); } log8.LogWarning(val2); return; } Quaternion val5 = Quaternion.Inverse(rootTransform.rotation); Vector3 val6 = val5 * (val3 - rootTransform.position); Quaternion rotationInRoot = val5 * rotation; Annexes.Add(new Annex(child, text, componentInChildren, footprintCollider, val6, rotationInRoot, val4)); Transform transform2 = ((Component)child).transform; string text2 = (((Object)(object)transform2 != (Object)null) ? Fmt(transform2.position) : ""); string empty = string.Empty; ManualLogSource log9 = Plugin.Log; val = new BepInExInfoLogInterpolatedStringHandler(123, 8, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" annex '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': footprint box size="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(Fmt(size)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", world half extents="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(Fmt(val4)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", box centre in the world="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(Fmt(val3)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", the annex itself at "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text2); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", offset from the root="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(Fmt(val6)); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(empty); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log9.LogInfo(val); } private static void CaptureMask(Structure root) { //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown bool flag = default(bool); try { StructureTemplate template = root.Template; PlacementTool val = (((Object)(object)template != (Object)null) ? template.placementTool : null); if ((Object)(object)val == (Object)null) { ManualLogSource log = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(181, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" PlacementTool.footprintCheckMask could not be reached (no placement tool on the root's template) - the annex sweep falls back to the mask the game passes into each validation call."); } log.LogWarning(val2); return; } LayerMask footprintCheckMask = val.footprintCheckMask; _maskValue = ((LayerMask)(ref footprintCheckMask)).value; _maskCaptured = true; ManualLogSource log2 = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(68, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" footprint check mask = 0x"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(_maskValue, "X8"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" (PlacementTool.footprintCheckMask on '"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(SafeName((Object)(object)val)); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("')."); } log2.LogInfo(val3); } catch (Exception ex) { ManualLogSource log3 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(134, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" reading PlacementTool.footprintCheckMask threw ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(") - the annex sweep falls back to the mask the game passes into each validation call."); } log3.LogWarning(val2); } } private static bool Evaluate(int maskValue, Vector3 candidatePosition, Quaternion candidateRotation, out Annex blockingAnnex, out Collider blockingCollider) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) blockingAnnex = null; blockingCollider = null; Transform val = (((Object)(object)_ghostPreview == (Object)null) ? null : _ghostPreview.transform); for (int i = 0; i < Annexes.Count; i++) { Annex annex = Annexes[i]; annex.BlockedThisFrame = false; annex.ObstacleThisFrame = null; Vector3 val2 = candidatePosition + candidateRotation * annex.OffsetInRoot; Quaternion val3 = candidateRotation * annex.RotationInRoot; Il2CppReferenceArray val4 = Physics.OverlapBox(val2, annex.HalfExtents, val3, maskValue); if (val4 == null) { continue; } Candidates.Clear(); for (int j = 0; j < ((Il2CppArrayBase)(object)val4).Length; j++) { Collider val5 = ((Il2CppArrayBase)(object)val4)[j]; if (val5 != null && !GhostSession.IsExemptCollider(val5) && (!((Object)(object)val != (Object)null) || !IsUnder(val5, val))) { Candidates.Add(val5); } } if (Candidates.Count != 0 && IsRefusedByGame(annex, out var refused)) { annex.BlockedThisFrame = true; annex.ObstacleThisFrame = DescribeObstacle(refused); if (blockingAnnex == null) { blockingAnnex = annex; blockingCollider = refused; } } } return blockingAnnex != null; } private static bool IsRefusedByGame(Annex annex, out Collider refused) { refused = null; if (_ignoreCollection == null) { ReportDelegationUnavailable("the game's own footprint rule was not available at ghost start"); return false; } StructureLogic logic = annex.Logic; BoxCollider footprint = annex.Footprint; if ((Object)(object)logic == (Object)null || (Object)(object)footprint == (Object)null) { ReportDelegationUnavailable("annex '" + annex.Name + "' no longer has the StructureLogic and footprint collider the game's own rule is asked through"); return false; } try { Il2CppReferenceArray val = new Il2CppReferenceArray(Candidates.ToArray()); if (((FootprintValidator)logic)._CheckValidFootprint(footprint, val, _ignoreCollection)) { return false; } refused = FindRefused(logic, footprint); return true; } catch (Exception ex) { ReportDelegationUnavailable($"asking the game's own rule about annex '{annex.Name}' threw ({ex.Message})"); return false; } } private static Collider FindRefused(StructureLogic logic, BoxCollider footprint) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown try { for (int i = 0; i < Candidates.Count; i++) { SingleCandidate[0] = Candidates[i]; Il2CppReferenceArray val = new Il2CppReferenceArray(SingleCandidate); if (!((FootprintValidator)logic)._CheckValidFootprint(footprint, val, _ignoreCollection)) { return Candidates[i]; } } } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(118, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" narrowing the refusal down to one collider threw ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(") - the annex is still blocked, and the first hit is named instead."); } log.LogWarning(val2); } finally { SingleCandidate[0] = null; } return Candidates[0]; } private static void ReportDelegationUnavailable(string reason) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown if (!_delegationFailureLogged) { _delegationFailureLogged = true; ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(144, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(reason); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" - that annex is treated as UNVALIDATED, the game's own verdict is left untouched and nothing here blocks the placement (logged once per move)."); } log.LogWarning(val); } } private static bool IsUnder(Collider collider, Transform root) { Transform transform = ((Component)collider).transform; if ((Object)(object)transform != (Object)null) { return transform.IsChildOf(root); } return false; } private static bool IsGhostLogic(StructureLogic logic) { EnsureGhostResolved(); if (_ghostLogicPointer == IntPtr.Zero) { return false; } return ((Il2CppObjectBase)logic).Pointer == _ghostLogicPointer; } private static void EnsureGhostResolved() { if ((Object)(object)_ghostLogic != (Object)null) { return; } _ghostLogicPointer = IntPtr.Zero; _ghostPreview = null; if (_ghostResolveCountdown > 0) { _ghostResolveCountdown--; return; } _ghostResolveCountdown = 5; StructurePreviewData ghostPreviewData = GhostSession.GhostPreviewData; if (ghostPreviewData == null) { return; } NodeStructurePreviewData val = ((Il2CppObjectBase)ghostPreviewData).TryCast(); if (val != null) { StructureLogic val2 = val.structureLogic; if ((Object)(object)val2 == (Object)null) { Preview preview = val.preview; StructurePreview val3 = (((Object)(object)preview != (Object)null) ? preview.structurePreview : null); val2 = (((Object)(object)val3 != (Object)null) ? val3.logic : null); } if (!((Object)(object)val2 == (Object)null)) { _ghostLogic = val2; _ghostLogicPointer = ((Il2CppObjectBase)val2).Pointer; _ghostPreview = val.previewInstance; BuildOverlay(); } } } private static void BuildOverlay() { //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: 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_016d: 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_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0185: 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_018c: Unknown result type (might be due to invalid IL or missing references) bool flag2 = default(bool); try { if (Annexes.Count == 0) { return; } GameObject ghostPreview = _ghostPreview; if ((Object)(object)ghostPreview == (Object)null) { return; } Transform transform = ghostPreview.transform; if ((Object)(object)transform == (Object)null) { return; } int count; bool flag = GameDrawsOwnFootprints(_ghostLogic, out count); if (!_footprintDecisionLogged) { _footprintDecisionLogged = true; if (flag) { ManualLogSource log = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(165, 2, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" annex overlay SKIPPED: the ghost's StructureLogic.fakeFootprints.Count="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" - the game already draws its own footprints for this structure, so no annex boxes are drawn."); } log.LogInfo(val); } else { ManualLogSource log2 = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(119, 3, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" annex overlay: drawing "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(Annexes.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" box(es) (StructureLogic.fakeFootprints.Count="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") - the game draws no footprints of its own here."); } log2.LogInfo(val); } } if (!flag && AnnexOverlay.Begin(ghostPreview)) { Vector3 lossyScale = transform.lossyScale; for (int i = 0; i < Annexes.Count; i++) { Annex annex = Annexes[i]; Structure structure = annex.Structure; GameObject annexRoot = (((Object)(object)structure != (Object)null) ? ((Component)structure).gameObject : null); AnnexOverlay.Add(annex.Name, annexRoot, Descale(annex.OffsetInRoot, lossyScale), annex.RotationInRoot, Descale(annex.HalfExtents * 2f, lossyScale)); } } } catch (Exception ex) { ManualLogSource log3 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(124, 2, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" building the annex overlay threw ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(") - no annex boxes are drawn on this move. Validation and the move itself are unaffected."); } log3.LogWarning(val2); } } private static void SyncOverlay() { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown try { for (int i = 0; i < Annexes.Count; i++) { AnnexOverlay.SetBlocked(i, Annexes[i].BlockedThisFrame); } } catch (Exception ex) { if (!_overlayFailureLogged) { _overlayFailureLogged = true; ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(111, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" recolouring the annex overlay threw - the verdict above is already written and stands (logged once per move): "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); } } } private static bool GameDrawsOwnFootprints(StructureLogic logic, out int count) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown count = 0; try { if ((Object)(object)logic == (Object)null) { return false; } List fakeFootprints = logic.fakeFootprints; if (fakeFootprints == null) { return false; } count = fakeFootprints.Count; return count > 0; } catch (Exception ex) { count = 0; ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(133, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" reading the ghost's StructureLogic.fakeFootprints threw ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") - treated as the game drawing none, so the annex overlay boxes ARE drawn."); } log.LogWarning(val); return false; } } private static Vector3 Descale(Vector3 value, Vector3 scale) { //IL_0000: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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) return new Vector3((Mathf.Abs(scale.x) < 0.0001f) ? value.x : (value.x / scale.x), (Mathf.Abs(scale.y) < 0.0001f) ? value.y : (value.y / scale.y), (Mathf.Abs(scale.z) < 0.0001f) ? value.z : (value.z / scale.z)); } private static void RecordVerdict(Annex annex, Collider obstacle) { if (annex == null) { IsBlocked = false; BlockingObstacleName = null; ReportVerdict($"clear ({Annexes.Count} annex(es) tested)"); } else { string text = annex.ObstacleThisFrame ?? DescribeObstacle(obstacle); IsBlocked = true; BlockingObstacleName = text; ReportVerdict($"BLOCKED - the GAME'S OWN footprint rule refuses annex '{annex.Name}' against obstacle '{text}'"); } } private static void ReportVerdict(string text) { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown if (_verdictSeen && string.Equals(text, _verdictText, StringComparison.Ordinal)) { return; } string verdictText = _verdictText; _verdictText = text; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val; if (!_verdictSeen) { _verdictSeen = true; ManualLogSource log = Plugin.Log; val = new BepInExInfoLogInterpolatedStringHandler(23, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" annex verdict: FIRST "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogInfo(val); NotifyBlockedTransition(); return; } ManualLogSource log2 = Plugin.Log; val = new BepInExInfoLogInterpolatedStringHandler(29, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" annex verdict CHANGED: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(verdictText); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" -> "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log2.LogInfo(val); NotifyBlockedTransition(); } private static void NotifyBlockedTransition() { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown if (!IsBlocked) { _notifiedObstacleName = null; return; } string blockingObstacleName = BlockingObstacleName; if (string.Equals(blockingObstacleName, _notifiedObstacleName, StringComparison.Ordinal)) { return; } _notifiedObstacleName = blockingObstacleName; try { Hud.Warn(IsPlayerFacingName(blockingObstacleName) ? ("Blocked by " + blockingObstacleName) : "Blocked by another structure"); } catch (Exception ex) { if (!_notifyFailureLogged) { _notifyFailureLogged = true; ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(70, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" notifying the player of a blocked move threw (logged once per move): "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); } } } private static bool IsPlayerFacingName(string name) { if (string.IsNullOrWhiteSpace(name)) { return false; } string text = name.TrimEnd(); if (text.EndsWith("(Clone)", StringComparison.OrdinalIgnoreCase)) { return false; } if (text.IndexOf(' ') < 0 && HasDigitAdjacentToX(text)) { return false; } for (int i = 0; i < RawPrefabPrefixes.Length; i++) { if (text.StartsWith(RawPrefabPrefixes[i], StringComparison.OrdinalIgnoreCase)) { return false; } } return true; } private static bool HasDigitAdjacentToX(string value) { for (int i = 0; i < value.Length; i++) { if (value[i] == 'x' || value[i] == 'X') { bool num = i > 0 && char.IsDigit(value[i - 1]); bool flag = i + 1 < value.Length && char.IsDigit(value[i + 1]); if (num || flag) { return true; } } } return false; } private static string DescribeObstacle(Collider collider) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown if (collider == null) { return "something"; } try { Structure componentInParent = ((Component)collider).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { bool flag = default(bool); try { string customName = componentInParent.GetCustomName(); if (!string.IsNullOrWhiteSpace(customName)) { return customName; } } catch (Exception ex) { ManualLogSource log = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(53, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" reading the blocking structure's custom name threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); } try { string structureName = componentInParent.StructureName; if (!string.IsNullOrWhiteSpace(structureName)) { return structureName; } } catch (Exception ex2) { ManualLogSource log2 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(46, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("[MovingDay][shell]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" reading the blocking structure's name threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex2.Message); } log2.LogWarning(val); } } return SafeName((Object)(object)collider); } catch (Exception ex3) { return ""; } } private static string SafeName(Object obj) { try { return (obj != (Object)null) ? obj.name : ""; } catch (Exception ex) { return ""; } } private static string Fmt(Vector3 v) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) return $"({v.x:F2},{v.y:F2},{v.z:F2})"; } } internal static class Targeting { private static PickingManager _pickingManager; private static readonly HashSet AllowedPlacementTools = new HashSet(StringComparer.Ordinal) { "TerraformingPointPlacementTool", "AnchorPointPlacementTool" }; private static bool _templateReadFailureLogged; internal static bool TryGetPickedPointer(out IntPtr pointer) { pointer = IntPtr.Zero; try { PickingManager pickingManager = GetPickingManager(); if ((Object)(object)pickingManager == (Object)null) { return false; } Pickable selectedPickable = pickingManager.SelectedPickable; if ((Object)(object)selectedPickable == (Object)null) { return false; } pointer = ((Il2CppObjectBase)selectedPickable).Pointer; return true; } catch { pointer = IntPtr.Zero; return false; } } internal static bool TryGetPickedStructure(out Structure structure) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown structure = null; try { PickingManager pickingManager = GetPickingManager(); if ((Object)(object)pickingManager == (Object)null) { return false; } Pickable selectedPickable = pickingManager.SelectedPickable; if ((Object)(object)selectedPickable == (Object)null) { return false; } GameObject gameObject = ((Component)selectedPickable).gameObject; if ((Object)(object)gameObject == (Object)null) { return false; } StructureInteraction val = gameObject.GetComponentInParent(); if ((Object)(object)val == (Object)null) { val = gameObject.GetComponentInChildren(true); } if ((Object)(object)val != (Object)null) { structure = val.GetStructure(); } if ((Object)(object)structure == (Object)null) { structure = gameObject.GetComponentInParent(); } return (Object)(object)structure != (Object)null; } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(50, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[MovingDay] resolving the picked structure threw: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex); } log.LogError(val2); structure = null; return false; } } internal static Structure ResolveRoot(Structure structure) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown if ((Object)(object)structure == (Object)null) { return null; } try { Structure val = structure; for (int i = 0; i < 64; i++) { Structure parent = val.Parent; if ((Object)(object)parent == (Object)null) { break; } val = parent; } return val; } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(43, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[MovingDay] resolving the move root threw: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex); } log.LogError(val2); return structure; } } internal static bool IsEligible(Structure structure, out string reason) { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown if ((Object)(object)structure == (Object)null) { reason = "nothing targeted"; return false; } try { if (!structure.IsActive) { reason = "it is not finished being built"; return false; } if (structure.Dismantled) { reason = "it is being dismantled"; return false; } if (structure.IsNonDismantlable()) { reason = "it cannot be dismantled"; return false; } if (structure.HasUnbuiltChildStructures()) { reason = "part of it is still being built"; return false; } if (!AllDescendantsMovable(structure, out var reason2)) { reason = reason2; return false; } string text = PlacementToolTypeName(structure); if (text == null || !AllowedPlacementTools.Contains(text)) { reason = "it uses a build style Moving Day can't move safely yet"; return false; } } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(37, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] eligibility check threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); reason = "its state could not be read"; return false; } reason = null; return true; } private static bool AllDescendantsMovable(Structure root, out string reason) { reason = null; StructureContainer childStructureContainer = root.childStructureContainer; if ((Object)(object)childStructureContainer == (Object)null) { return true; } List allChildren = childStructureContainer.allChildren; if (allChildren == null) { return true; } Transform transform = ((Component)root).transform; for (int i = 0; i < allChildren.Count; i++) { Structure val = allChildren[i]; if (!((Object)(object)val == (Object)null)) { Transform transform2 = ((Component)val).transform; if ((Object)(object)transform == (Object)null || (Object)(object)transform2 == (Object)null || !transform2.IsChildOf(transform)) { reason = "its attached structures aren't all connected to it"; return false; } if (!val.IsActive || val.Dismantled) { reason = "one of its attached structures is being removed"; return false; } } } return true; } private static string PlacementToolTypeName(Structure structure) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown try { StructureTemplate template = structure.Template; if ((Object)(object)template == (Object)null) { return null; } PlacementTool placementTool = template.placementTool; if ((Object)(object)placementTool == (Object)null) { return null; } return ((MemberInfo)((Object)placementTool).GetIl2CppType()).Name; } catch (Exception ex) { if (!_templateReadFailureLogged) { _templateReadFailureLogged = true; ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(146, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MovingDay] reading a structure's placement tool threw, so it is refused as an unsupported build style - reported once rather than once per look: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } return null; } } private static PickingManager GetPickingManager() { if ((Object)(object)_pickingManager == (Object)null) { _pickingManager = Object.FindObjectOfType(); } return _pickingManager; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "AskaMovingDay"; public const string PLUGIN_NAME = "Aska Moving Day"; public const string PLUGIN_VERSION = "1.0.1"; } }