using System;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using OtherLoader;
using UnityEngine;
using UnityEngine.UI;
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace Alloy
{
public static class EnumExtension
{
public static bool HasFlag(this Enum keys, Enum flag)
{
int num = Convert.ToInt32(keys);
int num2 = Convert.ToInt32(flag);
return (num & num2) == num2;
}
}
}
namespace MeatKit
{
public class HideInNormalInspectorAttribute : PropertyAttribute
{
}
}
namespace JalexInteractive.ImageLocket
{
[BepInProcess("h3vr.exe")]
[BepInPlugin("JalexInteractive.ImageLocket", "ImageLocket", "1.0.0")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
[Description("Built with MeatKit")]
public class ImageLocketPlugin : BaseUnityPlugin
{
private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
internal static ManualLogSource Logger;
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
LoadAssets();
}
private void LoadAssets()
{
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "JalexInteractive.ImageLocket");
OtherLoader.RegisterDirectLoad(BasePath, "JalexInteractive.ImageLocket", "", "", "ji-imagelocket", "");
}
}
}
namespace JalexInteractive
{
public class ImageLocket : MonoBehaviour
{
public bool open = false;
public float healMax = 1000f;
public Transform hinge;
private Quaternion openAngle;
private Quaternion closedAngle;
private static FVRPlayerBody player;
public Image img;
public FVRPhysicalObject fvrObj;
private void Awake()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: 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_002a: 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_003c: 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_004d: 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_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: 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_008b: Expected O, but got Unknown
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: 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)
player = Object.FindObjectOfType<FVRPlayerBody>();
openAngle = Quaternion.Euler(hinge.localRotation.x, hinge.localRotation.y, 20f);
closedAngle = Quaternion.Euler(hinge.localRotation.x, hinge.localRotation.y, -180f);
Texture2D val = new Texture2D(128, 128, (TextureFormat)12, false);
val.LoadImage(TextureGrab());
img.sprite = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.op_Implicit(((Component)img).transform.localPosition));
}
private void Update()
{
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: 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_0068: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)((FVRInteractiveObject)fvrObj).m_hand) && ((FVRInteractiveObject)fvrObj).m_hand.Input.TriggerDown)
{
ToggleOpen();
}
if (open)
{
hinge.localRotation = Quaternion.RotateTowards(hinge.localRotation, openAngle, 750f * Time.deltaTime);
if (healMax > 0f && player.Health < player.m_startingHealth + 500f && Object.op_Implicit((Object)(object)((FVRInteractiveObject)fvrObj).m_hand))
{
healMax -= 75f * Time.deltaTime;
FVRPlayerBody obj = player;
obj.Health += 75f * Time.deltaTime;
}
}
else
{
hinge.localRotation = Quaternion.RotateTowards(hinge.localRotation, closedAngle, 750f * Time.deltaTime);
if (healMax < 1000f)
{
healMax += 25f * Time.deltaTime;
}
}
}
private void ToggleOpen()
{
open = !open;
}
public static byte[] TextureGrab()
{
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string text;
if (File.Exists(directoryName + "\\locketimage.jpg"))
{
text = ".jpg";
}
else if (File.Exists(directoryName + "\\locketimage.png"))
{
text = ".png";
}
else if (File.Exists(directoryName + "\\locketimage.jpeg"))
{
text = ".jpeg";
}
else
{
Debug.LogError((object)"~ No valid locket texture file found ~");
text = "error";
}
string text2 = directoryName + "\\locketimage" + text;
Debug.Log((object)text2);
if (text != "error")
{
return File.ReadAllBytes(text2);
}
return null;
}
}
}