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;
[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 JerryMC
{
public class GrassBlock : MonoBehaviour, IFVRDamageable
{
public float cdcol;
public float cd = 0.25f;
public int damlv;
public GameObject[] damtex;
public float lastdam = 0f;
public float damhealth = 7000f;
public float requiredhealth = 7000f;
public AudioEvent breaking;
public AudioEvent placing;
public Transform center;
public GameObject Bald;
public GameObject NoBald;
public Transform top;
public LayerMask lm;
public GameObject Geo;
public Collider basecol;
public Collider baldcol;
public Collider nobaldcol;
private float preX;
private float preY;
private float preZ;
private float fixedX;
private float fixedY;
private float fixedZ;
public void Start()
{
//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_0019: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: 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)
Vector3 position = ((Component)this).transform.position;
preY = ((Component)this).gameObject.transform.position.y;
if (preY >= 0f)
{
fixedY = Mathf.Floor(preY);
}
if (preY < 0f)
{
fixedY = Mathf.Ceil(preY);
}
int num = Mathf.RoundToInt(position.x);
int num2 = Mathf.RoundToInt(position.z);
((Component)this).transform.position = new Vector3((float)num, fixedY + 0.5f, (float)num2);
((Component)this).transform.eulerAngles = Vector3.zero;
SM.PlayCoreSound((FVRPooledAudioType)41, placing, center.position);
}
public void Damage(Damage dam)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
if (cdcol <= 0f)
{
if (dam.damageSize >= requiredhealth)
{
SM.PlayCoreSound((FVRPooledAudioType)41, placing, center.position);
Object.Destroy((Object)(object)((Component)this).gameObject);
}
else if (dam.damageSize < requiredhealth)
{
damlv++;
lastdam = 5f;
SM.PlayCoreSound((FVRPooledAudioType)41, breaking, center.position);
cdcol = 0.05f;
}
}
}
public void OnCollisionEnter(Collision collision)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
Vector3 relativeVelocity = collision.relativeVelocity;
if (((Vector3)(ref relativeVelocity)).magnitude >= 1f && cdcol <= 0f)
{
damlv++;
lastdam = 5f;
SM.PlayCoreSound((FVRPooledAudioType)41, breaking, center.position);
cdcol = 0.05f;
}
}
private void FixedUpdate()
{
//IL_004d: 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_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: 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_0111: 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_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: 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_01a9: Unknown result type (might be due to invalid IL or missing references)
if (cdcol > 0f)
{
cdcol -= Time.deltaTime;
}
if (cdcol < 0f)
{
cdcol = 0f;
}
if (Geo.transform.lossyScale.x < 0.95f)
{
baldcol.enabled = true;
nobaldcol.enabled = true;
basecol.enabled = false;
}
else if (Geo.transform.lossyScale.x >= 0.95f)
{
baldcol.enabled = false;
nobaldcol.enabled = false;
basecol.enabled = true;
}
Geo.transform.localScale = Vector3.Lerp(Geo.transform.localScale, new Vector3(1f, 1f, 1f), Time.deltaTime * 5f);
Ray val = default(Ray);
((Ray)(ref val))..ctor(top.position, top.up);
RaycastHit val2 = default(RaycastHit);
if (Physics.Raycast(val, ref val2, 0.01f, LayerMask.op_Implicit(lm)))
{
Bald.SetActive(true);
NoBald.SetActive(false);
}
else
{
NoBald.SetActive(true);
Bald.SetActive(false);
}
if (damlv >= 7)
{
SM.PlayCoreSound((FVRPooledAudioType)41, placing, center.position);
Object.Destroy((Object)(object)((Component)this).gameObject);
}
if (damlv < 0)
{
damlv = 0;
}
if (lastdam > 0f)
{
cd = 0.25f;
lastdam -= Time.deltaTime;
}
if (lastdam <= 0f)
{
if (damlv > 0)
{
if (cd > 0f)
{
cd -= Time.deltaTime * 0.5f;
}
if (cd <= 0f)
{
damlv--;
cd = 0.25f;
}
}
if (damlv <= 0)
{
cd = 0.25f;
}
}
requiredhealth = 7000 - damlv * 1000;
for (int i = 0; i < damtex.Length; i++)
{
if (i != damlv)
{
damtex[i].SetActive(false);
}
else if (i == damlv)
{
damtex[i].SetActive(true);
}
}
}
}
public class GrassBlockSpawner : MonoBehaviour
{
public FVRPhysicalObject main;
public FVRObject cube;
public bool isTriggerOn = false;
public bool isTriggerReset = true;
public AudioEvent TriggerOn;
public AudioEvent TriggerOff;
public Transform Center;
private void Start()
{
}
private void OnCollisionEnter(Collision collision)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
if (isTriggerOn && ((Component)collision.collider).gameObject.layer == 19)
{
Vector3 relativeVelocity = collision.relativeVelocity;
if (((Vector3)(ref relativeVelocity)).magnitude > 0.25f)
{
SpawnCube();
isTriggerOn = false;
SM.PlayCoreSound((FVRPooledAudioType)41, TriggerOff, Center.position);
}
}
}
public void SpawnCube()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
Object.Instantiate<GameObject>(((AnvilAsset)cube).GetGameObject(), Center.position, new Quaternion(0f, 0f, 0f, 1f));
}
private void FixedUpdate()
{
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)((FVRInteractiveObject)main).m_hand != (Object)null)
{
if (((FVRInteractiveObject)main).m_hand.Input.TriggerFloat >= 0.75f && isTriggerReset)
{
isTriggerOn = true;
isTriggerReset = false;
SM.PlayCoreSound((FVRPooledAudioType)41, TriggerOn, Center.position);
}
else if ((double)((FVRInteractiveObject)main).m_hand.Input.TriggerFloat < 0.75 && !isTriggerReset)
{
isTriggerReset = true;
isTriggerOn = false;
SM.PlayCoreSound((FVRPooledAudioType)41, TriggerOff, Center.position);
}
}
else if ((Object)(object)((FVRInteractiveObject)main).m_hand == (Object)null)
{
isTriggerReset = true;
}
}
}
}
namespace JerryAr.GrassCube
{
[BepInPlugin("JerryAr.GrassCube", "GrassCube", "1.0.0")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
public class GrassCubePlugin : 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(), "JerryAr.GrassCube");
OtherLoader.RegisterDirectLoad(BasePath, "JerryAr.GrassCube", "", "", "grassblock", "");
}
}
}