using System; using System.Collections; 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 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 DeathHunter { public class DeathHunterGate : FVRInteractiveObject { public ClosedBoltWeapon Firearm; public Collider ReloadWell; public Collider Solid; public Collider MagazineGrab; public float Angle; public float OpenAngle = -78f; private float target; private float handStart; private float angleStart; private FVRFireArmMagazine securedMagazine; public bool IsOpen => Angle <= -60f; private void SetMagazineHandAccess(FVRFireArmMagazine magazine, bool enabled) { if ((Object)(object)magazine == (Object)null) { return; } Collider[] components = ((Component)magazine).GetComponents(); foreach (Collider val in components) { if (val.isTrigger) { val.enabled = enabled; } } } public override void Awake() { ((FVRInteractiveObject)this).Awake(); target = Angle; Apply(); } public override void BeginInteraction(FVRViveHand hand) { ((FVRInteractiveObject)this).BeginInteraction(hand); handStart = HandAngle(hand); angleStart = Angle; } private float HandAngle(FVRViveHand hand) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)this).transform.parent.InverseTransformPoint(((Component)hand).transform.position) - ((Component)this).transform.localPosition; return Mathf.Atan2(val.y, 0f - val.z) * 57.29578f; } public override void UpdateInteraction(FVRViveHand hand) { ((FVRInteractiveObject)this).UpdateInteraction(hand); SetAngle(Mathf.Clamp(angleStart + Mathf.DeltaAngle(handStart, HandAngle(hand)), OpenAngle, 0f)); } public override void EndInteraction(FVRViveHand hand) { ((FVRInteractiveObject)this).EndInteraction(hand); target = ((!(Angle < OpenAngle * 0.45f)) ? 0f : OpenAngle); } public override void SimpleInteraction(FVRViveHand hand) { target = ((!IsOpen) ? OpenAngle : 0f); } public override void FVRUpdate() { ((FVRInteractiveObject)this).FVRUpdate(); if (!((FVRInteractiveObject)this).IsHeld) { Angle = Mathf.MoveTowards(Angle, target, 240f * Time.deltaTime); Apply(); } else { Apply(); } } public void SetAngle(float degrees) { Angle = Mathf.Clamp(degrees, OpenAngle, 0f); target = Angle; Apply(); } public void Apply() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.localRotation = Quaternion.Euler(Angle, 0f, 0f); if ((Object)(object)ReloadWell != (Object)null) { ReloadWell.enabled = IsOpen; } if ((Object)(object)MagazineGrab != (Object)null) { MagazineGrab.enabled = IsOpen; } if ((Object)(object)Firearm != (Object)null) { Firearm.HasMagReleaseButton = IsOpen; if ((Object)(object)securedMagazine != (Object)(object)((FVRFireArm)Firearm).Magazine) { SetMagazineHandAccess(securedMagazine, enabled: true); securedMagazine = ((FVRFireArm)Firearm).Magazine; } if ((Object)(object)securedMagazine != (Object)null) { securedMagazine.IsExtractable = true; SetMagazineHandAccess(securedMagazine, IsOpen); } } } public override void OnDestroy() { SetMagazineHandAccess(securedMagazine, enabled: true); ((FVRInteractiveObject)this).OnDestroy(); } } public class DeathHunterGateAudio : MonoBehaviour { public DeathHunterGate Gate; public AudioEvent OpenSound; public AudioEvent CloseSound; public float MotionHysteresis = 8f; private int direction; private float extreme; private bool initialized; public void ResetMotion(float angle) { direction = 0; extreme = angle; initialized = true; } public AudioEvent Step(float angle) { if (!initialized) { ResetMotion(angle); return null; } if (direction == 0) { if (angle <= extreme - MotionHysteresis) { direction = -1; extreme = angle; return OpenSound; } if (angle >= extreme + MotionHysteresis) { direction = 1; extreme = angle; return CloseSound; } } else if (direction < 0) { extreme = Mathf.Min(extreme, angle); if (angle >= extreme + MotionHysteresis) { direction = 1; extreme = angle; return CloseSound; } } else { extreme = Mathf.Max(extreme, angle); if (angle <= extreme - MotionHysteresis) { direction = -1; extreme = angle; return OpenSound; } } return null; } private void Awake() { if ((Object)(object)Gate != (Object)null) { ResetMotion(Gate.Angle); } } public void UpdateSound() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Gate == (Object)null)) { AudioEvent val = Step(Gate.Angle); if (val != null) { SM.PlayGenericSound(val, ((Component)this).transform.position); } } } private void LateUpdate() { UpdateSound(); } } public class DeathHunterMagazine : FVRFireArmMagazine { public GameObject SourceRoundStack; public void SyncSourceRounds() { if ((Object)(object)SourceRoundStack != (Object)null && SourceRoundStack.activeSelf != base.m_numRounds > 0) { SourceRoundStack.SetActive(base.m_numRounds > 0); } } public override void FVRUpdate() { ((FVRFireArmMagazine)this).FVRUpdate(); SyncSourceRounds(); } public override bool IsInteractable() { if ((Object)(object)base.FireArm != (Object)null) { DeathHunterGate componentInChildren = ((Component)base.FireArm).GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null && !componentInChildren.IsOpen) { return false; } } return ((FVRFireArmMagazine)this).IsInteractable(); } public override void Awake() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected I4, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown FireArmRoundClass[] array = (FireArmRoundClass[])(object)new FireArmRoundClass[base.m_capacity]; FireArmRoundClass defaultRoundClass = AM.GetDefaultRoundClass(base.RoundType); for (int i = 0; i < array.Length; i++) { array[i] = (FireArmRoundClass)(int)defaultRoundClass; } FVRMagazineLoadingPattern val = new FVRMagazineLoadingPattern(); val.Classes = array; base.DefaultLoadingPattern = val; ((FVRFireArmMagazine)this).Awake(); } } public class DeathHunterScope : MonoBehaviour { public ClosedBoltWeapon Firearm; public FVRFireArmAttachmentMount Mount; public const string ScopeID = "ScopeClassic3-12x42mm"; public const float OcularDiameter = 0.034f; public const float FrontDiameter = 0.028f; public const float LensSpacing = 0.2095f; public const int DefaultReticleColorIndex = 8; public float LensLength = 0.2095f; public bool Ready; private IEnumerator Start() { yield return null; FVRObject entry = null; for (int i = 0; i < 300; i++) { if (IM.OD != null && IM.OD.TryGetValue("ScopeClassic3-12x42mm", out entry)) { break; } yield return null; } if ((Object)(object)entry == (Object)null) { Debug.LogError((object)"DEATHHUNTER_SCOPE_FAILED: native optic ID unavailable"); yield break; } AnvilCallback request = ((AnvilAsset)entry).GetGameObjectAsync(); yield return request; try { FVRFireArmAttachment val = null; foreach (FVRFireArmAttachment attachments in Mount.AttachmentsList) { if ((Object)(object)((FVRPhysicalObject)attachments).ObjectWrapper != (Object)null && ((FVRPhysicalObject)attachments).ObjectWrapper.ItemID == "ScopeClassic3-12x42mm") { val = attachments; break; } } if ((Object)(object)val == (Object)null) { GameObject result = request.Result; if ((Object)(object)result == (Object)null) { throw new Exception("Native scope prefab unavailable"); } val = Object.Instantiate(result).GetComponent(); ((Component)val).gameObject.SetActive(true); ((Component)val).transform.position = ((Component)Mount).transform.position; ((Component)val).transform.rotation = ((Component)Mount).transform.rotation; val.AttachToMount(Mount, false); } Configure(val); } catch (Exception ex) { Debug.LogError((object)("DEATHHUNTER_SCOPE_FAILED: " + ex)); } } public void Configure(FVRFireArmAttachment attachment) { //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0103: 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_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0236: 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_0290: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: 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) PIPScopeController componentInChildren = ((Component)attachment).GetComponentInChildren(true); if ((Object)(object)componentInChildren == (Object)null || (Object)(object)componentInChildren.PScope == (Object)null) { throw new Exception("Native PIP controller missing"); } PIPScope pScope = componentInChildren.PScope; componentInChildren.MagnificationValues = new List { 1.25f, 2f, 3f, 4f, 5f, 6f, 7f, 8f, 9f, 10f }; componentInChildren.MagnificationIndex = 0; componentInChildren.MagnificationOverride = -1f; pScope.currentMagnification = componentInChildren.MagnificationValues[0]; if (componentInChildren.ReticleColors != null && componentInChildren.ReticleColors.Count > 8) { componentInChildren.ReticleColorIndex = 8; pScope.reticleIllumination = componentInChildren.ReticleColors[8]; } pScope.maxFOV = 20f; componentInChildren.Components.Clear(); ((Component)attachment).transform.SetParent(((Component)Mount).transform, false); ((Component)attachment).transform.localPosition = Vector3.zero; ((Component)attachment).transform.localRotation = Quaternion.identity; ((Component)attachment).transform.localScale = Vector3.one; Renderer[] componentsInChildren = ((Component)attachment).GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { val.enabled = (Object)(object)val == (Object)(object)pScope.lensRenderer || (Object)(object)val == (Object)(object)pScope.frontLensRenderer; } Vector3 val2 = ((Component)Mount).transform.position - ((Component)pScope.lensRenderer).transform.position; Transform transform = ((Component)attachment).transform; transform.position += val2; pScope.ocularLensDiameter = 0.036f; pScope.frontLensDiameter = 0.042f; pScope.objectiveLensDiameter = 0.042f; ((Component)pScope.lensRenderer).transform.localScale = Vector3.one * (0.034f / pScope.ocularLensDiameter); float num = ((!(LensLength > 0f)) ? 0.2095f : LensLength); if ((Object)(object)pScope.frontLensRenderer != (Object)null) { ((Component)pScope.frontLensRenderer).transform.localScale = Vector3.one * (0.028f / pScope.frontLensDiameter); ((Component)pScope.frontLensRenderer).transform.position = ((Component)Mount).transform.position + ((Component)Mount).transform.forward * num; } pScope.frontLensOffset = num; pScope.cameraOffsetRearLens = num * 0.5f; pScope.cameraOffsetFrontLens = num * 0.5f; componentInChildren.OverrideFireArm = (FVRFireArm)(object)Firearm; componentInChildren.OverrideMuzzle = ((FVRFireArm)Firearm).MuzzlePos; ((FVRFireArmAttachmentInterface)componentInChildren).IsLocked = true; ((FVRFireArmAttachmentInterface)componentInChildren).ForceInteractable = true; Collider[] componentsInChildren2 = ((Component)attachment).GetComponentsInChildren(true); foreach (Collider val3 in componentsInChildren2) { bool enabled = (Object)(object)((Component)val3).GetComponent() != (Object)null || (Object)(object)((Component)val3).GetComponent() != (Object)null || (Object)(object)((Component)val3).GetComponent() != (Object)null; val3.enabled = enabled; } if (Application.isPlaying) { componentInChildren.UpdateScopeParams(); } Ready = true; Debug.Log((object)("DEATHHUNTER_SCOPE_READY: 34 mm ocular, 1.25-10x; firearm=" + ((FVRPhysicalObject)Firearm).ObjectWrapper.ItemID + "; reticleIndex=" + componentInChildren.ReticleColorIndex)); } private void OnDestroy() { if ((Object)(object)Mount == (Object)null) { return; } FVRFireArmAttachment[] array = Mount.AttachmentsList.ToArray(); foreach (FVRFireArmAttachment val in array) { if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)((Component)val).gameObject); } } } } } namespace LocalTest.DeathHunterPrototype { [BepInPlugin("LocalTest.DeathHunterPrototype", "DeathHunterPrototype", "0.1.4")] [BepInProcess("h3vr.exe")] [Description("Built with MeatKit")] [BepInDependency("h3vr.otherloader", "1.3.0")] public class DeathHunterPrototypePlugin : 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(), "LocalTest.DeathHunterPrototype"); OtherLoader.RegisterDirectLoad(BasePath, "LocalTest.DeathHunterPrototype", "", "", "death_hunter", ""); } } }