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 JerryRDG2
{
public class DynamicSmoke : MonoBehaviour
{
public float maxScale = 1f;
public float minScale = 0.01f;
public Rigidbody rig;
private void Start()
{
//IL_000d: 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_003f: Unknown result type (might be due to invalid IL or missing references)
rig.AddRelativeForce(((Component)this).transform.up * 0.5f, (ForceMode)5);
((Component)this).gameObject.transform.localScale = new Vector3(minScale, minScale, minScale);
}
private void Update()
{
//IL_0017: 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_0038: Unknown result type (might be due to invalid IL or missing references)
((Component)this).gameObject.transform.localScale = Vector3.Lerp(((Component)this).gameObject.transform.localScale, new Vector3(maxScale, maxScale, maxScale), Time.deltaTime);
}
}
public class RDG2 : MonoBehaviour, IFVRDamageable
{
public FVRPhysicalObject thisobj;
public Transform topPort;
public Transform bottomPort;
public FixedJoint Top;
public FixedJoint Bottom;
public GameObject flame;
public float FuzeCD = 5f;
public Rigidbody TopFuze;
public Rigidbody BottomFuze;
public bool TopNull;
public bool BottomNull;
public KillAfter KA;
public AudioEvent toptear;
public AudioEvent bottomtear;
public GameObject paperplate;
public GameObject toplid;
public float Infinity;
public FVRPhysicalObject topgrab;
public FVRPhysicalObject bottomgrab;
public SmokeSolidEmitter sm1;
public SmokeSolidEmitter sm2;
public float FF;
public Collider IgniteCol;
public Collider[] thisCol;
public float cd = 0.25f;
public bool isIg;
public float FFM = 0.25f;
private void Start()
{
topgrab.UsesGravity = false;
TopFuze.useGravity = false;
BottomFuze.useGravity = false;
}
private void OnCollisionStay(Collision collision)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: 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_009d: 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)
ContactPoint[] contacts = collision.contacts;
for (int i = 0; i < contacts.Length; i++)
{
ContactPoint val = contacts[i];
if (TopNull && ((Object)((Component)collision.collider).gameObject).name == "RDG2FF")
{
PhysicMaterial sharedMaterial = ((ContactPoint)(ref val)).otherCollider.sharedMaterial;
if ((Object)(object)sharedMaterial != (Object)null)
{
Vector3 relativeVelocity = collision.relativeVelocity;
float magnitude = ((Vector3)(ref relativeVelocity)).magnitude;
float num = ((!(magnitude < 0.01f)) ? sharedMaterial.dynamicFriction : sharedMaterial.staticFriction);
Vector3 normal = ((ContactPoint)(ref val)).normal;
float num2 = Mathf.Abs(Vector3.Dot(collision.impulse, normal)) / Time.fixedDeltaTime;
FF = num * num2;
}
}
else if (!TopNull || ((Object)((Component)collision.collider).gameObject).name != "RDG2FF")
{
FF = 0f;
}
}
}
private void Update()
{
//IL_0049: 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_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: 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_0279: Unknown result type (might be due to invalid IL or missing references)
//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
//IL_0383: Unknown result type (might be due to invalid IL or missing references)
//IL_0408: Unknown result type (might be due to invalid IL or missing references)
//IL_0418: Unknown result type (might be due to invalid IL or missing references)
//IL_04c9: Unknown result type (might be due to invalid IL or missing references)
//IL_04d9: Unknown result type (might be due to invalid IL or missing references)
//IL_06a6: Unknown result type (might be due to invalid IL or missing references)
//IL_06ba: Unknown result type (might be due to invalid IL or missing references)
//IL_06ca: Unknown result type (might be due to invalid IL or missing references)
//IL_046d: Unknown result type (might be due to invalid IL or missing references)
//IL_0477: Unknown result type (might be due to invalid IL or missing references)
//IL_052e: Unknown result type (might be due to invalid IL or missing references)
//IL_0538: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < thisCol.Length; i++)
{
Physics.IgnoreCollision(thisCol[i], IgniteCol);
}
((Component)this).gameObject.transform.localPosition = new Vector3(0f, 0f, 0f);
((Component)this).gameObject.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
if (!((FVRInteractiveObject)thisobj).m_isHeld)
{
if ((Object)(object)Top != (Object)null)
{
((Joint)Top).breakForce = Infinity;
}
if ((Object)(object)Bottom != (Object)null)
{
((Joint)Bottom).breakForce = Infinity;
}
}
else if (((FVRInteractiveObject)thisobj).m_isHeld)
{
if ((Object)(object)Top != (Object)null)
{
((Joint)Top).breakForce = 100f;
}
if ((Object)(object)Bottom != (Object)null)
{
((Joint)Bottom).breakForce = 100f;
}
}
if ((Object)(object)Top != (Object)null && (Object)(object)topgrab != (Object)null)
{
if (!((FVRInteractiveObject)topgrab).m_isHeld)
{
topgrab.UsesGravity = false;
TopFuze.useGravity = false;
((Component)TopFuze).gameObject.transform.position = ((Component)topPort).transform.position;
((Component)TopFuze).gameObject.transform.rotation = ((Component)topPort).transform.rotation;
}
else if (((FVRInteractiveObject)topgrab).m_isHeld)
{
topgrab.UsesGravity = true;
TopFuze.useGravity = true;
}
}
if ((Object)(object)Bottom != (Object)null && (Object)(object)bottomgrab != (Object)null)
{
if (!((FVRInteractiveObject)bottomgrab).m_isHeld)
{
bottomgrab.UsesGravity = false;
BottomFuze.useGravity = false;
((Component)BottomFuze).gameObject.transform.position = ((Component)bottomPort).transform.position;
((Component)BottomFuze).gameObject.transform.rotation = ((Component)bottomPort).transform.rotation;
}
else if (((FVRInteractiveObject)bottomgrab).m_isHeld)
{
bottomgrab.UsesGravity = true;
BottomFuze.useGravity = true;
}
}
if ((Object)(object)Top == (Object)null && !TopNull && (Object)(object)TopFuze != (Object)null)
{
SM.PlayCoreSound((FVRPooledAudioType)41, toptear, ((Component)topPort).transform.position);
((Component)TopFuze).gameObject.transform.SetParent((Transform)null);
TopFuze.useGravity = true;
TopNull = true;
topgrab.UsesGravity = true;
topgrab.DistantGrabbable = true;
}
if ((Object)(object)Bottom == (Object)null && !BottomNull && (Object)(object)BottomFuze != (Object)null)
{
SM.PlayCoreSound((FVRPooledAudioType)41, bottomtear, ((Component)topPort).transform.position);
((Component)BottomFuze).gameObject.transform.SetParent((Transform)null);
BottomFuze.useGravity = true;
BottomNull = true;
bottomgrab.UsesGravity = true;
}
if ((Object)(object)TopFuze != (Object)null && (Object)(object)paperplate != (Object)null && (Object)(object)Top == (Object)null && Vector3.Distance(((Component)TopFuze).gameObject.transform.position, ((Component)topPort).transform.position) > 0.05f && (Object)(object)paperplate.GetComponent<Rigidbody>() == (Object)null)
{
paperplate.transform.SetParent((Transform)null);
Rigidbody val = paperplate.AddComponent<Rigidbody>();
val.AddRelativeForce(paperplate.transform.up * 5f, (ForceMode)1);
}
if ((Object)(object)TopFuze != (Object)null && (Object)(object)toplid != (Object)null && (Object)(object)Top == (Object)null && Vector3.Distance(((Component)TopFuze).gameObject.transform.position, ((Component)topPort).transform.position) > 0.05f && (Object)(object)toplid.GetComponent<Rigidbody>() == (Object)null)
{
toplid.transform.SetParent((Transform)null);
Rigidbody val2 = toplid.AddComponent<Rigidbody>();
val2.AddRelativeForce(toplid.transform.up * 10f, (ForceMode)1);
}
if (FF > FFM)
{
isIg = true;
}
if (TopNull)
{
if (cd > 0f)
{
cd -= Time.deltaTime;
IgniteCol.enabled = false;
}
if (cd <= 0f)
{
if (!isIg)
{
IgniteCol.enabled = true;
}
else if (isIg)
{
IgniteCol.enabled = false;
}
}
if (isIg)
{
flame.SetActive(true);
if (FuzeCD > 0f)
{
FuzeCD -= Time.deltaTime;
}
else if (FuzeCD <= 0f)
{
((Component)sm1).gameObject.SetActive(true);
if (BottomNull)
{
((Component)sm2).gameObject.SetActive(true);
}
}
}
}
if (sm1.NumSmokeLeftToSpawn <= 0)
{
((FVRInteractiveObject)thisobj).ForceBreakInteraction();
((Component)thisobj).gameObject.transform.localScale = Vector3.Lerp(((Component)thisobj).gameObject.transform.localScale, new Vector3(0f, 0f, 0f), Time.deltaTime * 5f);
((Behaviour)KA).enabled = true;
}
}
private void OnDestroy()
{
if ((Object)(object)TopFuze != (Object)null)
{
Object.Destroy((Object)(object)((Component)TopFuze).gameObject);
}
if ((Object)(object)BottomFuze != (Object)null)
{
Object.Destroy((Object)(object)((Component)BottomFuze).gameObject);
}
if ((Object)(object)paperplate != (Object)null)
{
Object.Destroy((Object)(object)paperplate);
}
if ((Object)(object)toplid != (Object)null)
{
Object.Destroy((Object)(object)toplid);
}
}
public void Damage(Damage dam)
{
if (TopNull && dam.Dam_Thermal > 0f)
{
isIg = true;
}
}
}
}
namespace JerryAr.RDG2
{
[BepInPlugin("JerryAr.RDG2", "RDG2", "1.1.1")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
public class RDG2Plugin : 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.RDG2");
OtherLoader.RegisterDirectLoad(BasePath, "JerryAr.RDG2", "", "", "rdg2", "");
}
}
}