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 MMTools; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.UI; using src.UINavigator; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Path Brush Plus")] [assembly: AssemblyProduct("Path Brush Plus")] [assembly: ComVisible(false)] [assembly: Guid("4e4da601-492e-4c50-bf01-530cf2e1ff4d")] [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 PathBrushPlus { [BepInPlugin("com.cotl.betterbuildertools.pathbrushplus", "Path Brush Plus", "0.1.6")] public sealed class PathBrushPlusPlugin : BaseUnityPlugin { public const string PluginGuid = "com.cotl.betterbuildertools.pathbrushplus"; public const string PluginName = "Path Brush Plus"; public const string PluginVersion = "0.1.6"; private Harmony _harmony; private float _lastBrushTime; private KeyCode _cycleModeKey; private KeyCode _controllerCycleModeKey; private BrushMode _currentMode; private string _statusText; private float _statusUntil; private readonly HashSet _paintedThisHold = new HashSet(); private readonly List _previewObjects = new List(); private GameObject _promptRowObject; private GameObject _promptCellObject; private MMControlPrompt _promptControlPrompt; private TMP_Text _promptText; private bool? _promptWasController; private static readonly MethodInfo BuildMethod = AccessTools.Method(typeof(PlacementRegion), "Build", (Type[])null, (Type[])null); internal static ManualLogSource Log { get; private set; } private void Awake() { //IL_0039: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; PathBrushPlusConfig.Bind(((BaseUnityPlugin)this).Config); _currentMode = ParseMode(PathBrushPlusConfig.DefaultMode.Value, BrushMode.ThreeByThree); _cycleModeKey = ParseKey(PathBrushPlusConfig.CycleModeKey.Value, (KeyCode)118); _controllerCycleModeKey = ParseKey(PathBrushPlusConfig.ControllerCycleModeKey.Value, (KeyCode)338); _harmony = new Harmony("com.cotl.betterbuildertools.pathbrushplus"); _harmony.PatchAll(typeof(PathBrushPlusPlugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Path Brush Plus 0.1.6 loaded."); } private void OnDestroy() { ClearPreview(); DestroyPromptUi(); Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } _harmony = null; } private void Update() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Invalid comparison between Unknown and I4 //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Invalid comparison between Unknown and I4 //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) if (!PathBrushPlusConfig.Enabled.Value || (Object)(object)PlacementRegion.Instance == (Object)null || (Object)(object)PlacementObject.Instance == (Object)null) { _paintedThisHold.Clear(); ClearPreview(); return; } PlacementRegion instance = PlacementRegion.Instance; if (IsPathPlacement(instance)) { HandleModeToggle(); } if ((int)instance.CurrentMode != 5 && (int)instance.CurrentMode != 1) { _paintedThisHold.Clear(); return; } TYPES structureType = instance.StructureType; if (PathBrushPlusConfig.PathsOnly.Value && !StructureBrain.IsPath(structureType)) { _paintedThisHold.Clear(); return; } if (_currentMode == BrushMode.Vanilla) { _paintedThisHold.Clear(); return; } bool flag = IsPlaceHeld(); bool flag2 = IsRemoveHeld(); if (!flag && !flag2) { _paintedThisHold.Clear(); } else if (!(Time.unscaledTime - _lastBrushTime < PathBrushPlusConfig.BrushInterval.Value)) { _lastBrushTime = Time.unscaledTime; ApplyBrush(instance, structureType, flag, flag2); } } private void LateUpdate() { UpdatePreview(); UpdatePrompt(); } private void ApplyBrush(PlacementRegion region, TYPES type, bool placeHeld, bool removeHeld) { //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_002b: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) List brushOffsets = GetBrushOffsets(); if (brushOffsets.Count == 0) { return; } TileGridTile centerTile = GetCenterTile(region); if (centerTile == null) { return; } for (int i = 0; i < brushOffsets.Count; i++) { Vector2Int val = brushOffsets[i]; if (val == Vector2Int.zero) { continue; } TileGridTile tileGridTile = region.GetTileGridTile(centerTile.Position + val); if (tileGridTile != null) { if (removeHeld) { PathTileManager.Instance.DeleteTile(tileGridTile.WorldPosition); _paintedThisHold.Remove(tileGridTile.Position); } else if (placeHeld && !_paintedThisHold.Contains(tileGridTile.Position)) { BuildPath(region, type, tileGridTile); _paintedThisHold.Add(tileGridTile.Position); } } } } private static TileGridTile GetCenterTile(PlacementRegion region) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) try { return region.GetClosestTileGridTileAtWorldPosition(region.PlacementPosition); } catch { return null; } } private static void BuildPath(PlacementRegion region, TYPES type, TileGridTile tile) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_0025: 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_0040: Unknown result type (might be due to invalid IL or missing references) if (BuildMethod != null) { BuildMethod.Invoke(region, new object[6] { type, tile.WorldPosition, tile.Position, Vector2Int.one, true, false }); } else { PathTileManager.Instance.DeleteTile(tile.WorldPosition); PathTileManager.Instance.DisplayTile(type, tile.WorldPosition); PathTileManager.Instance.SetTile(type, tile.WorldPosition); } } private static bool IsPlaceHeld() { try { return InputManager.Gameplay.GetPlaceMoveUpgradeButtonHeld(MonoSingleton.Instance.AllowInputOnlyFromPlayer); } catch { return Input.GetMouseButton(0); } } private static bool IsRemoveHeld() { try { return InputManager.Gameplay.GetRemoveFlipButtonHeld(MonoSingleton.Instance.AllowInputOnlyFromPlayer); } catch { return Input.GetMouseButton(1); } } private void UpdatePreview() { //IL_0054: 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_00b5: 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_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_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) if (!PathBrushPlusConfig.ShowBrushPreview.Value || !PathBrushPlusConfig.Enabled.Value || (Object)(object)PlacementRegion.Instance == (Object)null || (Object)(object)PlacementObject.Instance == (Object)null || _currentMode == BrushMode.Vanilla) { ClearPreview(); return; } PlacementRegion instance = PlacementRegion.Instance; if (PathBrushPlusConfig.PathsOnly.Value && !StructureBrain.IsPath(instance.StructureType)) { ClearPreview(); return; } TileGridTile centerTile = GetCenterTile(instance); List brushOffsets = GetBrushOffsets(includeCenter: true); if (centerTile == null || brushOffsets.Count == 0 || (Object)(object)instance.PlacementSquare == (Object)null) { ClearPreview(); return; } EnsurePreviewCount(instance, brushOffsets.Count); int num = 0; for (int i = 0; i < brushOffsets.Count; i++) { Vector2Int val = brushOffsets[i]; TileGridTile tileGridTile = instance.GetTileGridTile(centerTile.Position + val); GameObject val2 = _previewObjects[num++]; if (tileGridTile == null) { val2.SetActive(false); continue; } val2.SetActive(true); val2.transform.SetParent(((Component)instance).transform, false); val2.transform.localPosition = new Vector3((float)((Vector2Int)(ref tileGridTile.Position)).x, (float)((Vector2Int)(ref tileGridTile.Position)).y, -0.05f); ApplyPreviewColor(val2, val == Vector2Int.zero); } for (int j = num; j < _previewObjects.Count; j++) { _previewObjects[j].SetActive(false); } } private void EnsurePreviewCount(PlacementRegion region, int needed) { while (_previewObjects.Count < needed) { GameObject val = Object.Instantiate(region.PlacementSquare, ((Component)region).transform); ((Object)val).name = "PathBrushPlusPreview"; Collider2D[] componentsInChildren = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Behaviour)componentsInChildren[i]).enabled = false; } _previewObjects.Add(val); } } private static void ApplyPreviewColor(GameObject preview, bool center) { //IL_0041: 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) SpriteRenderer[] componentsInChildren = preview.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].color = (center ? new Color(0.1f, 1f, 0.1f, 0.9f) : new Color(0.1f, 0.85f, 1f, 0.55f)); } } private void ClearPreview() { for (int i = 0; i < _previewObjects.Count; i++) { if ((Object)(object)_previewObjects[i] != (Object)null) { Object.Destroy((Object)(object)_previewObjects[i]); } } _previewObjects.Clear(); } private void HandleModeToggle() { //IL_0001: 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 (Input.GetKeyDown(_cycleModeKey) || (PathBrushPlusConfig.EnableControllerModeCycle.Value && Input.GetKeyDown(_controllerCycleModeKey))) { _currentMode = NextMode(_currentMode); _paintedThisHold.Clear(); ClearPreview(); ShowStatus("Path brush: " + ModeLabel(_currentMode)); } } private void UpdatePrompt() { //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (!PathBrushPlusConfig.ShowModePrompt.Value || !PathBrushPlusConfig.Enabled.Value || (Object)(object)PlacementRegion.Instance == (Object)null || (Object)(object)PlacementObject.Instance == (Object)null || (Object)(object)PlayerFarming.Instance == (Object)null || (Object)(object)PlayerFarming.Instance.indicator == (Object)null) { HidePrompt(); return; } PlacementRegion instance = PlacementRegion.Instance; if (!IsPathPlacement(instance) || (PathBrushPlusConfig.PathsOnly.Value && !StructureBrain.IsPath(instance.StructureType))) { HidePrompt(); } else if (EnsurePrompt(PlayerFarming.Instance.indicator)) { string text = ((Time.unscaledTime < _statusUntil && !string.IsNullOrEmpty(_statusText)) ? _statusText : ("Brush: " + ModeLabel(_currentMode))); bool flag = IsControllerInput(); _promptControlPrompt.playerFarming = PlayerFarming.Instance; _promptControlPrompt.PrioritizeMouse = false; _promptText.text = text; _promptCellObject.SetActive(true); SizePromptRow(_promptRowObject); _promptRowObject.SetActive(true); if (_promptWasController != flag) { _promptWasController = flag; RefreshPromptGlyph(flag); } } } private bool EnsurePrompt(Indicator indicator) { if ((Object)(object)_promptCellObject != (Object)null && (Object)(object)_promptControlPrompt != (Object)null && (Object)(object)_promptText != (Object)null) { return true; } if ((Object)(object)indicator == (Object)null || (Object)(object)indicator.FourthControlPrompt == (Object)null || (Object)(object)((Transform)indicator.FourthControlPrompt).parent == (Object)null || (Object)(object)indicator.Fourthtext == (Object)null) { return false; } EnsurePromptRow(indicator); if ((Object)(object)_promptRowObject == (Object)null) { return false; } CreatePromptCell(indicator); if ((Object)(object)_promptControlPrompt == (Object)null || (Object)(object)_promptText == (Object)null) { DestroyPromptUi(); return false; } _promptWasController = null; return true; } private void EnsurePromptRow(Indicator indicator) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown Transform promptParent = GetPromptParent(indicator); if (!((Object)(object)promptParent == (Object)null)) { Transform val = promptParent.Find("RemoteBuildCancel_BuilderToolsPromptRow"); if ((Object)(object)val != (Object)null) { ConfigurePromptRow(((Component)val).gameObject); AddVanillaPromptBackground(((Component)val).gameObject, indicator); _promptRowObject = ((Component)val).gameObject; _promptRowObject.SetActive(true); } else { GameObject val2 = new GameObject("RemoteBuildCancel_BuilderToolsPromptRow"); ((Transform)val2.AddComponent()).SetParent(promptParent, false); ConfigurePromptRow(val2); AddVanillaPromptBackground(val2, indicator); val2.transform.SetAsLastSibling(); _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 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) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("PathBrushPlus_ModeCell"); ((Transform)val.AddComponent()).SetParent(_promptRowObject.transform, false); LayoutElement obj = val.AddComponent(); obj.preferredWidth = 150f; obj.minWidth = 150f; HorizontalLayoutGroup obj2 = val.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 val2 = Object.Instantiate(((Component)indicator.FourthControlPrompt).gameObject, val.transform, false); ((Object)val2).name = "PathBrushPlus_ModeKey"; val2.SetActive(true); val2.transform.localScale = Vector3.one; _promptControlPrompt = val2.GetComponent() ?? val2.GetComponentInChildren(true); LayoutElement obj3 = val2.GetComponent() ?? val2.AddComponent(); obj3.preferredWidth = 50f; obj3.minWidth = 42f; obj3.preferredHeight = 40f; TMP_Text val3 = (TMP_Text)(object)Object.Instantiate(indicator.Fourthtext, val.transform, false); ((Object)((Component)val3).gameObject).name = "PathBrushPlus_ModeLabel"; ((Component)val3).gameObject.SetActive(true); val3.transform.localScale = Vector3.one; val3.alignment = (TextAlignmentOptions)4097; val3.enableAutoSizing = true; val3.fontSizeMin = 12f; val3.fontSizeMax = 22f; LayoutElement obj4 = ((Component)val3).GetComponent() ?? ((Component)val3).gameObject.AddComponent(); obj4.preferredWidth = 90f; obj4.minWidth = 90f; Behaviour[] components = ((Component)val3).GetComponents(); foreach (Behaviour val4 in components) { if ((Object)(object)val4 != (Object)null && ((object)val4).GetType().FullName == "I2.Loc.Localize") { val4.enabled = false; } } _promptCellObject = val; _promptText = val3; } private void RefreshPromptGlyph(bool controller) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_promptControlPrompt == (Object)null)) { SetCustomPromptKey(_promptControlPrompt, controller ? ControllerButtonLabel(_controllerCycleModeKey) : PathBrushPlusConfig.CycleModeKey.Value); } } 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 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 static bool IsControllerInput() { try { return (Object)(object)PlayerFarming.Instance != (Object)null && InputManager.General.InputIsController(PlayerFarming.Instance); } catch { return false; } } private void HidePrompt() { if ((Object)(object)_promptCellObject != (Object)null) { _promptCellObject.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 DestroyPromptUi() { if ((Object)(object)_promptCellObject != (Object)null) { Object.Destroy((Object)(object)_promptCellObject); } _promptCellObject = null; _promptControlPrompt = null; _promptText = null; _promptWasController = null; _promptRowObject = null; } private static bool IsPathPlacement(PlacementRegion region) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 if ((Object)(object)region != (Object)null) { if ((int)region.CurrentMode != 5) { return (int)region.CurrentMode == 1; } return true; } return false; } private List GetBrushOffsets(bool includeCenter = false) { if (_currentMode == BrushMode.Vanilla) { return new List(); } if (_currentMode == BrushMode.Fill) { return GetSquareOffsets(PathBrushPlusConfig.FillSize.Value, includeCenter); } int value = PathBrushPlusConfig.BrushRadius.Value; if (value <= 0) { return new List(); } return GetSquareOffsets(value * 2 + 1, includeCenter); } private static List GetSquareOffsets(int size, bool includeCenter) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) List list = new List(); if (size <= 1) { return list; } int num = -(size / 2); int num2 = num + size - 1; Vector2Int val = default(Vector2Int); for (int i = num; i <= num2; i++) { for (int j = num; j <= num2; j++) { ((Vector2Int)(ref val))..ctor(i, j); if (includeCenter || !(val == Vector2Int.zero)) { list.Add(val); } } } return list; } private void ShowStatus(string text) { _statusText = text; _statusUntil = Time.unscaledTime + 1.5f; } private static BrushMode NextMode(BrushMode mode) { return mode switch { BrushMode.Vanilla => BrushMode.ThreeByThree, BrushMode.ThreeByThree => BrushMode.Fill, _ => BrushMode.Vanilla, }; } private static string ModeLabel(BrushMode mode) { switch (mode) { case BrushMode.Vanilla: return "1x1"; case BrushMode.Fill: return PathBrushPlusConfig.FillSize.Value + "x" + PathBrushPlusConfig.FillSize.Value; default: { int num = PathBrushPlusConfig.BrushRadius.Value * 2 + 1; return num + "x" + num; } } } private static BrushMode ParseMode(string raw, BrushMode fallback) { try { return (BrushMode)Enum.Parse(typeof(BrushMode), raw, ignoreCase: true); } catch { return fallback; } } 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 enum BrushMode { Vanilla, ThreeByThree, Fill } internal static class PathBrushPlusConfig { internal static ConfigEntry Enabled; internal static ConfigEntry DefaultMode; internal static ConfigEntry CycleModeKey; internal static ConfigEntry EnableControllerModeCycle; internal static ConfigEntry ControllerCycleModeKey; internal static ConfigEntry BrushRadius; internal static ConfigEntry FillSize; internal static ConfigEntry PathsOnly; internal static ConfigEntry BrushInterval; internal static ConfigEntry ShowBrushPreview; internal static ConfigEntry ShowModePrompt; internal static ConfigEntry UseVanillaPromptSlot; internal static void Bind(ConfigFile config) { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Expected O, but got Unknown Enabled = config.Bind("General", "Enabled", true, "Enable Path Brush Plus."); DefaultMode = config.Bind("Brush", "DefaultMode", "ThreeByThree", "Starting brush mode: Vanilla, ThreeByThree, or Fill."); CycleModeKey = config.Bind("Controls", "CycleModeKey", "V", "KeyCode used while placing paths to cycle Vanilla, 3x3, and Fill brush modes."); EnableControllerModeCycle = config.Bind("Controls", "EnableControllerModeCycle", true, "Enable the configured controller KeyCode for cycling path brush modes."); ControllerCycleModeKey = config.Bind("Controls", "ControllerCycleModeKey", "JoystickButton8", "Controller KeyCode used while placing paths to cycle brush modes."); BrushRadius = config.Bind("Brush", "BrushRadius", 1, new ConfigDescription("Extra path radius. 1 makes a 3x3 brush.", (AcceptableValueBase)(object)new AcceptableValueRange(0, 4), Array.Empty())); FillSize = config.Bind("Brush", "FillSize", 10, new ConfigDescription("Square brush width/height used by Fill mode.", (AcceptableValueBase)(object)new AcceptableValueRange(2, 20), Array.Empty())); PathsOnly = config.Bind("Brush", "PathsOnly", true, "Only apply the brush to StructureBrain path types."); BrushInterval = config.Bind("Brush", "BrushInterval", 0.16f, new ConfigDescription("Minimum seconds between brush applications while holding place/remove.", (AcceptableValueBase)(object)new AcceptableValueRange(0.02f, 0.5f), Array.Empty())); ShowBrushPreview = config.Bind("UI", "ShowBrushPreview", true, "Show a separate preview overlay for the full brush area."); ShowModePrompt = config.Bind("UI", "ShowModePrompt", true, "Show the current path brush mode on the vanilla placement indicator."); UseVanillaPromptSlot = config.Bind("UI", "UseVanillaPromptSlot", false, "Use the deprecated vanilla fourth prompt slot for brush mode. This slot uses vanilla's back/cancel glyph, so leave this off unless you want the old text-only prompt behavior."); if (BrushInterval.Value < 0.16f) { BrushInterval.Value = 0.16f; } } } }