Decompiled source of ModulFinnLMG v1.0.0

ModulFinnLMG.dll

Decompiled 5 months 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 OpenScripts2;
using OtherLoader;
using Sodalite.Api;
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 ModifyFireSelector_OB : MonoBehaviour
{
	public Transform FireSelector;

	public InterpStyle interp;

	public Axis axis;

	public FireSelectorMode[] modesToSet;

	public int defaultMode;

	private OpenBoltReceiver hg;

	[HideInInspector]
	public Transform _FireSelector;

	[HideInInspector]
	public InterpStyle _interp;

	[HideInInspector]
	public Axis _axis;

	[HideInInspector]
	public FireSelectorMode[] _modesToSet;

	[HideInInspector]
	public int _defaultMode;

	private void Start()
	{
		//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)
		hg = ((Component)this).GetComponentInParent<OpenBoltReceiver>();
		_FireSelector = hg.FireSelectorSwitch;
		_interp = hg.FireSelector_InterpStyle;
		_axis = hg.FireSelector_Axis;
		_modesToSet = hg.FireSelector_Modes;
		_defaultMode = hg.m_fireSelectorMode;
		UpdateSelector();
	}

	private void UpdateSelector()
	{
		//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)
		hg.HasFireSelectorButton = true;
		hg.FireSelectorSwitch = FireSelector;
		hg.FireSelector_InterpStyle = interp;
		hg.FireSelector_Axis = axis;
		hg.FireSelector_Modes = modesToSet;
		hg.m_fireSelectorMode = defaultMode;
	}

	private void OnDestroy()
	{
		//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)
		hg.HasFireSelectorButton = true;
		hg.FireSelectorSwitch = _FireSelector;
		hg.FireSelector_InterpStyle = _interp;
		hg.FireSelector_Axis = _axis;
		hg.FireSelector_Modes = _modesToSet;
		hg.m_fireSelectorMode = _defaultMode;
	}
}
public class ModifyGrabTriggerArea : MonoBehaviour
{
	public GameObject ModularWeapon;

	public BoxCollider BC;

	public string PartCategory;

	public string Part;

	public Vector3 newCenter;

	public Vector3 newSize;

	private BoxCollider bc;

	private Vector3 oldCenter;

	private Vector3 oldSize;

	private IModularWeapon weap;

	private string curpart;

	private void Start()
	{
		//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_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		weap = ModularWeapon.GetComponent<IModularWeapon>();
		oldCenter = BC.center;
		oldSize = BC.size;
	}

	private void Update()
	{
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		curpart = weap.GetModularFVRFireArm.AllAttachmentPoints[PartCategory].SelectedModularWeaponPart;
		if (curpart == Part)
		{
			BC.center = newCenter;
			BC.size = newSize;
		}
		else
		{
			BC.center = oldCenter;
			BC.size = oldSize;
		}
	}
}
public class ModifySaw : ModularStock
{
	public enum EColliderType
	{
		Sphere,
		Capsule,
		Box
	}

	[Header("Handguard Extension Config")]
	[Tooltip("This GameObject defines where the extension of the AltGrip trigger will end up. It should contain a trigger to define what the new handguard interaction zone looks like. Gets removed on load for performance reasons, so don't put anything below it.")]
	public GameObject ForeGripExtensionDefinition;

	[HideInInspector]
	public TransformProxy ForeGripExtensionTransformProxy;

	[HideInInspector]
	public Vector3 TriggerCenter;

	[HideInInspector]
	public Vector3 TriggerSize;

	[HideInInspector]
	public Axis ColliderAxis;

	[HideInInspector]
	public EColliderType ColliderType;

	private FVRFireArm _firearm;

	private Collider _addedCollider;

