using System;
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 Bounce.Unmanaged;
using RadialUI;
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("InvisibilityPlugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("InvisibilityPlugin")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("InvisibilityPlugin")]
[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.invisibility", "Invisibility Plug-In", "1.2.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class InvisibilityPlugin : BaseUnityPlugin
{
public enum VisibleState
{
visibleAll,
visibleOwnerOrGM,
visibleNot
}
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 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)
{
return ((Component)match.GetChild(0)).gameObject;
}
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)
{
if (match.childCount > 0)
{
return ((Component)match.GetChild(0)).gameObject;
}
return null;
}
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 const string Name = "Invisibility Plug-In";
public const string Guid = "org.lordashes.plugins.invisibility";
public const string Version = "1.2.0.0";
private Dictionary<CreatureGuid, Texture> invisible = new Dictionary<CreatureGuid, Texture>();
private Guid subscription = System.Guid.Empty;
private ConfigEntry<KeyboardShortcut> triggerInvisibility { get; set; }
private ConfigEntry<KeyboardShortcut> triggerRefresh { get; set; }
public void HandleRequest(DatumChange change)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
string[] obj = new string[8] { "Invisibility Plugin: Change For ", change.source, ", Type: ", null, null, null, null, null };
ChangeAction action = change.action;
obj[3] = ((object)(ChangeAction)(ref action)).ToString();
obj[4] = ", From: ";
obj[5] = change.previous?.ToString();
obj[6] = ", To: ";
obj[7] = change.value?.ToString();
Debug.Log((object)string.Concat(obj));
ApplyVisibility(change);
}
private void ApplyVisibility(DatumChange change)
{
//IL_0007: 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_004a: 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_006a: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Invalid comparison between Unknown and I4
//IL_0149: 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_0169: 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)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_021d: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_023c: Unknown result type (might be due to invalid IL or missing references)
//IL_02de: Unknown result type (might be due to invalid IL or missing references)
//IL_0298: Unknown result type (might be due to invalid IL or missing references)
CreatureBoardAsset val = default(CreatureBoardAsset);
CreaturePresenter.TryGetAsset(new CreatureGuid(change.source), ref val);
if (!((Object)(object)val != (Object)null))
{
return;
}
string[] obj = new string[8] { "Invisibility Plugin: Creature : ", val.Name, " : ", null, null, null, null, null };
CreatureGuid creatureId = val.CreatureId;
obj[3] = ((object)(CreatureGuid)(ref creatureId)).ToString();
obj[4] = " : ";
ChangeAction action = change.action;
obj[5] = ((object)(ChangeAction)(ref action)).ToString();
obj[6] = " : Controlled? ";
obj[7] = LocalClient.HasControlOfCreature(new CreatureGuid(change.source)).ToString();
Debug.Log((object)string.Concat(obj));
VisibleState visibleState = VisibleState.visibleNot;
if ((int)change.action == 1)
{
visibleState = VisibleState.visibleAll;
if (invisible.ContainsKey(new CreatureGuid(change.source)))
{
Debug.Log((object)"Invisibility Plugin: Restoring Base Loader Texture");
((Renderer)Utility.GetBaseLoader(val.CreatureId).GetComponent<MeshRenderer>()).material.mainTexture = invisible[new CreatureGuid(change.source)];
Debug.Log((object)"Invisibility Plugin: Removing Mini From Invisibility List");
invisible.Remove(new CreatureGuid(change.source));
}
}
else
{
if (LocalClient.HasControlOfCreature(new CreatureGuid(change.source)))
{
visibleState = VisibleState.visibleOwnerOrGM;
}
if (!invisible.ContainsKey(new CreatureGuid(change.source)))
{
Debug.Log((object)"Invisibility Plugin: Storing Base Loader Texture");
try
{
invisible.Add(new CreatureGuid(change.source), ((Renderer)Utility.GetBaseLoader(val.CreatureId).GetComponent<MeshRenderer>()).material.mainTexture);
}
catch (Exception)
{
Debug.Log((object)"Invisibility Plugin: Mini Not Yet Ready");
AssetDataPlugin.Reset("org.lordashes.plugins.invisibility");
return;
}
}
Debug.Log((object)"Invisibility Plugin: Changing Base Loader Texture");
((Renderer)Utility.GetBaseLoader(val.CreatureId).GetComponent<MeshRenderer>()).material.mainTexture = (Texture)(object)Image.LoadTexture("org.lordashes.plugins.invisibility\\Invisibility.png", (CacheType)999);
}
Debug.Log((object)"Invisibility Plugin: Getting Renderer");
Renderer componentInChildren = (Renderer)(object)Utility.GetAssetLoader(val.CreatureId).GetComponentInChildren<MeshRenderer>();
if ((Object)(object)componentInChildren == (Object)null)
{
componentInChildren = (Renderer)(object)Utility.GetAssetLoader(val.CreatureId).GetComponentInChildren<SkinnedMeshRenderer>();
}
if ((Object)(object)componentInChildren != (Object)null)
{
Debug.Log((object)("Invisibility Plugin: Turned " + ((object)componentInChildren).GetType().ToString() + " To " + visibleState));
componentInChildren.enabled = visibleState != VisibleState.visibleNot;
componentInChildren = (Renderer)(object)Utility.GetBaseLoader(val.CreatureId).GetComponentInChildren<MeshRenderer>();
componentInChildren.enabled = visibleState != VisibleState.visibleNot;
}
else
{
Debug.Log((object)("Invisibility Plugin: Could Not Find Renderer To Turn On For " + val.Name));
}
Debug.Log((object)"Invisibility Plugin: Getting Indicator Renderer");
MeshRenderer[] componentsInChildren = Utility.GetBaseLoader(val.CreatureId).GetComponentsInChildren<MeshRenderer>();
MeshRenderer[] array = componentsInChildren;
foreach (MeshRenderer val2 in array)
{
if (((Object)val2).name == "Indicator")
{
Debug.Log((object)("Invisibility Plugin: Turned Indicator To " + visibleState));
((Renderer)val2).enabled = visibleState != VisibleState.visibleNot;
break;
}
}
}
private void SetRequest(CreatureGuid cid)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
if (!invisible.ContainsKey(cid))
{
AssetDataPlugin.SetInfo(((object)(CreatureGuid)(ref cid)).ToString(), "org.lordashes.plugins.invisibility", "Invisible", false);
}
else
{
AssetDataPlugin.ClearInfo(((object)(CreatureGuid)(ref cid)).ToString(), "org.lordashes.plugins.invisibility", false);
}
}
private void Awake()
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: 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)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: 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_0188: Expected O, but got Unknown
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Expected O, but got Unknown
Debug.Log((object)"Invisibility Plugin: I'm Ready To Make Minis Disappear.");
triggerInvisibility = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Toggle Invisibility", new KeyboardShortcut((KeyCode)105, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), (ConfigDescription)null);
triggerRefresh = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Refresh", new KeyboardShortcut((KeyCode)105, (KeyCode[])(object)new KeyCode[1] { (KeyCode)305 }), (ConfigDescription)null);
if (((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Move Original Hide To GM Menu", false, (ConfigDescription)null).Value)
{
RadialUIPlugin.HideDefaultCharacterMenuItem("org.lordashes.plugins.invisibility.hideGMHide", "Hide", (ShouldShowMenu)null);
RadialUIPlugin.AddCustomButtonGMSubmenu("org.lordashes.plugins.invisibility.addGMHide", new ItemArgs
{
Title = "GM Hide",
Icon = Image.LoadSprite("Hide.png", (CacheType)999),
Action = delegate
{
//IL_0001: 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_0035: 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_0069: Unknown result type (might be due to invalid IL or missing references)
CreatureBoardAsset val2 = default(CreatureBoardAsset);
CreaturePresenter.TryGetAsset(new CreatureGuid(RadialUIPlugin.GetLastRadialTargetCreature()), ref val2);
string[] obj4 = new string[5] { "GM Hiding ", val2.Name, " (", null, null };
CreatureGuid creatureId2 = val2.CreatureId;
obj4[3] = ((object)(CreatureGuid)(ref creatureId2)).ToString();
obj4[4] = ")";
Debug.Log((object)string.Concat(obj4));
if ((Object)(object)val2 != (Object)null)
{
CreatureManager.SetCreatureExplicitHideState(val2.CreatureId, !val2.IsExplicitlyHidden);
}
},
CloseMenuOnActivate = true
}, (Func<NGuid, NGuid, bool>)((NGuid m, NGuid r) => true));
}
RadialUIPlugin.AddCustomButtonOnCharacter("org.lordashes.plugins.invisibility.addPCHide", new ItemArgs
{
Title = "PC Hide",
Icon = Image.LoadSprite("Hide.png", (CacheType)999),
Action = delegate
{
//IL_0001: 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_0035: 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_006a: Unknown result type (might be due to invalid IL or missing references)
CreatureBoardAsset val = default(CreatureBoardAsset);
CreaturePresenter.TryGetAsset(new CreatureGuid(RadialUIPlugin.GetLastRadialTargetCreature()), ref val);
string[] obj3 = new string[5] { "Player Hiding ", val.Name, " (", null, null };
CreatureGuid creatureId = val.CreatureId;
obj3[3] = ((object)(CreatureGuid)(ref creatureId)).ToString();
obj3[4] = ")";
Debug.Log((object)string.Concat(obj3));
if ((Object)(object)val != (Object)null)
{
SetRequest(val.CreatureId);
}
},
CloseMenuOnActivate = true
}, (Func<NGuid, NGuid, bool>)((NGuid m, NGuid r) => LocalClient.CanControlCreature(new CreatureGuid(r))));
Utility.PostOnMainPage(((object)this).GetType());
}
private void Update()
{
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Expected O, but got Unknown
if (Utility.isBoardLoaded())
{
if (subscription == System.Guid.Empty)
{
Debug.Log((object)"Invisibility Plugin: Subscribing To Invisibility Plugin Stat Messages...");
AssetDataPlugin.Reset("org.lordashes.plugins.invisibility");
subscription = AssetDataPlugin.Subscribe("org.lordashes.plugins.invisibility", (Action<DatumChange>)HandleRequest);
}
if (Utility.StrictKeyCheck(triggerInvisibility.Value))
{
Debug.Log((object)"Invisibility Plugin: Toggling Invisibility State...");
_ = LocalClient.SelectedCreatureId;
if (true)
{
SetRequest(LocalClient.SelectedCreatureId);
}
}
if (!Utility.StrictKeyCheck(triggerRefresh.Value))
{
return;
}
Debug.Log((object)"Invisibility Plugin: Refreshing Invisibility States...");
{
foreach (CreatureBoardAsset item in (IEnumerable<CreatureBoardAsset>)CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets())
{
DatumChange val = new DatumChange();
CreatureGuid creatureId = item.CreatureId;
val.source = ((object)(CreatureGuid)(ref creatureId)).ToString();
creatureId = item.CreatureId;
val.action = (ChangeAction)((!(AssetDataPlugin.ReadInfo(((object)(CreatureGuid)(ref creatureId)).ToString(), "org.lordashes.plugins.invisibility") != "")) ? 1 : 3);
val.key = "org.lordashes.plugins.invisibility";
val.value = "Refresh:" + DateTime.UtcNow;
ApplyVisibility(val);
}
return;
}
}
if (subscription != System.Guid.Empty)
{
AssetDataPlugin.Unsubscribe(subscription);
subscription = System.Guid.Empty;
}
}
private void PlayerHide(CreatureGuid cid, string txt, MapMenuItem mmi)
{
//IL_0001: 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_0035: 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_006a: Unknown result type (might be due to invalid IL or missing references)
CreatureBoardAsset val = default(CreatureBoardAsset);
CreaturePresenter.TryGetAsset(new CreatureGuid(RadialUIPlugin.GetLastRadialTargetCreature()), ref val);
string[] obj = new string[5] { "Invisibility Plugin: Player Hiding ", val.Name, " (", null, null };
CreatureGuid creatureId = val.CreatureId;
obj[3] = ((object)(CreatureGuid)(ref creatureId)).ToString();
obj[4] = ")";
Debug.Log((object)string.Concat(obj));
if ((Object)(object)val != (Object)null)
{
SetRequest(val.CreatureId);
}
}
private void GMHide(CreatureGuid cid, string txt, MapMenuItem mmi)
{
//IL_0001: 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_0035: 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_0069: Unknown result type (might be due to invalid IL or missing references)
CreatureBoardAsset val = default(CreatureBoardAsset);
CreaturePresenter.TryGetAsset(new CreatureGuid(RadialUIPlugin.GetLastRadialTargetCreature()), ref val);
string[] obj = new string[5] { "Invisibility Plugin: GM Hiding ", val.Name, " (", null, null };
CreatureGuid creatureId = val.CreatureId;
obj[3] = ((object)(CreatureGuid)(ref creatureId)).ToString();
obj[4] = ")";
Debug.Log((object)string.Concat(obj));
if ((Object)(object)val != (Object)null)
{
CreatureManager.SetCreatureExplicitHideState(val.CreatureId, !val.IsExplicitlyHidden);
}
}
}