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 DataModel;
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("GetInGetOutPlugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GetInGetOutPlugin")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("GetInGetOutPlugin")]
[assembly: ComVisible(false)]
[assembly: Guid("c303405d-e66c-4316-9cdb-4e3ca15c6360")]
[assembly: AssemblyFileVersion("2.2.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("2.2.0.0")]
namespace LordAshes;
[BepInPlugin("org.lordashes.plugins.getingetout", "Get In / Get Out Plug-In", "2.2.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class GetInGetOutPlugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(MovableBoardAsset), "SwitchState")]
public static class Patch01
{
public static bool Prefix(State state)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Invalid comparison between Unknown and I4
if ((int)state == 1)
{
Debug.Log((object)"Get In / Get Out Plugin: Patch: Object Dropped");
_callback();
}
return true;
}
}
public static class PatchAssistant
{
public static object GetProperty(object instance, string propertyName)
{
Type type = instance.GetType();
foreach (PropertyInfo runtimeProperty in type.GetRuntimeProperties())
{
if (runtimeProperty.Name.Contains(propertyName))
{
return runtimeProperty.GetValue(instance);
}
}
PropertyInfo[] properties = type.GetProperties();
foreach (PropertyInfo propertyInfo in properties)
{
if (propertyInfo.Name.Contains(propertyName))
{
return propertyInfo.GetValue(instance);
}
}
return null;
}
public static void SetProperty(object instance, string propertyName, object value)
{
Type type = instance.GetType();
foreach (PropertyInfo runtimeProperty in type.GetRuntimeProperties())
{
if (runtimeProperty.Name.Contains(propertyName))
{
runtimeProperty.SetValue(instance, value);
return;
}
}
PropertyInfo[] properties = type.GetProperties();
foreach (PropertyInfo propertyInfo in properties)
{
if (propertyInfo.Name.Contains(propertyName))
{
propertyInfo.SetValue(instance, value);
break;
}
}
}
public static object GetField(object instance, string fieldName)
{
Type type = instance.GetType();
foreach (FieldInfo runtimeField in type.GetRuntimeFields())
{
if (runtimeField.Name.Contains(fieldName))
{
return runtimeField.GetValue(instance);
}
}
FieldInfo[] fields = type.GetFields();
foreach (FieldInfo fieldInfo in fields)
{
if (fieldInfo.Name.Contains(fieldName))
{
return fieldInfo.GetValue(instance);
}
}
return null;
}
public static void SetField(object instance, string fieldName, object value)
{
Type type = instance.GetType();
foreach (FieldInfo runtimeField in type.GetRuntimeFields())
{
if (runtimeField.Name.Contains(fieldName))
{
runtimeField.SetValue(instance, value);
return;
}
}
FieldInfo[] fields = type.GetFields();
foreach (FieldInfo fieldInfo in fields)
{
if (fieldInfo.Name.Contains(fieldName))
{
fieldInfo.SetValue(instance, value);
break;
}
}
}
public static object UseMethod(object instance, string methodName, object[] parameters)
{
Type type = instance.GetType();
foreach (MethodInfo runtimeMethod in type.GetRuntimeMethods())
{
if (runtimeMethod.Name.Contains(methodName))
{
return runtimeMethod.Invoke(instance, parameters);
}
}
MethodInfo[] methods = type.GetMethods();
foreach (MethodInfo methodInfo in methods)
{
if (methodInfo.Name.Contains(methodName))
{
return methodInfo.Invoke(instance, parameters);
}
}
return null;
}
}
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 GetRootObject(CreatureGuid cid)
{
//IL_0003: 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_0062: Expected O, but got Unknown
CreatureBoardAsset val = null;
CreaturePresenter.TryGetAsset(cid, ref val);
if ((Object)(object)val != (Object)null)
{
Type typeFromHandle = typeof(CreatureBoardAsset);
foreach (FieldInfo runtimeField in typeFromHandle.GetRuntimeFields())
{
if (runtimeField.Name == "_creatureRoot")
{
Transform val2 = (Transform)runtimeField.GetValue(val);
return ((Component)val2).gameObject;
}
}
}
return null;
}
public static GameObject GetBaseObject(CreatureGuid cid)
{
//IL_0003: 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_0062: Expected O, but got Unknown
CreatureBoardAsset val = null;
CreaturePresenter.TryGetAsset(cid, ref val);
if ((Object)(object)val != (Object)null)
{
Type typeFromHandle = typeof(CreatureBoardAsset);
foreach (FieldInfo runtimeField in typeFromHandle.GetRuntimeFields())
{
if (runtimeField.Name == "_base")
{
CreatureBase val2 = (CreatureBase)runtimeField.GetValue(val);
return ((Component)((Component)val2).transform.GetChild(0)).gameObject;
}
}
}
return null;
}
public static GameObject GetAssetObject(CreatureGuid cid)
{
//IL_0003: 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_0062: Expected O, but got Unknown
CreatureBoardAsset val = null;
CreaturePresenter.TryGetAsset(cid, ref val);
if ((Object)(object)val != (Object)null)
{
Type typeFromHandle = typeof(CreatureBoardAsset);
foreach (FieldInfo runtimeField in typeFromHandle.GetRuntimeFields())
{
if (runtimeField.Name == "_creatureRoot")
{
Transform val2 = (Transform)runtimeField.GetValue(val);
return ((Component)val2.GetChild(0).GetChild(2).GetChild(0)).gameObject;
}
}
}
return null;
}
}
public static Action _callback;
public const string Name = "Get In / Get Out Plug-In";
public const string Guid = "org.lordashes.plugins.getingetout";
public const string Version = "2.2.0.0";
private Dictionary<CreatureGuid, string> locations = new Dictionary<CreatureGuid, string>();
public static void Register(Action callback)
{
_callback = callback;
}
private void Awake()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
Debug.Log((object)"Get In / Get Out Plugin: Active.");
Harmony val = new Harmony("org.lordashes.plugins.getingetout");
val.PatchAll();
Register(delegate
{
CheckAreas();
});
}
private void Update()
{
if (!Utility.isBoardLoaded())
{
}
}
public void CheckAreas()
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: 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_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: 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_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0202: Unknown result type (might be due to invalid IL or missing references)
//IL_0224: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: Unknown result type (might be due to invalid IL or missing references)
//IL_0232: Unknown result type (might be due to invalid IL or missing references)
//IL_0237: Unknown result type (might be due to invalid IL or missing references)
//IL_0254: Unknown result type (might be due to invalid IL or missing references)
//IL_0263: Unknown result type (might be due to invalid IL or missing references)
//IL_026f: Unknown result type (might be due to invalid IL or missing references)
//IL_0274: Unknown result type (might be due to invalid IL or missing references)
//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
//IL_04f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0513: Unknown result type (might be due to invalid IL or missing references)
//IL_0525: Unknown result type (might be due to invalid IL or missing references)
//IL_0357: Unknown result type (might be due to invalid IL or missing references)
//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0304: Unknown result type (might be due to invalid IL or missing references)
//IL_0334: Unknown result type (might be due to invalid IL or missing references)
//IL_0375: Unknown result type (might be due to invalid IL or missing references)
//IL_046e: Unknown result type (might be due to invalid IL or missing references)
//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
//IL_040c: Unknown result type (might be due to invalid IL or missing references)
//IL_043c: Unknown result type (might be due to invalid IL or missing references)
HideVolumeMenuPlugin val = HideVolumeMenuPlugin.Instance();
Dictionary<NGuid, StateHideVolume> currentHideVolumeStates = val.CurrentHideVolumeStates;
foreach (CreatureBoardAsset item in (IEnumerable<CreatureBoardAsset>)CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets())
{
if (!locations.ContainsKey(item.CreatureId))
{
locations.Add(item.CreatureId, "");
}
string[] obj = new string[6]
{
"Get In / Get Out Plugin: Creature ",
StatMessaging.GetCreatureName(item),
" at ",
null,
null,
null
};
Vector3 val2 = Utility.GetRootObject(item.CreatureId).transform.position;
obj[3] = ((object)(Vector3)(ref val2)).ToString();
obj[4] = " was in ";
obj[5] = locations[item.CreatureId];
Debug.Log((object)string.Concat(obj));
bool flag = false;
foreach (StateHideVolume value in currentHideVolumeStates.Values)
{
string[] obj2 = new string[14]
{
"Get In / Get Out Plugin: Hide Volume ", value.Name, " Bounds ", null, null, null, null, null, null, null,
null, null, null, null
};
HideVolume hideVolume = value.Volume.HideVolume;
val2 = ((Bounds)(ref hideVolume.Bounds)).min;
obj2[3] = val2.x.ToString();
obj2[4] = "->";
hideVolume = value.Volume.HideVolume;
val2 = ((Bounds)(ref hideVolume.Bounds)).max;
obj2[5] = val2.x.ToString();
obj2[6] = ",";
hideVolume = value.Volume.HideVolume;
val2 = ((Bounds)(ref hideVolume.Bounds)).min;
obj2[7] = val2.y.ToString();
obj2[8] = "->";
hideVolume = value.Volume.HideVolume;
val2 = ((Bounds)(ref hideVolume.Bounds)).max;
obj2[9] = val2.y.ToString();
obj2[10] = ",";
hideVolume = value.Volume.HideVolume;
val2 = ((Bounds)(ref hideVolume.Bounds)).min;
obj2[11] = val2.z.ToString();
obj2[12] = "->";
hideVolume = value.Volume.HideVolume;
val2 = ((Bounds)(ref hideVolume.Bounds)).max;
obj2[13] = val2.z.ToString();
Debug.Log((object)string.Concat(obj2));
if (isInside(Utility.GetRootObject(item.CreatureId).transform.position, value.Volume.HideVolume.Bounds))
{
Debug.Log((object)("Get In / Get Out Plugin: Creature Is In Now In Area " + value.Name));
flag = true;
if (locations[item.CreatureId] == "" && locations[item.CreatureId] != value.Name)
{
locations[item.CreatureId] = value.Name;
StatMessaging.SetInfo(item.CreatureId, "AssetLocation", value.Name);
Debug.Log((object)("Get In / Get Out Plugin: " + StatMessaging.GetCreatureName(item) + " has entered " + locations[item.CreatureId]));
}
else if (locations[item.CreatureId] != "" && locations[item.CreatureId] != value.Name)
{
Debug.Log((object)("Get In / Get Out Plugin: " + StatMessaging.GetCreatureName(item) + " has exited " + locations[item.CreatureId]));
locations[item.CreatureId] = "";
StatMessaging.ClearInfo(item.CreatureId, "AssetLocation");
locations[item.CreatureId] = value.Name;
StatMessaging.SetInfo(item.CreatureId, "AssetLocation", value.Name);
Debug.Log((object)("Get In / Get Out Plugin: " + StatMessaging.GetCreatureName(item) + " has entered " + locations[item.CreatureId]));
}
else
{
Debug.Log((object)("Get In / Get Out Plugin: " + StatMessaging.GetCreatureName(item) + " is still in " + locations[item.CreatureId]));
}
}
if (flag)
{
break;
}
}
if (!flag && locations[item.CreatureId] != "")
{
Debug.Log((object)("Get In / Get Out Plugin: " + StatMessaging.GetCreatureName(item) + " has exited " + locations[item.CreatureId]));
locations[item.CreatureId] = "";
StatMessaging.ClearInfo(item.CreatureId, "AssetLocation");
}
}
}
public bool isInside(Vector3 pos, Bounds bounds)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: 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)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: 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_0060: Unknown result type (might be due to invalid IL or missing references)
if (pos.x < ((Bounds)(ref bounds)).min.x)
{
return false;
}
if (pos.x > ((Bounds)(ref bounds)).max.x)
{
return false;
}
if (pos.z < ((Bounds)(ref bounds)).min.z)
{
return false;
}
if (pos.z > ((Bounds)(ref bounds)).max.z)
{
return false;
}
return true;
}
}