using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Bounce.Singletons;
using HarmonyLib;
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("MonsterStatsPlugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MonsterStatsPlugin")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("MonsterStatsPlugin")]
[assembly: ComVisible(false)]
[assembly: Guid("c303405d-e66c-4316-9cdb-4e3ca15c6360")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LordAshes;
[BepInPlugin("org.lordashes.plugins.monsterstats", "Monster Stats Plug-In", "1.0.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class MonsterStatsPlugin : BaseUnityPlugin
{
public static class Utility
{
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 + "\nLord Ashes' " + val.Name + " - " + val.Version;
}
}
}
catch (Exception ex)
{
Debug.Log((object)ex);
}
};
}
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;
}
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;
}
}
public const string Name = "Monster Stats Plug-In";
public const string Guid = "org.lordashes.plugins.monsterstats";
public const string Version = "1.0.0.0";
public static MonsterStatsPlugin _self = null;
public static string edition = "5E";
public static List<string> monsterOptions = new List<string>();
public static CreatureBoardAsset monsterAsset = null;
public static GUIStyle guistyle = new GUIStyle();
public static List<CreatureBoardAsset> recordedAssets = null;
public static bool startupSequence = true;
private void Awake()
{
//IL_004a: 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)
Debug.Log((object)("Monster Stats Plugin: " + ((object)this).GetType().AssemblyQualifiedName + " Active."));
_self = this;
guistyle.alignment = (TextAnchor)4;
guistyle.fontSize = 16;
guistyle.normal.textColor = Color.white;
guistyle.normal.background = Texture2D.blackTexture;
((MonoBehaviour)this).StartCoroutine("StartupDelay");
new Harmony("org.lordashes.plugins.monsterstats").PatchAll();
Utility.PostOnMainPage(((object)this).GetType());
}
private void Update()
{
if (recordedAssets == null)
{
recordedAssets = new List<CreatureBoardAsset>();
}
if (recordedAssets.Count == CreaturePresenter.AllCreatureAssets.Count)
{
return;
}
foreach (CreatureBoardAsset allCreatureAsset in CreaturePresenter.AllCreatureAssets)
{
if (!recordedAssets.Contains(allCreatureAsset))
{
recordedAssets.Add(allCreatureAsset);
Debug.Log((object)("Monster Stats Plugin: Found New Asset. Startup Sequence = " + startupSequence));
if (!startupSequence)
{
Debug.Log((object)("Monster Stats Plugin: Requesting Monster Selection For " + allCreatureAsset.Name));
monsterAsset = allCreatureAsset;
GetMonsterChoice(allCreatureAsset);
}
}
}
}
private void OnGUI()
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
if (monsterOptions.Count <= 0)
{
return;
}
int num = Screen.width / 2 - 150;
int num2 = 60;
for (int i = 0; i < monsterOptions.Count; i++)
{
if (GUI.Button(new Rect((float)num, (float)num2, 300f, 30f), monsterOptions[i], guistyle))
{
Debug.Log((object)("Monster Stats Plugin: Requesting Monster Selection For " + monsterOptions[i]));
CreatureBoardAsset val = monsterAsset;
string text = monsterOptions[i];
monsterAsset = null;
monsterOptions.Clear();
GetMonsterStats(new object[2]
{
monsterOptions[i],
monsterAsset
});
}
num2 += 40;
}
}
public static void GetMonsterChoice(CreatureBoardAsset asset)
{
Debug.Log((object)("Monster Stats Plugin: Calling " + Paths.PluginPath + "\\Testing\\MonsterStats." + edition + ".exe LIST " + asset.Name));
Process process = new Process
{
StartInfo = new ProcessStartInfo
{
WorkingDirectory = Paths.PluginPath + "\\Testing\\",
FileName = Paths.PluginPath + "\\Testing\\MonsterStats." + edition + ".exe",
Arguments = "LIST " + StripName(asset.Name),
UseShellExecute = false,
RedirectStandardOutput = true
}
};
process.Start();
string text = process.StandardOutput.ReadToEnd();
process.WaitForExit();
Debug.Log((object)("Monster Stats Plugin: Found " + text.Split(new string[1] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).Length + " Entries"));
string[] array = text.Split(new string[1] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
foreach (string item in array)
{
monsterOptions.Add(item);
}
}
public static void GetMonsterStats(object[] inputs)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Expected O, but got Unknown
string text = (string)inputs[0];
CreatureBoardAsset val = (CreatureBoardAsset)inputs[1];
Debug.Log((object)("Monster Stats Plugin: Getting Monster Stats For '" + val.Name + "'"));
Debug.Log((object)("Monster Stats Plugin: Calling " + Paths.PluginPath + "\\Testing\\MonsterStats." + edition + ".exe GET " + text));
Process process = new Process
{
StartInfo = new ProcessStartInfo
{
WorkingDirectory = Paths.PluginPath + "\\Testing\\",
FileName = Paths.PluginPath + "\\Testing\\MonsterStats." + edition + ".exe",
Arguments = "GET " + text,
UseShellExecute = false,
RedirectStandardOutput = true
}
};
process.Start();
string text2 = process.StandardOutput.ReadToEnd();
process.WaitForExit();
Debug.Log((object)("Monster Stats Plugin: Get " + text2.Split(new string[1] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).Length + " Stats For Monster 'Monster Stats Plug-In'"));
string[] array = text2.Split(new string[1] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
foreach (string item in array)
{
monsterOptions.Add(item);
}
}
public IEnumerator StartupDelay()
{
yield return (object)new WaitForSeconds(5f);
Debug.Log((object)"Monster Stats Plugin: Toggling Startup Sequence To False");
startupSequence = false;
}
public static string StripName(string name)
{
if (!name.Contains("<size=0>"))
{
return name;
}
return name.Substring(0, name.IndexOf("<size=0>")).Trim();
}
}