Decompiled source of DTIR v1.0.2
DTIR.dll
Decompiled a week agousing System; using System.Collections.Generic; 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 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] namespace Lua.DTIR; [BepInPlugin("Lua.DTIR", "DTIR", "1.0.2")] [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 DTIRPlugin : 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(), "Lua.DTIR"); OtherLoader.RegisterDirectLoad(BasePath, "Lua.DTIR", "", "lua_dtir", "", ""); GameAPI.PreloadAllAssets(Path.Combine(BasePath, "mw_dtir")); } } public class AdvanceMagazineAudioProfile : MonoBehaviour { [Header("References")] [Tooltip("Auto-populated from this GameObject if left empty.")] public FVRFireArmMagazine Magazine; [Header("Audio — Empty Magazine")] [Tooltip("Profile used for MagazineIn / MagazineOut when the magazine is empty.")] public FVRFirearmMagazineAudioSet EmptyProfile; private FVRFirearmMagazineAudioSet _originalProfileOverride; private bool _originalUsesOverrideInOut; private bool _wasEmpty; private void Start() { if ((Object)(object)Magazine == (Object)null) { Magazine = ((Component)this).GetComponent<FVRFireArmMagazine>(); } if ((Object)(object)Magazine == (Object)null) { Debug.LogWarning((object)"[AdvanceMagazineAudioProfile] No FVRFireArmMagazine found on this GameObject.", (Object)(object)this); ((Behaviour)this).enabled = false; return; } _originalProfileOverride = Magazine.ProfileOverride; _originalUsesOverrideInOut = Magazine.UsesOverrideInOut; _wasEmpty = !Magazine.HasARound(); ApplyProfile(_wasEmpty); } private void Update() { if (!((Object)(object)Magazine == (Object)null)) { bool flag = !Magazine.HasARound(); if (flag != _wasEmpty) { _wasEmpty = flag; ApplyProfile(flag); } } } private void ApplyProfile(bool isEmpty) { if (isEmpty && (Object)(object)EmptyProfile != (Object)null) { Magazine.UsesOverrideInOut = true; Magazine.ProfileOverride = EmptyProfile; } else { Magazine.UsesOverrideInOut = _originalUsesOverrideInOut; Magazine.ProfileOverride = _originalProfileOverride; } } } public class BoltReleaseChargingHandle : MonoBehaviour { public ClosedBoltWeapon Weapon; public ClosedBoltHandle Handle; public float LaunchSpeed = 5f; [Tooltip("If true, the handle stays at Rear until bolt release is pressed again. If false, it returns forward when pulled back manually.")] public bool HandleReturnsManually = false; private bool m_wasLocked; private void Start() { if ((Object)(object)Weapon == (Object)null || (Object)(object)Handle == (Object)null) { Debug.LogWarning((object)"[BoltReleaseChargingHandle] Weapon or Handle reference is missing.", (Object)(object)this); ((Behaviour)this).enabled = false; } else { m_wasLocked = Weapon.Bolt.IsBoltLocked(); } } private void Update() { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Invalid comparison between Unknown and I4 //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Invalid comparison between Unknown and I4 bool flag = Weapon.Bolt.IsBoltLocked(); if (m_wasLocked && !flag && Weapon.HasBoltReleaseButton && (int)Handle.CurPos == 4) { Handle.Speed_Forward = LaunchSpeed; } if ((int)Handle.CurPos == 0 && Handle.Speed_Forward > 0f) { Handle.Speed_Forward = 0f; } if (!HandleReturnsManually && !flag && !((FVRInteractiveObject)Handle).IsHeld && (int)Handle.CurPos == 4 && Handle.Speed_Forward == 0f) { Handle.Speed_Forward = LaunchSpeed; } m_wasLocked = flag; } } public class ClosedBoltMagRelease : FVRInteractiveObject { public ClosedBoltWeapon Weapon; protected void Awake() { ((FVRInteractiveObject)this).Awake(); } public override void SimpleInteraction(FVRViveHand hand) { if ((Object)(object)Weapon != (Object)null && ((Object)(object)((FVRInteractiveObject)Weapon).m_hand == (Object)null || (Object)(object)hand != (Object)(object)((FVRInteractiveObject)Weapon).m_hand)) { ((FVRFireArm)Weapon).EjectMag(false); } ((FVRInteractiveObject)this).SimpleInteraction(hand); } } public class PartRecoilImpulse : MonoBehaviour { public enum ImpulseMode { Rotation, Translation } public enum ImpulseAxis { X, Y, Z } [Serializable] public class RecoilPart { public Transform Piece; public ImpulseMode Mode = ImpulseMode.Rotation; public ImpulseAxis Axis = ImpulseAxis.X; public Vector2 Range = new Vector2(0f, 45f); public float ReturnSpeed = 5f; public float ImpulseStrength = 1f; [NonSerialized] public float CurrentLerp = 0f; } [Header("Parts")] public List<RecoilPart> Parts = new List<RecoilPart>(); private FVRFireArm m_firearm; private void Awake() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown GM.CurrentSceneSettings.ShotFiredEvent += new ShotFired(OnShotFired); } private void OnDestroy() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown if ((Object)(object)GM.CurrentSceneSettings != (Object)null) { GM.CurrentSceneSettings.ShotFiredEvent -= new ShotFired(OnShotFired); } } private void Start() { m_firearm = ((Component)this).GetComponentInParent<FVRFireArm>(); if ((Object)(object)m_firearm == (Object)null) { Debug.LogWarning((object)"[PartRecoilImpulse] No FVRFireArm found in parent hierarchy.", (Object)(object)this); } for (int i = 0; i < Parts.Count; i++) { ApplyToPart(Parts[i]); } } private void OnShotFired(FVRFireArm firearm) { if (!((Object)(object)firearm != (Object)(object)m_firearm)) { for (int i = 0; i < Parts.Count; i++) { Parts[i].CurrentLerp = Mathf.Clamp01(Parts[i].ImpulseStrength); ApplyToPart(Parts[i]); } } } private void Update() { for (int i = 0; i < Parts.Count; i++) { RecoilPart recoilPart = Parts[i]; if (recoilPart.CurrentLerp > 0f) { recoilPart.CurrentLerp = Mathf.MoveTowards(recoilPart.CurrentLerp, 0f, Time.deltaTime * recoilPart.ReturnSpeed); ApplyToPart(recoilPart); } } } private void ApplyToPart(RecoilPart part) { //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) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)part.Piece == (Object)null) { return; } float num = Mathf.Lerp(part.Range.x, part.Range.y, part.CurrentLerp); if (part.Mode == ImpulseMode.Rotation) { Vector3 localEulerAngles = part.Piece.localEulerAngles; if (part.Axis == ImpulseAxis.X) { localEulerAngles.x = num; } else if (part.Axis == ImpulseAxis.Y) { localEulerAngles.y = num; } else { localEulerAngles.z = num; } part.Piece.localEulerAngles = localEulerAngles; } else { Vector3 localPosition = part.Piece.localPosition; if (part.Axis == ImpulseAxis.X) { localPosition.x = num; } else if (part.Axis == ImpulseAxis.Y) { localPosition.y = num; } else { localPosition.z = num; } part.Piece.localPosition = localPosition; } } } public enum ControlMode { simple = 1, touch } public class VehicleControl : MonoBehaviour { [Serializable] public class CarWheels { public ConnectWheel wheels; } [Serializable] public class ConnectWheel { public bool frontWheelDrive = true; public Transform frontRight; public Transform frontLeft; public WheelSetting frontSetting; public bool backWheelDrive = true; public Transform backRight; public Transform backLeft; public WheelSetting rearSetting; } [Serializable] public class WheelSetting { public float Radius = 0.4f; public float Weight = 1000f; public float Distance = 0.2f; } [Serializable] public class CarLights { public Light[] brakeLights; public Light[] reverseLights; } [Serializable] public class CarSounds { public AudioSource IdleEngine; public AudioSource LowEngine; public AudioSource HighEngine; public float minPitch = 1f; public float maxPitch = 10f; public AudioSource nitro; public AudioSource switchGear; } [Serializable] public class CarParticles { public GameObject brakeParticlePerfab; public ParticleSystem shiftParticle1; public ParticleSystem shiftParticle2; private GameObject[] wheelParticle = (GameObject[])(object)new GameObject[4]; } [Serializable] public class CarSetting { public bool showNormalGizmos = false; public Transform carSteer; public HitGround[] hitGround; public List<Transform> cameraSwitchView; public float springs = 25000f; public float dampers = 1500f; public float carPower = 120f; public float shiftPower = 150f; public float brakePower = 8000f; public Vector3 shiftCentre = new Vector3(0f, -0.8f, 0f); public float maxSteerAngle = 25f; public float shiftDownRPM = 1500f; public float shiftUpRPM = 2500f; public float idleRPM = 500f; public float stiffness = 2f; public bool automaticGear = true; public float[] gears = new float[6] { -10f, 9f, 6f, 4.5f, 3f, 2.5f }; public float LimitBackwardSpeed = 60f; public float LimitForwardSpeed = 220f; } [Serializable] public class HitGround { public string tag = "street"; public bool grounded = false; public AudioClip brakeSound; public AudioClip groundSound; public Color brakeColor; } private class WheelComponent { public Transform wheel; public WheelCollider collider; public Vector3 startPos; public float rotation = 0f; public float rotation2 = 0f; public float maxSteer; public bool drive; public float pos_y = 0f; public WheelSetting settings; } public ControlMode controlMode = ControlMode.simple; public bool activeControl = false; public CarWheels carWheels; public CarLights carLights; public CarSounds carSounds; public CarParticles carParticles; public CarSetting carSetting; [HideInInspector] public float steer = 0f; [HideInInspector] public float accel = 0f; [HideInInspector] public bool brake; private bool shifmotor; [HideInInspector] public float curTorque = 100f; [HideInInspector] public float powerShift = 100f; [HideInInspector] public bool shift; private float torque = 100f; [HideInInspector] public float speed = 0f; private float lastSpeed = -10f; private bool shifting = false; private float[] efficiencyTable = new float[22] { 0.6f, 0.65f, 0.7f, 0.75f, 0.8f, 0.85f, 0.9f, 1f, 1f, 0.95f, 0.8f, 0.7f, 0.6f, 0.5f, 0.45f, 0.4f, 0.36f, 0.33f, 0.3f, 0.2f, 0.1f, 0.05f }; private float efficiencyTableStep = 250f; private float Pitch; private float PitchDelay; private float shiftTime = 0f; private float shiftDelay = 0f; [HideInInspector] public int currentGear = 0; [HideInInspector] public bool NeutralGear = true; [HideInInspector] public float motorRPM = 0f; [HideInInspector] public bool Backward = false; [HideInInspector] public float accelFwd = 0f; [HideInInspector] public float accelBack = 0f; [HideInInspector] public float steerAmount = 0f; private float wantedRPM = 0f; private float w_rotate; private float slip; private float slip2 = 0f; private GameObject[] Particle = (GameObject[])(object)new GameObject[4]; private Vector3 steerCurAngle; private Rigidbody myRigidbody; private WheelComponent[] wheels; public bool isOn = true; public bool isForciblyOff = false; private WheelComponent SetWheelComponent(Transform wheel, float maxSteer, bool drive, float pos_y, WheelSetting setting) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown //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) WheelComponent wheelComponent = new WheelComponent(); GameObject val = new GameObject(((Object)wheel).name + "WheelCollider"); val.transform.parent = ((Component)this).transform; val.transform.position = wheel.position; val.transform.eulerAngles = ((Component)this).transform.eulerAngles; pos_y = val.transform.localPosition.y; WheelCollider val2 = (WheelCollider)val.AddComponent(typeof(WheelCollider)); wheelComponent.wheel = wheel; wheelComponent.collider = val.GetComponent<WheelCollider>(); wheelComponent.drive = drive; wheelComponent.pos_y = pos_y; wheelComponent.maxSteer = maxSteer; wheelComponent.startPos = val.transform.localPosition; wheelComponent.settings = setting; return wheelComponent; } private void Awake() { //IL_0078: 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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_013e: 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_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) if (carSetting.automaticGear) { NeutralGear = false; } myRigidbody = ((Component)((Component)this).transform).GetComponent<Rigidbody>(); wheels = new WheelComponent[4]; wheels[0] = SetWheelComponent(carWheels.wheels.frontRight, carSetting.maxSteerAngle, carWheels.wheels.frontWheelDrive, carWheels.wheels.frontRight.position.y, carWheels.wheels.frontSetting); wheels[1] = SetWheelComponent(carWheels.wheels.frontLeft, carSetting.maxSteerAngle, carWheels.wheels.frontWheelDrive, carWheels.wheels.frontLeft.position.y, carWheels.wheels.frontSetting); wheels[2] = SetWheelComponent(carWheels.wheels.backRight, 0f, carWheels.wheels.backWheelDrive, carWheels.wheels.backRight.position.y, carWheels.wheels.rearSetting); wheels[3] = SetWheelComponent(carWheels.wheels.backLeft, 0f, carWheels.wheels.backWheelDrive, carWheels.wheels.backLeft.position.y, carWheels.wheels.rearSetting); if (Object.op_Implicit((Object)(object)carSetting.carSteer)) { steerCurAngle = carSetting.carSteer.localEulerAngles; } WheelComponent[] array = wheels; foreach (WheelComponent wheelComponent in array) { WheelCollider collider = wheelComponent.collider; collider.suspensionDistance = wheelComponent.settings.Distance; JointSpring suspensionSpring = collider.suspensionSpring; suspensionSpring.spring = carSetting.springs; suspensionSpring.damper = carSetting.dampers; collider.suspensionSpring = suspensionSpring; collider.radius = wheelComponent.settings.Radius; collider.mass = wheelComponent.settings.Weight; WheelFrictionCurve val = collider.forwardFriction; ((WheelFrictionCurve)(ref val)).asymptoteValue = 5000f; ((WheelFrictionCurve)(ref val)).extremumSlip = 2f; ((WheelFrictionCurve)(ref val)).asymptoteSlip = 20f; ((WheelFrictionCurve)(ref val)).stiffness = carSetting.stiffness; collider.forwardFriction = val; val = collider.sidewaysFriction; ((WheelFrictionCurve)(ref val)).asymptoteValue = 7500f; ((WheelFrictionCurve)(ref val)).asymptoteSlip = 2f; ((WheelFrictionCurve)(ref val)).stiffness = carSetting.stiffness; collider.sidewaysFriction = val; } } public void TurnOnEngine(bool forcibly) { if (!isForciblyOff) { isOn = true; } else if (forcibly) { isForciblyOff = false; isOn = true; } } public void TurnOffEngine(bool forcibly) { isForciblyOff = forcibly; isOn = false; } public void ShiftTo(int newGear) { ((Component)carSounds.switchGear).GetComponent<AudioSource>().Play(); currentGear = newGear; if (currentGear == 0) { NeutralGear = true; } else { NeutralGear = false; } if (currentGear == -1) { currentGear = 0; } } public void ShiftUp(bool ignoreDelay) { float timeSinceLevelLoad = Time.timeSinceLevelLoad; if ((timeSinceLevelLoad < shiftDelay && !ignoreDelay) || currentGear >= carSetting.gears.Length - 1) { return; } ((Component)carSounds.switchGear).GetComponent<AudioSource>().Play(); if (!carSetting.automaticGear) { if (currentGear == 0) { if (NeutralGear) { currentGear++; NeutralGear = false; } else { NeutralGear = true; } } else { currentGear++; } } else { currentGear++; } shiftDelay = timeSinceLevelLoad + 1f; shiftTime = 1.5f; } public void ShiftDown(bool ignoreDelay) { float timeSinceLevelLoad = Time.timeSinceLevelLoad; if ((timeSinceLevelLoad < shiftDelay && !ignoreDelay) || (currentGear <= 0 && !NeutralGear)) { return; } ((Component)carSounds.switchGear).GetComponent<AudioSource>().Play(); if (!carSetting.automaticGear) { if (currentGear == 1) { if (!NeutralGear) { currentGear--; NeutralGear = true; } } else if (currentGear == 0) { NeutralGear = false; } else { currentGear--; } } else { currentGear--; } shiftDelay = timeSinceLevelLoad + 0.1f; shiftTime = 2f; } private void OnCollisionEnter(Collision collision) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_00b7: 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) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)((Component)collision.transform.root).GetComponent<VehicleControl>())) { VehicleControl component = ((Component)collision.transform.root).GetComponent<VehicleControl>(); Vector3 relativeVelocity = collision.relativeVelocity; component.slip2 = Mathf.Clamp(((Vector3)(ref relativeVelocity)).magnitude, 0f, 10f); myRigidbody.angularVelocity = new Vector3((0f - myRigidbody.angularVelocity.x) * 0.5f, myRigidbody.angularVelocity.y * 0.5f, (0f - myRigidbody.angularVelocity.z) * 0.5f); myRigidbody.velocity = new Vector3(myRigidbody.velocity.x, myRigidbody.velocity.y * 0.5f, myRigidbody.velocity.z); } } private void OnCollisionStay(Collision collision) { if (Object.op_Implicit((Object)(object)((Component)collision.transform.root).GetComponent<VehicleControl>())) { ((Component)collision.transform.root).GetComponent<VehicleControl>().slip2 = 5f; } } private void Update() { } private void FixedUpdate() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_0704: Unknown result type (might be due to invalid IL or missing references) //IL_0709: Unknown result type (might be due to invalid IL or missing references) //IL_0751: Unknown result type (might be due to invalid IL or missing references) //IL_075a: Unknown result type (might be due to invalid IL or missing references) //IL_075f: Unknown result type (might be due to invalid IL or missing references) //IL_079b: Unknown result type (might be due to invalid IL or missing references) //IL_0acf: Unknown result type (might be due to invalid IL or missing references) //IL_0ae0: Unknown result type (might be due to invalid IL or missing references) //IL_0ae5: Unknown result type (might be due to invalid IL or missing references) //IL_0fca: Unknown result type (might be due to invalid IL or missing references) //IL_0fd4: Unknown result type (might be due to invalid IL or missing references) //IL_0ee6: Unknown result type (might be due to invalid IL or missing references) //IL_0eed: Unknown result type (might be due to invalid IL or missing references) //IL_0ef2: Unknown result type (might be due to invalid IL or missing references) //IL_0f0c: Unknown result type (might be due to invalid IL or missing references) //IL_0f17: Unknown result type (might be due to invalid IL or missing references) //IL_0f1c: Unknown result type (might be due to invalid IL or missing references) //IL_0f25: Unknown result type (might be due to invalid IL or missing references) //IL_0fec: Unknown result type (might be due to invalid IL or missing references) //IL_0b3b: Unknown result type (might be due to invalid IL or missing references) //IL_0b40: Unknown result type (might be due to invalid IL or missing references) //IL_0d23: Unknown result type (might be due to invalid IL or missing references) if (!isOn) { accel = 0f; } Vector3 velocity = myRigidbody.velocity; speed = ((Vector3)(ref velocity)).magnitude * 2.7f; if (speed < lastSpeed - 10f && slip < 10f) { slip = lastSpeed / 15f; } lastSpeed = speed; if (slip2 != 0f) { slip2 = Mathf.MoveTowards(slip2, 0f, 0.1f); } myRigidbody.centerOfMass = carSetting.shiftCentre; if (!carWheels.wheels.frontWheelDrive && !carWheels.wheels.backWheelDrive) { accel = 0f; } if (Object.op_Implicit((Object)(object)carSetting.carSteer)) { carSetting.carSteer.localEulerAngles = new Vector3(steerCurAngle.x, steerCurAngle.y, steerCurAngle.z + steer * -120f); } if (carSetting.automaticGear && currentGear == 1 && accel < 0f) { if (speed < 5f) { ShiftDown(ignoreDelay: false); } } else if (carSetting.automaticGear && currentGear == 0 && accel > 0f) { if (speed < 5f) { ShiftUp(ignoreDelay: false); } } else if (carSetting.automaticGear && motorRPM > carSetting.shiftUpRPM && accel > 0f && speed > 10f && !brake) { ShiftUp(ignoreDelay: false); } else if (carSetting.automaticGear && motorRPM < carSetting.shiftDownRPM && currentGear > 1) { ShiftDown(ignoreDelay: false); } if (speed < 1f) { Backward = true; } if (currentGear != 0 || !Backward) { Backward = false; } Light[] brakeLights = carLights.brakeLights; foreach (Light val in brakeLights) { if (brake || accel < 0f || speed < 1f) { val.intensity = Mathf.MoveTowards(val.intensity, 8f, 0.5f); } else { val.intensity = Mathf.MoveTowards(val.intensity, 0f, 0.5f); } ((Behaviour)val).enabled = val.intensity != 0f; } Light[] reverseLights = carLights.reverseLights; foreach (Light val2 in reverseLights) { if (speed > 2f && currentGear == 0) { val2.intensity = Mathf.MoveTowards(val2.intensity, 8f, 0.5f); } else { val2.intensity = Mathf.MoveTowards(val2.intensity, 0f, 0.5f); } ((Behaviour)val2).enabled = val2.intensity != 0f; } wantedRPM = 5500f * accel * 0.1f + wantedRPM * 0.9f; float num = 0f; int num2 = 0; bool flag = false; int num3 = 0; WheelComponent[] array = wheels; WheelHit val4 = default(WheelHit); foreach (WheelComponent wheelComponent in array) { WheelCollider collider = wheelComponent.collider; if (wheelComponent.drive) { num = ((!NeutralGear && brake && currentGear < 2) ? (num + accel * carSetting.idleRPM) : (NeutralGear ? (num + carSetting.idleRPM * accel) : (num + collider.rpm))); num2++; } if (brake || accel < 0f) { if (accel < 0f || (brake && (wheelComponent == wheels[2] || wheelComponent == wheels[3]))) { if (brake && accel > 0f) { slip = Mathf.Lerp(slip, 5f, accel * 0.01f); } else if (speed > 1f) { slip = Mathf.Lerp(slip, 1f, 0.002f); } else { slip = Mathf.Lerp(slip, 1f, 0.02f); } wantedRPM = 0f; collider.brakeTorque = carSetting.brakePower; wheelComponent.rotation = w_rotate; } } else { float brakeTorque; if (accel == 0f || NeutralGear) { float num4 = (collider.brakeTorque = 1000f); brakeTorque = num4; } else { float num4 = (collider.brakeTorque = 0f); brakeTorque = num4; } collider.brakeTorque = brakeTorque; slip = ((!(speed > 0f)) ? (slip = Mathf.Lerp(slip, 0.01f, 0.02f)) : ((!(speed > 100f)) ? (slip = Mathf.Lerp(slip, 1.5f, 0.02f)) : (slip = Mathf.Lerp(slip, 1f + Mathf.Abs(steer), 0.02f)))); w_rotate = wheelComponent.rotation; } WheelFrictionCurve val3 = collider.forwardFriction; ((WheelFrictionCurve)(ref val3)).asymptoteValue = 5000f; ((WheelFrictionCurve)(ref val3)).extremumSlip = 2f; ((WheelFrictionCurve)(ref val3)).asymptoteSlip = 20f; ((WheelFrictionCurve)(ref val3)).stiffness = carSetting.stiffness / (slip + slip2); collider.forwardFriction = val3; val3 = collider.sidewaysFriction; ((WheelFrictionCurve)(ref val3)).stiffness = carSetting.stiffness / (slip + slip2); ((WheelFrictionCurve)(ref val3)).extremumSlip = 0.2f + Mathf.Abs(steer); collider.sidewaysFriction = val3; if (shift && currentGear > 1 && speed > 50f && shifmotor && Mathf.Abs(steer) < 0.2f) { if (powerShift == 0f) { shifmotor = false; } powerShift = Mathf.MoveTowards(powerShift, 0f, Time.deltaTime * 10f); carSounds.nitro.volume = Mathf.Lerp(carSounds.nitro.volume, 1f, Time.deltaTime * 10f); if (!carSounds.nitro.isPlaying) { ((Component)carSounds.nitro).GetComponent<AudioSource>().Play(); } curTorque = ((!(powerShift > 0f)) ? carSetting.carPower : carSetting.shiftPower); carParticles.shiftParticle1.emissionRate = Mathf.Lerp(carParticles.shiftParticle1.emissionRate, (float)((powerShift > 0f) ? 50 : 0), Time.deltaTime * 10f); carParticles.shiftParticle2.emissionRate = Mathf.Lerp(carParticles.shiftParticle2.emissionRate, (float)((powerShift > 0f) ? 50 : 0), Time.deltaTime * 10f); } else { if (powerShift > 20f) { shifmotor = true; } carSounds.nitro.volume = Mathf.MoveTowards(carSounds.nitro.volume, 0f, Time.deltaTime * 2f); if (carSounds.nitro.volume == 0f) { carSounds.nitro.Stop(); } powerShift = Mathf.MoveTowards(powerShift, 100f, Time.deltaTime * 5f); curTorque = carSetting.carPower; carParticles.shiftParticle1.emissionRate = Mathf.Lerp(carParticles.shiftParticle1.emissionRate, 0f, Time.deltaTime * 10f); carParticles.shiftParticle2.emissionRate = Mathf.Lerp(carParticles.shiftParticle2.emissionRate, 0f, Time.deltaTime * 10f); } wheelComponent.rotation = Mathf.Repeat(wheelComponent.rotation + Time.deltaTime * collider.rpm * 360f / 60f, 360f); wheelComponent.rotation2 = Mathf.Lerp(wheelComponent.rotation2, collider.steerAngle, 0.1f); wheelComponent.wheel.localRotation = Quaternion.Euler(wheelComponent.rotation, wheelComponent.rotation2, 0f); Vector3 localPosition = wheelComponent.wheel.localPosition; if (collider.GetGroundHit(ref val4)) { if (Object.op_Implicit((Object)(object)carParticles.brakeParticlePerfab)) { if ((Object)(object)Particle[num3] == (Object)null) { Particle[num3] = Object.Instantiate<GameObject>(carParticles.brakeParticlePerfab, wheelComponent.wheel.position, Quaternion.identity); ((Object)Particle[num3]).name = "WheelParticle"; Particle[num3].transform.parent = ((Component)this).transform; Particle[num3].AddComponent<AudioSource>(); Particle[num3].GetComponent<AudioSource>().maxDistance = 50f; Particle[num3].GetComponent<AudioSource>().spatialBlend = 1f; Particle[num3].GetComponent<AudioSource>().dopplerLevel = 5f; Particle[num3].GetComponent<AudioSource>().rolloffMode = (AudioRolloffMode)2; } ParticleSystem component = Particle[num3].GetComponent<ParticleSystem>(); bool flag2 = false; for (int l = 0; l < carSetting.hitGround.Length; l++) { if (((Component)((WheelHit)(ref val4)).collider).CompareTag(carSetting.hitGround[l].tag)) { flag2 = carSetting.hitGround[l].grounded; if ((brake || Mathf.Abs(((WheelHit)(ref val4)).sidewaysSlip) > 0.5f) && speed > 1f) { Particle[num3].GetComponent<AudioSource>().clip = carSetting.hitGround[l].brakeSound; } else if ((Object)(object)Particle[num3].GetComponent<AudioSource>().clip != (Object)(object)carSetting.hitGround[l].groundSound && !Particle[num3].GetComponent<AudioSource>().isPlaying) { Particle[num3].GetComponent<AudioSource>().clip = carSetting.hitGround[l].groundSound; } Particle[num3].GetComponent<ParticleSystem>().startColor = carSetting.hitGround[l].brakeColor; } } if (flag2 && speed > 5f && !brake) { component.enableEmission = true; Particle[num3].GetComponent<AudioSource>().volume = 0.5f; if (!Particle[num3].GetComponent<AudioSource>().isPlaying) { Particle[num3].GetComponent<AudioSource>().Play(); } } else if ((brake || Mathf.Abs(((WheelHit)(ref val4)).sidewaysSlip) > 0.6f) && speed > 1f) { if (accel < 0f || ((brake || Mathf.Abs(((WheelHit)(ref val4)).sidewaysSlip) > 0.6f) && (wheelComponent == wheels[2] || wheelComponent == wheels[3]))) { if (!Particle[num3].GetComponent<AudioSource>().isPlaying) { Particle[num3].GetComponent<AudioSource>().Play(); } component.enableEmission = true; Particle[num3].GetComponent<AudioSource>().volume = 10f; } } else { component.enableEmission = false; Particle[num3].GetComponent<AudioSource>().volume = Mathf.Lerp(Particle[num3].GetComponent<AudioSource>().volume, 0f, Time.deltaTime * 10f); } } localPosition.y -= Vector3.Dot(wheelComponent.wheel.position - ((WheelHit)(ref val4)).point, ((Component)this).transform.TransformDirection(0f, 1f, 0f) / ((Component)this).transform.lossyScale.x) - collider.radius; localPosition.y = Mathf.Clamp(localPosition.y, -10f, wheelComponent.pos_y); flag = flag || wheelComponent.drive; } else { if ((Object)(object)Particle[num3] != (Object)null) { ParticleSystem component2 = Particle[num3].GetComponent<ParticleSystem>(); component2.enableEmission = false; } localPosition.y = wheelComponent.startPos.y - wheelComponent.settings.Distance; myRigidbody.AddForce(Vector3.down * 5000f); } num3++; wheelComponent.wheel.localPosition = localPosition; } if (num2 > 1) { num /= (float)num2; } motorRPM = 0.95f * motorRPM + 0.05f * Mathf.Abs(num * carSetting.gears[currentGear]); if (motorRPM > 5500f) { motorRPM = 5200f; } int num7 = (int)(motorRPM / efficiencyTableStep); if (num7 >= efficiencyTable.Length) { num7 = efficiencyTable.Length - 1; } if (num7 < 0) { num7 = 0; } float num8 = curTorque * carSetting.gears[currentGear] * efficiencyTable[num7]; WheelComponent[] array2 = wheels; foreach (WheelComponent wheelComponent2 in array2) { WheelCollider collider2 = wheelComponent2.collider; if (wheelComponent2.drive) { if (Mathf.Abs(collider2.rpm) > Mathf.Abs(wantedRPM)) { collider2.motorTorque = 0f; } else { float motorTorque = collider2.motorTorque; if (!brake && accel != 0f && !NeutralGear) { if ((speed < carSetting.LimitForwardSpeed && currentGear > 0) || (speed < carSetting.LimitBackwardSpeed && currentGear == 0)) { collider2.motorTorque = motorTorque * 0.9f + num8 * 1f; } else { collider2.motorTorque = 0f; collider2.brakeTorque = 2000f; } } else { collider2.motorTorque = 0f; } } } if (brake || slip2 > 2f) { collider2.steerAngle = Mathf.Lerp(collider2.steerAngle, steer * wheelComponent2.maxSteer, 0.02f); continue; } float num9 = Mathf.Clamp(speed / carSetting.maxSteerAngle, 1f, carSetting.maxSteerAngle); collider2.steerAngle = steer * (wheelComponent2.maxSteer / num9); } Pitch = Mathf.Clamp(1.2f + (motorRPM - carSetting.idleRPM) / (carSetting.shiftUpRPM - carSetting.idleRPM), 1f, 10f); shiftTime = Mathf.MoveTowards(shiftTime, 0f, 0.1f); if (Pitch == 1f) { carSounds.IdleEngine.volume = Mathf.Lerp(carSounds.IdleEngine.volume, 1f, 0.1f); carSounds.LowEngine.volume = Mathf.Lerp(carSounds.LowEngine.volume, 0.5f, 0.1f); carSounds.HighEngine.volume = Mathf.Lerp(carSounds.HighEngine.volume, 0f, 0.1f); } else { carSounds.IdleEngine.volume = Mathf.Lerp(carSounds.IdleEngine.volume, 1.8f - Pitch, 0.1f); if ((Pitch > PitchDelay || accel > 0f) && shiftTime == 0f) { carSounds.LowEngine.volume = Mathf.Lerp(carSounds.LowEngine.volume, 0f, 0.2f); carSounds.HighEngine.volume = Mathf.Lerp(carSounds.HighEngine.volume, 1f, 0.1f); } else { carSounds.LowEngine.volume = Mathf.Lerp(carSounds.LowEngine.volume, 0.5f, 0.1f); carSounds.HighEngine.volume = Mathf.Lerp(carSounds.HighEngine.volume, 0f, 0.2f); } carSounds.HighEngine.pitch = Pitch; carSounds.LowEngine.pitch = Pitch; PitchDelay = Pitch; } if (!isOn) { carSounds.IdleEngine.volume = 0f; carSounds.LowEngine.volume = 0f; carSounds.HighEngine.volume = 0f; } } private void OnDrawGizmos() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_0061: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: 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_00b1: Unknown result type (might be due to invalid IL or missing references) if (carSetting.showNormalGizmos && !Application.isPlaying) { Matrix4x4 matrix = Matrix4x4.TRS(((Component)this).transform.position, ((Component)this).transform.rotation, ((Component)this).transform.lossyScale); Gizmos.matrix = matrix; Gizmos.color = new Color(1f, 0f, 0f, 0.5f); Gizmos.DrawCube(Vector3.up / 1.5f, new Vector3(2.5f, 2f, 6f)); Gizmos.DrawSphere(carSetting.shiftCentre / ((Component)this).transform.lossyScale.x, 0.2f); } } }
VolksScripts.dll
Decompiled a week agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using FistVR; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyCompany("VolksScripts")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("VolksScripts")] [assembly: AssemblyTitle("VolksScripts")] [assembly: AssemblyVersion("1.0.0.0")] namespace VolksScripts; public class AdvanceCloseBoltRelease : FVRInteractiveObject { public enum SlapDirectionAxis { Forward, NegativeForward, Right, NegativeRight, Up, NegativeUp } [Header("Firearm References")] [Tooltip("Parent closed bolt weapon component.")] public ClosedBoltWeapon Weapon; [Tooltip("Transform used as reference for directional slap normal calculation.")] public Transform SlapNormalTransform; [Header("Slap Detection Config")] [Tooltip("Enable velocity and optional angle thresholds for physical controller slaps.")] public bool EnableSlapDetection = true; [Tooltip("Minimum hand velocity required to register as a slap.")] public float MinSlapSpeed = 0.5f; [Tooltip("Require hand movement to align with a specific surface normal vector.")] public bool CheckSlapDirection; [Tooltip("Axis direction representing the inward slap normal.")] public SlapDirectionAxis SlapAxis = SlapDirectionAxis.NegativeForward; [Tooltip("Minimum dot product alignment required if directional check is enabled.")] public float SlapAngleThreshold = 0.2f; [Tooltip("Cooldown period after a slap to prevent double-triggering.")] public float SlapCooldownDuration = 0.2f; [Header("Grab And Click Config")] [Tooltip("Allow grabbing the button directly and pressing a button to release the bolt.")] public bool EnableGrabAndClick = true; private float m_slapCooldownTimer; public void Awake() { ((FVRInteractiveObject)this).Awake(); if ((Object)(object)Weapon == (Object)null) { Weapon = ((Component)this).GetComponentInParent<ClosedBoltWeapon>(); } if ((Object)(object)SlapNormalTransform == (Object)null) { SlapNormalTransform = ((Component)this).transform; } } private void OnDisable() { m_slapCooldownTimer = 0f; } public override void Poke(FVRViveHand hand) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)hand == (Object)null || (Object)(object)Weapon == (Object)null || (Object)(object)Weapon.Bolt == (Object)null || !Weapon.Bolt.IsBoltLocked() || ((Object)(object)((FVRInteractiveObject)Weapon).m_hand != (Object)null && (Object)(object)hand == (Object)(object)((FVRInteractiveObject)Weapon).m_hand) || m_slapCooldownTimer > 0f) { return; } if (EnableSlapDetection) { Vector3 velLinearWorld = hand.Input.VelLinearWorld; if (((Vector3)(ref velLinearWorld)).magnitude < MinSlapSpeed) { return; } if (CheckSlapDirection && (Object)(object)SlapNormalTransform != (Object)null) { Vector3 inwardNormal = GetInwardNormal(); if (Vector3.Dot(((Vector3)(ref velLinearWorld)).normalized, inwardNormal) < SlapAngleThreshold) { return; } } } ReleaseBoltAction(hand); m_slapCooldownTimer = SlapCooldownDuration; } public override void UpdateInteraction(FVRViveHand hand) { ((FVRInteractiveObject)this).UpdateInteraction(hand); if (EnableGrabAndClick && !((Object)(object)Weapon == (Object)null) && !((Object)(object)Weapon.Bolt == (Object)null) && Weapon.Bolt.IsBoltLocked() && !((Object)(object)hand == (Object)null) && IsReleaseInputPressed(hand)) { ReleaseBoltAction(hand); ((FVRInteractiveObject)this).EndInteraction(hand); } } public void FVRUpdate() { ((FVRInteractiveObject)this).FVRUpdate(); if (m_slapCooldownTimer > 0f) { m_slapCooldownTimer -= Time.deltaTime; if (m_slapCooldownTimer < 0f) { m_slapCooldownTimer = 0f; } } } private bool IsReleaseInputPressed(FVRViveHand hand) { if ((Object)(object)hand == (Object)null) { return false; } if (hand.IsInStreamlinedMode) { if (!hand.Input.AXButtonDown && !hand.Input.BYButtonDown) { return hand.Input.TriggerDown; } return true; } if (!hand.Input.TouchpadDown) { return hand.Input.TriggerDown; } return true; } private void ReleaseBoltAction(FVRViveHand hand) { if ((Object)(object)Weapon != (Object)null && (Object)(object)Weapon.Bolt != (Object)null && Weapon.Bolt.IsBoltLocked()) { Weapon.Bolt.ReleaseBolt(); if ((Object)(object)hand != (Object)null && (Object)(object)hand.Buzzer != (Object)null) { hand.Buzz(hand.Buzzer.Buzz_BeginInteraction); } } } private Vector3 GetInwardNormal() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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) if ((Object)(object)SlapNormalTransform == (Object)null) { return Vector3.forward; } return (Vector3)(SlapAxis switch { SlapDirectionAxis.Forward => SlapNormalTransform.forward, SlapDirectionAxis.NegativeForward => -SlapNormalTransform.forward, SlapDirectionAxis.Right => SlapNormalTransform.right, SlapDirectionAxis.NegativeRight => -SlapNormalTransform.right, SlapDirectionAxis.Up => SlapNormalTransform.up, SlapDirectionAxis.NegativeUp => -SlapNormalTransform.up, _ => -SlapNormalTransform.forward, }); } } public class AdvancedAR15Flipper : FVRInteractiveObject { public enum Axis { X, Y, Z } [Header("Transform Config")] [Tooltip("The rotating visual transform of the flip sight or magnifier.")] public Transform Flipsight; [Tooltip("The local rotation axis used for flipping.")] public Axis RotAxis; [Tooltip("The local rotation angle when the sight is folded/closed.")] public float ClosedRot; [Tooltip("The local rotation angle when the sight is deployed/open.")] public float OpenRot = -90f; [Header("Animation Speeds")] [Tooltip("Angular speed in degrees per second when toggled via click/SimpleInteraction.")] public float ClickAnimSpeed = 360f; [Tooltip("Angular speed in degrees per second when flipped via physical hand swipe/slap.")] public float SwipeAnimSpeed = 1200f; [Header("Swipe Interaction Config")] [Tooltip("If true, allows the player to swipe the sight open with their VR hand.")] public bool AllowSwipeOpen = true; [Tooltip("If true, allows the player to swipe the sight closed with their VR hand.")] public bool AllowSwipeClose = true; [Tooltip("Reference transform defining the position and forward swipe direction to deploy/open the sight.")] public Transform SlapPoint_Open; [Tooltip("Reference transform defining the position and forward swipe direction to fold/close the sight.")] public Transform SlapPoint_Close; [Tooltip("Maximum distance from the slap point for a hand swipe to register.")] public float SlapDistance = 0.08f; [Tooltip("Minimum linear hand speed in meters per second required to trigger a swipe.")] public float MinSwipeSpeed = 0.6f; [Tooltip("Directional alignment threshold (dot product) required between hand velocity and slap point forward vector.")] public float SwipeDotThreshold = 0.4f; [Header("Audio Config")] [Tooltip("If true, plays audio events when flipping open or closed.")] public bool UsesSound = true; [Tooltip("Audio event played when the sight deploys/opens.")] public AudioEvent AudEvent_Open; [Tooltip("Audio event played when the sight folds/closes.")] public AudioEvent AudEvent_Close; [Header("Initial State")] [Tooltip("If true, the sight spawns in the open/deployed position.")] public bool StartsOpen; [Header("Debug")] [Tooltip("Outputs interaction and swipe detection logs to the Unity console.")] public bool EnableDebugLogging; private bool m_isOpen; private float m_curRot; private float m_tarRot; private float m_curSpeed; protected override void Awake() { ((FVRInteractiveObject)this).Awake(); m_isOpen = StartsOpen; m_curRot = (m_isOpen ? OpenRot : ClosedRot); m_tarRot = m_curRot; m_curSpeed = ClickAnimSpeed; if ((Object)(object)Flipsight != (Object)null) { ApplyRotation(m_curRot); } } public override void SimpleInteraction(FVRViveHand hand) { ((FVRInteractiveObject)this).SimpleInteraction(hand); if (m_isOpen) { Close(ClickAnimSpeed); } else { Open(ClickAnimSpeed); } if (EnableDebugLogging) { Debug.Log((object)("[AdvancedAR15Flipper] Click interaction toggled state to: " + (m_isOpen ? "Open" : "Closed") + " on " + ((Object)((Component)this).gameObject).name), (Object)(object)this); } } protected override void FVRUpdate() { ((FVRInteractiveObject)this).FVRUpdate(); CheckHandSwipes(); if ((Object)(object)Flipsight != (Object)null && Mathf.Abs(m_tarRot - m_curRot) > 0.01f) { m_curRot = Mathf.MoveTowards(m_curRot, m_tarRot, Time.deltaTime * m_curSpeed); ApplyRotation(m_curRot); } } private void CheckHandSwipes() { if ((Object)(object)GM.CurrentMovementManager == (Object)null || GM.CurrentMovementManager.Hands == null) { return; } for (int i = 0; i < GM.CurrentMovementManager.Hands.Length; i++) { FVRViveHand val = GM.CurrentMovementManager.Hands[i]; if ((Object)(object)val == (Object)null) { continue; } if (!m_isOpen && AllowSwipeOpen && (Object)(object)SlapPoint_Open != (Object)null) { if (EvaluateSwipe(SlapPoint_Open, val)) { Open(SwipeAnimSpeed); val.Buzz(val.Buzzer.Buzz_BeginInteraction); if (EnableDebugLogging) { Debug.Log((object)("[AdvancedAR15Flipper] Physical swipe OPEN detected from " + ((Object)val).name + " on " + ((Object)((Component)this).gameObject).name), (Object)(object)this); } break; } } else if (m_isOpen && AllowSwipeClose && (Object)(object)SlapPoint_Close != (Object)null && EvaluateSwipe(SlapPoint_Close, val)) { Close(SwipeAnimSpeed); val.Buzz(val.Buzzer.Buzz_BeginInteraction); if (EnableDebugLogging) { Debug.Log((object)("[AdvancedAR15Flipper] Physical swipe CLOSE detected from " + ((Object)val).name + " on " + ((Object)((Component)this).gameObject).name), (Object)(object)this); } break; } } } private bool EvaluateSwipe(Transform slapPoint, FVRViveHand hand) { //IL_0001: 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_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_004c: 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) if (Vector3.Distance(slapPoint.position, ((HandInput)(ref hand.Input)).Pos) > SlapDistance) { return false; } if (((Vector3)(ref hand.Input.VelLinearWorld)).magnitude < MinSwipeSpeed) { return false; } Vector3 normalized = ((Vector3)(ref hand.Input.VelLinearWorld)).normalized; return Vector3.Dot(slapPoint.forward, normalized) >= SwipeDotThreshold; } public void Open(float speed) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) if (!m_isOpen || Mathf.Abs(m_tarRot - OpenRot) > 0.01f) { m_isOpen = true; m_tarRot = OpenRot; m_curSpeed = speed; if (UsesSound && AudEvent_Open != null) { SM.PlayCoreSound((FVRPooledAudioType)10, AudEvent_Open, ((Component)this).transform.position); } } } public void Close(float speed) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) if (m_isOpen || Mathf.Abs(m_tarRot - ClosedRot) > 0.01f) { m_isOpen = false; m_tarRot = ClosedRot; m_curSpeed = speed; if (UsesSound && AudEvent_Close != null) { SM.PlayCoreSound((FVRPooledAudioType)10, AudEvent_Close, ((Component)this).transform.position); } } } private void ApplyRotation(float rot) { //IL_0019: 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) //IL_0063: Unknown result type (might be due to invalid IL or missing references) if (RotAxis == Axis.X) { Flipsight.localEulerAngles = new Vector3(rot, 0f, 0f); } else if (RotAxis == Axis.Y) { Flipsight.localEulerAngles = new Vector3(0f, rot, 0f); } else if (RotAxis == Axis.Z) { Flipsight.localEulerAngles = new Vector3(0f, 0f, rot); } } public bool IsOpen() { return m_isOpen; } } public class BoltReleaseChargingHandle : MonoBehaviour { public ClosedBoltWeapon Weapon; public ClosedBoltHandle Handle; public float LaunchSpeed = 5f; [Tooltip("If true, the handle stays at Rear until bolt release is pressed again. If false, it returns forward when pulled back manually.")] public bool HandleReturnsManually; private bool m_wasLocked; private void Start() { if ((Object)(object)Weapon == (Object)null || (Object)(object)Handle == (Object)null) { Debug.LogWarning((object)"[BoltReleaseChargingHandle] Weapon or Handle reference is missing.", (Object)(object)this); ((Behaviour)this).enabled = false; } else { m_wasLocked = Weapon.Bolt.IsBoltLocked(); } } private void Update() { //IL_004e: 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) //IL_0035: Invalid comparison between Unknown and I4 //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Invalid comparison between Unknown and I4 bool flag = Weapon.Bolt.IsBoltLocked(); if (m_wasLocked && !flag && Weapon.HasBoltReleaseButton && (int)Handle.CurPos == 4) { Handle.Speed_Forward = LaunchSpeed; } if ((int)Handle.CurPos == 0 && Handle.Speed_Forward > 0f) { Handle.Speed_Forward = 0f; } if (!HandleReturnsManually && !flag && !((FVRInteractiveObject)Handle).IsHeld && (int)Handle.CurPos == 4 && Handle.Speed_Forward == 0f) { Handle.Speed_Forward = LaunchSpeed; } m_wasLocked = flag; } } public class EmptyMagInGunAudioSet : MonoBehaviour { [Tooltip("Reference to the firearm component. If unassigned, will be retrieved from this GameObject.")] public FVRFireArm FireArm; [Tooltip("Reference to the chamber component. If unassigned, will be retrieved automatically.")] public FVRFireArmChamber Chamber; [Tooltip("If true, having a live unspent round in the chamber prevents the firearm from switching to empty audio.")] public bool ConsiderChamberLiveRound = true; [Tooltip("If true, having no magazine inserted is treated as empty.")] public bool TreatNoMagazineAsEmpty = true; [Tooltip("If true, triggers empty bolt sounds when 1 round or fewer remains in the magazine instead of 0.")] public bool TriggerOnOneRoundRemaining; [Tooltip("Outputs state transitions and audio swap notifications to the Unity console.")] public bool EnableDebugLogging; [Header("Last Round Fired Feedback")] [Tooltip("Audio event played immediately when the final round in the firearm is discharged.")] public AudioEvent LastRoundFiredAudio; [Header("Empty Bolt Audio Overrides")] [Tooltip("Audio event played when releasing the bolt while empty. Falls back to default if unassigned.")] public AudioEvent BoltRelease_Empty; [Tooltip("Audio event played when racking the bolt rearward while empty. Falls back to default if unassigned.")] public AudioEvent BoltSlideBack_Empty; [Tooltip("Audio event played when racking the bolt rearward while held and empty. Falls back to default if unassigned.")] public AudioEvent BoltSlideBackHeld_Empty; [Tooltip("Audio event played when the bolt catches or locks to the rear while empty. Falls back to default if unassigned.")] public AudioEvent BoltSlideBackLocked_Empty; [Tooltip("Audio event played when the bolt slides forward into battery while empty. Falls back to default if unassigned.")] public AudioEvent BoltSlideForward_Empty; [Tooltip("Audio event played when the bolt is guided forward while held and empty. Falls back to default if unassigned.")] public AudioEvent BoltSlideForwardHeld_Empty; private FVRFireArm m_fireArm; private FVRFireArmChamber m_chamber; private FVRFirearmAudioSet m_originalAudioSet; private FVRFirearmAudioSet m_audioSetInstance; private AudioEvent m_defaultBoltRelease; private AudioEvent m_defaultBoltSlideBack; private AudioEvent m_defaultBoltSlideBackHeld; private AudioEvent m_defaultBoltSlideBackLocked; private AudioEvent m_defaultBoltSlideForward; private AudioEvent m_defaultBoltSlideForwardHeld; private bool m_wasEmpty; private bool m_wasChamberFull; private bool m_wasChamberSpent; private bool m_isInitialized; private bool m_hasLoggedInitWarning; private void Awake() { EmptyMagInGunAudioSet[] components = ((Component)this).GetComponents<EmptyMagInGunAudioSet>(); if (components.Length > 1 && (Object)(object)components[0] != (Object)(object)this) { ((Behaviour)this).enabled = false; Object.Destroy((Object)(object)this); } } private void Start() { Initialize(); } private void Initialize() { if (m_isInitialized) { return; } if ((Object)(object)FireArm != (Object)null) { m_fireArm = FireArm; } else { m_fireArm = ((Component)this).GetComponent<FVRFireArm>(); } if ((Object)(object)m_fireArm == (Object)null) { if (!m_hasLoggedInitWarning) { Debug.LogWarning((object)("[EmptyMagInGunAudioSet] No FVRFireArm component found on " + ((Object)((Component)this).gameObject).name + " or its inspector fields."), (Object)(object)this); m_hasLoggedInitWarning = true; } return; } if ((Object)(object)Chamber != (Object)null) { m_chamber = Chamber; } else { m_chamber = ((Component)m_fireArm).GetComponentInChildren<FVRFireArmChamber>(); } if ((Object)(object)m_chamber == (Object)null && !m_hasLoggedInitWarning) { Debug.LogWarning((object)("[EmptyMagInGunAudioSet] No FVRFireArmChamber found on " + ((Object)((Component)this).gameObject).name + ". Chamber-based checks will be skipped."), (Object)(object)this); m_hasLoggedInitWarning = true; } else if ((Object)(object)m_chamber != (Object)null) { m_wasChamberFull = m_chamber.IsFull; m_wasChamberSpent = m_chamber.IsSpent; } if ((Object)(object)m_fireArm.AudioClipSet == (Object)null) { if (!m_hasLoggedInitWarning) { Debug.LogWarning((object)("[EmptyMagInGunAudioSet] FVRFireArm on " + ((Object)((Component)this).gameObject).name + " does not have an AudioClipSet assigned."), (Object)(object)this); m_hasLoggedInitWarning = true; } return; } m_originalAudioSet = m_fireArm.AudioClipSet; m_audioSetInstance = Object.Instantiate<FVRFirearmAudioSet>(m_originalAudioSet); m_fireArm.AudioClipSet = m_audioSetInstance; m_defaultBoltRelease = m_audioSetInstance.BoltRelease; m_defaultBoltSlideBack = m_audioSetInstance.BoltSlideBack; m_defaultBoltSlideBackHeld = m_audioSetInstance.BoltSlideBackHeld; m_defaultBoltSlideBackLocked = m_audioSetInstance.BoltSlideBackLocked; m_defaultBoltSlideForward = m_audioSetInstance.BoltSlideForward; m_defaultBoltSlideForwardHeld = m_audioSetInstance.BoltSlideForwardHeld; m_isInitialized = true; m_wasEmpty = false; ApplyAudioState(isEmpty: false); if (EnableDebugLogging) { Debug.Log((object)("[EmptyMagInGunAudioSet] Successfully initialized on " + ((Object)((Component)this).gameObject).name)); } } private void Update() { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) if (!m_isInitialized) { Initialize(); if (!m_isInitialized) { return; } } if ((Object)(object)m_fireArm == (Object)null || (Object)(object)m_audioSetInstance == (Object)null) { return; } if ((Object)(object)m_chamber != (Object)null) { if (m_wasChamberFull && !m_wasChamberSpent && m_chamber.IsFull && m_chamber.IsSpent) { bool flag = false; if ((Object)(object)m_fireArm.Magazine == (Object)null) { flag = true; } else if (!m_fireArm.Magazine.HasARound()) { flag = true; } if (flag && LastRoundFiredAudio != null) { SM.PlayCoreSound((FVRPooledAudioType)10, LastRoundFiredAudio, ((Component)this).transform.position); if (EnableDebugLogging) { Debug.Log((object)("[EmptyMagInGunAudioSet] Last round fired audio played on: " + ((Object)((Component)this).gameObject).name)); } } } m_wasChamberFull = m_chamber.IsFull; m_wasChamberSpent = m_chamber.IsSpent; } bool flag2 = (Object)(object)m_chamber != (Object)null && m_chamber.IsFull && !m_chamber.IsSpent; bool flag3 = false; if (ConsiderChamberLiveRound && flag2) { flag3 = false; } else if ((Object)(object)m_fireArm.Magazine != (Object)null) { flag3 = ((!TriggerOnOneRoundRemaining) ? (!m_fireArm.Magazine.HasARound()) : (!m_fireArm.Magazine.HasARound() || m_fireArm.Magazine.m_numRounds <= 1)); } else if (TreatNoMagazineAsEmpty) { flag3 = true; } if (flag3 != m_wasEmpty) { m_wasEmpty = flag3; ApplyAudioState(flag3); if (EnableDebugLogging) { Debug.Log((object)("[EmptyMagInGunAudioSet] Empty state changed to " + flag3 + " on " + ((Object)((Component)this).gameObject).name)); } } } private void ApplyAudioState(bool isEmpty) { if (!((Object)(object)m_audioSetInstance == (Object)null)) { if (isEmpty) { m_audioSetInstance.BoltRelease = ((BoltRelease_Empty != null) ? BoltRelease_Empty : m_defaultBoltRelease); m_audioSetInstance.BoltSlideBack = ((BoltSlideBack_Empty != null) ? BoltSlideBack_Empty : m_defaultBoltSlideBack); m_audioSetInstance.BoltSlideBackHeld = ((BoltSlideBackHeld_Empty != null) ? BoltSlideBackHeld_Empty : m_defaultBoltSlideBackHeld); m_audioSetInstance.BoltSlideBackLocked = ((BoltSlideBackLocked_Empty != null) ? BoltSlideBackLocked_Empty : m_defaultBoltSlideBackLocked); m_audioSetInstance.BoltSlideForward = ((BoltSlideForward_Empty != null) ? BoltSlideForward_Empty : m_defaultBoltSlideForward); m_audioSetInstance.BoltSlideForwardHeld = ((BoltSlideForwardHeld_Empty != null) ? BoltSlideForwardHeld_Empty : m_defaultBoltSlideForwardHeld); } else { m_audioSetInstance.BoltRelease = m_defaultBoltRelease; m_audioSetInstance.BoltSlideBack = m_defaultBoltSlideBack; m_audioSetInstance.BoltSlideBackHeld = m_defaultBoltSlideBackHeld; m_audioSetInstance.BoltSlideBackLocked = m_defaultBoltSlideBackLocked; m_audioSetInstance.BoltSlideForward = m_defaultBoltSlideForward; m_audioSetInstance.BoltSlideForwardHeld = m_defaultBoltSlideForwardHeld; } } } private void OnDestroy() { if ((Object)(object)m_fireArm != (Object)null && (Object)(object)m_originalAudioSet != (Object)null && (Object)(object)m_fireArm.AudioClipSet == (Object)(object)m_audioSetInstance) { m_fireArm.AudioClipSet = m_originalAudioSet; } if ((Object)(object)m_audioSetInstance != (Object)null) { Object.Destroy((Object)(object)m_audioSetInstance); } } } public class HandgunExternalSafety : FVRInteractiveObject { [Header("Weapon & Transform Settings")] public Handgun Weapon; public Transform SafetySwitch; [Header("Animation Settings")] public Axis Axis; public InterpStyle InterpStyle; [Header("Positions (Rotation or Translation values)")] public float SafetyOnPosition; public float SafetyOffPosition; public void Awake() { ((FVRInteractiveObject)this).Awake(); UpdateSwitchVisual(); } public override void SimpleInteraction(FVRViveHand hand) { ((FVRInteractiveObject)this).SimpleInteraction(hand); ToggleSafetyState(); } private void ToggleSafetyState() { if ((Object)(object)Weapon != (Object)null) { Weapon.ToggleSafety(); UpdateSwitchVisual(); } } private void UpdateSwitchVisual() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Weapon == (Object)null) && !((Object)(object)SafetySwitch == (Object)null)) { float num = (Weapon.IsSafetyEngaged ? SafetyOnPosition : SafetyOffPosition); ((FVRPhysicalObject)Weapon).SetAnimatedComponent(SafetySwitch, num, InterpStyle, Axis); } } } public class PartRecoilImpulse : MonoBehaviour { public enum ImpulseMode { Rotation, Translation } public enum ImpulseAxis { X, Y, Z } [Serializable] public class RecoilPart { public Transform Piece; public ImpulseMode Mode; public ImpulseAxis Axis; public Vector2 Range = new Vector2(0f, 45f); public float ReturnSpeed = 5f; public float ImpulseStrength = 1f; [NonSerialized] public float CurrentLerp; } [Header("Parts")] public List<RecoilPart> Parts = new List<RecoilPart>(); private FVRFireArm m_firearm; private void Awake() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown GM.CurrentSceneSettings.ShotFiredEvent += new ShotFired(OnShotFired); } private void OnDestroy() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown if ((Object)(object)GM.CurrentSceneSettings != (Object)null) { GM.CurrentSceneSettings.ShotFiredEvent -= new ShotFired(OnShotFired); } } private void Start() { m_firearm = ((Component)this).GetComponentInParent<FVRFireArm>(); if ((Object)(object)m_firearm == (Object)null) { Debug.LogWarning((object)"[PartRecoilImpulse] No FVRFireArm found in parent hierarchy.", (Object)(object)this); } for (int i = 0; i < Parts.Count; i++) { ApplyToPart(Parts[i]); } } private void OnShotFired(FVRFireArm firearm) { if (!((Object)(object)firearm != (Object)(object)m_firearm)) { for (int i = 0; i < Parts.Count; i++) { Parts[i].CurrentLerp = Mathf.Clamp01(Parts[i].ImpulseStrength); ApplyToPart(Parts[i]); } } } private void Update() { for (int i = 0; i < Parts.Count; i++) { RecoilPart recoilPart = Parts[i]; if (recoilPart.CurrentLerp > 0f) { recoilPart.CurrentLerp = Mathf.MoveTowards(recoilPart.CurrentLerp, 0f, Time.deltaTime * recoilPart.ReturnSpeed); ApplyToPart(recoilPart); } } } private void ApplyToPart(RecoilPart part) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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) //IL_0044: 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_0078: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)part.Piece == (Object)null) { return; } float num = Mathf.Lerp(part.Range.x, part.Range.y, part.CurrentLerp); if (part.Mode == ImpulseMode.Rotation) { Vector3 localEulerAngles = part.Piece.localEulerAngles; if (part.Axis == ImpulseAxis.X) { localEulerAngles.x = num; } else if (part.Axis == ImpulseAxis.Y) { localEulerAngles.y = num; } else { localEulerAngles.z = num; } part.Piece.localEulerAngles = localEulerAngles; } else { Vector3 localPosition = part.Piece.localPosition; if (part.Axis == ImpulseAxis.X) { localPosition.x = num; } else if (part.Axis == ImpulseAxis.Y) { localPosition.y = num; } else { localPosition.z = num; } part.Piece.localPosition = localPosition; } } } public class PistolSlideChargingHandle : MonoBehaviour { [Header("Handgun References")] public Handgun Handgun; [Header("Grab Trigger")] [Tooltip("The collider representing the grab area. If left empty, it will search this GameObject.")] public Collider GrabCollider; [Header("Rotating Handle Settings")] public bool HasRotatingPart = true; public Transform RotatingPart; public Vector3 RotatingPartNeutralEulers; public Vector3 RotatingPartLeftEulers; public Vector3 RotatingPartRightEulers; public float RotationSpeed = 10f; private HandgunSlide m_slide; private Vector3 m_currentRotEulers; private FVRViveHand m_touchingHand; private bool m_isGrabbingHandle; private void Awake() { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Handgun == (Object)null) { Handgun = ((Component)this).GetComponentInParent<Handgun>(); } if ((Object)(object)Handgun != (Object)null) { m_slide = Handgun.Slide; } if ((Object)(object)m_slide == (Object)null) { Debug.LogError((object)"PistolSlideChargingHandle: No Handgun Slide could be resolved!"); return; } if ((Object)(object)GrabCollider == (Object)null) { GrabCollider = ((Component)this).GetComponent<Collider>(); } if ((Object)(object)GrabCollider != (Object)null) { GrabCollider.isTrigger = true; } else { Debug.LogWarning((object)"PistolSlideChargingHandle: No GrabCollider assigned or found on this GameObject!"); } if ((Object)(object)RotatingPart != (Object)null) { m_currentRotEulers = RotatingPartNeutralEulers; RotatingPart.localEulerAngles = m_currentRotEulers; } } private void OnTriggerEnter(Collider other) { FVRViveHand component = ((Component)other).GetComponent<FVRViveHand>(); if ((Object)(object)component != (Object)null) { m_touchingHand = component; } } private void OnTriggerExit(Collider other) { FVRViveHand component = ((Component)other).GetComponent<FVRViveHand>(); if ((Object)(object)component != (Object)null && (Object)(object)component == (Object)(object)m_touchingHand) { m_touchingHand = null; } } private void Update() { if (!((Object)(object)m_slide == (Object)null)) { UpdateGrabbingState(); UpdateHandleRotation(); } } private void UpdateGrabbingState() { if (((FVRInteractiveObject)m_slide).IsHeld && (Object)(object)((FVRInteractiveObject)m_slide).m_hand != (Object)null) { if (!m_isGrabbingHandle && (Object)(object)((FVRInteractiveObject)m_slide).m_hand == (Object)(object)m_touchingHand) { m_isGrabbingHandle = true; } } else { m_isGrabbingHandle = false; } } private void UpdateHandleRotation() { //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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) if (HasRotatingPart && !((Object)(object)RotatingPart == (Object)null)) { if (m_isGrabbingHandle && (Object)(object)((FVRInteractiveObject)m_slide).m_hand != (Object)null) { Vector3 val = ((Component)this).transform.position - ((FVRInteractiveObject)m_slide).m_hand.PalmTransform.position; Vector3 val2 = ((!(Vector3.Dot(((Vector3)(ref val)).normalized, ((Component)this).transform.right) > 0f)) ? RotatingPartRightEulers : RotatingPartLeftEulers); m_currentRotEulers = Vector3.MoveTowards(m_currentRotEulers, val2, Time.deltaTime * RotationSpeed * 100f); } else { m_currentRotEulers = Vector3.MoveTowards(m_currentRotEulers, RotatingPartNeutralEulers, Time.deltaTime * RotationSpeed * 100f); } RotatingPart.localEulerAngles = m_currentRotEulers; } } } public class RPMCalculator : MonoBehaviour { [Header("Assign only one bugee here")] public ClosedBolt ClosedBolt; public OpenBoltReceiverBolt OpenBolt; public HandgunSlide HandgunSlide; [Header("Simulation Settings (Don't touch this bugee unless you know how physics in Unity works)")] public float SimStepSize = 0.0005f; public int MaxSimSteps = 100000; [Header("Forward Calculator - Results")] public float Result_RPM; public float Result_CycleTimeMS; public float Result_RearwardTimeMS; public float Result_ForwardTimeMS; [Header("Reverse Calculator - Inputs")] [Tooltip("The RPM you want the weapon to fire at.")] public float Reverse_DesiredRPM = 600f; [Tooltip("What percentage of the cycle the bolt spends travelling rearward. Remainder is the forward (spring) stroke. Typical range: 20 to 50.")] [Range(1f, 99f)] public float Reverse_RearwardSplitPercent = 35f; [Tooltip("The maximum forward speed the spring drives the bolt toward. Pin this to a value that feels right for the weapon, the script will solve SpringStiffness to match.")] public float Reverse_DesiredSpeedForward = 10f; [Header("Reverse Calculator - Results")] public float Reverse_Result_SpeedForward; public float Reverse_Result_SpeedRearward; public float Reverse_Result_SpringStiffness; private float m_zForward; private float m_zRear; private float m_speedRearward; private float m_speedForward; private float m_springStiffness; [ContextMenu("Calculate RPM")] public void Calculate() { if (TryReadFields() && ValidateFields() && SimulateRearward(m_speedRearward, out var rearwardTime) && SimulateForward(m_speedForward, m_springStiffness, out var forwardTime)) { float num = rearwardTime + forwardTime; Result_RearwardTimeMS = rearwardTime * 1000f; Result_ForwardTimeMS = forwardTime * 1000f; Result_CycleTimeMS = num * 1000f; Result_RPM = 60f / num; Debug.Log((object)("[RPMCalculator] RPM: " + Result_RPM.ToString("F0") + " | Cycle: " + Result_CycleTimeMS.ToString("F2") + "ms | Rearward: " + Result_RearwardTimeMS.ToString("F2") + "ms | Forward: " + Result_ForwardTimeMS.ToString("F2") + "ms")); } } [ContextMenu("Reverse Calculate this evil bugee ")] public void ReverseCalculate() { if (!TryReadFields()) { return; } if (Reverse_DesiredRPM <= 0f) { Debug.LogError((object)"[RPMCalculator] Reverse_DesiredRPM must be greater than 0."); return; } if (Reverse_DesiredSpeedForward <= 0f) { Debug.LogError((object)"[RPMCalculator] Reverse_DesiredSpeedForward must be greater than 0."); return; } if (Mathf.Approximately(m_zForward, m_zRear)) { Debug.LogError((object)"[RPMCalculator] Forward and Rear positions are the same. No travel distance to simulate."); return; } float num = 60f / Reverse_DesiredRPM; float num2 = num * (Reverse_RearwardSplitPercent / 100f); float targetForwardTime = num * (1f - Reverse_RearwardSplitPercent / 100f); float reverse_Result_SpeedRearward = 0f - Mathf.Abs(m_zForward - m_zRear) / num2; if (!SolveSpringStiffness(targetForwardTime, Reverse_DesiredSpeedForward, out var result)) { Debug.LogError((object)"[RPMCalculator] Could not solve SpringStiffness. Try increasing Reverse_DesiredSpeedForward or lowering Reverse_DesiredRPM – the bolt may not be physically able to cross the travel distance in the time available."); return; } Reverse_Result_SpeedRearward = reverse_Result_SpeedRearward; Reverse_Result_SpeedForward = Reverse_DesiredSpeedForward; Reverse_Result_SpringStiffness = result; Debug.Log((object)("[RPMCalculator] Reverse Result for " + Reverse_DesiredRPM.ToString("F0") + " RPM: | Speed_Rearward: " + reverse_Result_SpeedRearward.ToString("F4") + " | Speed_Forward: " + Reverse_DesiredSpeedForward.ToString("F4") + " | SpringStiffness: " + result.ToString("F4"))); } private bool SolveSpringStiffness(float targetForwardTime, float speedForward, out float result) { result = 0f; float num = Mathf.Abs(m_zForward - m_zRear) / speedForward; if (targetForwardTime < num) { return false; } float num2 = 0.001f; float num3 = 10000f; for (int i = 0; i < 64; i++) { float num4 = (num2 + num3) * 0.5f; SimulateForward(speedForward, num4, out var forwardTime); if (forwardTime > targetForwardTime) { num2 = num4; } else { num3 = num4; } } result = (num2 + num3) * 0.5f; return true; } private bool SimulateRearward(float speedRearward, out float rearwardTime) { rearwardTime = 0f; float num = m_zForward; int num2 = 0; while (num > m_zRear && num2 < MaxSimSteps) { num += speedRearward * SimStepSize; num = Mathf.Max(num, m_zRear); rearwardTime += SimStepSize; num2++; } if (num2 >= MaxSimSteps) { Debug.LogError((object)"[RPMCalculator] Hit max steps on rearward stroke."); return false; } return true; } private bool SimulateForward(float speedForward, float springStiffness, out float forwardTime) { forwardTime = 0f; float num = m_zRear; float num2 = 0f; int num3 = 0; while (num < m_zForward && num3 < MaxSimSteps) { num2 = Mathf.MoveTowards(num2, speedForward, SimStepSize * springStiffness); num += num2 * SimStepSize; num = Mathf.Min(num, m_zForward); forwardTime += SimStepSize; num3++; } if (num3 >= MaxSimSteps) { forwardTime = float.MaxValue; return false; } return true; } private bool TryReadFields() { //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) int num = 0; if ((Object)(object)ClosedBolt != (Object)null) { num++; } if ((Object)(object)OpenBolt != (Object)null) { num++; } if ((Object)(object)HandgunSlide != (Object)null) { num++; } if (num == 0) { Debug.LogError((object)"[RPMCalculator] No component assigned."); return false; } if (num > 1) { Debug.LogError((object)"[RPMCalculator] More than one component assigned. Only assign one at a time."); return false; } if ((Object)(object)ClosedBolt != (Object)null) { if ((Object)(object)ClosedBolt.Point_Bolt_Forward == (Object)null || (Object)(object)ClosedBolt.Point_Bolt_Rear == (Object)null) { Debug.LogError((object)"[RPMCalculator] ClosedBolt is missing Point_Bolt_Forward or Point_Bolt_Rear."); return false; } m_zForward = ClosedBolt.Point_Bolt_Forward.localPosition.z; m_zRear = ClosedBolt.Point_Bolt_Rear.localPosition.z; m_speedRearward = ClosedBolt.Speed_Rearward; m_speedForward = ClosedBolt.Speed_Forward; m_springStiffness = ClosedBolt.SpringStiffness; } else if ((Object)(object)OpenBolt != (Object)null) { if ((Object)(object)OpenBolt.Point_Bolt_Forward == (Object)null || (Object)(object)OpenBolt.Point_Bolt_Rear == (Object)null) { Debug.LogError((object)"[RPMCalculator] OpenBoltReceiverBolt is missing Point_Bolt_Forward or Point_Bolt_Rear."); return false; } m_zForward = OpenBolt.Point_Bolt_Forward.localPosition.z; m_zRear = OpenBolt.Point_Bolt_Rear.localPosition.z; m_speedRearward = OpenBolt.BoltSpeed_Rearward; m_speedForward = OpenBolt.BoltSpeed_Forward; m_springStiffness = OpenBolt.BoltSpringStiffness; } else { if ((Object)(object)HandgunSlide.Point_Slide_Forward == (Object)null || (Object)(object)HandgunSlide.Point_Slide_Rear == (Object)null) { Debug.LogError((object)"[RPMCalculator] HandgunSlide is missing Point_Slide_Forward or Point_Slide_Rear."); return false; } m_zForward = HandgunSlide.Point_Slide_Forward.localPosition.z; m_zRear = HandgunSlide.Point_Slide_Rear.localPosition.z; m_speedRearward = HandgunSlide.Speed_Rearward; m_speedForward = HandgunSlide.Speed_Forward; m_springStiffness = HandgunSlide.SpringStiffness; } return true; } private bool ValidateFields() { if (Mathf.Approximately(m_zForward, m_zRear)) { Debug.LogError((object)"[RPMCalculator] Forward and Rear positions are the same."); return false; } if (m_speedRearward >= 0f) { Debug.LogError((object)("[RPMCalculator] Rearward speed should be negative. Current value: " + m_speedRearward)); return false; } if (m_speedForward <= 0f) { Debug.LogError((object)("[RPMCalculator] Forward speed must be greater than 0. Current value: " + m_speedForward)); return false; } if (m_springStiffness <= 0f) { Debug.LogError((object)("[RPMCalculator] SpringStiffness must be greater than 0. Current value: " + m_springStiffness)); return false; } return true; } } public class SecondaryMagPos : MonoBehaviour { [Header("References")] public FVRFireArm FireArm; public FVRFireArmReloadTriggerWell TriggerWell; [Header("Mount Override")] public Transform MountPos; public Transform EjectPos; private Transform m_defaultMountPos; private Transform m_defaultEjectPos; private Vector3 m_defaultMountLocalPos; private Quaternion m_defaultMountLocalRot; private Vector3 m_defaultEjectLocalPos; private Quaternion m_defaultEjectLocalRot; private bool m_initialized; private bool m_overrideActive; private FVRFireArmMagazine m_pendingMag; private int m_pendingStableFrames; private const int kStableFramesRequired = 2; private FVRFireArmMagazine m_appliedMag; private void Start() { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)FireArm == (Object)null || (Object)(object)TriggerWell == (Object)null) { ((Behaviour)this).enabled = false; return; } if ((Object)(object)MountPos == (Object)null) { ((Behaviour)this).enabled = false; return; } m_defaultMountPos = FireArm.MagazineMountPos; m_defaultEjectPos = FireArm.MagazineEjectPos; if ((Object)(object)m_defaultMountPos == (Object)null) { ((Behaviour)this).enabled = false; return; } m_defaultMountLocalPos = m_defaultMountPos.localPosition; m_defaultMountLocalRot = m_defaultMountPos.localRotation; if ((Object)(object)m_defaultEjectPos != (Object)null) { m_defaultEjectLocalPos = m_defaultEjectPos.localPosition; m_defaultEjectLocalRot = m_defaultEjectPos.localRotation; } m_initialized = true; m_pendingMag = null; m_pendingStableFrames = 0; m_appliedMag = null; } private void Update() { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) if (!m_initialized) { return; } FVRFireArmMagazine magazine = FireArm.Magazine; if ((Object)(object)magazine == (Object)(object)m_pendingMag) { if (m_pendingStableFrames < 2) { m_pendingStableFrames++; } } else { m_pendingMag = magazine; m_pendingStableFrames = 0; } if (m_pendingStableFrames < 2 || (Object)(object)m_pendingMag == (Object)(object)m_appliedMag) { return; } FireArmMagazineType val = (TriggerWell.UsesTypeOverride ? TriggerWell.TypeOverride : FireArm.MagazineType); if ((Object)(object)m_pendingMag != (Object)null && m_pendingMag.MagazineType == val) { m_overrideActive = true; m_appliedMag = m_pendingMag; return; } if (m_overrideActive) { m_overrideActive = false; RestoreDefaults(); } m_appliedMag = null; } private void LateUpdate() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_007b: Unknown result type (might be due to invalid IL or missing references) if (m_initialized && m_overrideActive) { m_defaultMountPos.position = MountPos.position; m_defaultMountPos.rotation = MountPos.rotation; if ((Object)(object)m_defaultEjectPos != (Object)null && (Object)(object)EjectPos != (Object)null) { m_defaultEjectPos.position = EjectPos.position; m_defaultEjectPos.rotation = EjectPos.rotation; } } } private void RestoreDefaults() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) m_defaultMountPos.localPosition = m_defaultMountLocalPos; m_defaultMountPos.localRotation = m_defaultMountLocalRot; if ((Object)(object)m_defaultEjectPos != (Object)null) { m_defaultEjectPos.localPosition = m_defaultEjectLocalPos; m_defaultEjectPos.localRotation = m_defaultEjectLocalRot; } } private void OnDisable() { if (m_initialized) { RestoreDefaults(); } } private void OnDestroy() { if (m_initialized) { RestoreDefaults(); } } }