using System.Collections; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using PlanBuild.Plans; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace BakaPlanHide; [BepInPlugin("baka.PlanHide", "Baka PlanHide", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class PlanHidePlugin : BaseUnityPlugin { public const string PluginGuid = "baka.PlanHide"; public const string PluginName = "Baka PlanHide"; public const string PluginVersion = "1.0.0"; private ConfigEntry _hotKey; private ConfigEntry _affectVisibility; private ConfigEntry _affectCollision; private ConfigEntry _showMessage; private bool _hidden; private void Awake() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) _hotKey = ((BaseUnityPlugin)this).Config.Bind("General", "Toggle Hotkey", new KeyboardShortcut((KeyCode)277, (KeyCode[])(object)new KeyCode[0]), "Key that toggles PlanBuild plan (ghost) projections on/off. While toggled off, plan pieces are made invisible and lose collision so you can edit terrain straight through them. Set/clear in the F1 Configuration Manager."); _affectCollision = ((BaseUnityPlugin)this).Config.Bind("General", "Disable Collision When Hidden", true, "When hidden, disable plan-piece colliders so terrain tools (Hoe/Cultivator) pass through the projection instead of hitting it."); _affectVisibility = ((BaseUnityPlugin)this).Config.Bind("General", "Disable Visibility When Hidden", true, "When hidden, disable plan-piece renderers so the semi-transparent ghost is not drawn."); _showMessage = ((BaseUnityPlugin)this).Config.Bind("General", "Show On-Screen Message", true, "Print a centre-screen message each time the projection is toggled."); ((MonoBehaviour)this).StartCoroutine(ReassertLoop()); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Baka PlanHide 1.0.0 loaded. Toggle key: " + _hotKey.Value)); } private void Update() { //IL_001c: 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) if (!((Object)(object)Player.m_localPlayer == (Object)null) && !IsTextInputActive()) { KeyboardShortcut value = _hotKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { Toggle(); } } } private void Toggle() { _hidden = !_hidden; ApplyAll(_hidden); if (_showMessage.Value && (Object)(object)Player.m_localPlayer != (Object)null) { ((Character)Player.m_localPlayer).Message((MessageType)2, _hidden ? "Plan projections: HIDDEN" : "Plan projections: SHOWN", 0, (Sprite)null); } } private IEnumerator ReassertLoop() { WaitForSeconds wait = new WaitForSeconds(0.5f); while (true) { yield return wait; if (_hidden) { ApplyAll(hide: true); } } } private void ApplyAll(bool hide) { PlanPiece[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (PlanPiece val in array) { if ((Object)(object)val == (Object)null) { continue; } if (_affectVisibility.Value) { Renderer[] componentsInChildren = ((Component)val).GetComponentsInChildren(true); for (int j = 0; j < componentsInChildren.Length; j++) { componentsInChildren[j].enabled = !hide; } } if (_affectCollision.Value) { Collider[] componentsInChildren2 = ((Component)val).GetComponentsInChildren(true); for (int k = 0; k < componentsInChildren2.Length; k++) { componentsInChildren2[k].enabled = !hide; } } } } private static bool IsTextInputActive() { if (Console.IsVisible()) { return true; } if (TextInput.IsVisible()) { return true; } return false; } }