using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Lamb.UI; using MMTools; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Remote Build Cancel")] [assembly: AssemblyProduct("Remote Build Cancel")] [assembly: ComVisible(false)] [assembly: Guid("04fd6213-8fb5-4236-8792-8e002100f026")] [assembly: AssemblyFileVersion("0.1.6.0")] [assembly: AssemblyVersion("0.1.6.0")] [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 RemoteBuildCancel { [BepInPlugin("com.cotl.betterbuildertools.remotebuildcancel", "Remote Build Cancel", "0.1.9")] public sealed class RemoteBuildCancelPlugin : BaseUnityPlugin { public const string PluginGuid = "com.cotl.betterbuildertools.remotebuildcancel"; public const string PluginName = "Remote Build Cancel"; public const string PluginVersion = "0.1.9"; private Harmony _harmony; private KeyCode _cancelKey; private KeyCode _mouseCancelKey; private KeyCode _controllerCancelKey; private KeyCode _editModeKey; private int _lastBuiltId = -1; private bool _hasCachedBuildMode; private TYPES _cachedBuildType; private GameObject _cachedPlacementPrefab; private Mode _cachedBuildMode = (Mode)5; private bool _hasLastBuildSelection; private TYPES _lastBuildType; private GameObject _lastBuildPlacementPrefab; private Mode _lastBuildMode = (Mode)5; private float _preserveCachedModeUntil; private Indicator _promptOwner; private GameObject _modePromptObject; private GameObject _modePromptTextObject; private MMControlPrompt _modeControlPrompt; private TMP_Text _modePromptText; private GameObject _cancelPromptObject; private GameObject _cancelPromptTextObject; private MMControlPrompt _cancelControlPrompt; private TMP_Text _cancelPromptText; private GameObject _promptRowObject; private GameObject _modePromptCellObject; private GameObject _cancelPromptCellObject; private bool _promptCreationWarningLogged; private bool? _modePromptWasController; private bool? _cancelPromptWasController; private static readonly MethodInfo ClearPrefabsMethod = AccessTools.Method(typeof(PlacementRegion), "ClearPrefabs", (Type[])null, (Type[])null); private static readonly FieldInfo TilesField = AccessTools.Field(typeof(PlacementRegion), "Tiles"); private static readonly FieldInfo TilesInitiatedField = AccessTools.Field(typeof(PlacementRegion), "tilesInitiated"); private static readonly FieldInfo IsEditingBuildingsField = AccessTools.Field(typeof(PlacementRegion), "isEditingBuildings"); private static readonly FieldInfo PreviousEditingPositionField = AccessTools.Field(typeof(PlacementRegion), "previousEditingPosition"); private static readonly FieldInfo CurrentStructureToMoveField = AccessTools.Field(typeof(PlacementRegion), "CurrentStructureToMove"); private static readonly FieldInfo CurrentStructureToUpgradeField = AccessTools.Field(typeof(PlacementRegion), "CurrentStructureToUpgrade"); private static readonly FieldInfo PlacementObjectField = AccessTools.Field(typeof(PlacementRegion), "placementObject"); private static readonly FieldInfo PlacementUiField = AccessTools.Field(typeof(PlacementRegion), "placementUI"); internal static ManualLogSource Log { get; private set; } internal static RemoteBuildCancelPlugin Instance { get; private set; } private void Awake() { //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_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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_0091: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; RemoteBuildCancelConfig.Bind(((BaseUnityPlugin)this).Config); _cancelKey = ParseKey(RemoteBuildCancelConfig.CancelKey.Value, (KeyCode)290); _mouseCancelKey = ParseKey(RemoteBuildCancelConfig.MouseCancelKey.Value, (KeyCode)325); _controllerCancelKey = ParseKey(RemoteBuildCancelConfig.ControllerCancelKey.Value, (KeyCode)332); _editModeKey = ParseKey(RemoteBuildCancelConfig.EditModeKey.Value, (KeyCode)99); _harmony = new Harmony("com.cotl.betterbuildertools.remotebuildcancel"); _harmony.PatchAll(typeof(RemoteBuildCancelPlugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Remote Build Cancel 0.1.9 loaded."); } private void OnDestroy() { DestroyAllPromptUi(); Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } _harmony = null; Instance = null; } private unsafe void Update() { //IL_0038: 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_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0198: 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) if (!RemoteBuildCancelConfig.Enabled.Value) { HideModePrompt(); HideCancelPrompt(); return; } RememberActiveBuildSelection(); if (!IsActiveBuildPlacement()) { if (((Object)(object)PlacementRegion.Instance == (Object)null || (int)PlacementRegion.Instance.CurrentMode == 0) && Time.unscaledTime >= _preserveCachedModeUntil) { ClearCachedBuildMode(); } HideModePrompt(); HideCancelPrompt(); } else if (RemoteBuildCancelConfig.EnableEditModeToggle.Value && EditModePressed()) { ToggleBuildEditMode(); } else { if (!CancelPressed()) { return; } Structure val = GetHoveredStructure(); if ((Object)(object)val == (Object)null && RemoteBuildCancelConfig.FallbackToLastPlaced.Value) { val = FindStructureById(_lastBuiltId); } if ((Object)(object)val == (Object)null || val.Brain == null || val.Brain.Data == null) { Log.LogInfo((object)"Remote cancel: no hovered/latest structure found."); return; } if (RemoteBuildCancelConfig.OnlyCancelBuildSites.Value && !IsBuildSite(val.Brain.Data.Type)) { Log.LogInfo((object)("Remote cancel ignored non-build-site structure " + ((object)Unsafe.As(ref val.Brain.Data.Type)/*cast due to .constrained prefix*/).ToString() + ".")); return; } if (!RemoteBuildCancelConfig.AllowCriticalStructures.Value && IsCritical(val.Brain.Data.Type)) { Log.LogWarning((object)("Blocked remote cancel for protected structure type " + ((object)Unsafe.As(ref val.Brain.Data.Type)/*cast due to .constrained prefix*/).ToString() + ".")); return; } TYPES type = val.Brain.Data.Type; if (RemoveStructureCleanly(val)) { Log.LogInfo((object)("Remote canceled " + ((object)(*(TYPES*)(&type))/*cast due to .constrained prefix*/).ToString() + ".")); } } } private void LateUpdate() { UpdateEditModePrompt(); UpdateCancelPrompt(); } private bool CancelPressed() { //IL_0001: 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_0029: Unknown result type (might be due to invalid IL or missing references) if (Input.GetKeyDown(_cancelKey) || Input.GetKeyDown(_mouseCancelKey)) { return true; } if (RemoteBuildCancelConfig.EnableControllerCancel.Value) { return Input.GetKeyDown(_controllerCancelKey); } return false; } private bool EditModePressed() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if (Input.GetKeyDown(_editModeKey) || Input.GetKeyDown((KeyCode)99)) { return true; } if (!RemoteBuildCancelConfig.UseVanillaEditModeAction.Value) { return false; } try { return InputManager.UI.GetEditBuildingsButtonDown((PlayerFarming)null); } catch { return false; } } private void ToggleBuildEditMode() { //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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) PlacementRegion instance = PlacementRegion.Instance; if ((Object)(object)instance == (Object)null) { return; } Log.LogInfo((object)("Edit toggle request: mode=" + ((object)Unsafe.As(ref instance.CurrentMode)/*cast due to .constrained prefix*/).ToString() + ", type=" + ((object)Unsafe.As(ref instance.StructureType)/*cast due to .constrained prefix*/).ToString() + ", edit=" + IsEditBuildingsMode(instance) + ", cached=" + _hasCachedBuildMode + ", remembered=" + _hasLastBuildSelection + ".")); if (IsEditBuildingsMode(instance)) { if (!_hasCachedBuildMode && _hasLastBuildSelection) { _cachedBuildType = _lastBuildType; _cachedPlacementPrefab = _lastBuildPlacementPrefab; _cachedBuildMode = _lastBuildMode; _hasCachedBuildMode = true; } if (_hasCachedBuildMode) { SwitchToBuildMode(instance); } else { OpenBuildCatalogueFromEditMode(instance); } } else { SwitchToEditMode(instance); } } private void SwitchToEditMode(PlacementRegion region) { //IL_000a: 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: Invalid comparison between Unknown and I4 //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 //IL_002f: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Invalid comparison between Unknown and I4 //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: 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_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)region == (Object)null || (int)region.CurrentMode == 0 || (int)region.CurrentMode == 3 || (int)region.CurrentMode == 4 || (int)region.CurrentMode == 2) { return; } _cachedBuildType = region.StructureType; _cachedPlacementPrefab = region.PlacementGameObject; _cachedBuildMode = region.CurrentMode; _hasCachedBuildMode = (int)_cachedBuildType != 0 && (int)_cachedBuildType != 215 && (Object)(object)_cachedPlacementPrefab != (Object)null; if (!_hasCachedBuildMode) { Log.LogWarning((object)"Could not cache the active building before entering Edit mode."); return; } _hasLastBuildSelection = true; _lastBuildType = _cachedBuildType; _lastBuildPlacementPrefab = _cachedPlacementPrefab; _lastBuildMode = _cachedBuildMode; Vector3 val = (((Object)(object)PlacementObject.Instance != (Object)null) ? ((Component)PlacementObject.Instance).transform.position : region.PlacementPosition); if (val == Vector3.zero && (Object)(object)PlayerFarming.Instance != (Object)null) { val = ((Component)PlayerFarming.Instance).transform.position; } try { HideModePrompt(); PreserveCachedModeDuringTransition(); PrepareRegionForModeSwitch(region, enteringEditMode: true); region.StructureType = (TYPES)215; region.PlacementGameObject = TypeAndPlacementObjects.GetByType((TYPES)215).PlacementObject; region.CurrentMode = (Mode)3; region.Play(val); Log.LogInfo((object)"Switched active placement to Edit Buildings mode."); } catch (Exception ex) { Log.LogWarning((object)("Could not switch active placement to Edit Buildings mode: " + ex.Message)); } } private void SwitchToBuildMode(PlacementRegion region) { //IL_0009: 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_001b: Invalid comparison between Unknown and I4 //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Invalid comparison between Unknown and I4 //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) if (!_hasCachedBuildMode || (int)_cachedBuildType == 0 || (int)_cachedBuildType == 215) { Log.LogInfo((object)"Build mode toggle ignored because there is no previous building selection to restore."); return; } GameObject val = _cachedPlacementPrefab; if ((Object)(object)val == (Object)null) { TypeAndPlacementObject byType = TypeAndPlacementObjects.GetByType(_cachedBuildType); val = ((byType != null) ? byType.PlacementObject : null); } if ((Object)(object)val == (Object)null) { Log.LogWarning((object)"Could not restore Build mode because the cached placement prefab is unavailable."); return; } Vector3 val2 = (((Object)(object)PlacementObject.Instance != (Object)null) ? ((Component)PlacementObject.Instance).transform.position : region.PlacementPosition); if (val2 == Vector3.zero) { val2 = GameManager.GetInstance().CamFollowTarget.GetCameraTargetWorldPosition(); } try { HideModePrompt(); PreserveCachedModeDuringTransition(); PrepareRegionForModeSwitch(region, enteringEditMode: false); region.StructureType = _cachedBuildType; region.PlacementGameObject = val; region.CurrentMode = (Mode)(((int)_cachedBuildMode == 1) ? 1 : 5); region.Play(val2); Log.LogInfo((object)("Restored Build mode with " + ((object)Unsafe.As(ref _cachedBuildType)/*cast due to .constrained prefix*/).ToString() + ".")); } catch (Exception ex) { Log.LogWarning((object)("Could not restore Build mode: " + ex.Message)); } } private void OpenBuildCatalogueFromEditMode(PlacementRegion region) { //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)region == (Object)null || (Object)(object)MonoSingleton.Instance == (Object)null || (Object)(object)MonoSingleton.Instance.BuildMenuTemplate == (Object)null) { Log.LogWarning((object)"Could not return to the build catalogue because the build menu is unavailable."); return; } try { ((MonoBehaviour)region).StopAllCoroutines(); DestroyPlacementTiles(region); ClearPrefabsMethod?.Invoke(region, null); DestroyPrivateObject(region, PlacementObjectField); DestroyPrivateObject(region, PlacementUiField); TilesInitiatedField?.SetValue(region, false); IsEditingBuildingsField?.SetValue(region, false); CurrentStructureToMoveField?.SetValue(region, null); CurrentStructureToUpgradeField?.SetValue(region, null); region.StructureType = (TYPES)0; region.CurrentMode = (Mode)0; region.PlacementPosition = Vector3.zero; GameManager.overridePlayerPosition = false; ClearCachedBuildMode(); HideModePrompt(); HideCancelPrompt(); Time.timeScale = 0f; MonoSingleton.Instance.ShowBuildMenu((TYPES)0); Log.LogInfo((object)"Returned from externally opened Edit Buildings mode to the build catalogue."); } catch (Exception ex) { Log.LogWarning((object)("Could not return from Edit Buildings mode to the build catalogue: " + ex.Message)); } } private static void PrepareRegionForModeSwitch(PlacementRegion region, bool enteringEditMode) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) ((MonoBehaviour)region).StopAllCoroutines(); DestroyPlacementTiles(region); ClearPrefabsMethod?.Invoke(region, null); TilesInitiatedField?.SetValue(region, false); IsEditingBuildingsField?.SetValue(region, enteringEditMode); PreviousEditingPositionField?.SetValue(region, Vector3.zero); CurrentStructureToMoveField?.SetValue(region, null); CurrentStructureToUpgradeField?.SetValue(region, null); } private static void DestroyPlacementTiles(PlacementRegion region) { if (!(TilesField?.GetValue(region) is List list)) { return; } PlacementTile[] array = list.ToArray(); foreach (PlacementTile val in array) { if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)((Component)val).gameObject); } } list.Clear(); } private static void DestroyPrivateObject(PlacementRegion region, FieldInfo field) where T : Component { object? obj = field?.GetValue(region); T val = (T)((obj is T) ? obj : null); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)((Component)val).gameObject); field.SetValue(region, null); } } private void UpdateEditModePrompt() { //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) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Invalid comparison between Unknown and I4 //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Invalid comparison between Unknown and I4 if (!RemoteBuildCancelConfig.ShowEditModePrompt.Value || !RemoteBuildCancelConfig.Enabled.Value || !RemoteBuildCancelConfig.EnableEditModeToggle.Value || (Object)(object)PlacementRegion.Instance == (Object)null || (Object)(object)PlayerFarming.Instance == (Object)null || (Object)(object)PlayerFarming.Instance.indicator == (Object)null || !IsActiveBuildPlacement()) { HideModePrompt(); return; } Mode currentMode = PlacementRegion.Instance.CurrentMode; bool flag = IsEditBuildingsMode(PlacementRegion.Instance); if (!flag && (int)currentMode != 1 && (int)currentMode != 5) { HideModePrompt(); return; } Indicator indicator = PlayerFarming.Instance.indicator; if (EnsureModePrompt(indicator)) { _modeControlPrompt.playerFarming = PlayerFarming.Instance; bool flag2 = IsControllerInput(); _modeControlPrompt.PrioritizeMouse = false; _modePromptText.text = (flag ? "Build" : "Edit"); _modePromptCellObject.SetActive(true); SizePromptRow(_promptRowObject); _promptRowObject.SetActive(true); _modePromptObject.SetActive(true); _modePromptTextObject.SetActive(true); if (_modePromptWasController != flag2) { _modePromptWasController = flag2; RefreshModePromptGlyph(flag2); } } } private bool EnsureModePrompt(Indicator indicator) { if ((Object)(object)_promptOwner != (Object)null && (Object)(object)_promptOwner != (Object)(object)indicator) { DestroyAllPromptUi(); } if ((Object)(object)_promptOwner == (Object)(object)indicator && (Object)(object)_modePromptCellObject != (Object)null && (Object)(object)_modeControlPrompt != (Object)null && (Object)(object)_modePromptText != (Object)null) { return true; } EnsurePromptRow(indicator); if ((Object)(object)_promptRowObject == (Object)null) { return false; } CreatePromptCell(indicator, "RemoteBuildCancel_ModeToggleCell", 120f, out _modePromptCellObject, out _modePromptObject, out _modeControlPrompt, out _modePromptTextObject, out _modePromptText); if ((Object)(object)_modeControlPrompt == (Object)null || (Object)(object)_modePromptText == (Object)null) { DestroyModePrompt(); return false; } _modePromptWasController = null; return true; } private void RefreshModePromptGlyph(bool controller) { if (!((Object)(object)_modeControlPrompt == (Object)null)) { if (controller) { _modeControlPrompt.IgnoreControllerChange = false; _modeControlPrompt.Category = 1; _modeControlPrompt.Action = 51; _modeControlPrompt.ForceUpdate(); } else { SetCustomPromptKey(_modeControlPrompt, "C"); } } } private void UpdateCancelPrompt() { if (!RemoteBuildCancelConfig.ShowCancelPrompt.Value || !RemoteBuildCancelConfig.Enabled.Value || !IsActiveBuildPlacement() || (Object)(object)PlayerFarming.Instance == (Object)null || (Object)(object)PlayerFarming.Instance.indicator == (Object)null) { HideCancelPrompt(); return; } Structure val = GetHoveredStructure(); if ((Object)(object)val == (Object)null && RemoteBuildCancelConfig.FallbackToLastPlaced.Value) { val = FindStructureById(_lastBuiltId); } if (!CanRemoteCancel(val)) { HideCancelPrompt(); return; } Indicator indicator = PlayerFarming.Instance.indicator; if (EnsureCancelPrompt(indicator)) { bool flag = IsControllerInput(); _cancelControlPrompt.playerFarming = PlayerFarming.Instance; _cancelControlPrompt.PrioritizeMouse = false; _cancelPromptText.text = "Cancel Build"; _cancelPromptCellObject.SetActive(true); SizePromptRow(_promptRowObject); _promptRowObject.SetActive(true); _cancelPromptObject.SetActive(true); _cancelPromptTextObject.SetActive(true); if (_cancelPromptWasController != flag) { _cancelPromptWasController = flag; RefreshCancelPromptGlyph(flag); } } } private bool EnsureCancelPrompt(Indicator indicator) { if ((Object)(object)_promptOwner != (Object)null && (Object)(object)_promptOwner != (Object)(object)indicator) { DestroyAllPromptUi(); } if ((Object)(object)_promptOwner == (Object)(object)indicator && (Object)(object)_cancelPromptCellObject != (Object)null && (Object)(object)_cancelControlPrompt != (Object)null && (Object)(object)_cancelPromptText != (Object)null) { return true; } EnsurePromptRow(indicator); if ((Object)(object)_promptRowObject == (Object)null) { return false; } CreatePromptCell(indicator, "RemoteBuildCancel_CancelCell", 165f, out _cancelPromptCellObject, out _cancelPromptObject, out _cancelControlPrompt, out _cancelPromptTextObject, out _cancelPromptText); if ((Object)(object)_cancelControlPrompt == (Object)null || (Object)(object)_cancelPromptText == (Object)null) { DestroyCancelPrompt(); return false; } _cancelPromptWasController = null; return true; } private void EnsurePromptRow(Indicator indicator) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown if ((Object)(object)_promptRowObject != (Object)null && (Object)(object)_promptOwner == (Object)(object)indicator) { return; } Transform promptParent = GetPromptParent(indicator); if (!((Object)(object)promptParent == (Object)null)) { Transform val = promptParent.Find("RemoteBuildCancel_BuilderToolsPromptRow"); if ((Object)(object)val != (Object)null) { EnsureExistingPromptRow(((Component)val).gameObject, indicator); _promptOwner = indicator; _promptRowObject = ((Component)val).gameObject; return; } GameObject val2 = new GameObject("RemoteBuildCancel_BuilderToolsPromptRow"); ((Transform)val2.AddComponent()).SetParent(promptParent, false); ConfigurePromptRow(val2); AddVanillaPromptBackground(val2, indicator); val2.transform.SetAsLastSibling(); _promptOwner = indicator; _promptRowObject = val2; } } private static void ConfigurePromptRow(GameObject row) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_005a: 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_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown RectTransform obj = row.GetComponent() ?? row.AddComponent(); obj.anchorMin = new Vector2(0.5f, 0f); obj.anchorMax = new Vector2(0.5f, 0f); obj.pivot = new Vector2(0f, 0f); obj.anchoredPosition = new Vector2(240f, 112f); obj.sizeDelta = new Vector2(0f, 52f); LayoutElement obj2 = row.GetComponent() ?? row.AddComponent(); obj2.minWidth = 0f; obj2.preferredWidth = 0f; obj2.flexibleWidth = 0f; obj2.minHeight = 52f; obj2.preferredHeight = 52f; obj2.flexibleHeight = 0f; ContentSizeFitter obj3 = row.GetComponent() ?? row.AddComponent(); obj3.horizontalFit = (FitMode)2; obj3.verticalFit = (FitMode)0; ((Behaviour)obj3).enabled = false; HorizontalLayoutGroup obj4 = row.GetComponent() ?? row.AddComponent(); ((LayoutGroup)obj4).padding = new RectOffset(18, 18, 5, 5); ((HorizontalOrVerticalLayoutGroup)obj4).spacing = 18f; ((LayoutGroup)obj4).childAlignment = (TextAnchor)4; ((HorizontalOrVerticalLayoutGroup)obj4).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj4).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj4).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)obj4).childForceExpandHeight = true; } private static void SizePromptRow(GameObject row) { //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)row == (Object)null) { return; } RectTransform component = row.GetComponent(); HorizontalLayoutGroup component2 = row.GetComponent(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null) { return; } float num = ((LayoutGroup)component2).padding.left + ((LayoutGroup)component2).padding.right; int num2 = 0; for (int i = 0; i < row.transform.childCount; i++) { GameObject gameObject = ((Component)row.transform.GetChild(i)).gameObject; if (!gameObject.activeSelf || ((Object)gameObject).name.IndexOf("VanillaPromptBackground", StringComparison.Ordinal) >= 0) { continue; } LayoutElement component3 = gameObject.GetComponent(); float num3 = (((Object)(object)component3 != (Object)null) ? Mathf.Max(component3.minWidth, component3.preferredWidth) : 0f); if (num3 <= 0f) { RectTransform component4 = gameObject.GetComponent(); float num4; if (!((Object)(object)component4 != (Object)null)) { num4 = 0f; } else { Rect rect = component4.rect; num4 = ((Rect)(ref rect)).width; } num3 = num4; } if (num3 <= 0f) { num3 = 40f; } if (num2 > 0) { num += ((HorizontalOrVerticalLayoutGroup)component2).spacing; } num += num3; num2++; } num = Mathf.Max(num, 1f); component.SetSizeWithCurrentAnchors((Axis)0, num); component.SetSizeWithCurrentAnchors((Axis)1, 52f); LayoutElement component5 = row.GetComponent(); if ((Object)(object)component5 != (Object)null) { component5.minWidth = num; component5.preferredWidth = num; } } private static Transform GetPromptParent(Indicator indicator) { Transform val = (((Object)(object)indicator != (Object)null && (Object)(object)indicator.ControlPromptUI != (Object)null) ? indicator.ControlPromptUI.transform : (((Object)(object)indicator != (Object)null) ? ((Component)indicator).transform : null)); if ((Object)(object)val == (Object)null) { return null; } Canvas val2 = ((Component)val).GetComponent() ?? ((Component)val).GetComponentInParent(); if (!((Object)(object)val2 != (Object)null)) { if (!((Object)(object)val.parent != (Object)null)) { return val; } return val.parent; } return ((Component)val2).transform; } private static void EnsureExistingPromptRow(GameObject row, Indicator indicator) { if (!((Object)(object)row == (Object)null)) { ConfigurePromptRow(row); AddVanillaPromptBackground(row, indicator); } } private static void AddVanillaPromptBackground(GameObject row, Indicator indicator) { //IL_007b: 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_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) Image val = (((Object)(object)indicator != (Object)null && (Object)(object)indicator.BG != (Object)null) ? (((Component)indicator.BG).GetComponent() ?? ((Component)indicator.BG).GetComponentInChildren(true)) : null); Image val2 = row.GetComponent() ?? row.AddComponent(); ((Behaviour)val2).enabled = true; ((Graphic)val2).raycastTarget = false; val2.sprite = (((Object)(object)val != (Object)null) ? val.sprite : null); val2.type = (Type)(((Object)(object)val != (Object)null) ? ((int)val.type) : 0); if ((Object)(object)val2.sprite == (Object)null) { val2.sprite = Sprite.Create(Texture2D.whiteTexture, new Rect(0f, 0f, 1f, 1f), new Vector2(0.5f, 0.5f)); val2.type = (Type)0; } ((Graphic)val2).color = new Color(0f, 0f, 0f, 0.88f); ((Graphic)val2).canvasRenderer.SetColor(((Graphic)val2).color); for (int i = 0; i < row.transform.childCount; i++) { Transform child = row.transform.GetChild(i); if (((Object)child).name.IndexOf("VanillaPromptBackground", StringComparison.Ordinal) >= 0) { ((Component)child).gameObject.SetActive(false); } } } private void CreatePromptCell(Indicator indicator, string cellName, float preferredWidth, out GameObject cellObject, out GameObject promptObject, out MMControlPrompt controlPrompt, out GameObject textObject, out TMP_Text promptText) { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_0150: 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) cellObject = null; promptObject = null; controlPrompt = null; textObject = null; promptText = null; RectTransform val = (((Object)(object)indicator.FourthControlPrompt != (Object)null) ? indicator.FourthControlPrompt : indicator.ThirdControlPrompt); if ((Object)(object)val == (Object)null) { val = (((Object)(object)indicator.SecondaryControlPrompt != (Object)null) ? indicator.SecondaryControlPrompt : indicator.ControlPrompt); } TMP_Text val2 = (TMP_Text)(object)(((Object)(object)indicator.Fourthtext != (Object)null) ? indicator.Fourthtext : indicator.Thirdtext); if ((Object)(object)val2 == (Object)null) { val2 = (TMP_Text)(object)(((Object)(object)indicator.SecondaryText != (Object)null) ? indicator.SecondaryText : indicator.text); } if ((Object)(object)_promptRowObject == (Object)null || (Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { return; } GameObject val3 = new GameObject(cellName); ((Transform)val3.AddComponent()).SetParent(_promptRowObject.transform, false); LayoutElement obj = val3.AddComponent(); obj.preferredWidth = preferredWidth; obj.minWidth = preferredWidth; HorizontalLayoutGroup obj2 = val3.AddComponent(); ((HorizontalOrVerticalLayoutGroup)obj2).spacing = 6f; ((LayoutGroup)obj2).childAlignment = (TextAnchor)4; ((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = true; GameObject val4 = Object.Instantiate(((Component)val).gameObject, val3.transform, false); ((Object)val4).name = cellName + "_Key"; val4.SetActive(true); val4.transform.localScale = Vector3.one; controlPrompt = val4.GetComponent() ?? val4.GetComponentInChildren(true); LayoutElement obj3 = val4.GetComponent() ?? val4.AddComponent(); obj3.preferredWidth = 50f; obj3.minWidth = 42f; obj3.preferredHeight = 40f; TMP_Text val5 = Object.Instantiate(val2, val3.transform, false); ((Object)((Component)val5).gameObject).name = cellName + "_Label"; ((Component)val5).gameObject.SetActive(true); val5.transform.localScale = Vector3.one; val5.alignment = (TextAlignmentOptions)4097; val5.enableAutoSizing = true; val5.fontSizeMin = 12f; val5.fontSizeMax = 22f; LayoutElement obj4 = ((Component)val5).GetComponent() ?? ((Component)val5).gameObject.AddComponent(); obj4.preferredWidth = preferredWidth - 58f; obj4.minWidth = preferredWidth - 58f; Behaviour[] components = ((Component)val5).GetComponents(); foreach (Behaviour val6 in components) { if ((Object)(object)val6 != (Object)null && ((object)val6).GetType().FullName == "I2.Loc.Localize") { val6.enabled = false; } } cellObject = val3; promptObject = val4; textObject = ((Component)val5).gameObject; promptText = val5; } private void RefreshCancelPromptGlyph(bool controller) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_cancelControlPrompt == (Object)null)) { SetCustomPromptKey(_cancelControlPrompt, controller ? ControllerButtonLabel(_controllerCancelKey) : "MMB"); } } private static void SetCustomPromptKey(MMControlPrompt prompt, string label) { prompt.IgnoreControllerChange = true; object? obj = AccessTools.Field(typeof(MMControlPrompt), "_text")?.GetValue(prompt); TMP_Text val = (TMP_Text)((obj is TMP_Text) ? obj : null); object? obj2 = AccessTools.Field(typeof(MMControlPrompt), "_iconText")?.GetValue(prompt); TMP_Text val2 = (TMP_Text)((obj2 is TMP_Text) ? obj2 : null); object? obj3 = AccessTools.Field(typeof(MMControlPrompt), "_icon")?.GetValue(prompt); Image val3 = (Image)((obj3 is Image) ? obj3 : null); if ((Object)(object)val != (Object)null) { val.text = label; val.fontSize = 20f; val.enableAutoSizing = true; val.fontSizeMin = 8f; val.fontSizeMax = 20f; ((Component)val).gameObject.SetActive(true); } if ((Object)(object)val2 != (Object)null) { ((Component)val2).gameObject.SetActive(false); } if ((Object)(object)val3 != (Object)null) { ((Component)val3).gameObject.SetActive(true); } } private void HideCancelPrompt() { if ((Object)(object)_cancelPromptCellObject != (Object)null) { _cancelPromptCellObject.SetActive(false); } RefreshPromptRowVisibility(_promptRowObject); } private void DestroyCancelPrompt() { if ((Object)(object)_cancelPromptCellObject != (Object)null) { Object.Destroy((Object)(object)_cancelPromptCellObject); } else { if ((Object)(object)_cancelPromptObject != (Object)null) { Object.Destroy((Object)(object)_cancelPromptObject); } if ((Object)(object)_cancelPromptTextObject != (Object)null) { Object.Destroy((Object)(object)_cancelPromptTextObject); } } _cancelPromptCellObject = null; _cancelPromptObject = null; _cancelPromptTextObject = null; _cancelControlPrompt = null; _cancelPromptText = null; _cancelPromptWasController = null; } private void HideModePrompt() { if ((Object)(object)_modePromptCellObject != (Object)null && _modePromptCellObject.activeSelf) { _modePromptCellObject.SetActive(false); } RefreshPromptRowVisibility(_promptRowObject); } private static void RefreshPromptRowVisibility(GameObject row) { if ((Object)(object)row == (Object)null) { return; } bool active = false; for (int i = 0; i < row.transform.childCount; i++) { GameObject gameObject = ((Component)row.transform.GetChild(i)).gameObject; if (gameObject.activeSelf && ((Object)gameObject).name.IndexOf("VanillaPromptBackground", StringComparison.Ordinal) < 0) { active = true; break; } } SizePromptRow(row); row.SetActive(active); } private void DestroyModePrompt() { if ((Object)(object)_modePromptCellObject != (Object)null) { Object.Destroy((Object)(object)_modePromptCellObject); } else { if ((Object)(object)_modePromptObject != (Object)null) { Object.Destroy((Object)(object)_modePromptObject); } if ((Object)(object)_modePromptTextObject != (Object)null) { Object.Destroy((Object)(object)_modePromptTextObject); } } _modePromptCellObject = null; _modePromptObject = null; _modePromptTextObject = null; _modeControlPrompt = null; _modePromptText = null; _modePromptWasController = null; } private void DestroyAllPromptUi() { DestroyModePrompt(); DestroyCancelPrompt(); if ((Object)(object)_promptRowObject != (Object)null) { Object.Destroy((Object)(object)_promptRowObject); } _promptRowObject = null; _promptOwner = null; } private static bool IsControllerInput() { try { return (Object)(object)PlayerFarming.Instance != (Object)null && InputManager.General.InputIsController(PlayerFarming.Instance); } catch { return false; } } private bool CanRemoteCancel(Structure target) { //IL_0037: 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) if ((Object)(object)target == (Object)null || target.Brain == null || target.Brain.Data == null) { return false; } if (RemoteBuildCancelConfig.OnlyCancelBuildSites.Value && !IsBuildSite(target.Brain.Data.Type)) { return false; } if (!RemoteBuildCancelConfig.AllowCriticalStructures.Value) { return !IsCritical(target.Brain.Data.Type); } return true; } private unsafe static string ControllerButtonLabel(KeyCode key) { //IL_0000: 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_0034: Expected I4, but got Unknown return (key - 330) switch { 0 => "A", 1 => "B", 2 => "X", 3 => "Y", 4 => "LB", 5 => "RB", 6 => "Back", 7 => "Start", 8 => "LS", 9 => "RS", _ => ((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString().Replace("JoystickButton", "Pad "), }; } private void ClearCachedBuildMode() { //IL_0009: 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) _hasCachedBuildMode = false; _cachedBuildType = (TYPES)0; _cachedPlacementPrefab = null; _cachedBuildMode = (Mode)5; _preserveCachedModeUntil = 0f; } private void PreserveCachedModeDuringTransition() { _preserveCachedModeUntil = Time.unscaledTime + 0.75f; } private void RememberActiveBuildSelection() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Invalid comparison between Unknown and I4 //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) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) PlacementRegion instance = PlacementRegion.Instance; if (!((Object)(object)instance == (Object)null) && ((int)instance.CurrentMode == 1 || (int)instance.CurrentMode == 5) && (int)instance.StructureType != 0 && (int)instance.StructureType != 215 && !((Object)(object)instance.PlacementGameObject == (Object)null)) { _hasLastBuildSelection = true; _lastBuildType = instance.StructureType; _lastBuildPlacementPrefab = instance.PlacementGameObject; _lastBuildMode = instance.CurrentMode; } } internal void RememberLatest(StructureBrain brain) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (brain != null && brain.Data != null && IsActiveBuildPlacement() && (!RemoteBuildCancelConfig.OnlyCancelBuildSites.Value || IsBuildSite(brain.Data.Type))) { _lastBuiltId = brain.Data.ID; } } private static Structure GetHoveredStructure() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) Structure val = (((Object)(object)PlacementRegion.Instance != (Object)null) ? PlacementRegion.Instance.GetHoveredStructure() : null); if ((Object)(object)val != (Object)null) { return val; } if ((Object)(object)PlacementRegion.Instance != (Object)null) { return GetNearestStructureAtPlacement(PlacementRegion.Instance.PlacementPosition, RemoteBuildCancelConfig.TargetRadius.Value); } return null; } private static Structure GetNearestStructureAtPlacement(Vector3 position, float radius) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) Structure result = null; float num = radius; Structure[] array = Structure.Structures.ToArray(); foreach (Structure val in array) { if (!((Object)(object)val == (Object)null) && val.Brain != null && val.Brain.Data != null) { float num2 = Vector3.Distance(position, ((Component)val).transform.position); if (num2 <= num) { result = val; num = num2; } } } return result; } private static Structure FindStructureById(int id) { if (id < 0) { return null; } Structure[] array = Structure.Structures.ToArray(); foreach (Structure val in array) { if ((Object)(object)val != (Object)null && val.Brain != null && val.Brain.Data != null && val.Brain.Data.ID == id) { return val; } } return null; } private static bool RemoveStructureCleanly(Structure structure) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)structure == (Object)null || structure.Brain == null || structure.Brain.Data == null) { return false; } TYPES type = structure.Brain.Data.Type; TYPES toBuildType = structure.Brain.Data.ToBuildType; try { if ((Object)(object)PlacementRegion.Instance != (Object)null) { PlacementRegion.Instance.DestroyBuilding(structure); } else { structure.RemoveStructure(); Object.Destroy((Object)(object)((Component)structure).gameObject); } RefundBuildSiteMaterials(type, toBuildType); return true; } catch (Exception ex) { Log.LogWarning((object)("Remote cancel clean removal failed: " + ex.Message)); return false; } } private static void RefundBuildSiteMaterials(TYPES type, TYPES toBuildType) { //IL_0000: 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_000f: 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_0030: Unknown result type (might be due to invalid IL or missing references) if (!IsBuildSite(type)) { return; } List cost = StructuresData.GetCost(((int)toBuildType != 0) ? toBuildType : type); if (cost == null) { return; } for (int i = 0; i < cost.Count; i++) { ItemCost val = cost[i]; if (val.CostValue > 0) { Inventory.AddItem(val.CostItem, val.CostValue, true); } } RefreshPlacementCostUi(); } private static void RefreshPlacementCostUi() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) PlacementRegion instance = PlacementRegion.Instance; if ((Object)(object)instance == (Object)null) { return; } try { object? obj = PlacementUiField?.GetValue(instance); PlacementObjectUI val = (PlacementObjectUI)((obj is PlacementObjectUI) ? obj : null); if ((Object)(object)val != (Object)null) { val.UpdateText(instance.StructureType); } } catch (Exception ex) { Log.LogDebug((object)("Could not refresh live placement cost UI: " + ex.Message)); } } private static bool IsActiveBuildPlacement() { //IL_0029: 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_003b: Invalid comparison between Unknown and I4 //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Invalid comparison between Unknown and I4 //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Invalid comparison between Unknown and I4 PlacementRegion instance = PlacementRegion.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)PlacementObject.Instance == (Object)null) { return false; } if (IsEditBuildingsMode(instance)) { return true; } if ((int)instance.CurrentMode == 0) { return false; } Mode currentMode = instance.CurrentMode; if ((int)currentMode != 1 && (int)currentMode != 5) { return (int)currentMode == 3; } return true; } private static bool IsEditBuildingsMode(PlacementRegion region) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Invalid comparison between Unknown and I4 if ((Object)(object)region == (Object)null) { return false; } if ((int)region.StructureType == 215) { return true; } try { if (IsEditingBuildingsField != null && (bool)IsEditingBuildingsField.GetValue(region)) { return true; } } catch { } return (int)region.CurrentMode == 3; } private static bool IsBuildSite(TYPES type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)type != 31) { return (int)type == 118; } return true; } private unsafe static bool IsCritical(TYPES type) { string text = ((object)(*(TYPES*)(&type))/*cast due to .constrained prefix*/).ToString(); if (!text.Contains("TEMPLE") && !text.Contains("SHRINE") && !text.Contains("ALTAR")) { return text.Contains("BUILDER"); } return true; } private static KeyCode ParseKey(string raw, KeyCode fallback) { //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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) try { return (KeyCode)Enum.Parse(typeof(KeyCode), raw, ignoreCase: true); } catch { return fallback; } } } internal static class RemoteBuildCancelConfig { internal static ConfigEntry Enabled; internal static ConfigEntry CancelKey; internal static ConfigEntry MouseCancelKey; internal static ConfigEntry EnableControllerCancel; internal static ConfigEntry ControllerCancelKey; internal static ConfigEntry EnableEditModeToggle; internal static ConfigEntry UseVanillaEditModeAction; internal static ConfigEntry EditModeKey; internal static ConfigEntry ShowEditModePrompt; internal static ConfigEntry ShowCancelPrompt; internal static ConfigEntry OnlyCancelBuildSites; internal static ConfigEntry FallbackToLastPlaced; internal static ConfigEntry AllowCriticalStructures; internal static ConfigEntry TargetRadius; internal static void Bind(ConfigFile config) { //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Expected O, but got Unknown Enabled = config.Bind("General", "Enabled", true, "Enable Remote Build Cancel."); CancelKey = config.Bind("Controls", "CancelKey", "F9", "KeyCode used to cancel the hovered or latest placed structure."); MouseCancelKey = config.Bind("Controls", "MouseCancelKey", "Mouse2", "Mouse KeyCode used to cancel the hovered or latest placed structure. Mouse2 is middle mouse."); EnableControllerCancel = config.Bind("Controls", "EnableControllerCancel", true, "Enable the configured controller KeyCode for canceling the hovered or latest placed structure."); ControllerCancelKey = config.Bind("Controls", "ControllerCancelKey", "JoystickButton2", "Controller KeyCode used to cancel the hovered or latest placed structure."); EnableEditModeToggle = config.Bind("Controls", "EnableEditModeToggle", true, "Allow switching from active placement into Edit Buildings mode without reopening the build catalogue."); UseVanillaEditModeAction = config.Bind("Controls", "UseVanillaEditModeAction", true, "Use the game's normal Edit Buildings input action while actively placing a structure."); EditModeKey = config.Bind("Controls", "EditModeKey", "F7", "Fallback keyboard KeyCode used to switch active placement into Edit Buildings mode."); ShowEditModePrompt = config.Bind("UI", "ShowEditModePrompt", true, "Show a vanilla bottom-bar prompt for switching active placement into Edit Buildings mode."); ShowCancelPrompt = config.Bind("UI", "ShowCancelPrompt", true, "Show a vanilla bottom-bar prompt for the middle-mouse or controller remote-cancel action."); OnlyCancelBuildSites = config.Bind("Behavior", "OnlyCancelBuildSites", true, "Only allow remote cancel for unbuilt BUILD_SITE / BUILDSITE_BUILDINGPROJECT structures."); FallbackToLastPlaced = config.Bind("Behavior", "FallbackToLastPlaced", true, "Cancel the most recently placed structure if no hovered structure is found."); AllowCriticalStructures = config.Bind("Safety", "AllowCriticalStructures", false, "Allow remote cancel for temple/shrine/altar/builder style critical structures."); TargetRadius = config.Bind("Targeting", "TargetRadius", 1.25f, new ConfigDescription("Fallback radius around the build cursor when vanilla hover targeting returns nothing.", (AcceptableValueBase)(object)new AcceptableValueRange(0.25f, 5f), Array.Empty())); } } [HarmonyPatch(typeof(StructureManager), "AddStructure")] internal static class StructureManagerAddStructurePatch { private static void Postfix(StructureBrain __result) { RemoteBuildCancelPlugin.Instance?.RememberLatest(__result); } } }