	public override void Awake()
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Expected O, but got Unknown
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: 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_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: 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_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		((ModularStock)this).Awake();
		if ((Object)(object)ForeGripExtensionDefinition != (Object)null)
		{
			ForeGripExtensionTransformProxy = new TransformProxy(ForeGripExtensionDefinition.transform, false);
			Collider component = ForeGripExtensionDefinition.GetComponent<Collider>();
			CapsuleCollider val = (CapsuleCollider)(object)((component is CapsuleCollider) ? component : null);
			if (val == null)
			{
				SphereCollider val2 = (SphereCollider)(object)((component is SphereCollider) ? component : null);
				if (val2 == null)
				{
					BoxCollider val3 = (BoxCollider)(object)((component is BoxCollider) ? component : null);
					if (val3 == null)
					{
						if (component == null)
						{
							ModularWorkshopManager.LogWarning((MonoBehaviour)(object)this, "ForeGripDefinition " + ((Object)ForeGripExtensionDefinition).name + " doesn't contain a collider you goofus! Shit's about to break!");
						}
					}
					else
					{
						TriggerCenter = val3.center;
						TriggerSize = val3.size;
						ColliderType = EColliderType.Box;
					}
				}
				else
				{
					TriggerCenter = val2.center;
					TriggerSize = new Vector3(val2.radius, 0f, 0f);
					ColliderType = EColliderType.Sphere;
				}
			}
			else
			{
				TriggerCenter = val.center;
				TriggerSize = new Vector3(val.radius, val.height, 0f);
				ColliderType = EColliderType.Capsule;
				switch (val.direction)
				{
				case 0:
					ColliderAxis = (Axis)0;
					break;
				case 1:
					ColliderAxis = (Axis)1;
					break;
				case 2:
					ColliderAxis = (Axis)2;
					break;
				default:
					ColliderAxis = (Axis)0;
					break;
				}
			}
			Object.Destroy((Object)(object)ForeGripExtensionDefinition);
		}
		else if ((Object)(object)ForeGripExtensionDefinition == (Object)null)
		{
			ModularWorkshopManager.LogError((MonoBehaviour)(object)this, "ForeGripExtensionDefinition is empty but you want this to be a functional foregrip extension you goofus! Shit's about to break!");
		}
	}

	public override void EnablePart()
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: 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_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: 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)
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0146: Expected I4, but got Unknown
		//IL_016c: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		((ModularWeaponPart)this).EnablePart();
		if (UnityEngineExtensions.TryGetComponentInParent<FVRFireArm>((Component)(object)((Component)this).transform, ref _firearm))
		{
			Vector3 val = ForeGripExtensionTransformProxy.parent.TransformPoint(ForeGripExtensionTransformProxy.localPosition + UnityEngineExtensions.MultiplyComponentWise(TriggerCenter, ForeGripExtensionTransformProxy.localScale));
			Vector3 center = _firearm.Foregrip.transform.InverseTransformPoint(val);
			switch (ColliderType)
			{
			case EColliderType.Sphere:
			{
				_addedCollider = (Collider)(object)_firearm.Foregrip.AddComponent<SphereCollider>();
				Collider addedCollider7 = _addedCollider;
				((SphereCollider)((addedCollider7 is SphereCollider) ? addedCollider7 : null)).center = center;
				Collider addedCollider8 = _addedCollider;
				((SphereCollider)((addedCollider8 is SphereCollider) ? addedCollider8 : null)).radius = TriggerSize.x;
				break;
			}
			case EColliderType.Capsule:
			{
				_addedCollider = (Collider)(object)_firearm.Foregrip.AddComponent<CapsuleCollider>();
				Collider addedCollider3 = _addedCollider;
				((CapsuleCollider)((addedCollider3 is CapsuleCollider) ? addedCollider3 : null)).center = center;
				Collider addedCollider4 = _addedCollider;
				((CapsuleCollider)((addedCollider4 is CapsuleCollider) ? addedCollider4 : null)).radius = TriggerSize.x;
				Collider addedCollider5 = _addedCollider;
				((CapsuleCollider)((addedCollider5 is CapsuleCollider) ? addedCollider5 : null)).height = TriggerSize.y;
				Collider addedCollider6 = _addedCollider;
				((CapsuleCollider)((addedCollider6 is CapsuleCollider) ? addedCollider6 : null)).direction = (int)ColliderAxis;
				break;
			}
			case EColliderType.Box:
			{
				_addedCollider = (Collider)(object)_firearm.Foregrip.AddComponent<BoxCollider>();
				Collider addedCollider = _addedCollider;
				((BoxCollider)((addedCollider is BoxCollider) ? addedCollider : null)).center = center;
				Collider addedCollider2 = _addedCollider;
				((BoxCollider)((addedCollider2 is BoxCollider) ? addedCollider2 : null)).size = TriggerSize;
				break;
			}
			}
			_addedCollider.isTrigger = true;
		}
		else if ((Object)(object)_firearm == (Object)null)
		{
			ModularWorkshopManager.LogWarning((MonoBehaviour)(object)this, "Firearm not found! ModularHandguardExtension disabled!");
		}
	}

	public override void DisablePart()
	{
		((ModularWeaponPart)this).DisablePart();
		if ((Object)(object)_addedCollider != (Object)null)
		{
			Object.Destroy((Object)(object)_addedCollider);
		}
	}
}
public class ModifyTrigger : MonoBehaviour
{
	private OpenBoltReceiver receiver;

	public Transform trig;

	public float fireThres;

	public float resetThres;

	public InterpStyle interpStyle;

	private Transform _trig;

	private float _fireThres;

	private float _resetThres;

	private InterpStyle _interpStyle;

	private void Start()
	{
		//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)
		receiver = ((Component)this).GetComponentInParent<OpenBoltReceiver>();
		_trig = receiver.Trigger;
		_fireThres = receiver.TriggerFiringThreshold;
		_resetThres = receiver.TriggerResetThreshold;
		_interpStyle = receiver.TriggerInterpStyle;
		UpdateTrigger();
	}

	public void UpdateTrigger()
	{
		//IL_003b: 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)
		receiver.Trigger = trig;
		receiver.TriggerFiringThreshold = fireThres;
		receiver.TriggerResetThreshold = resetThres;
		receiver.TriggerInterpStyle = interpStyle;
	}

	public void OnDestroy()
	{
		//IL_003b: 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)
		receiver.Trigger = _trig;
		receiver.TriggerFiringThreshold = _fireThres;
		receiver.TriggerResetThreshold = _resetThres;
		receiver.TriggerInterpStyle = _interpStyle;
	}
}
namespace MeatKit
{
	public class HideInNormalInspectorAttribute : PropertyAttribute
	{
	}
}
namespace localpcnerd.ModulFinnLMG
{
	[BepInPlugin("localpcnerd.ModulFinnLMG", "ModulFinnLMG", "1.0.0")]
	[BepInProcess("h3vr.exe")]
	[Description("Built with MeatKit")]
	[BepInDependency("h3vr.otherloader", "1.3.0")]
	[BepInDependency("h3vr.cityrobo.ModularWorkshopManager", "1.0.0")]
	[BepInDependency("nrgill28.Sodalite", "1.4.1")]
	public class ModulFinnLMGPlugin : 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(), "localpcnerd.ModulFinnLMG");
			OtherLoader.RegisterDirectLoad(BasePath, "localpcnerd.ModulFinnLMG", "", "", "finn_lmg", "");
			GameAPI.PreloadAllAssets(Path.Combine(BasePath, "mw_modulfinnlmg"));
		}
	}
}