using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using UnityEngine;
using UnityEngine.Animations;
using UnityEngine.Playables;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("VITRUV1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("VITRUV1")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("dc8f52fa-0119-4632-b631-8dc19b322480")]
[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")]
public class LogicButtocksHaHa : MonoBehaviour
{
private Transform modelParent;
private Animator animator;
private RectTransform uiRect;
private Vector2 lastMousePos;
private Vector3 lastRotationDirection = Vector3.up;
private float lastInteractionTime;
private bool isDragging = false;
private bool isClick = false;
private const float clickThreshold = 5f;
private bool isSpinning = true;
private Vector3 originalScale = new Vector3(0.7f, 0.7f, 1f);
private Vector3 targetScale;
private float scaleLerpSpeed = 2f;
private float scaleHoldTime = 0f;
private float scaleStartTime = 0f;
public void Initialize(Transform modelParent, Animator animator, RectTransform uiRect)
{
//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)
this.modelParent = modelParent;
this.animator = animator;
this.uiRect = uiRect;
lastInteractionTime = Time.time;
targetScale = originalScale;
}
private void Awake()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
lastInteractionTime = Time.time;
isSpinning = true;
targetScale = originalScale;
}
private bool IsMouseOverUI()
{
//IL_0007: 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_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: 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)
Vector2 val = default(Vector2);
RectTransformUtility.ScreenPointToLocalPointInRectangle(uiRect, Vector2.op_Implicit(Input.mousePosition), (Camera)null, ref val);
Rect rect = uiRect.rect;
return ((Rect)(ref rect)).Contains(val);
}
private void Update()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: 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_0174: 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)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: 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_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: 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_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
((Component)this).transform.localScale = Vector3.Lerp(((Component)this).transform.localScale, targetScale, Time.deltaTime * scaleLerpSpeed);
if (IsMouseOverUI())
{
if (Input.GetMouseButtonDown(0))
{
lastMousePos = Vector2.op_Implicit(Input.mousePosition);
lastInteractionTime = Time.time;
isClick = true;
}
if (Input.GetMouseButton(0))
{
Vector2 val = Vector2.op_Implicit(Input.mousePosition);
float num = val.x - lastMousePos.x;
if (isClick && Vector2.Distance(val, lastMousePos) > 5f)
{
isClick = false;
}
if (!isClick)
{
lastRotationDirection = ((num > 0f) ? Vector3.up : Vector3.down);
modelParent.Rotate(Vector3.up, num * 0.5f);
isDragging = true;
lastInteractionTime = Time.time;
isSpinning = false;
}
lastMousePos = val;
}
else
{
isDragging = false;
}
if (Input.GetMouseButtonUp(0) && isClick)
{
targetScale = originalScale * 1.25f;
scaleStartTime = Time.time;
}
}
if (targetScale != originalScale && Time.time - scaleStartTime > scaleHoldTime)
{
targetScale = originalScale;
}
if (!isDragging && Time.time - lastInteractionTime > 10f)
{
isSpinning = true;
}
if (isSpinning)
{
modelParent.Rotate(lastRotationDirection, Time.deltaTime * 10f);
}
}
}
[BepInPlugin("doomahreal.ultrakill.VITRUV1", "VITRUV1", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private GameObject modelInstance;
private Camera renderCamera;
private RenderTexture renderTexture;
private Transform modelParent;
private Animator animator;
private AssetBundle loadedBundle;
private readonly string modelName = "veebulshit";
private readonly string targetImagePath = "Canvas/Main Menu (1)/V1";
private void Awake()
{
SceneManager.sceneLoaded += OnSceneLoaded;
SceneManager.sceneUnloaded += OnSceneUnloaded;
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
//IL_008c: 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)
if (SceneHelper.CurrentScene != "Main Menu")
{
return;
}
GameObject val = GameObject.Find(targetImagePath);
if ((Object)(object)val == (Object)null)
{
return;
}
foreach (Transform item in val.transform)
{
Transform val2 = item;
RawImage component = ((Component)val2).GetComponent<RawImage>();
if ((Object)(object)component != (Object)null)
{
component.texture = null;
((Graphic)component).color = new Color(1f, 1f, 1f, 0f);
}
Image component2 = ((Component)val2).GetComponent<Image>();
if ((Object)(object)component2 != (Object)null)
{
component2.sprite = null;
((Graphic)component2).color = new Color(1f, 1f, 1f, 0f);
}
}
SetupRenderTexture(val);
LoadModel(val);
}
private void OnSceneUnloaded(Scene scene)
{
if (!(SceneHelper.CurrentScene == "Main Menu"))
{
if ((Object)(object)modelInstance != (Object)null)
{
Object.Destroy((Object)(object)modelInstance);
}
if ((Object)(object)modelParent != (Object)null)
{
Object.Destroy((Object)(object)((Component)modelParent).gameObject);
}
if ((Object)(object)renderCamera != (Object)null)
{
Object.Destroy((Object)(object)((Component)renderCamera).gameObject);
}
if ((Object)(object)renderTexture != (Object)null)
{
renderTexture.Release();
}
if ((Object)(object)loadedBundle != (Object)null)
{
loadedBundle.Unload(true);
loadedBundle = null;
}
}
}
private void SetupRenderTexture(GameObject uiObject)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
//IL_002a: 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)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: 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_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
renderTexture = new RenderTexture(1024, 1024, 16);
renderTexture.Create();
renderCamera = new GameObject("RenderCamera").AddComponent<Camera>();
renderCamera.clearFlags = (CameraClearFlags)2;
renderCamera.backgroundColor = new Color(0f, 0f, 0f, 0f);
renderCamera.cullingMask = LayerMask.GetMask(new string[1] { "Armor" });
((Component)renderCamera).transform.position = new Vector3(-0.1f, 2.111f, 4.2928f);
((Component)renderCamera).transform.rotation = Quaternion.Euler(0f, 180f, 0f);
renderCamera.targetTexture = renderTexture;
renderCamera.orthographic = true;
renderCamera.orthographicSize = 2.25f;
RawImage val = uiObject.GetComponent<RawImage>();
Image component = uiObject.GetComponent<Image>();
if ((Object)(object)val == (Object)null)
{
if ((Object)(object)component != (Object)null)
{
Object.DestroyImmediate((Object)(object)component);
}
val = uiObject.AddComponent<RawImage>();
}
val.texture = (Texture)(object)renderTexture;
RectTransform component2 = uiObject.GetComponent<RectTransform>();
if ((Object)(object)component2 != (Object)null)
{
component2.anchoredPosition -= new Vector2(0f, 20f);
}
}
private void LoadModel(GameObject uiObject)
{
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
Assembly executingAssembly = Assembly.GetExecutingAssembly();
string text = executingAssembly.GetManifestResourceNames().FirstOrDefault((string name) => name.EndsWith(".bundle"));
if (text == null)
{
return;
}
using Stream stream = executingAssembly.GetManifestResourceStream(text);
if (stream == null)
{
return;
}
byte[] array = new byte[stream.Length];
stream.Read(array, 0, array.Length);
loadedBundle = AssetBundle.LoadFromMemory(array);
if ((Object)(object)loadedBundle == (Object)null)
{
return;
}
GameObject val = loadedBundle.LoadAsset<GameObject>(modelName);
if (!((Object)(object)val == (Object)null))
{
modelParent = new GameObject("ModelParent").transform;
modelInstance = Object.Instantiate<GameObject>(val, modelParent);
modelInstance.layer = LayerMask.NameToLayer("Armor");
Transform[] componentsInChildren = modelInstance.GetComponentsInChildren<Transform>();
foreach (Transform val2 in componentsInChildren)
{
((Component)val2).gameObject.layer = LayerMask.NameToLayer("Armor");
}
if (modelInstance.transform.childCount > 0)
{
animator = ((Component)modelInstance.transform.GetChild(0)).GetComponent<Animator>();
}
AnimationClip[] array2 = loadedBundle.LoadAllAssets<AnimationClip>();
if (array2.Length != 0)
{
AnimationClip clip = array2[0];
PlayAnimationClip(clip);
}
LogicButtocksHaHa logicButtocksHaHa = uiObject.AddComponent<LogicButtocksHaHa>();
logicButtocksHaHa.Initialize(modelParent, animator, uiObject.GetComponent<RectTransform>());
}
}
private void PlayAnimationClip(AnimationClip clip)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: 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_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: 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)
if (!((Object)(object)animator == (Object)null) && !((Object)(object)clip == (Object)null))
{
PlayableGraph val = PlayableGraph.Create();
((PlayableGraph)(ref val)).SetTimeUpdateMode((DirectorUpdateMode)1);
AnimationPlayableOutput val2 = AnimationPlayableOutput.Create(val, "AnimationOutput", animator);
AnimationClipPlayable val3 = AnimationClipPlayable.Create(val, clip);
PlayableOutputExtensions.SetSourcePlayable<AnimationPlayableOutput, AnimationClipPlayable>(val2, val3);
((PlayableGraph)(ref val)).Play();
}
}
}