Decompiled source of CetmeAmeli65Caseless v1.0.0

CetmeAmeli65Caseless.dll

Decompiled a week ago
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 ModularWorkshop;
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]
public class EjectionChanger : MonoBehaviour, IPartFireArmRequirement
{
	[Header("Ejection Config")]
	public Vector3 NewEjectionSpeed;

	public Vector3 NewEjectionSpin;

	private Vector3 _origEjectionSpeed;

	private Vector3 _origEjectionSpin;

	private ClosedBoltWeapon _ejectionFirearm;

	public FVRFireArm FireArm
	{
		get
		{
			return (FVRFireArm)(object)_ejectionFirearm;
		}
		set
		{
			if ((Object)(object)_ejectionFirearm != (Object)null)
			{
				RemoveEjection();
			}
			ClosedBoltWeapon val = (ClosedBoltWeapon)(object)((value is ClosedBoltWeapon) ? value : null);
			if ((Object)(object)val != (Object)null)
			{
				ApplyEjection(val);
			}
			else
			{
				_ejectionFirearm = null;
			}
		}
	}

	private void ApplyEjection(ClosedBoltWeapon firearm)
	{
		//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_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: 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_004c: 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_005d: Unknown result type (might be due to invalid IL or missing references)
		_ejectionFirearm = firearm;
		if (!((Object)(object)_ejectionFirearm == (Object)null))
		{
			_origEjectionSpeed = _ejectionFirearm.EjectionSpeed;
			_origEjectionSpin = _ejectionFirearm.EjectionSpin;
			_ejectionFirearm.EjectionSpeed = NewEjectionSpeed;
			_ejectionFirearm.EjectionSpin = NewEjectionSpin;
			Debug.Log((object)"EjectionChanger: Applying new ejection values.");
		}
	}

	private void RemoveEjection()
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		Debug.Log((object)"EjectionChanger: Reverting ejection values.");
		if (!((Object)(object)_ejectionFirearm == (Object)null))
		{
			_ejectionFirearm.EjectionSpeed = _origEjectionSpeed;
			_ejectionFirearm.EjectionSpin = _origEjectionSpin;
			_ejectionFirearm = null;
		}
	}
}
namespace Volks.CetmeAmeli65Caseless;

[BepInPlugin("Volks.CetmeAmeli65Caseless", "CetmeAmeli65Caseless", "1.0.0")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
public class CetmeAmeli65CaselessPlugin : 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(), "Volks.CetmeAmeli65Caseless");
		OtherLoader.RegisterDirectLoad(BasePath, "Volks.CetmeAmeli65Caseless", "", "", "cetmeameli65caseless", "");
	}
}
public class AudioConsistencyEnforcer : MonoBehaviour
{
	[Header("Audio Profiles")]
	public FVRFirearmAudioSet BaseHandlingAudioProfile;

	private FVRFireArm _firearm;

	private FVRFirearmAudioSet _lastAudioClipSet;

	private void Awake()
	{
		_firearm = ((Component)this).GetComponent<FVRFireArm>();
		if ((Object)(object)_firearm != (Object)null && (Object)(object)_firearm.AudioClipSet != (Object)null)
		{
			_lastAudioClipSet = _firearm.AudioClipSet;
			BaseHandlingAudioProfile = ScriptableObject.CreateInstance<FVRFirearmAudioSet>();
			SaveBaseHandlingAudio(_lastAudioClipSet);
		}
		else
		{
			Debug.LogError((object)"AudioConsistencyEnforcer: No FVRFireArm or AudioClipSet found on the object!");
		}
	}

	private void LateUpdate()
	{
		if ((Object)(object)_firearm == (Object)null)
		{
			return;
		}
		FVRFirearmAudioSet audioClipSet = _firearm.AudioClipSet;
		if ((Object)(object)audioClipSet == (Object)null)
		{
			Debug.LogWarning((object)"AudioConsistencyEnforcer: AudioClipSet is null!");
			return;
		}
		if ((Object)(object)audioClipSet != (Object)(object)_lastAudioClipSet)
		{
			_lastAudioClipSet = audioClipSet;
		}
		EnforceHandlingSounds(audioClipSet);
	}

