using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using BepInEx;
using FistVR;
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("SpineHero")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SpineHeroDLL")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("B5F1C390-B573-400B-807F-3EEE54451116")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SpineHeroDLLnamespace;
public class ScalableQBSlot : FVRQuickBeltSlot
{
public Vector3 HeldObjectLocalScale;
public Vector3 HeldObjectSize;
public FVRInteractiveObject LastHeldObject;
public Vector3 LastScale = Vector3.zero;
public Vector3 TargetSize = new Vector3(0.1f, 0.1f, 0.1f);
public List<Transform> AllTrans;
public List<GameObject> AllPO;
public bool CheckAttachment = true;
public bool HardnessObjHandled = false;
private Bounds CalculateBounds(GameObject root)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
Bounds result = default(Bounds);
bool flag = false;
Collider[] componentsInChildren = root.GetComponentsInChildren<Collider>();
Collider[] array = componentsInChildren;
foreach (Collider val in array)
{
if ((Object)(object)val != (Object)null)
{
Bounds bounds = val.bounds;
if (!flag)
{
result = bounds;
flag = true;
}
else
{
((Bounds)(ref result)).Encapsulate(bounds);
}
}
}
if (!flag)
{
result = default(Bounds);
((Bounds)(ref result)).center = Vector3.zero;
((Bounds)(ref result)).size = new Vector3(0.1f, 0.1f, 0.1f);
}
return result;
}
private List<Transform> GetAllChildren(Transform parent)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
List<Transform> list = new List<Transform>();
foreach (Transform item in parent)
{
Transform val = item;
list.Add(val);
list.AddRange(GetAllChildren(val));
}
return list;
}
private List<GameObject> FindObjectsWithComponent<T>(Transform parent) where T : Component
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Expected O, but got Unknown
List<GameObject> list = new List<GameObject>();
if ((Object)(object)((Component)parent).GetComponent<T>() != (Object)null)
{
list.Add(((Component)parent).gameObject);
}
foreach (Transform item in parent)
{
Transform parent2 = item;
list.AddRange(FindObjectsWithComponent<T>(parent2));
}
return list;
}
private void Update()
{
//IL_0375: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: 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_01cd: Unknown result type (might be due to invalid IL or missing references)
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
//IL_01f7: 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_0410: Unknown result type (might be due to invalid IL or missing references)
//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
//IL_0338: Unknown result type (might be due to invalid IL or missing references)
//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: 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)
Type typeFromHandle = typeof(FVRQuickBeltSlot);
typeFromHandle.GetMethod("Update", BindingFlags.Instance | BindingFlags.NonPublic)?.Invoke(this, null);
if (Object.op_Implicit((Object)(object)base.HeldObject))
{
if ((Object)(object)base.HeldObject == (Object)(object)LastHeldObject)
{
((Component)LastHeldObject).gameObject.transform.localScale = LastScale;
if (CheckAttachment)
{
List<Transform> allChildren = GetAllChildren(((Component)base.HeldObject).gameObject.transform);
if (allChildren.Count != AllTrans.Count)
{
List<GameObject> list = FindObjectsWithComponent<FVRPhysicalObject>(((Component)base.HeldObject).gameObject.transform);
foreach (GameObject item in list)
{
if (!AllPO.Contains(item) && !HardnessObjHandled)
{
Transform transform = item.transform;
transform.localScale *= LastScale.x;
}
}
HardnessObjHandled = false;
AllTrans = allChildren;
AllPO = list;
}
}
}
else
{
if (Object.op_Implicit((Object)(object)LastHeldObject))
{
((Component)LastHeldObject).gameObject.transform.localScale = HeldObjectLocalScale;
}
LastHeldObject = null;
if (Object.op_Implicit((Object)(object)base.HeldObject))
{
Bounds val = CalculateBounds(((Component)base.HeldObject).gameObject);
HeldObjectSize = ((Bounds)(ref val)).size;
HeldObjectLocalScale = ((Component)base.HeldObject).gameObject.transform.localScale;
Vector3 heldObjectLocalScale = HeldObjectLocalScale;
if (HeldObjectSize.x > TargetSize.x || HeldObjectSize.y > TargetSize.y || HeldObjectSize.z > TargetSize.z)
{
float val2 = HeldObjectLocalScale.x * TargetSize.x / HeldObjectSize.x;
float val3 = HeldObjectLocalScale.y * TargetSize.y / HeldObjectSize.y;
float val4 = HeldObjectLocalScale.z * TargetSize.z / HeldObjectSize.z;
float num = Math.Min(Math.Min(val2, val3), val4);
((Vector3)(ref heldObjectLocalScale))..ctor(num, num, num);
LastScale = heldObjectLocalScale;
AllTrans = GetAllChildren(((Component)base.HeldObject).gameObject.transform);
AllPO = FindObjectsWithComponent<FVRPhysicalObject>(((Component)base.HeldObject).gameObject.transform);
}
((Component)base.HeldObject).gameObject.transform.localScale = heldObjectLocalScale;
LastHeldObject = base.HeldObject;
}
}
}
else
{
if (Object.op_Implicit((Object)(object)LastHeldObject))
{
((Component)LastHeldObject).gameObject.transform.localScale = HeldObjectLocalScale;
}
LastHeldObject = null;
}
if (Object.op_Implicit((Object)(object)base.HeldObject) && ((FVRPhysicalObject)/*isinst with value type is only supported in some contexts*/).m_isHardnessed)
{
FVRInteractiveObject heldObject = base.HeldObject;
if (Object.op_Implicit((Object)(object)((heldObject is FVRPhysicalObject) ? heldObject : null).m_hand))
{
((Component)LastHeldObject).gameObject.transform.localScale = HeldObjectLocalScale;
CheckAttachment = false;
HardnessObjHandled = true;
}
else
{
((Component)LastHeldObject).gameObject.transform.localScale = LastScale;
CheckAttachment = true;
}
}
}
}
[BepInPlugin("GUID.SpineHeroDLL", "SpineHeroDLL", "1.0.0")]
[BepInProcess("h3vr.exe")]
public class SpineHeroDLL : BaseUnityPlugin
{
public GameObject SpineHeroObjectL = null;
public GameObject SpineHeroObjectR = null;
public bool newobj = false;
private float timer = 0f;
private float UpdateRate = 0.1f;
public void Start()
{
}
public void Update()
{
//IL_0368: Unknown result type (might be due to invalid IL or missing references)
//IL_036d: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_042d: Unknown result type (might be due to invalid IL or missing references)
//IL_0432: 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_040e: 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_02c0: Unknown result type (might be due to invalid IL or missing references)
//IL_032c: Unknown result type (might be due to invalid IL or missing references)
//IL_0342: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Expected O, but got Unknown
//IL_04cc: Unknown result type (might be due to invalid IL or missing references)
//IL_04d1: Unknown result type (might be due to invalid IL or missing references)
//IL_0497: Unknown result type (might be due to invalid IL or missing references)
//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Expected O, but got Unknown
timer += Time.deltaTime;
if (!(timer > UpdateRate))
{
return;
}
timer -= UpdateRate;
if (Object.op_Implicit((Object)(object)SpineHeroObjectL) && Object.op_Implicit((Object)(object)SpineHeroObjectR))
{
if (newobj)
{
SpineHeroObjectL.transform.parent = ((Component)GM.CurrentPlayerBody.LeftHand).transform;
SpineHeroObjectL.transform.localPosition = Vector3.zero;
SpineHeroObjectL.transform.localRotation = Quaternion.identity;
foreach (Transform item in SpineHeroObjectL.gameObject.transform)
{
Transform val = item;
if (((Component)val).gameObject.tag == "QuickbeltSlot")
{
FVRQuickBeltSlot component = ((Component)val).GetComponent<FVRQuickBeltSlot>();
GM.CurrentPlayerBody.QBSlots_Internal.Add(component);
}
}
SpineHeroObjectR.transform.parent = ((Component)GM.CurrentPlayerBody.RightHand).transform;
SpineHeroObjectR.transform.localPosition = Vector3.zero;
SpineHeroObjectR.transform.localRotation = Quaternion.Euler(0f, 0f, -180f);
foreach (Transform item2 in SpineHeroObjectR.gameObject.transform)
{
Transform val2 = item2;
if (((Component)val2).gameObject.tag == "QuickbeltSlot")
{
FVRQuickBeltSlot component2 = ((Component)val2).GetComponent<FVRQuickBeltSlot>();
GM.CurrentPlayerBody.QBSlots_Internal.Add(component2);
}
}
newobj = false;
}
if (SpineHeroObjectR.transform.childCount < 5)
{
Object.DestroyImmediate((Object)(object)SpineHeroObjectL);
Object.DestroyImmediate((Object)(object)SpineHeroObjectR);
AnvilCallback<GameObject> gameObjectAsync = ((AnvilAsset)IM.OD["SpineHeroObject"]).GetGameObjectAsync();
if (Object.op_Implicit((Object)(object)gameObjectAsync.Result))
{
SpineHeroObjectL = Object.Instantiate<GameObject>(gameObjectAsync.Result);
SpineHeroObjectL.transform.position = new Vector3(0f, 0f, 0f);
SpineHeroObjectL.transform.rotation = Quaternion.identity;
Console.Write("Initial new post SpineHeroObject");
}
AnvilCallback<GameObject> gameObjectAsync2 = ((AnvilAsset)IM.OD["SpineHeroObject"]).GetGameObjectAsync();
if (Object.op_Implicit((Object)(object)gameObjectAsync2.Result))
{
SpineHeroObjectR = Object.Instantiate<GameObject>(gameObjectAsync2.Result);
SpineHeroObjectR.transform.position = new Vector3(0f, 0f, 0f);
SpineHeroObjectR.transform.rotation = Quaternion.identity;
Console.Write("Initial new post SpineHeroObject");
}
newobj = true;
}
return;
}
Scene activeScene = SceneManager.GetActiveScene();
if (!(((Scene)(ref activeScene)).name != "MainMenu3"))
{
return;
}
if (IM.OD.ContainsKey("SpineHeroObject"))
{
AnvilCallback<GameObject> gameObjectAsync3 = ((AnvilAsset)IM.OD["SpineHeroObject"]).GetGameObjectAsync();
if (Object.op_Implicit((Object)(object)gameObjectAsync3.Result))
{
SpineHeroObjectL = Object.Instantiate<GameObject>(gameObjectAsync3.Result);
SpineHeroObjectL.transform.position = new Vector3(0f, 0f, 0f);
SpineHeroObjectL.transform.rotation = Quaternion.identity;
Console.Write("Initial new post SpineHeroObject");
}
else
{
activeScene = SceneManager.GetActiveScene();
Console.Write("Can't find spawned SpineHeroObject,please wait for the assets load or report a bug,current scene name : {0}", ((Scene)(ref activeScene)).name);
}
AnvilCallback<GameObject> gameObjectAsync4 = ((AnvilAsset)IM.OD["SpineHeroObject"]).GetGameObjectAsync();
if (Object.op_Implicit((Object)(object)gameObjectAsync4.Result))
{
SpineHeroObjectR = Object.Instantiate<GameObject>(gameObjectAsync4.Result);
SpineHeroObjectR.transform.position = new Vector3(0f, 0f, 0f);
SpineHeroObjectR.transform.rotation = Quaternion.identity;
Console.Write("Initial new post SpineHeroObject");
}
else
{
activeScene = SceneManager.GetActiveScene();
Console.Write("Can't find spawned SpineHeroObject,please wait for the assets load or report a bug,current scene name : {0}", ((Scene)(ref activeScene)).name);
}
newobj = true;
return;
}
foreach (KeyValuePair<string, FVRObject> item3 in IM.OD)
{
if (item3.Key.Contains("Spine"))
{
Console.Write("{0}", item3.Key);
}
}
Console.Write("Can't find ");
}
}