using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using Bounce.Singletons;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("UIAssetPlugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("UIAssetPlugin")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("UIAssetPlugin")]
[assembly: ComVisible(false)]
[assembly: Guid("c303405d-e66c-4316-9cdb-4e3ca15c6360")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.2.0.0")]
namespace LordAshes;
[BepInPlugin("org.lordashes.plugins.uiassets", "UI Asset Plug-In", "1.2.0.0")]
public class UIAssetPlugin : BaseUnityPlugin
{
public static class Utility
{
private static GameInput gameInputInstance;
private static MethodInfo gameInputDisable;
private static MethodInfo gameInputEnable;
public static void GameInputEnabled(bool setting)
{
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Expected O, but got Unknown
if (gameInputInstance == null || gameInputDisable == null || gameInputEnable == null)
{
try
{
Debug.Log((object)"Plane Image Plugin: Getting Game Input Reference");
gameInputInstance = null;
gameInputDisable = null;
gameInputEnable = null;
gameInputInstance = (GameInput)(from f in typeof(ControllerManager).GetRuntimeFields()
where f.Name == "_gameInput"
select f).ToArray()[0].GetValue(null);
gameInputDisable = (from m in typeof(GameInput).GetMethods()
where m.Name == "Disable"
select m).ElementAt(0);
gameInputEnable = (from m in typeof(GameInput).GetMethods()
where m.Name == "Enable"
select m).ElementAt(0);
}
catch
{
Debug.LogWarning((object)"Plane Image Plugin: Unable To Get Game Input Reference Or Reference To One Of Its Methods");
}
}
if (setting)
{
Debug.Log((object)"Plane Image Plugin: Enabling Game Input");
gameInputEnable.Invoke(gameInputInstance, new object[0]);
}
else
{
Debug.Log((object)"Plane Image Plugin: Disabling Game Input");
gameInputDisable.Invoke(gameInputInstance, new object[0]);
}
}
public static bool isBoardLoaded()
{
return SimpleSingletonBehaviour<CameraController>.HasInstance && SingletonStateMBehaviour<BoardSessionManager, State<BoardSessionManager>>.HasInstance && !BoardSessionManager.IsLoading;
}
public static bool StrictKeyCheck(KeyboardShortcut check)
{
//IL_002e: 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_003f: Unknown result type (might be due to invalid IL or missing references)
if (!((KeyboardShortcut)(ref check)).IsUp())
{
return false;
}
KeyCode[] array = new KeyCode[6];
RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
KeyCode[] array2 = (KeyCode[])(object)array;
foreach (KeyCode val in array2)
{
if (Input.GetKey(val) != ((KeyboardShortcut)(ref check)).Modifiers.Contains(val))
{
return false;
}
}
return true;
}
public static Guid GuidFromString(string input)
{
using MD5 mD = MD5.Create();
byte[] b = mD.ComputeHash(Encoding.Default.GetBytes(input));
return new Guid(b);
}
public static GameObject GetBaseLoader(CreatureGuid cid)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
try
{
CreatureBoardAsset val = null;
CreaturePresenter.TryGetAsset(cid, ref val);
if ((Object)(object)val != (Object)null)
{
Transform match = null;
Traverse(((Component)val).transform, "BaseLoader", 0, 10, ref match);
if ((Object)(object)match != (Object)null)
{
Debug.Log((object)("UI Asset Plugin: Base Loader '" + ((Object)match.GetChild(0)).name + "' Found"));
return ((Component)match.GetChild(0)).gameObject;
}
Debug.LogWarning((object)"UI Asset Plugin: Could Not Find Base Loader");
return null;
}
return null;
}
catch
{
return null;
}
}
public static GameObject GetAssetLoader(CreatureGuid cid)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
try
{
CreatureBoardAsset val = null;
CreaturePresenter.TryGetAsset(cid, ref val);
if ((Object)(object)val != (Object)null)
{
Transform match = null;
Traverse(((Component)val).transform, "AssetLoader", 0, 10, ref match);
if ((Object)(object)match != (Object)null)
{
Debug.Log((object)("UI Asset Plugin: Asset Loader '" + ((Object)match.GetChild(0)).name + "' Found"));
return ((Component)match.GetChild(0)).gameObject;
}
Debug.LogWarning((object)"UI Asset Plugin: Could Not Find Asset Loader");
return null;
}
return null;
}
catch
{
return null;
}
}
public static void Traverse(Transform root, string seek, int depth, int depthMax, ref Transform match)
{
try
{
if ((Object)(object)match != (Object)null)
{
return;
}
if (((Object)root).name == seek)
{
match = root;
return;
}
foreach (Transform item in ExtensionMethods.Children(root))
{
if (depth < depthMax)
{
Traverse(item, seek, depth + 1, depthMax, ref match);
}
}
}
catch
{
}
}
public static float ParseFloat(string value)
{
return float.Parse(value, CultureInfo.InvariantCulture);
}
public static string GetCreatureName(string nameBlock)
{
if (nameBlock == null)
{
return "(Unknown)";
}
if (!nameBlock.Contains("<size=0>"))
{
return nameBlock;
}
return nameBlock.Substring(0, nameBlock.IndexOf("<size=0>")).Trim();
}
public static void PostOnMainPage(MemberInfo plugin)
{
SceneManager.sceneLoaded += delegate(Scene scene, LoadSceneMode mode)
{
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Expected O, but got Unknown
try
{
if (((Scene)(ref scene)).name == "UI")
{
TextMeshProUGUI uITextByName = GetUITextByName("BETA");
if (Object.op_Implicit((Object)(object)uITextByName))
{
((TMP_Text)uITextByName).text = "INJECTED BUILD - unstable mods";
}
}
else
{
TextMeshProUGUI uITextByName2 = GetUITextByName("TextMeshPro Text");
if (Object.op_Implicit((Object)(object)uITextByName2))
{
BepInPlugin val = (BepInPlugin)Attribute.GetCustomAttribute(plugin, typeof(BepInPlugin));
if (((TMP_Text)uITextByName2).text.EndsWith("</size>"))
{
((TMP_Text)uITextByName2).text = ((TMP_Text)uITextByName2).text + "\n\nMods Currently Installed:\n";
}
TextMeshProUGUI val2 = uITextByName2;
((TMP_Text)val2).text = ((TMP_Text)val2).text + "\nPlugin Masters' " + val.Name + " - " + val.Version;
}
}
}
catch (Exception ex)
{
Debug.Log((object)ex);
}
};
}
private static TextMeshProUGUI GetUITextByName(string name)
{
TextMeshProUGUI[] array = Object.FindObjectsOfType<TextMeshProUGUI>();
for (int i = 0; i < array.Length; i++)
{
if (((Object)array[i]).name == name)
{
return array[i];
}
}
return null;
}
}
private enum Triggers
{
command,
backward,
forward,
search,
select,
reveal,
hide,
fly,
nofly,
delete
}
public class Wildcard : Regex
{
public Wildcard(string pattern)
: base(WildcardToRegex(pattern))
{
}
public Wildcard(string pattern, RegexOptions options)
: base(WildcardToRegex(pattern), options)
{
}
public static string WildcardToRegex(string pattern)
{
return "^" + Regex.Escape(pattern).Replace("\\*", ".*").Replace("\\?", ".") + "$";
}
}
public const string Name = "UI Asset Plug-In";
public const string Guid = "org.lordashes.plugins.uiassets";
public const string Version = "1.2.0.0";
public static UIAssetPlugin _self;
private int assetIndex = 0;
private int statusShowing = -1;
private string statusMessage = "";
private string menuString = "Command: 1=Cycle Backward | 2=Cycle Forward | 3=Search | 4=Select | 5=Reveal | 6=Hide | 7=Fly | 8=No Fly | 9=Delete | End=Exit";
private ConfigEntry<KeyboardShortcut>[] triggerKey { get; set; } = new ConfigEntry<KeyboardShortcut>[10];
private void Awake()
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: 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_01c3: Unknown result type (might be due to invalid IL or missing references)
Debug.Log((object)("UI Asset Plugin: " + ((object)this).GetType().AssemblyQualifiedName + " Active."));
_self = this;
triggerKey[0] = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Toggle Command Mode", new KeyboardShortcut((KeyCode)279, Array.Empty<KeyCode>()), (ConfigDescription)null);
triggerKey[1] = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Toggle Assets Backward", new KeyboardShortcut((KeyCode)49, Array.Empty<KeyCode>()), (ConfigDescription)null);
triggerKey[2] = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Toggle Assets Forward", new KeyboardShortcut((KeyCode)50, Array.Empty<KeyCode>()), (ConfigDescription)null);
triggerKey[3] = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Assets Search", new KeyboardShortcut((KeyCode)51, Array.Empty<KeyCode>()), (ConfigDescription)null);
triggerKey[4] = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Assets Select", new KeyboardShortcut((KeyCode)52, Array.Empty<KeyCode>()), (ConfigDescription)null);
triggerKey[5] = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Assets Reveal", new KeyboardShortcut((KeyCode)53, Array.Empty<KeyCode>()), (ConfigDescription)null);
triggerKey[6] = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Assets Hide", new KeyboardShortcut((KeyCode)54, Array.Empty<KeyCode>()), (ConfigDescription)null);
triggerKey[7] = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Assets Fly", new KeyboardShortcut((KeyCode)55, Array.Empty<KeyCode>()), (ConfigDescription)null);
triggerKey[8] = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Assets Ground", new KeyboardShortcut((KeyCode)56, Array.Empty<KeyCode>()), (ConfigDescription)null);
triggerKey[9] = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Assets Delete", new KeyboardShortcut((KeyCode)57, Array.Empty<KeyCode>()), (ConfigDescription)null);
Utility.PostOnMainPage(((object)this).GetType());
}
private void Update()
{
//IL_0016: 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_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_0100: 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_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_0215: Unknown result type (might be due to invalid IL or missing references)
//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
//IL_0284: 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_022f: Unknown result type (might be due to invalid IL or missing references)
//IL_0248: Unknown result type (might be due to invalid IL or missing references)
//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
//IL_0367: Unknown result type (might be due to invalid IL or missing references)
//IL_036c: Unknown result type (might be due to invalid IL or missing references)
//IL_0317: Unknown result type (might be due to invalid IL or missing references)
//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
//IL_0386: Unknown result type (might be due to invalid IL or missing references)
//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
//IL_044a: Unknown result type (might be due to invalid IL or missing references)
if (!Utility.isBoardLoaded())
{
return;
}
KeyboardShortcut value = triggerKey[0].Value;
if (((KeyboardShortcut)(ref value)).IsUp())
{
if (!statusMessage.StartsWith("Command"))
{
Debug.Log((object)"UI Asset Plugin: Command On");
assetIndex--;
DisplayMessage(menuString);
Utility.GameInputEnabled(setting: false);
}
else
{
Debug.Log((object)"UI Asset Plugin: Command Off");
statusMessage = "";
statusShowing = -1;
Utility.GameInputEnabled(setting: true);
}
}
if (!statusMessage.StartsWith("Command"))
{
return;
}
value = triggerKey[2].Value;
if (((KeyboardShortcut)(ref value)).IsUp())
{
Debug.Log((object)"UI Asset Plugin: Cycle Forward");
assetIndex++;
DisplayMessage("");
return;
}
value = triggerKey[1].Value;
if (((KeyboardShortcut)(ref value)).IsUp())
{
Debug.Log((object)"UI Asset Plugin: Cycle Backward");
assetIndex--;
DisplayMessage("");
return;
}
value = triggerKey[3].Value;
if (((KeyboardShortcut)(ref value)).IsUp())
{
Debug.Log((object)"UI Asset Plugin: Search Asset");
SystemMessage.AskForTextInput("Asset Name Search", "Name Pattern", 1, "Search", (Action<string>)delegate(string pattern)
{
//IL_0001: 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_0049: Unknown result type (might be due to invalid IL or missing references)
int length = CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets().Length;
List<CreatureBoardAsset> source = ((IEnumerable<CreatureBoardAsset>)(object)CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets()).ToList();
string message = "Command Status: No Matching Asset Found";
assetIndex--;
for (int i = 0; i < length; i++)
{
assetIndex++;
if (assetIndex > CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets().Length - 1)
{
assetIndex = 0;
}
if (Regex.IsMatch(source.ElementAt(assetIndex).Name, pattern))
{
message = "Command Status: Found " + Utility.GetCreatureName(source.ElementAt(assetIndex).Name);
break;
}
}
DisplayMessage(message);
}, (Action)null, "Cancel", (Action)null, "");
return;
}
value = triggerKey[4].Value;
if (((KeyboardShortcut)(ref value)).IsUp())
{
Debug.Log((object)"UI Asset Plugin: Select Asset");
CreatureBoardAsset val = ((IEnumerable<CreatureBoardAsset>)(object)CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets()).ElementAt(assetIndex);
val.Select();
DisplayMessage("Command Status: " + Utility.GetCreatureName(val.Name) + " Selected");
return;
}
value = triggerKey[5].Value;
if (((KeyboardShortcut)(ref value)).IsUp())
{
Debug.Log((object)"UI Asset Plugin: Reveal Asset");
CreatureBoardAsset val2 = ((IEnumerable<CreatureBoardAsset>)(object)CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets()).ElementAt(assetIndex);
CreatureManager.SetCreatureExplicitHideState(val2.CreatureId, false);
DisplayMessage("Command Status: " + Utility.GetCreatureName(val2.Name) + " Revealed");
return;
}
value = triggerKey[6].Value;
if (((KeyboardShortcut)(ref value)).IsUp())
{
Debug.Log((object)"UI Asset Plugin: Hide Asset");
CreatureBoardAsset val3 = ((IEnumerable<CreatureBoardAsset>)(object)CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets()).ElementAt(assetIndex);
CreatureManager.SetCreatureExplicitHideState(val3.CreatureId, true);
DisplayMessage("Command Status: " + Utility.GetCreatureName(val3.Name) + " Hidden");
return;
}
value = triggerKey[7].Value;
if (((KeyboardShortcut)(ref value)).IsUp())
{
Debug.Log((object)"UI Asset Plugin: Fly Asset");
CreatureBoardAsset val4 = ((IEnumerable<CreatureBoardAsset>)(object)CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets()).ElementAt(assetIndex);
((MovableBoardAsset)val4).EnableFlying(true);
DisplayMessage("Command Status: " + Utility.GetCreatureName(val4.Name) + " Is Flying");
return;
}
value = triggerKey[8].Value;
if (((KeyboardShortcut)(ref value)).IsUp())
{
Debug.Log((object)"UI Asset Plugin: Ground Asset");
CreatureBoardAsset val5 = ((IEnumerable<CreatureBoardAsset>)(object)CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets()).ElementAt(assetIndex);
((MovableBoardAsset)val5).EnableFlying(false);
DisplayMessage("Command Status: " + Utility.GetCreatureName(val5.Name) + " Is Grounded");
return;
}
value = triggerKey[9].Value;
if (((KeyboardShortcut)(ref value)).IsUp())
{
Debug.Log((object)"UI Asset Plugin: Delete Asset");
CreatureBoardAsset val6 = ((IEnumerable<CreatureBoardAsset>)(object)CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets()).ElementAt(assetIndex);
DisplayMessage("Command Status: " + Utility.GetCreatureName(val6.Name) + " Deleted");
Object.Destroy((Object)(object)((Component)val6).gameObject);
val6.RequestDelete();
if (assetIndex > CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets().Length - 1)
{
assetIndex = 0;
}
}
}
private void OnGUI()
{
//IL_0015: 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_0039: 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_00a2: 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)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: Unknown result type (might be due to invalid IL or missing references)
if (statusShowing >= 0 && CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets().Length > 0)
{
if (assetIndex < 0)
{
assetIndex = CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets().Length - 1;
}
if (assetIndex > CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets().Length - 1)
{
assetIndex = 0;
}
CreatureBoardAsset val = ((IEnumerable<CreatureBoardAsset>)(object)CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets()).ElementAt(assetIndex);
Rect val2 = new Rect((float)(Screen.width / 2), (float)(Screen.height - 70), (float)(Screen.width / 2), 120f);
string[] obj = new string[14]
{
"UI Asset: ",
Utility.GetCreatureName(val.Name),
" (",
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null
};
CreatureGuid creatureId = val.CreatureId;
obj[3] = ((object)(CreatureGuid)(ref creatureId)).ToString();
obj[4] = "), Unique: ";
obj[5] = val.IsUnique.ToString();
obj[6] = ", Visible: ";
obj[7] = ((MovableBoardAsset)val).IsVisible.ToString();
obj[8] = ", Hidden: ";
obj[9] = val.IsExplicitlyHidden.ToString();
obj[10] = ", Flying: ";
obj[11] = ((MovableBoardAsset)val).IsFlying.ToString();
obj[12] = ", Enabled: ";
obj[13] = ((Behaviour)val).enabled.ToString();
GUI.Label(val2, string.Concat(obj));
GUI.Label(new Rect((float)(Screen.width / 2), (float)(Screen.height - 40), (float)(Screen.width / 2), 120f), statusMessage);
}
}
private void DisplayMessage(string message)
{
if (message != "")
{
statusMessage = message;
}
if (statusShowing <= 0)
{
Debug.Log((object)"UI Asset Plugin: Starting Status");
((MonoBehaviour)_self).StartCoroutine(HideStatus());
}
statusShowing = 12;
}
private IEnumerator HideStatus()
{
for (statusShowing = 12; statusShowing > 0; statusShowing--)
{
yield return (object)new WaitForSeconds(0.25f);
}
statusMessage = menuString;
}
}