	private void SaveBaseHandlingAudio(FVRFirearmAudioSet source)
	{
		BaseHandlingAudioProfile.BoltRelease = source.BoltRelease;
		BaseHandlingAudioProfile.BoltSlideBack = source.BoltSlideBack;
		BaseHandlingAudioProfile.BoltSlideForward = source.BoltSlideForward;
		BaseHandlingAudioProfile.BoltSlideBackHeld = source.BoltSlideBackHeld;
		BaseHandlingAudioProfile.BoltSlideBackLocked = source.BoltSlideBackLocked;
		BaseHandlingAudioProfile.BreachOpen = source.BreachOpen;
		BaseHandlingAudioProfile.BreachClose = source.BreachClose;
		BaseHandlingAudioProfile.CatchOnSear = source.CatchOnSear;
		BaseHandlingAudioProfile.ChamberManual = source.ChamberManual;
		BaseHandlingAudioProfile.FireSelector = source.FireSelector;
		BaseHandlingAudioProfile.HammerHit = source.HammerHit;
		BaseHandlingAudioProfile.HandleBack = source.HandleBack;
		BaseHandlingAudioProfile.HandleBackEmpty = source.HandleBackEmpty;
		BaseHandlingAudioProfile.HandleForward = source.HandleForward;
		BaseHandlingAudioProfile.HandleForwardEmpty = source.HandleForwardEmpty;
		BaseHandlingAudioProfile.HandleUp = source.HandleUp;
		BaseHandlingAudioProfile.HandleDown = source.HandleDown;
		BaseHandlingAudioProfile.HandleGrab = source.HandleGrab;
		BaseHandlingAudioProfile.Prefire = source.Prefire;
		BaseHandlingAudioProfile.Safety = source.Safety;
		BaseHandlingAudioProfile.TriggerReset = source.TriggerReset;
		BaseHandlingAudioProfile.TopCoverRelease = source.TopCoverRelease;
		BaseHandlingAudioProfile.TopCoverUp = source.TopCoverUp;
		BaseHandlingAudioProfile.TopCoverDown = source.TopCoverDown;
		BaseHandlingAudioProfile.StockOpen = source.StockOpen;
		BaseHandlingAudioProfile.StockClosed = source.StockClosed;
		BaseHandlingAudioProfile.BipodOpen = source.BipodOpen;
		BaseHandlingAudioProfile.BipodClosed = source.BipodClosed;
		BaseHandlingAudioProfile.BeltGrab = source.BeltGrab;
		BaseHandlingAudioProfile.BeltRelease = source.BeltRelease;
		BaseHandlingAudioProfile.BeltSeat = source.BeltSeat;
		BaseHandlingAudioProfile.BeltSettle = source.BeltSettle;
		Debug.Log((object)"AudioConsistencyEnforcer: Base handling audio saved successfully!");
	}

	private void EnforceHandlingSounds(FVRFirearmAudioSet targetProfile)
	{
		targetProfile.BoltRelease = BaseHandlingAudioProfile.BoltRelease;
		targetProfile.BoltSlideBack = BaseHandlingAudioProfile.BoltSlideBack;
		targetProfile.BoltSlideForward = BaseHandlingAudioProfile.BoltSlideForward;
		targetProfile.BoltSlideBackHeld = BaseHandlingAudioProfile.BoltSlideBackHeld;
		targetProfile.BoltSlideBackLocked = BaseHandlingAudioProfile.BoltSlideBackLocked;
		targetProfile.BreachOpen = BaseHandlingAudioProfile.BreachOpen;
		targetProfile.BreachClose = BaseHandlingAudioProfile.BreachClose;
		targetProfile.CatchOnSear = BaseHandlingAudioProfile.CatchOnSear;
		targetProfile.ChamberManual = BaseHandlingAudioProfile.ChamberManual;
		targetProfile.FireSelector = BaseHandlingAudioProfile.FireSelector;
		targetProfile.HammerHit = BaseHandlingAudioProfile.HammerHit;
		targetProfile.HandleBack = BaseHandlingAudioProfile.HandleBack;
		targetProfile.HandleBackEmpty = BaseHandlingAudioProfile.HandleBackEmpty;
		targetProfile.HandleForward = BaseHandlingAudioProfile.HandleForward;
		targetProfile.HandleForwardEmpty = BaseHandlingAudioProfile.HandleForwardEmpty;
		targetProfile.HandleUp = BaseHandlingAudioProfile.HandleUp;
		targetProfile.HandleDown = BaseHandlingAudioProfile.HandleDown;
		targetProfile.HandleGrab = BaseHandlingAudioProfile.HandleGrab;
		targetProfile.Prefire = BaseHandlingAudioProfile.Prefire;
		targetProfile.Safety = BaseHandlingAudioProfile.Safety;
		targetProfile.TriggerReset = BaseHandlingAudioProfile.TriggerReset;
		targetProfile.TopCoverRelease = BaseHandlingAudioProfile.TopCoverRelease;
		targetProfile.TopCoverUp = BaseHandlingAudioProfile.TopCoverUp;
		targetProfile.TopCoverDown = BaseHandlingAudioProfile.TopCoverDown;
		targetProfile.StockOpen = BaseHandlingAudioProfile.StockOpen;
		targetProfile.StockClosed = BaseHandlingAudioProfile.StockClosed;
		targetProfile.BipodOpen = BaseHandlingAudioProfile.BipodOpen;
		targetProfile.BipodClosed = BaseHandlingAudioProfile.BipodClosed;
		targetProfile.BeltGrab = BaseHandlingAudioProfile.BeltGrab;
		targetProfile.BeltRelease = BaseHandlingAudioProfile.BeltRelease;
		targetProfile.BeltSeat = BaseHandlingAudioProfile.BeltSeat;
		targetProfile.BeltSettle = BaseHandlingAudioProfile.BeltSettle;
	}
}
public class BoltActionDustCover : FVRInteractiveObject
{
	public FVRFireArm BoltActionRifle;

