using System;
using System.Collections;
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 UnityEditor;
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 BitWizrd.HuntSpencer1882Compact
{
[BepInPlugin("BitWizrd.HuntSpencer1882Compact", "HuntSpencer1882Compact", "1.0.1")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
public class HuntSpencer1882CompactPlugin : 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(), "BitWizrd.HuntSpencer1882Compact");
OtherLoader.RegisterDirectLoad(BasePath, "BitWizrd.HuntSpencer1882Compact", "", "spencer1882_compact", "", "");
}
}
}
public class BloodBondSR : MonoBehaviour
{
private void Awake()
{
string name = "Ammo_69_CashMoney_D100(Clone)";
((Object)((Component)this).gameObject).name = name;
Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren<Collider>(true);
for (int i = 0; i < componentsInChildren.Length; i++)
{
((Object)((Component)componentsInChildren[i]).gameObject).name = name;
}
}
}
public class CylindersphereAdjuster : EditorWindow
{
private Transform centerTransform;
private float offset = 1E-05f;
private string offsetString = "0.00001";
private bool useLocalSpace = true;
private string instructions = "Select the sphere objects you want to adjust. When using Local Space, each object's local position will be adjusted radially (from its parent's center). When not using Local Space, a Center Transform (or world origin if left empty) is used to compute the radial offset.";
[MenuItem("Tools/Cylindersphere Adjuster")]
public static void ShowWindow()
{
EditorWindow.GetWindow<CylindersphereAdjuster>("Cylindersphere Adjuster");
}
private void OnGUI()
{
EditorGUILayout.LabelField("Cylindersphere Adjuster", EditorStyles.boldLabel, (GUILayoutOption[])(object)new GUILayoutOption[0]);
EditorGUILayout.HelpBox(instructions, (MessageType)1);
useLocalSpace = EditorGUILayout.Toggle("Use Local Space", useLocalSpace, (GUILayoutOption[])(object)new GUILayoutOption[0]);
if (!useLocalSpace)
{
ref Transform reference = ref centerTransform;
Object obj = EditorGUILayout.ObjectField("Center Transform", (Object)(object)centerTransform, typeof(Transform), true, (GUILayoutOption[])(object)new GUILayoutOption[0]);
reference = (Transform)(object)((obj is Transform) ? obj : null);
}
offsetString = EditorGUILayout.TextField("Offset", offsetString, (GUILayoutOption[])(object)new GUILayoutOption[0]);
if (!float.TryParse(offsetString, out offset))
{
offset = 1E-05f;
offsetString = offset.ToString("0.000000");
}
else
{
offsetString = offset.ToString("0.000000");
}
if (GUILayout.Button("Apply Adjustment to Selected", (GUILayoutOption[])(object)new GUILayoutOption[0]))
{
AdjustSelectedObjects();
}
}
private void AdjustSelectedObjects()
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: 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_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
if (Selection.gameObjects.Length == 0)
{
EditorUtility.DisplayDialog("No Objects Selected", "Please select the sphere objects to adjust.", "OK");
return;
}
GameObject[] gameObjects = Selection.gameObjects;
foreach (GameObject val in gameObjects)
{
if (useLocalSpace)
{
Undo.RecordObject((Object)(object)val.transform, "Adjust Local Position");
Vector3 localPosition = val.transform.localPosition;
if (localPosition == Vector3.zero)
{
Debug.LogWarning((object)("Object " + ((Object)val).name + " has a local position of zero and cannot be adjusted."));
continue;
}
float magnitude = ((Vector3)(ref localPosition)).magnitude;
float num = magnitude + offset;
Vector3 localPosition2 = ((Vector3)(ref localPosition)).normalized * num;
val.transform.localPosition = localPosition2;
continue;
}
Undo.RecordObject((Object)(object)val.transform, "Adjust World Position");
Vector3 val2 = ((!Object.op_Implicit((Object)(object)centerTransform)) ? Vector3.zero : centerTransform.position);
Vector3 val3 = val.transform.position - val2;
if (val3 == Vector3.zero)
{
Debug.LogWarning((object)("Object " + ((Object)val).name + " is at the center point and cannot be adjusted."));
continue;
}
float magnitude2 = ((Vector3)(ref val3)).magnitude;
float num2 = magnitude2 + offset;
Vector3 position = val2 + ((Vector3)(ref val3)).normalized * num2;
val.transform.position = position;
}
}
}
namespace BitWizrd.ShotgunMod
{
public class FullyAutomaticShotgun : TubeFedShotgun
{
public float fireRate = 5f;
private float nextFireTime = 0f;
private bool m_triggerWasHeldOnGrab = false;
public override void BeginInteraction(FVRViveHand hand)
{
((FVRFireArm)this).BeginInteraction(hand);
m_triggerWasHeldOnGrab = hand.Input.TriggerFloat >= base.TriggerBreakThreshold;
}
public override void UpdateInteraction(FVRViveHand hand)
{
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: 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)
base.m_triggerFloat = Mathf.Clamp(hand.Input.TriggerFloat, 0f, 1f);
if (base.m_triggerFloat >= base.TriggerBreakThreshold && Time.time >= nextFireTime && !m_triggerWasHeldOnGrab && base.m_isHammerCocked && (int)base.Bolt.CurPos == 0)
{
((TubeFedShotgun)this).ReleaseHammer();
nextFireTime = Time.time + 1f / fireRate;
}
if (base.m_triggerFloat < base.TriggerResetThreshold)
{
m_triggerWasHeldOnGrab = false;
}
((FVRPhysicalObject)this).SetAnimatedComponent(base.Trigger, Mathf.Lerp(base.TriggerUnheld, base.TriggerHeld, base.m_triggerFloat), base.TriggerInterp, base.TriggerAxis);
}
}
}
public class HuntDollarSR : MonoBehaviour
{
private IEnumerator Start()
{
yield return (object)new WaitForSeconds(3f);
string str = "CharcoalBriquette(Clone)";
((Object)((Component)this).gameObject).name = str;
Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren<Collider>(true);
for (int i = 0; i < componentsInChildren.Length; i++)
{
Component val = (Component)(object)componentsInChildren[i];
((Object)val.gameObject).name = str;
}
}
}
public class PlayRandomSoundOnSpawn : MonoBehaviour
{
public AudioClip[] spawnSounds;
public float volume = 1f;
[Header("Pitch Settings")]
public float minPitch = 0.9f;
public float maxPitch = 1.1f;
private AudioSource audioSource;
private void Start()
{
if (spawnSounds.Length > 0)
{
audioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
audioSource.playOnAwake = false;
audioSource.spatialBlend = 1f;
audioSource.volume = volume;
AudioClip val = spawnSounds[Random.Range(0, spawnSounds.Length)];
audioSource.pitch = Random.Range(minPitch, maxPitch);
audioSource.PlayOneShot(val);
}
}
}
public class RandomSpinOnSpawn : MonoBehaviour
{
public float spinForce = 0.5f;
public Vector3 torqueAxis = new Vector3(1f, 0f, 0f);
private Rigidbody rb;
private void Start()
{
//IL_003e: 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_005f: Unknown result type (might be due to invalid IL or missing references)
rb = ((Component)this).GetComponent<Rigidbody>();
if ((Object)(object)rb != (Object)null)
{
((Component)this).transform.rotation = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f);
rb.AddTorque(((Vector3)(ref torqueAxis)).normalized * spinForce, (ForceMode)1);
}
}
}
namespace BitWizrd.Shotgun
{
public class ToggleLinkShotgun : TubeFedShotgun
{
public ToggleLinkShotgunBolt ToggleBolt;
public Transform CockingTrigger;
public float CockedTriggerAngle = 20f;
public float UncockedTriggerAngle = 0f;
public bool LockProxyRoundInChamber = true;
public override void FVRUpdate()
{
//IL_0075: 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_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: 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_0129: Unknown result type (might be due to invalid IL or missing references)
((TubeFedShotgun)this).FVRUpdate();
if ((Object)(object)base.Chamber != (Object)null && base.Chamber.IsFull)
{
float boltLerpBetweenRearAndFore = ToggleBolt.GetBoltLerpBetweenRearAndFore();
float num = 1f - boltLerpBetweenRearAndFore;
if (num >= ToggleBolt.ToggleDropThreshold || !ToggleBolt.IsToggleLinkDown)
{
base.Chamber.ProxyRound.position = ((Component)base.Chamber).transform.position;
base.Chamber.ProxyRound.rotation = ((Component)base.Chamber).transform.rotation;
}
else
{
float num2 = Mathf.Clamp01((ToggleBolt.ToggleDropThreshold - num) / (ToggleBolt.ToggleDropThreshold - ToggleBolt.FullyRearThreshold));
base.Chamber.ProxyRound.position = Vector3.Lerp(((Component)base.Chamber).transform.position, base.RoundPos_Ejection.position, num2);
base.Chamber.ProxyRound.rotation = Quaternion.Slerp(((Component)base.Chamber).transform.rotation, base.RoundPos_Ejection.rotation, num2);
}
}
}
private void Update()
{
if (!((Object)(object)base.Handle == (Object)null))
{
((TubeFedShotgunBolt)ToggleBolt).UpdateBolt();
((TubeFedShotgun)this).UpdateCarrier();
UpdateCockingTrigger();
}
}
private void UpdateCockingTrigger()
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)CockingTrigger == (Object)null))
{
float num = ((!((TubeFedShotgun)this).IsHammerCocked) ? UncockedTriggerAngle : CockedTriggerAngle);
CockingTrigger.localRotation = Quaternion.Euler(num, 0f, 0f);
}
}
public override void UpdateInteraction(FVRViveHand hand)
{
((TubeFedShotgun)this).UpdateInteraction(hand);
if ((Object)(object)ToggleBolt != (Object)null && !ToggleBolt.IsBoltAtRest)
{
typeof(TubeFedShotgun).GetField("m_triggerFloat", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(this, 0f);
}
}
public void ReleaseHammer()
{
if (!((Object)(object)ToggleBolt == (Object)null) && ToggleBolt.IsBoltAtRest)
{
FieldInfo field = typeof(TubeFedShotgun).GetField("m_triggerFloat", BindingFlags.Instance | BindingFlags.NonPublic);
float num = 0f;
if ((object)field != null)
{
num = (float)field.GetValue(this);
}
if (!(num > 0.1f))
{
((TubeFedShotgun)this).ReleaseHammer();
}
}
}
public override void FireMuzzleSmoke()
{
if ((Object)(object)ToggleBolt != (Object)null && !ToggleBolt.IsBoltAtRest)
{
for (int i = 0; i < ((FVRFireArm)this).GasOutEffects.Length; i++)
{
((FVRFireArm)this).GasOutEffects[i].AddGas(((FVRFireArm)this).IsSuppressed());
}
}
else
{
((FVRFireArm)this).FireMuzzleSmoke();
}
}
public override void FVRFixedUpdate()
{
((FVRFireArm)this).FVRFixedUpdate();
((FVRFireArm)this).IsBreachOpenForGasOut = !ToggleBolt.IsBoltAtRest;
}
}
public class ToggleLinkShotgunBolt : TubeFedShotgunBolt
{
private enum PumpState
{
Forward,
Rearward,
SpringUp,
AtRear,
ForwardMotion
}
public Transform ToggleBolt;
public float ToggleDownAngle = -13f;
public float ToggleEjectAngle = 15f;
public float ToggleResetAngle = 0f;
public float FullyRearThreshold = 0.05f;
public float FullyForwardThreshold = 0.99f;
public float ToggleDropThreshold = 0.5f;
public float springDuration = 0.08f;
public float minBounceFactor = 0.3f;
public float maxBounceFactor = 0.6f;
private TubeFedShotgun parentShotgun;
private TubeFedShotgunHandle pumpHandle;
private float customProgress = 1f;
private PumpState currentState = PumpState.Forward;
private float springTimer = 0f;
private float springStartAngle = 0f;
private float springBounceFactor = 0f;
public Transform ClipToRotate;
public float ClipMaxZAngle = 15f;
public float ClipRotationBeginProgress = 0.8f;
public float ClipRotationEndProgress = 0.75f;
private bool isToggleLinkDown = false;
private float forwardStartProgress = 0f;
public bool IsBoltAtRest => currentState == PumpState.Forward;
public bool IsToggleLinkDown => isToggleLinkDown;
private void Start()
{
//IL_00a7: 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)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
parentShotgun = ((Component)this).GetComponentInParent<TubeFedShotgun>();
if ((Object)(object)parentShotgun != (Object)null)
{
pumpHandle = parentShotgun.Handle;
}
if ((Object)(object)ToggleBolt != (Object)null)
{
if ((Object)(object)ToggleBolt.parent != (Object)null)
{
ToggleBolt.localRotation = ToggleBolt.parent.rotation * Quaternion.Euler(ToggleResetAngle, 0f, 0f);
}
else
{
ToggleBolt.rotation = Quaternion.Euler(ToggleResetAngle, 0f, 0f);
}
}
if ((Object)(object)pumpHandle != (Object)null)
{
customProgress = pumpHandle.GetBoltLerpBetweenRearAndFore();
}
}
private void Update()
{
//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
//IL_0311: Unknown result type (might be due to invalid IL or missing references)
//IL_0305: Unknown result type (might be due to invalid IL or missing references)
//IL_039f: Unknown result type (might be due to invalid IL or missing references)
//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)pumpHandle == (Object)null || (Object)(object)ToggleBolt == (Object)null)
{
return;
}
customProgress = Mathf.Clamp01(pumpHandle.GetBoltLerpBetweenRearAndFore());
float num = ToggleResetAngle;
switch (currentState)
{
case PumpState.Forward:
num = ToggleResetAngle;
if (customProgress < FullyForwardThreshold)
{
currentState = PumpState.Rearward;
}
break;
case PumpState.Rearward:
num = ((!(customProgress >= ToggleDropThreshold)) ? ToggleDownAngle : Mathf.Lerp(ToggleResetAngle, ToggleDownAngle, (1f - customProgress) / (1f - ToggleDropThreshold)));
if (customProgress < ToggleDropThreshold)
{
isToggleLinkDown = true;
}
if (customProgress <= FullyRearThreshold)
{
springBounceFactor = Random.Range(minBounceFactor, maxBounceFactor);
currentState = PumpState.SpringUp;
springTimer = 0f;
springStartAngle = ToggleDownAngle;
BoltEvent_SmackRear();
BoltEvent_ExtractRoundFromMag();
BoltEvent_EjectRound();
}
break;
case PumpState.SpringUp:
{
springTimer += Time.deltaTime;
float num4 = Mathf.Clamp01(springTimer / springDuration);
float num5 = ElasticBounce(num4, springBounceFactor);
num = Mathf.Lerp(springStartAngle, ToggleEjectAngle, num5);
if (springTimer > 0f)
{
isToggleLinkDown = false;
}
if (num4 >= 1f)
{
currentState = PumpState.AtRear;
num = ToggleEjectAngle;
if ((Object)(object)parentShotgun != (Object)null)
{
parentShotgun.CockHammer();
}
}
break;
}
case PumpState.AtRear:
num = ToggleEjectAngle;
if (GetBoltLerpBetweenRearAndFore() <= ClipRotationEndProgress + 0.12f)
{
forwardStartProgress = customProgress;
currentState = PumpState.ForwardMotion;
}
break;
case PumpState.ForwardMotion:
{
float num2 = FullyForwardThreshold - forwardStartProgress;
float num3 = ((!(num2 > 0f)) ? 1f : Mathf.Clamp01((customProgress - forwardStartProgress) / num2));
num = Mathf.Lerp(ToggleEjectAngle, ToggleResetAngle, num3);
if (customProgress >= FullyForwardThreshold)
{
currentState = PumpState.Forward;
num = ToggleResetAngle;
BoltEvent_ArriveAtFore();
if ((Object)(object)parentShotgun != (Object)null && (Object)(object)parentShotgun.Bolt != (Object)null && parentShotgun.Bolt.m_isBoltLocked)
{
BoltEvent_BoltCaught();
}
}
break;
}
}
ToggleBolt.localRotation = Quaternion.Euler(num, 0f, 0f);
if (currentState == PumpState.Forward)
{
base.CurPos = (BoltPos)0;
}
else
{
base.CurPos = (BoltPos)1;
}
float boltLerpBetweenRearAndFore = GetBoltLerpBetweenRearAndFore();
if ((Object)(object)ClipToRotate != (Object)null)
{
float num6 = 0f;
if (boltLerpBetweenRearAndFore >= ClipRotationBeginProgress)
{
num6 = ClipMaxZAngle;
}
else if (boltLerpBetweenRearAndFore <= ClipRotationEndProgress)
{
num6 = 0f;
}
else
{
float num7 = (boltLerpBetweenRearAndFore - ClipRotationEndProgress) / (ClipRotationBeginProgress - ClipRotationEndProgress);
num6 = Mathf.Lerp(0f, ClipMaxZAngle, num7);
}
Quaternion localRotation = ClipToRotate.localRotation;
Vector3 eulerAngles = ((Quaternion)(ref localRotation)).eulerAngles;
ClipToRotate.localRotation = Quaternion.Euler(eulerAngles.x, eulerAngles.y, num6);
}
if ((Object)(object)parentShotgun != (Object)null)
{
typeof(TubeFedShotgun).GetField("IsBreachOpenForGasOut", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(parentShotgun, !IsBoltAtRest);
}
}
private float ElasticBounce(float t, float amplitude)
{
if (t == 0f)
{
return 0f;
}
if (t == 1f)
{
return 1f;
}
float num = (float)Math.PI * 2f / 3f;
return Mathf.Pow(2f, -10f * t) * Mathf.Sin((t * 10f - 0.75f) * num) * amplitude + 1f;
}
private void InvokeBaseMethod(string methodName)
{
typeof(TubeFedShotgunBolt).GetMethod(methodName, BindingFlags.Instance | BindingFlags.NonPublic)?.Invoke(this, null);
}
private void BoltEvent_ArriveAtFore()
{
InvokeBaseMethod("BoltEvent_ArriveAtFore");
}
private void BoltEvent_EjectRound()
{
InvokeBaseMethod("BoltEvent_EjectRound");
}
private void BoltEvent_ExtractRoundFromMag()
{
InvokeBaseMethod("BoltEvent_ExtractRoundFromMag");
}
private void BoltEvent_SmackRear()
{
InvokeBaseMethod("BoltEvent_SmackRear");
}
private void BoltEvent_BoltCaught()
{
InvokeBaseMethod("BoltEvent_BoltCaught");
}
public float GetBoltLerpBetweenRearAndFore()
{
return 1f - customProgress;
}
}
}