	public BoltActionRifle_Handle BoltActionRifle_Handle;

	public Transform DustCoverGeo;

	private bool m_isOpen;

	public float OpenRot;

	public float ClosedRot;

	public float RotSpeed = 360f;

	private float m_curRot;

	private float m_tarRot;

	public AudioEvent AudEvent_CoverOpen;

	public AudioEvent AudEvent_CoverClose;

	public override void Awake()
	{
		((FVRInteractiveObject)this).Awake();
		m_curRot = ClosedRot;
		m_tarRot = ClosedRot;
	}

	public override void SimpleInteraction(FVRViveHand hand)
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Invalid comparison between Unknown and I4
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		((FVRInteractiveObject)this).SimpleInteraction(hand);
		if ((Object)(object)BoltActionRifle_Handle != (Object)null && (int)BoltActionRifle_Handle.HandleRot == 2)
		{
			if (m_isOpen)
			{
				Close();
			}
			else
			{
				Open();
			}
		}
		else if ((Object)(object)BoltActionRifle_Handle != (Object)null && (int)BoltActionRifle_Handle.HandleRot == 0 && m_isOpen)
		{
			Close();
		}
	}

	private void ToggleDustCoverState()
	{
		if (m_isOpen)
		{
			Close();
		}
		else
		{
			Open();
		}
	}

	public override void FVRUpdate()
	{
		//IL_0029: 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)
		((FVRInteractiveObject)this).FVRUpdate();
		if (!m_isOpen && (Object)(object)BoltActionRifle_Handle != (Object)null && (int)BoltActionRifle_Handle.HandleRot == 0)
		{
			Open();
		}
		if (Mathf.Abs(m_tarRot - m_curRot) > 0.01f)
		{
			m_curRot = Mathf.MoveTowards(m_curRot, m_tarRot, Time.deltaTime * RotSpeed);
			if ((Object)(object)DustCoverGeo != (Object)null)
			{
				DustCoverGeo.localEulerAngles = new Vector3(0f, 0f, m_curRot);
			}
		}
	}

	private void Open()
	{
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		if (!m_isOpen)
		{
			m_isOpen = true;
			m_tarRot = OpenRot;
			RotSpeed = 1900f;
			if (AudEvent_CoverOpen != null && (Object)(object)BoltActionRifle != (Object)null)
			{
				BoltActionRifle.PlayAudioAsHandling(AudEvent_CoverOpen, ((Component)this).transform.position);
			}
		}
	}

	private void Close()
	{
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		if (m_isOpen)
		{
			m_isOpen = false;
			m_tarRot = ClosedRot;
			RotSpeed = 800f;
			if (AudEvent_CoverClose != null && (Object)(object)BoltActionRifle != (Object)null)
			{
				BoltActionRifle.PlayAudioAsHandling(AudEvent_CoverClose, ((Component)this).transform.position);
			}
		}
	}
}