Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of BlackridgeArmory v1.0.1
BepInEx\plugins\BlackridgeArmory\BlackridgeArmory.dll
Decompiled 2 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using BlackridgeArmory.Assets; using BlackridgeArmory.Config; using BlackridgeArmory.Patches; using BlackridgeArmory.Weapons; using HarmonyLib; using Microsoft.CodeAnalysis; using REPOLib.Modules; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("Autodesk.Fbx")] [assembly: IgnoresAccessChecksTo("Discord.Sdk")] [assembly: IgnoresAccessChecksTo("Domain_Reload")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")] [assembly: IgnoresAccessChecksTo("Klattersynth")] [assembly: IgnoresAccessChecksTo("Photon3Unity3D")] [assembly: IgnoresAccessChecksTo("PhotonChat")] [assembly: IgnoresAccessChecksTo("PhotonRealtime")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")] [assembly: IgnoresAccessChecksTo("PhotonVoice.API")] [assembly: IgnoresAccessChecksTo("PhotonVoice")] [assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")] [assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")] [assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")] [assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Modules.Unity.Addressables")] [assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Modules.UnityLocalization")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization")] [assembly: IgnoresAccessChecksTo("Sirenix.Utilities")] [assembly: IgnoresAccessChecksTo("Unity.Addressables")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.InternalAPIEngineBridge.013")] [assembly: IgnoresAccessChecksTo("Unity.Localization")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.MemoryProfiler")] [assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.ResourceManager")] [assembly: IgnoresAccessChecksTo("Unity.ScriptableBuildPipeline")] [assembly: IgnoresAccessChecksTo("Unity.Splines")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("websocket-sharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("KestrelOrdnance")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright (c) 2026 KestrelOrdnance")] [assembly: AssemblyDescription("Curated high-detail tactical firearms pack for R.E.P.O. featuring the AK-47, M4A1 Carbine, SPAS-12, AWM .338, and Desert Eagle .50.")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1")] [assembly: AssemblyProduct("Blackridge Armory")] [assembly: AssemblyTitle("BlackridgeArmory")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BlackridgeArmory { [BepInPlugin("com.kestrelordnance.blackridgearmory", "Blackridge Armory", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { public const string PluginGuid = "com.kestrelordnance.blackridgearmory"; public const string PluginName = "Blackridge Armory"; public const string PluginVersion = "1.0.1"; private Harmony? _harmony; internal static Plugin Instance { get; private set; } internal static ManualLogSource Log { get; private set; } private void Awake() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; ArmoryConfig.Initialize(((BaseUnityPlugin)this).Config); _harmony = new Harmony("com.kestrelordnance.blackridgearmory"); _harmony.PatchAll(typeof(StatsManagerPatches)); _harmony.PatchAll(typeof(ItemGunPatches)); _harmony.PatchAll(typeof(ItemAttributesPatches)); _harmony.PatchAll(typeof(ShopManagerPatches)); Log.LogInfo((object)string.Format("{0} v{1} initialized (Preset: {2}).", "Blackridge Armory", "1.0.1", ArmoryConfig.Preset.Value)); } private void OnDestroy() { Harmony? harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } } namespace BlackridgeArmory.Weapons { internal sealed class ShellCasingBehaviour : MonoBehaviour { private const int MaxActiveCasings = 36; private static readonly Queue<ShellCasingBehaviour> ActiveCasings = new Queue<ShellCasingBehaviour>(); private Vector3 _velocity; private Vector3 _angularVelocity; private float _lifeRemaining = 3.5f; private int _bounces; private bool _settled; private AudioClip? _clinkClip; private float _clinkVolume; private Vector3 _initialScale; public void Launch(Vector3 initialVelocity, Vector3 spinEuler, AudioClip? clinkClip, float clinkVolume) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) _velocity = initialVelocity; _angularVelocity = spinEuler; _clinkClip = clinkClip; _clinkVolume = clinkVolume; _initialScale = ((Component)this).transform.localScale; _lifeRemaining = 3.5f; _bounces = 0; _settled = false; ActiveCasings.Enqueue(this); while (ActiveCasings.Count > 36) { ShellCasingBehaviour shellCasingBehaviour = ActiveCasings.Dequeue(); if ((Object)(object)shellCasingBehaviour != (Object)null) { Object.Destroy((Object)(object)((Component)shellCasingBehaviour).gameObject); } } } private void Update() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_007e: 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_0089: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: 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_00a8: 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) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) float deltaTime = Time.deltaTime; _lifeRemaining -= deltaTime; if (_lifeRemaining <= 0f) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } if (_lifeRemaining < 0.45f) { float num = Mathf.Clamp01(_lifeRemaining / 0.45f); ((Component)this).transform.localScale = _initialScale * num; } if (_settled) { return; } _velocity += Physics.gravity * deltaTime; Vector3 val = _velocity * deltaTime; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude > 0.0001f) { int num2 = LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()); RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(((Component)this).transform.position, val / magnitude, ref val2, magnitude + 0.015f, num2, (QueryTriggerInteraction)1)) { ((Component)this).transform.position = ((RaycastHit)(ref val2)).point + ((RaycastHit)(ref val2)).normal * 0.012f; _velocity = Vector3.Reflect(_velocity, ((RaycastHit)(ref val2)).normal) * 0.42f; _angularVelocity *= 0.55f; _bounces++; if (_bounces == 1 && (Object)(object)_clinkClip != (Object)null && _clinkVolume > 0.01f) { AudioSource.PlayClipAtPoint(_clinkClip, ((RaycastHit)(ref val2)).point, Mathf.Clamp01(_clinkVolume * 0.35f)); } if (_bounces >= 3 || ((Vector3)(ref _velocity)).sqrMagnitude < 0.08f) { _settled = true; _velocity = Vector3.zero; _angularVelocity = Vector3.zero; } } else { Transform transform = ((Component)this).transform; transform.position += val; } } ((Component)this).transform.Rotate(_angularVelocity * deltaTime, (Space)1); } } internal sealed class SwayStabilizer : MonoBehaviour { public bool IsBlackridgeWeapon; private PhysGrabObject? _physGrab; private Rigidbody? _rb; private float _recoilGraceUntil; private void Awake() { _physGrab = ((Component)this).GetComponent<PhysGrabObject>(); _rb = ((Component)this).GetComponent<Rigidbody>(); } public void NotifyShotFired(float graceSeconds = 0.09f) { _recoilGraceUntil = Mathf.Max(_recoilGraceUntil, Time.time + graceSeconds); } private void FixedUpdate() { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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_00eb: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_physGrab == (Object)null || (Object)(object)_rb == (Object)null || !_physGrab.grabbed || !ArmoryConfig.EnableStrengthSwayStabilizer.Value || (!IsBlackridgeWeapon && !ArmoryConfig.ApplyStabilizerToVanillaGuns.Value) || _physGrab.isRotating || Time.time < _recoilGraceUntil) { return; } float num = Mathf.Clamp01(ArmoryConfig.StabilizerDamping.Value); if (!(num <= 0.001f)) { float num2 = Mathf.Lerp(1f, 0.68f, num); Rigidbody? rb = _rb; rb.angularVelocity *= num2; float num3 = Mathf.Lerp(14f, 4.8f, num); Vector3 angularVelocity = _rb.angularVelocity; if (((Vector3)(ref angularVelocity)).sqrMagnitude > num3 * num3) { Rigidbody? rb2 = _rb; angularVelocity = _rb.angularVelocity; rb2.angularVelocity = ((Vector3)(ref angularVelocity)).normalized * num3; } } } } internal sealed class TacticalFireController : MonoBehaviour { public FireMode FireMode; public float AutoFireInterval = 0.115f; public float BurstShotInterval = 0.075f; public int BurstCount = 3; private ItemGun? _itemGun; private ItemToggle? _itemToggle; private ItemBattery? _itemBattery; private PhysGrabObject? _physGrab; private bool _wasHoldingFire; private float _nextAutoToggleTime; private int _burstShotsRemaining; private float _nextBurstTime; internal bool IsExecutingBurstFollowup { get; private set; } private void Awake() { _itemGun = ((Component)this).GetComponent<ItemGun>(); _itemToggle = ((Component)this).GetComponent<ItemToggle>(); _itemBattery = ((Component)this).GetComponent<ItemBattery>(); _physGrab = ((Component)this).GetComponent<PhysGrabObject>(); } public void NotifyMasterShotFired() { if (FireMode == FireMode.ThreeRoundBurst && !IsExecutingBurstFollowup && SemiFunc.IsMasterClientOrSingleplayer()) { _burstShotsRemaining = Mathf.Max(0, BurstCount - 1); _nextBurstTime = Time.time + Mathf.Max(0.045f, BurstShotInterval); } } private void Update() { if (!((Object)(object)_itemGun == (Object)null) && !((Object)(object)_itemToggle == (Object)null) && !((Object)(object)_itemBattery == (Object)null) && !((Object)(object)_physGrab == (Object)null)) { if (FireMode == FireMode.FullAuto) { UpdateFullAuto(); } else if (FireMode == FireMode.ThreeRoundBurst && _burstShotsRemaining > 0) { UpdateBurstFollowups(); } } } private void UpdateFullAuto() { //IL_009c: 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_00af: Invalid comparison between Unknown and I4 if (!_physGrab.grabbedLocal || _itemToggle.disabled) { _wasHoldingFire = false; } else if (!SemiFunc.InputHold((InputKey)2)) { _wasHoldingFire = false; } else if (!_wasHoldingFire) { _wasHoldingFire = true; _nextAutoToggleTime = Time.time + Mathf.Max(0.09f, AutoFireInterval * 1.25f); } else if (!(Time.time < _nextAutoToggleTime)) { if (_itemBattery.batteryLife <= 0.1f) { _nextAutoToggleTime = Time.time + 0.35f; } else if ((int)_itemGun.stateCurrent == 0 || (int)_itemGun.stateCurrent == 3) { int num = SemiFunc.PhotonViewIDPlayerAvatarLocal(); _itemToggle.ToggleItem(!_itemToggle.toggleState, num); _nextAutoToggleTime = Time.time + Mathf.Max(0.06f, AutoFireInterval); } } } private void UpdateBurstFollowups() { //IL_007c: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMasterClientOrSingleplayer()) { _burstShotsRemaining = 0; } else if (!((Component)this).gameObject.activeInHierarchy || _itemBattery.batteryLife <= 0.1f) { _burstShotsRemaining = 0; } else if (!(Time.time < _nextBurstTime)) { _burstShotsRemaining--; _nextBurstTime = Time.time + Mathf.Max(0.045f, BurstShotInterval); IsExecutingBurstFollowup = true; try { _itemGun.stateCurrent = (State)0; _itemGun.stateTimer = 0f; _itemGun.Shoot(); } finally { IsExecutingBurstFollowup = false; } } } } internal sealed class TacticalVisualEffects : MonoBehaviour { public string WeaponId = string.Empty; public ActionAnimationType ActionAnimation; public float ActionRecoilDistance = 0.06f; public string CasingMeshFile = "casing_rifle.brmesh"; public string ActionSfxFile = string.Empty; public float CasingScale = 1f; public Transform? ActionTransform; public Transform? EjectionPortTransform; private Vector3 _actionRestPos; private Quaternion _actionRestRot; private bool _restCaptured; private float _animTime = -1f; private float _animDuration = 0.12f; private bool _actionSfxPlayed; private bool _casingEjected; private float _lastTriggerTime = -10f; private AudioClip? _actionClip; private AudioClip? _clinkClip; private SwayStabilizer? _stabilizer; private void Awake() { CaptureRestPose(); _stabilizer = ((Component)this).GetComponent<SwayStabilizer>(); if (!string.IsNullOrEmpty(ActionSfxFile)) { _actionClip = AudioLoader.LoadWav(ActionSfxFile); } _clinkClip = AudioLoader.LoadWav("sfx_shell_clink.wav"); } private void CaptureRestPose() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0034: Unknown result type (might be due to invalid IL or missing references) if (!_restCaptured && !((Object)(object)ActionTransform == (Object)null)) { _actionRestPos = ActionTransform.localPosition; _actionRestRot = ActionTransform.localRotation; _restCaptured = true; } } public void OnShotFired() { if (!(Time.time - _lastTriggerTime < 0.03f)) { _lastTriggerTime = Time.time; CaptureRestPose(); _stabilizer?.NotifyShotFired(); _animTime = 0f; _actionSfxPlayed = false; _casingEjected = false; switch (ActionAnimation) { case ActionAnimationType.ReciprocatingSlide: _animDuration = 0.105f; EjectShellCasing(); _casingEjected = true; break; case ActionAnimationType.PumpForend: _animDuration = 0.44f; break; case ActionAnimationType.BoltCycle: _animDuration = 0.8f; break; } } } private void Update() { //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) if (_animTime < 0f) { return; } _animTime += Time.deltaTime; if (!ArmoryConfig.EnableAnimatedActions.Value || (Object)(object)ActionTransform == (Object)null || !_restCaptured) { if (!_casingEjected && _animTime >= _animDuration * 0.45f) { EjectShellCasing(); _casingEjected = true; } if (!_actionSfxPlayed && (Object)(object)_actionClip != (Object)null && _animTime >= 0.15f) { PlayActionSound(); _actionSfxPlayed = true; } if (_animTime >= _animDuration) { _animTime = -1f; } return; } switch (ActionAnimation) { case ActionAnimationType.ReciprocatingSlide: UpdateReciprocatingSlide(); break; case ActionAnimationType.PumpForend: UpdatePumpForend(); break; case ActionAnimationType.BoltCycle: UpdateBoltCycle(); break; } if (_animTime >= _animDuration) { ActionTransform.localPosition = _actionRestPos; ActionTransform.localRotation = _actionRestRot; _animTime = -1f; } } private void UpdateReciprocatingSlide() { //IL_0057: 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_0074: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp01(_animTime / _animDuration); float num2 = ((num < 0.32f) ? Mathf.SmoothStep(0f, 1f, num / 0.32f) : Mathf.SmoothStep(1f, 0f, (num - 0.32f) / 0.68f)); ActionTransform.localPosition = _actionRestPos + new Vector3(0f, 0f, (0f - ActionRecoilDistance) * num2); } private void UpdatePumpForend() { //IL_008f: 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_00ac: Unknown result type (might be due to invalid IL or missing references) if (_animTime < 0.13f) { return; } if (!_actionSfxPlayed) { PlayActionSound(); _actionSfxPlayed = true; } float num = _animTime - 0.13f; float num2; if (num < 0.15f) { num2 = Mathf.SmoothStep(0f, 1f, num / 0.15f); } else { if (!_casingEjected) { EjectShellCasing(); _casingEjected = true; } num2 = Mathf.SmoothStep(1f, 0f, Mathf.Clamp01((num - 0.15f) / 0.16f)); } ActionTransform.localPosition = _actionRestPos + new Vector3(0f, 0f, (0f - ActionRecoilDistance) * num2); } private void UpdateBoltCycle() { //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) if (_animTime < 0.22f) { return; } if (!_actionSfxPlayed) { PlayActionSound(); _actionSfxPlayed = true; } float num = _animTime - 0.22f; float num2 = 0f; float num3 = 0f; if (num < 0.12f) { num2 = Mathf.SmoothStep(0f, 58f, num / 0.12f); } else if (num < 0.28f) { num2 = 58f; num3 = Mathf.SmoothStep(0f, 1f, (num - 0.12f) / 0.16f); } else if (num < 0.44f) { if (!_casingEjected) { EjectShellCasing(); _casingEjected = true; } num2 = 58f; num3 = Mathf.SmoothStep(1f, 0f, (num - 0.28f) / 0.16f); } else { num2 = Mathf.SmoothStep(58f, 0f, Mathf.Clamp01((num - 0.44f) / 0.14f)); } ActionTransform.localPosition = _actionRestPos + new Vector3(0f, 0f, (0f - ActionRecoilDistance) * num3); ActionTransform.localRotation = _actionRestRot * Quaternion.Euler(0f, 0f, num2); } private void PlayActionSound() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_actionClip == (Object)null)) { float num = Mathf.Clamp01(ArmoryConfig.WeaponAudioVolume.Value * 0.72f); AudioSource.PlayClipAtPoint(_actionClip, ((Component)this).transform.position, num); } } private void EjectShellCasing() { //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_003e: 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) //IL_0054: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_0088: 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_00a4: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) if (!ArmoryConfig.EnableShellEjection.Value || (Object)(object)EjectionPortTransform == (Object)null) { return; } try { LoadedMesh loadedMesh = MeshLoader.Load(CasingMeshFile); GameObject val = new GameObject("BR_ShellCasing"); val.transform.position = EjectionPortTransform.position; val.transform.rotation = EjectionPortTransform.rotation * Quaternion.Euler(0f, 90f, 0f); val.transform.localScale = Vector3.one * CasingScale; val.AddComponent<MeshFilter>().sharedMesh = loadedMesh.Mesh; ((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterials = MaterialLibrary.ResolveMaterials(loadedMesh.MaterialIds); Vector3 initialVelocity = EjectionPortTransform.right * Random.Range(1.6f, 2.5f) + EjectionPortTransform.up * Random.Range(1.1f, 1.85f) - EjectionPortTransform.forward * Random.Range(0.25f, 0.75f); Vector3 spinEuler = default(Vector3); ((Vector3)(ref spinEuler))..ctor(Random.Range(-640f, 640f), Random.Range(-520f, 520f), Random.Range(-720f, 720f)); val.AddComponent<ShellCasingBehaviour>().Launch(initialVelocity, spinEuler, _clinkClip, ArmoryConfig.WeaponAudioVolume.Value); } catch (Exception ex) { Plugin.Log.LogDebug((object)("Shell casing spawn skipped: " + ex.Message)); } } } internal static class WeaponCatalog { public static readonly IReadOnlyList<WeaponDefinition> All = new List<WeaponDefinition> { new WeaponDefinition { Id = "deagle", ConfigSectionName = "DesertEagle50", PrefabName = "Item Gun Blackridge DesertEagle50", DisplayName = "Desert Eagle .50", Description = "Heavy .50 AE stainless hand cannon. Compact, affordable, and hits hard enough to stagger charging creatures.", BodyMeshFile = "deagle_body.brmesh", ActionMeshFile = "deagle_action.brmesh", CasingMeshFile = "casing_rifle.brmesh", ShootSfxFile = "sfx_deagle_shot.wav", ActionSfxFile = null, FireMode = FireMode.SemiAuto, ActionAnimation = ActionAnimationType.ReciprocatingSlide, ShopVolume = (itemVolume)0, EmojiFallback = (emojiIcon)23, PriceMultiplier = 0.95f, MaxInRun = 3, MaxAmountInShop = 1, EnemyDamage = 115, PlayerDamage = 85, PelletsPerShot = 1, ShotsPerCharge = 10, ShootCooldown = 0.28f, BurstShotInterval = 0f, Spread = 0.55f, Range = 42f, RecoilForce = 6.2f, CameraShake = 1.25f, SoundAlertRadius = 24f, EnemyStunTime = 2f, EnemyStunType = (EnemyType)2, EnemyImpact = (BreakImpact)2, EnemyHitForce = 18f, EnemyHitTorque = 6f, PhysImpact = (BreakImpact)2, PhysHitForce = 12f, VisualScale = 1.22f, Mass = 1.6f, MuzzleLocalPos = new Vector3(0f, 0.042f, 0.2f), EjectionLocalPos = new Vector3(0.02f, 0.046f, 0.015f), BatteryLocalPos = new Vector3(0f, 0.088f, -0.025f), VisualPivotOffset = new Vector3(0f, -0.012f, -0.035f), ActionRecoilDistance = 0.052f, TracerColor = new Color(1f, 0.82f, 0.35f, 1f), MuzzleLightColor = new Color(1f, 0.72f, 0.28f, 1f), MuzzleLightIntensity = 3.2f, CasingScale = 0.95f }, new WeaponDefinition { Id = "ak47", ConfigSectionName = "AK47", PrefabName = "Item Gun Blackridge AK47", DisplayName = "AK-47", Description = "Full-auto 7.62mm assault rifle with lacquered wood furniture. Hold trigger for sustained automatic fire.", BodyMeshFile = "ak47_body.brmesh", ActionMeshFile = "ak47_action.brmesh", CasingMeshFile = "casing_rifle.brmesh", ShootSfxFile = "sfx_ak47_shot.wav", ActionSfxFile = null, FireMode = FireMode.FullAuto, ActionAnimation = ActionAnimationType.ReciprocatingSlide, ShopVolume = (itemVolume)1, EmojiFallback = (emojiIcon)23, PriceMultiplier = 1.55f, MaxInRun = 3, MaxAmountInShop = 1, EnemyDamage = 55, PlayerDamage = 45, PelletsPerShot = 1, ShotsPerCharge = 28, ShootCooldown = 0.115f, BurstShotInterval = 0f, Spread = 1.15f, Range = 58f, RecoilForce = 4.2f, CameraShake = 0.9f, SoundAlertRadius = 28f, EnemyStunTime = 0.95f, EnemyStunType = (EnemyType)1, EnemyImpact = (BreakImpact)2, EnemyHitForce = 12f, EnemyHitTorque = 4f, PhysImpact = (BreakImpact)1, PhysHitForce = 9f, VisualScale = 1.12f, Mass = 2.4f, MuzzleLocalPos = new Vector3(0f, 0.03f, 0.452f), EjectionLocalPos = new Vector3(0.024f, 0.035f, 0.055f), BatteryLocalPos = new Vector3(0f, 0.088f, -0.025f), VisualPivotOffset = new Vector3(0f, -0.012f, -0.05f), ActionRecoilDistance = 0.068f, TracerColor = new Color(1f, 0.68f, 0.24f, 1f), MuzzleLightColor = new Color(1f, 0.58f, 0.18f, 1f), MuzzleLightIntensity = 3f, CasingScale = 1.15f }, new WeaponDefinition { Id = "m4a1", ConfigSectionName = "M4A1", PrefabName = "Item Gun Blackridge M4A1", DisplayName = "M4A1 Carbine", Description = "Precision 3-round burst tactical carbine fitted with holographic red-dot sight and vertical foregrip.", BodyMeshFile = "m4a1_body.brmesh", ActionMeshFile = "m4a1_action.brmesh", CasingMeshFile = "casing_rifle.brmesh", ShootSfxFile = "sfx_m4a1_shot.wav", ActionSfxFile = null, FireMode = FireMode.ThreeRoundBurst, ActionAnimation = ActionAnimationType.ReciprocatingSlide, ShopVolume = (itemVolume)1, EmojiFallback = (emojiIcon)23, PriceMultiplier = 1.7f, MaxInRun = 3, MaxAmountInShop = 1, EnemyDamage = 60, PlayerDamage = 48, PelletsPerShot = 1, ShotsPerCharge = 24, ShootCooldown = 0.36f, BurstShotInterval = 0.075f, Spread = 0.4f, Range = 68f, RecoilForce = 3.4f, CameraShake = 0.78f, SoundAlertRadius = 24f, EnemyStunTime = 1.35f, EnemyStunType = (EnemyType)2, EnemyImpact = (BreakImpact)2, EnemyHitForce = 11f, EnemyHitTorque = 3.5f, PhysImpact = (BreakImpact)1, PhysHitForce = 8.5f, VisualScale = 1.12f, Mass = 2.2f, MuzzleLocalPos = new Vector3(0f, 0.032f, 0.43f), EjectionLocalPos = new Vector3(0.024f, 0.035f, 0.064f), BatteryLocalPos = new Vector3(0f, 0.125f, -0.025f), VisualPivotOffset = new Vector3(0f, -0.014f, -0.045f), ActionRecoilDistance = 0.048f, TracerColor = new Color(1f, 0.9f, 0.62f, 1f), MuzzleLightColor = new Color(1f, 0.85f, 0.55f, 1f), MuzzleLightIntensity = 2.8f, CasingScale = 1.05f }, new WeaponDefinition { Id = "spas12", ConfigSectionName = "SPAS12", PrefabName = "Item Gun Blackridge SPAS12", DisplayName = "SPAS-12", Description = "Heavy 12-gauge combat shotgun firing 8 tight buckshot pellets with brutal close-quarters knockback.", BodyMeshFile = "spas12_body.brmesh", ActionMeshFile = "spas12_action.brmesh", CasingMeshFile = "casing_shotgun.brmesh", ShootSfxFile = "sfx_spas12_shot.wav", ActionSfxFile = "sfx_spas12_pump.wav", FireMode = FireMode.PumpAction, ActionAnimation = ActionAnimationType.PumpForend, ShopVolume = (itemVolume)1, EmojiFallback = (emojiIcon)24, PriceMultiplier = 2.15f, MaxInRun = 2, MaxAmountInShop = 1, EnemyDamage = 42, PlayerDamage = 26, PelletsPerShot = 8, ShotsPerCharge = 7, ShootCooldown = 0.64f, BurstShotInterval = 0f, Spread = 5.2f, Range = 24f, RecoilForce = 10.5f, CameraShake = 1.85f, SoundAlertRadius = 34f, EnemyStunTime = 3.2f, EnemyStunType = (EnemyType)3, EnemyImpact = (BreakImpact)3, EnemyHitForce = 28f, EnemyHitTorque = 10f, PhysImpact = (BreakImpact)3, PhysHitForce = 20f, VisualScale = 1.1f, Mass = 2.8f, MuzzleLocalPos = new Vector3(0f, 0.037f, 0.59f), EjectionLocalPos = new Vector3(0.025f, 0.03f, 0.078f), BatteryLocalPos = new Vector3(0f, 0.115f, 0.02f), VisualPivotOffset = new Vector3(0f, -0.015f, -0.11f), ActionRecoilDistance = 0.085f, TracerColor = new Color(1f, 0.45f, 0.14f, 1f), MuzzleLightColor = new Color(1f, 0.48f, 0.12f, 1f), MuzzleLightIntensity = 4.2f, CasingScale = 1.15f }, new WeaponDefinition { Id = "awm", ConfigSectionName = "AWM338", PrefabName = "Item Gun Blackridge AWM338", DisplayName = "AWM .338", Description = "Bolt-action anti-materiel sniper rifle. Massive armor-piercing rounds capable of dropping heavy creatures at long range.", BodyMeshFile = "awm_body.brmesh", ActionMeshFile = "awm_action.brmesh", CasingMeshFile = "casing_rifle.brmesh", ShootSfxFile = "sfx_awm_shot.wav", ActionSfxFile = "sfx_awm_bolt.wav", FireMode = FireMode.BoltAction, ActionAnimation = ActionAnimationType.BoltCycle, ShopVolume = (itemVolume)2, EmojiFallback = (emojiIcon)24, PriceMultiplier = 2.55f, MaxInRun = 2, MaxAmountInShop = 1, EnemyDamage = 420, PlayerDamage = 150, PelletsPerShot = 1, ShotsPerCharge = 5, ShootCooldown = 1.35f, BurstShotInterval = 0f, Spread = 0.08f, Range = 115f, RecoilForce = 12f, CameraShake = 2.1f, SoundAlertRadius = 42f, EnemyStunTime = 3.6f, EnemyStunType = (EnemyType)4, EnemyImpact = (BreakImpact)3, EnemyHitForce = 38f, EnemyHitTorque = 14f, PhysImpact = (BreakImpact)3, PhysHitForce = 28f, VisualScale = 1.08f, Mass = 3.2f, MuzzleLocalPos = new Vector3(0f, 0.034f, 0.576f), EjectionLocalPos = new Vector3(0.025f, 0.038f, 0.05f), BatteryLocalPos = new Vector3(0f, 0.082f, -0.155f), VisualPivotOffset = new Vector3(0f, -0.018f, -0.085f), ActionRecoilDistance = 0.085f, TracerColor = new Color(0.55f, 0.94f, 1f, 1f), MuzzleLightColor = new Color(0.95f, 0.88f, 0.65f, 1f), MuzzleLightIntensity = 4.6f, CasingScale = 1.45f } }; private static readonly Dictionary<string, WeaponDefinition> ByPrefabName = BuildLookup(); private static Dictionary<string, WeaponDefinition> BuildLookup() { Dictionary<string, WeaponDefinition> dictionary = new Dictionary<string, WeaponDefinition>(); foreach (WeaponDefinition item in All) { dictionary[item.PrefabName] = item; } return dictionary; } public static bool TryGetByPrefabName(string prefabName, out WeaponDefinition definition) { return ByPrefabName.TryGetValue(prefabName, out definition); } } internal enum FireMode { SemiAuto, FullAuto, ThreeRoundBurst, PumpAction, BoltAction } internal enum ActionAnimationType { ReciprocatingSlide, PumpForend, BoltCycle } internal sealed class WeaponDefinition { public string Id { get; set; } = string.Empty; public string ConfigSectionName { get; set; } = string.Empty; public string PrefabName { get; set; } = string.Empty; public string DisplayName { get; set; } = string.Empty; public string Description { get; set; } = string.Empty; public string BodyMeshFile { get; set; } = string.Empty; public string ActionMeshFile { get; set; } = string.Empty; public string CasingMeshFile { get; set; } = string.Empty; public string ShootSfxFile { get; set; } = string.Empty; public string? ActionSfxFile { get; set; } public FireMode FireMode { get; set; } public ActionAnimationType ActionAnimation { get; set; } public itemVolume ShopVolume { get; set; } public emojiIcon EmojiFallback { get; set; } public float PriceMultiplier { get; set; } public int MaxInRun { get; set; } public int MaxAmountInShop { get; set; } public int EnemyDamage { get; set; } public int PlayerDamage { get; set; } public int PelletsPerShot { get; set; } public int ShotsPerCharge { get; set; } public float ShootCooldown { get; set; } public float BurstShotInterval { get; set; } public float Spread { get; set; } public float Range { get; set; } public float RecoilForce { get; set; } public float CameraShake { get; set; } public float SoundAlertRadius { get; set; } public float EnemyStunTime { get; set; } public EnemyType EnemyStunType { get; set; } public BreakImpact EnemyImpact { get; set; } public float EnemyHitForce { get; set; } public float EnemyHitTorque { get; set; } public BreakImpact PhysImpact { get; set; } public float PhysHitForce { get; set; } public float VisualScale { get; set; } public float Mass { get; set; } public Vector3 MuzzleLocalPos { get; set; } public Vector3 EjectionLocalPos { get; set; } public Vector3 BatteryLocalPos { get; set; } public Vector3 VisualPivotOffset { get; set; } public float ActionRecoilDistance { get; set; } public Color TracerColor { get; set; } public Color MuzzleLightColor { get; set; } public float MuzzleLightIntensity { get; set; } public float CasingScale { get; set; } } internal static class WeaponPrefabFactory { private static bool _initialized; private static GameObject? _prefabVault; private static readonly List<Item> _registeredItems = new List<Item>(); public static IReadOnlyList<Item> RegisteredItems => _registeredItems; public static void TryRegisterAll(StatsManager? statsManager) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown if (_initialized || (Object)(object)statsManager == (Object)null || statsManager.itemDictionary == null || statsManager.itemDictionary.Count == 0) { return; } Item val = FindDonorGunItem(statsManager); if ((Object)(object)val == (Object)null || val.prefab == null || (Object)(object)((PrefabRef<GameObject>)(object)val.prefab).Prefab == (Object)null) { Plugin.Log.LogWarning((object)"Could not locate a vanilla ItemGun donor prefab yet; will retry on next StatsManager init."); return; } _initialized = true; GameObject prefab = ((PrefabRef<GameObject>)(object)val.prefab).Prefab; Material val2 = FindOpaqueDonorMaterial(prefab); MaterialLibrary.Initialize(val2); _prefabVault = new GameObject("BlackridgeArmory_PrefabVault"); _prefabVault.SetActive(false); Object.DontDestroyOnLoad((Object)(object)_prefabVault); float num = (((Object)(object)val.value != (Object)null && val.value.valueMin > 0.01f) ? val.value.valueMin : 4.5f); float num2 = (((Object)(object)val.value != (Object)null && val.value.valueMax > 0.01f) ? val.value.valueMax : 5f); ManualLogSource log = Plugin.Log; object[] obj = new object[4] { ((Object)val).name, num, num2, null }; object obj2; if (val2 == null) { obj2 = null; } else { Shader shader = val2.shader; obj2 = ((shader != null) ? ((Object)shader).name : null); } if (obj2 == null) { obj2 = "fallback"; } obj[3] = obj2; log.LogInfo((object)string.Format("Using vanilla donor '{0}' (base value {1:0.##}-{2:0.##}, shader '{3}').", obj)); AudioClip dryFireClip = AudioLoader.LoadWav("sfx_dry_fire.wav"); int num3 = 0; foreach (WeaponDefinition item in WeaponCatalog.All) { WeaponConfigEntries weapon = ArmoryConfig.GetWeapon(item.Id); if (!weapon.Enabled.Value) { Plugin.Log.LogInfo((object)("Skipping disabled weapon: " + item.DisplayName)); continue; } try { Item val3 = BuildAndRegisterWeapon(item, weapon, val, prefab, num, num2, dryFireClip); if ((Object)(object)val3 != (Object)null) { _registeredItems.Add(val3); num3++; } } catch (Exception arg) { Plugin.Log.LogError((object)$"Failed to construct weapon '{item.DisplayName}': {arg}"); } } Plugin.Log.LogInfo((object)$"Blackridge Armory registered {num3}/{WeaponCatalog.All.Count} tactical firearms."); } private static Item? BuildAndRegisterWeapon(WeaponDefinition def, WeaponConfigEntries cfg, Item donorItem, GameObject donorPrefab, float baseValueMin, float baseValueMax, AudioClip? dryFireClip) { //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Expected O, but got Unknown //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Expected O, but got Unknown //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Expected O, but got Unknown //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Expected O, but got Unknown //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Expected O, but got Unknown //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_041c: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_04c8: Unknown result type (might be due to invalid IL or missing references) //IL_04d3: Unknown result type (might be due to invalid IL or missing references) //IL_04d8: Unknown result type (might be due to invalid IL or missing references) //IL_04db: Unknown result type (might be due to invalid IL or missing references) //IL_04e8: Unknown result type (might be due to invalid IL or missing references) //IL_04f5: Unknown result type (might be due to invalid IL or missing references) //IL_07e0: Unknown result type (might be due to invalid IL or missing references) //IL_07e8: Unknown result type (might be due to invalid IL or missing references) //IL_07ed: Unknown result type (might be due to invalid IL or missing references) //IL_07f5: Unknown result type (might be due to invalid IL or missing references) //IL_07fa: Unknown result type (might be due to invalid IL or missing references) //IL_08c1: Unknown result type (might be due to invalid IL or missing references) //IL_08c8: Unknown result type (might be due to invalid IL or missing references) //IL_08cd: Unknown result type (might be due to invalid IL or missing references) //IL_090f: Unknown result type (might be due to invalid IL or missing references) //IL_0914: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate<GameObject>(donorPrefab, _prefabVault.transform); ((Object)val).name = def.PrefabName; ItemGun component = val.GetComponent<ItemGun>(); ItemAttributes component2 = val.GetComponent<ItemAttributes>(); PhysGrabObject component3 = val.GetComponent<PhysGrabObject>(); ItemBattery component4 = val.GetComponent<ItemBattery>(); ItemEquippable component5 = val.GetComponent<ItemEquippable>(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null || (Object)(object)component3 == (Object)null) { Plugin.Log.LogError((object)("Donor prefab '" + ((Object)donorPrefab).name + "' is missing required components for '" + def.DisplayName + "'.")); Object.DestroyImmediate((Object)(object)val); return null; } Quaternion val2 = (((Object)(object)component.gunMuzzle != (Object)null) ? (Quaternion.Inverse(val.transform.rotation) * component.gunMuzzle.rotation) : Quaternion.identity); Vector3 val3 = ComputeVanillaVisualCenter(val, component4); Collider val4 = FindPrimaryNonTriggerCollider(val); int layer = (((Object)(object)val4 != (Object)null) ? ((Component)val4).gameObject.layer : val.layer); string tag = (((Object)(object)val4 != (Object)null) ? ((Component)val4).gameObject.tag : val.tag); PhysicsMaterial val5 = (((Object)(object)val4 != (Object)null) ? val4.sharedMaterial : null); HideLegacyVisuals(val, component4); ClearLegacyNonTriggerColliders(val); GameObject val6 = new GameObject("BlackridgeVisualRoot"); val6.transform.SetParent(val.transform, false); val6.transform.localPosition = val3 + val2 * (def.VisualPivotOffset * def.VisualScale); val6.transform.localRotation = val2; val6.transform.localScale = Vector3.one * def.VisualScale; val6.layer = layer; LoadedMesh loadedMesh = MeshLoader.Load(def.BodyMeshFile); GameObject val7 = new GameObject("BodyMesh"); val7.transform.SetParent(val6.transform, false); val7.layer = layer; val7.AddComponent<MeshFilter>().sharedMesh = loadedMesh.Mesh; ((Renderer)val7.AddComponent<MeshRenderer>()).sharedMaterials = MaterialLibrary.ResolveMaterials(loadedMesh.MaterialIds); LoadedMesh loadedMesh2 = MeshLoader.Load(def.ActionMeshFile); GameObject val8 = new GameObject("ActionMesh"); val8.transform.SetParent(val6.transform, false); val8.layer = layer; val8.AddComponent<MeshFilter>().sharedMesh = loadedMesh2.Mesh; ((Renderer)val8.AddComponent<MeshRenderer>()).sharedMaterials = MaterialLibrary.ResolveMaterials(loadedMesh2.MaterialIds); if ((Object)(object)component.gunMuzzle == (Object)null) { GameObject val9 = new GameObject("GunMuzzle"); component.gunMuzzle = val9.transform; } component.gunMuzzle.SetParent(val6.transform, false); component.gunMuzzle.localPosition = def.MuzzleLocalPos; component.gunMuzzle.localRotation = Quaternion.identity; component.gunMuzzle.localScale = Vector3.one; GameObject val10 = new GameObject("EjectionPort"); val10.transform.SetParent(val6.transform, false); val10.transform.localPosition = def.EjectionLocalPos; val10.transform.localRotation = Quaternion.identity; if ((Object)(object)component4 != (Object)null && (Object)(object)component4.batteryTransform != (Object)null) { Vector3 val11 = val6.transform.TransformPoint(def.BatteryLocalPos); component4.batteryTransform.localPosition = val.transform.InverseTransformPoint(val11); } Bounds bounds = loadedMesh.Mesh.bounds; ((Bounds)(ref bounds)).Encapsulate(loadedMesh2.Mesh.bounds); GameObject val12 = new GameObject("WeaponCollider"); val12.transform.SetParent(val6.transform, false); val12.layer = layer; val12.tag = tag; BoxCollider val13 = val12.AddComponent<BoxCollider>(); val13.center = ((Bounds)(ref bounds)).center; val13.size = new Vector3(Mathf.Max(0.055f, ((Bounds)(ref bounds)).size.x), Mathf.Max(0.085f, ((Bounds)(ref bounds)).size.y), Mathf.Max(0.16f, ((Bounds)(ref bounds)).size.z)); if ((Object)(object)val5 != (Object)null) { ((Collider)val13).sharedMaterial = val5; } PhysGrabObjectBoxCollider obj = val12.AddComponent<PhysGrabObjectBoxCollider>(); obj.drawGizmos = false; obj.unEquipCollider = false; PhysGrabObjectCollider obj2 = val12.AddComponent<PhysGrabObjectCollider>(); obj2.physGrabObject = component3; obj2.colliderID = 0; component3.colliders = new List<Transform> { val12.transform }; PhysGrabObjectImpactDetector component6 = val.GetComponent<PhysGrabObjectImpactDetector>(); if ((Object)(object)component6 != (Object)null) { component6.colliderTransforms = new List<Transform> { val12.transform }; } component3.massOriginal = def.Mass; component3.isGun = true; Vector3 val14 = ((Bounds)(ref bounds)).size * def.VisualScale; component3.itemWidthX = val14.x; component3.itemHeightY = val14.y; component3.itemLengthZ = val14.z; Rigidbody component7 = val.GetComponent<Rigidbody>(); if ((Object)(object)component7 != (Object)null) { component7.mass = def.Mass; } int value = cfg.Damage.Value; if ((Object)(object)component.bulletPrefab != (Object)null) { GameObject val15 = Object.Instantiate<GameObject>(component.bulletPrefab, _prefabVault.transform); ((Object)val15).name = "Bullet_" + def.Id; ConfigureBulletPrefab(val15, def, value); component.bulletPrefab = val15; } if ((Object)(object)component.muzzleFlashPrefab != (Object)null) { GameObject val16 = Object.Instantiate<GameObject>(component.muzzleFlashPrefab, _prefabVault.transform); ((Object)val16).name = "MuzzleFlash_" + def.Id; ConfigureMuzzleFlashPrefab(val16, def); component.muzzleFlashPrefab = val16; } int effectiveShots = ArmoryConfig.GetEffectiveShots(def); float effectiveRecoil = ArmoryConfig.GetEffectiveRecoil(def); float value2 = cfg.FireCooldown.Value; component.numberOfBullets = def.PelletsPerShot; component.gunRandomSpread = cfg.Spread.Value; component.gunRange = def.Range; component.gunRecoilForce = effectiveRecoil; component.cameraShakeMultiplier = def.CameraShake; component.shootCooldown = value2; component.batteryDrainFullBar = false; component.batteryDrainFullBars = 0; component.batteryDrain = 100f / (float)Mathf.Max(1, effectiveShots); component.misfirePercentageChange = 0f; component.investigateRadius = def.SoundAlertRadius; component.hasBuildUp = false; component.hasOneShot = false; AudioClip val17 = AudioLoader.LoadWav(def.ShootSfxFile); if ((Object)(object)val17 != (Object)null) { component.soundShoot = CloneSoundWithClip(component.soundShoot, val17, ArmoryConfig.WeaponAudioVolume.Value); component.soundShootGlobal = CloneSoundWithClip(component.soundShootGlobal, val17, ArmoryConfig.WeaponAudioVolume.Value * 0.65f); } if ((Object)(object)dryFireClip != (Object)null) { component.soundNoAmmoClick = CloneSoundWithClip(component.soundNoAmmoClick, dryFireClip, ArmoryConfig.WeaponAudioVolume.Value * 0.85f); } TacticalFireController tacticalFireController = val.AddComponent<TacticalFireController>(); tacticalFireController.FireMode = def.FireMode; tacticalFireController.AutoFireInterval = value2; tacticalFireController.BurstShotInterval = def.BurstShotInterval; tacticalFireController.BurstCount = 3; TacticalVisualEffects tacticalVisualEffects = val.AddComponent<TacticalVisualEffects>(); tacticalVisualEffects.WeaponId = def.Id; tacticalVisualEffects.ActionAnimation = def.ActionAnimation; tacticalVisualEffects.ActionRecoilDistance = def.ActionRecoilDistance; tacticalVisualEffects.CasingMeshFile = def.CasingMeshFile; tacticalVisualEffects.ActionSfxFile = def.ActionSfxFile ?? string.Empty; tacticalVisualEffects.CasingScale = def.CasingScale; tacticalVisualEffects.ActionTransform = val8.transform; tacticalVisualEffects.EjectionPortTransform = val10.transform; val.AddComponent<SwayStabilizer>().IsBlackridgeWeapon = true; Item val18 = Object.Instantiate<Item>(donorItem); ((Object)val18).name = def.PrefabName; val18.disabled = false; val18.itemName = def.DisplayName; val18.itemNameLocalized = null; val18.description = def.Description; val18.itemType = (itemType)9; val18.itemVolume = def.ShopVolume; val18.emojiIcon = def.EmojiFallback; val18.maxAmount = def.MaxInRun; val18.maxAmountInShop = cfg.MaxInShop.Value; val18.maxPurchase = false; val18.physicalItem = true; float effectivePriceMultiplier = ArmoryConfig.GetEffectivePriceMultiplier(def); Value val19 = ScriptableObject.CreateInstance<Value>(); ((Object)val19).name = "Value_" + def.Id; val19.valueMin = Mathf.Max(1f, baseValueMin * effectivePriceMultiplier); val19.valueMax = Mathf.Max(val19.valueMin + 0.5f, baseValueMax * effectivePriceMultiplier); val18.value = val19; component2.item = val18; component2.itemName = def.DisplayName; component2.itemAssetName = ((Object)val18).name; component2.promptName = def.DisplayName; component2.itemType = (itemType)9; component2.emojiIcon = def.EmojiFallback; component2.itemValueMin = val19.valueMin; component2.itemValueMax = val19.valueMax; component2.hasIcon = false; component2.icon = null; if ((Object)(object)component5 != (Object)null) { component5.ItemIcon = null; component5.itemEmojiIcon = def.EmojiFallback; } if (Items.RegisterItem(component2) == null) { Plugin.Log.LogError((object)("REPOLib.Modules.Items.RegisterItem returned null for '" + def.DisplayName + "'.")); Object.DestroyImmediate((Object)(object)val); return null; } Plugin.Log.LogInfo((object)$"Registered [{def.DisplayName}] | Mode: {def.FireMode} | DMG: {value}x{def.PelletsPerShot} | Shots: {effectiveShots} | PriceMult: {effectivePriceMultiplier:0.00}x"); return val18; } private static void ConfigureBulletPrefab(GameObject bulletPrefab, WeaponDefinition def, int effectiveDamage) { //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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) ItemGunBullet component = bulletPrefab.GetComponent<ItemGunBullet>(); if (!((Object)(object)component == (Object)null)) { HurtCollider val = (((Object)(object)component.hurtCollider != (Object)null) ? component.hurtCollider : bulletPrefab.GetComponentInChildren<HurtCollider>(true)); if ((Object)(object)val != (Object)null) { val.enemyLogic = true; val.enemyDamage = effectiveDamage; val.enemyStun = true; val.enemyStunTime = def.EnemyStunTime; val.enemyStunType = def.EnemyStunType; val.enemyImpact = def.EnemyImpact; val.enemyHitForce = def.EnemyHitForce; val.enemyHitTorque = def.EnemyHitTorque; val.playerDamage = def.PlayerDamage; val.physImpact = def.PhysImpact; val.physHitForce = def.PhysHitForce; } if ((Object)(object)component.shootLine != (Object)null) { component.shootLine.startColor = def.TracerColor; component.shootLine.endColor = new Color(def.TracerColor.r, def.TracerColor.g, def.TracerColor.b, 0.15f); } if ((Object)(object)component.hitLight != (Object)null) { component.hitLight.color = def.MuzzleLightColor; } } } private static void ConfigureMuzzleFlashPrefab(GameObject flashPrefab, WeaponDefinition def) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) ItemGunMuzzleFlash component = flashPrefab.GetComponent<ItemGunMuzzleFlash>(); if ((Object)(object)component != (Object)null && (Object)(object)component.shootLight != (Object)null) { component.shootLight.color = def.MuzzleLightColor; component.shootLight.intensity = def.MuzzleLightIntensity; } } private static Sound CloneSoundWithClip(Sound? donor, AudioClip clip, float volumeMultiplier) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) Sound val = new Sound(); if (donor != null) { Sound.CopySound(donor, val); } else { val.Volume = 0.85f; val.Pitch = 1f; val.PitchRandom = 0.05f; val.SpatialBlend = 1f; val.FalloffMultiplier = 1f; val.Type = (AudioType)9; } val.Sounds = (AudioClip[])(object)new AudioClip[1] { clip }; val.Volume = Mathf.Clamp(val.Volume * volumeMultiplier, 0.05f, 1.5f); val.VolumeDefault = val.Volume; val.Pitch = 1f; val.PitchDefault = 1f; val.PitchRandom = 0.045f; val.DefaultsStored = true; return val; } private static Item? FindDonorGunItem(StatsManager statsManager) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Invalid comparison between Unknown and I4 Item val = null; Item val2 = null; foreach (Item value in statsManager.itemDictionary.Values) { if ((Object)(object)value == (Object)null || (int)value.itemType != 9 || value.prefab == null) { continue; } GameObject prefab = ((PrefabRef<GameObject>)(object)value.prefab).Prefab; if ((Object)(object)prefab == (Object)null) { continue; } ItemGun component = prefab.GetComponent<ItemGun>(); if (!((Object)(object)component == (Object)null)) { if (((Object)value).name.IndexOf("Handgun", StringComparison.OrdinalIgnoreCase) >= 0) { return value; } if ((Object)(object)val == (Object)null && component.numberOfBullets == 1 && ((Object)value).name.IndexOf("Tranq", StringComparison.OrdinalIgnoreCase) < 0) { val = value; } if (val2 == null) { val2 = value; } } } return val ?? val2; } private static Material? FindOpaqueDonorMaterial(GameObject donorPrefab) { MeshRenderer[] componentsInChildren = donorPrefab.GetComponentsInChildren<MeshRenderer>(true); foreach (MeshRenderer val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !((Object)(object)((Renderer)val).sharedMaterial == (Object)null) && !((Object)(object)((Component)val).GetComponentInParent<BatteryVisualLogic>(true) != (Object)null) && (Object)(object)((Renderer)val).sharedMaterial.shader != (Object)null) { return ((Renderer)val).sharedMaterial; } } return null; } private static Vector3 ComputeVanillaVisualCenter(GameObject clone, ItemBattery? itemBattery) { //IL_0011: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_00b8: Unknown result type (might be due to invalid IL or missing references) Transform val = itemBattery?.batteryTransform; bool flag = false; Bounds val2 = default(Bounds); MeshFilter[] componentsInChildren = clone.GetComponentsInChildren<MeshFilter>(true); foreach (MeshFilter val3 in componentsInChildren) { if (!((Object)(object)val3 == (Object)null) && !((Object)(object)val3.sharedMesh == (Object)null) && (!((Object)(object)val != (Object)null) || (!((Object)(object)((Component)val3).transform == (Object)(object)val) && !((Component)val3).transform.IsChildOf(val))) && !((Object)(object)((Component)val3).GetComponentInParent<BatteryVisualLogic>(true) != (Object)null)) { Transform transform = clone.transform; Transform transform2 = ((Component)val3).transform; Bounds bounds = val3.sharedMesh.bounds; Vector3 val4 = transform.InverseTransformPoint(transform2.TransformPoint(((Bounds)(ref bounds)).center)); if (!flag) { ((Bounds)(ref val2))..ctor(val4, Vector3.zero); flag = true; } else { ((Bounds)(ref val2)).Encapsulate(val4); } } } if (!flag) { return Vector3.zero; } return ((Bounds)(ref val2)).center; } private static Collider? FindPrimaryNonTriggerCollider(GameObject clone) { Collider[] componentsInChildren = clone.GetComponentsInChildren<Collider>(true); foreach (Collider val in componentsInChildren) { if ((Object)(object)val != (Object)null && !val.isTrigger && (Object)(object)((Component)val).GetComponent<HurtCollider>() == (Object)null) { return val; } } return null; } private static void HideLegacyVisuals(GameObject clone, ItemBattery? itemBattery) { Transform val = itemBattery?.batteryTransform; Renderer[] componentsInChildren = clone.GetComponentsInChildren<Renderer>(true); foreach (Renderer val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null) && (!((Object)(object)val != (Object)null) || (!((Object)(object)((Component)val2).transform == (Object)(object)val) && !((Component)val2).transform.IsChildOf(val))) && !((Object)(object)((Component)val2).GetComponentInParent<BatteryVisualLogic>(true) != (Object)null) && !(val2 is ParticleSystemRenderer) && !(val2 is LineRenderer)) { val2.enabled = false; } } } private static void ClearLegacyNonTriggerColliders(GameObject clone) { Collider[] componentsInChildren = clone.GetComponentsInChildren<Collider>(true); foreach (Collider val in componentsInChildren) { if ((Object)(object)val == (Object)null || val.isTrigger || (Object)(object)((Component)val).GetComponent<HurtCollider>() != (Object)null) { continue; } PhysGrabObjectBoxCollider component = ((Component)val).GetComponent<PhysGrabObjectBoxCollider>(); if (!((Object)(object)component != (Object)null) || !component.unEquipCollider) { PhysGrabObjectCollider component2 = ((Component)val).GetComponent<PhysGrabObjectCollider>(); if ((Object)(object)component2 != (Object)null) { Object.DestroyImmediate((Object)(object)component2); } if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } Object.DestroyImmediate((Object)(object)val); } } } } } namespace BlackridgeArmory.Patches { [HarmonyPatch(typeof(ItemAttributes))] internal static class ItemAttributesPatches { [HarmonyPatch("GetItemNameLocalized")] [HarmonyPostfix] private static void GetItemNameLocalizedPostfix(ItemAttributes __instance, ref string __result) { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance.item == (Object)null) && WeaponCatalog.TryGetByPrefabName(((Object)__instance.item).name, out WeaponDefinition definition)) { __result = definition.DisplayName; } } } [HarmonyPatch(typeof(ItemGun))] internal static class ItemGunPatches { [HarmonyPatch("Start")] [HarmonyPostfix] private static void StartPostfix(ItemGun __instance) { if (!((Object)(object)__instance == (Object)null) && ArmoryConfig.ApplyStabilizerToVanillaGuns.Value && (Object)(object)((Component)__instance).GetComponent<SwayStabilizer>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<SwayStabilizer>().IsBlackridgeWeapon = false; } } [HarmonyPatch("Shoot")] [HarmonyPostfix] private static void ShootPostfix(ItemGun __instance, bool __result) { if (__result && !((Object)(object)__instance == (Object)null)) { ((Component)__instance).GetComponent<TacticalFireController>()?.NotifyMasterShotFired(); } } [HarmonyPatch("MuzzleFlash")] [HarmonyPostfix] private static void MuzzleFlashPostfix(ItemGun __instance) { if (!((Object)(object)__instance == (Object)null)) { TacticalVisualEffects component = ((Component)__instance).GetComponent<TacticalVisualEffects>(); if ((Object)(object)component != (Object)null) { component.OnShotFired(); } else { ((Component)__instance).GetComponent<SwayStabilizer>()?.NotifyShotFired(); } } } } [HarmonyPatch(typeof(ShopManager))] internal static class ShopManagerPatches { [HarmonyPatch("GetAllItemsFromStatsManager")] [HarmonyPostfix] private static void GetAllItemsFromStatsManagerPostfix(ShopManager __instance) { if ((Object)(object)__instance == (Object)null || __instance.potentialItems == null || !ArmoryConfig.EnableShopPresenceBoost.Value) { return; } IReadOnlyList<Item> registeredItems = WeaponPrefabFactory.RegisteredItems; if (registeredItems.Count == 0) { return; } int num = Mathf.Clamp(ArmoryConfig.ShopPresenceBoostSlots.Value, 1, 3); foreach (Item item in registeredItems) { if (!((Object)(object)item == (Object)null) && !item.disabled && __instance.potentialItems.Contains(item)) { for (int i = 0; i < num; i++) { __instance.potentialItems.Add(item); } } } } } [HarmonyPatch(typeof(StatsManager))] internal static class StatsManagerPatches { [HarmonyPatch("LoadItemsFromFolder")] [HarmonyPostfix] private static void LoadItemsFromFolderPostfix(StatsManager __instance) { WeaponPrefabFactory.TryRegisterAll(__instance); } [HarmonyPatch("RunStartStats")] [HarmonyPrefix] private static void RunStartStatsPrefix(StatsManager __instance) { WeaponPrefabFactory.TryRegisterAll(__instance); } } } namespace BlackridgeArmory.Config { public enum BalancePreset { VanillaBalanced, TacticalAction, HardcoreHorror, Custom } internal sealed class WeaponConfigEntries { public ConfigEntry<bool> Enabled { get; set; } public ConfigEntry<float> PriceMultiplier { get; set; } public ConfigEntry<int> Damage { get; set; } public ConfigEntry<int> ShotsPerCharge { get; set; } public ConfigEntry<float> FireCooldown { get; set; } public ConfigEntry<float> Spread { get; set; } public ConfigEntry<float> RecoilForce { get; set; } public ConfigEntry<int> MaxInShop { get; set; } } internal static class ArmoryConfig { private static readonly Dictionary<string, WeaponConfigEntries> _weapons = new Dictionary<string, WeaponConfigEntries>(); public static ConfigEntry<BalancePreset> Preset { get; private set; } = null; public static ConfigEntry<bool> EnableShopPresenceBoost { get; private set; } = null; public static ConfigEntry<int> ShopPresenceBoostSlots { get; private set; } = null; public static ConfigEntry<bool> EnableStrengthSwayStabilizer { get; private set; } = null; public static ConfigEntry<float> StabilizerDamping { get; private set; } = null; public static ConfigEntry<bool> ApplyStabilizerToVanillaGuns { get; private set; } = null; public static ConfigEntry<bool> EnableAnimatedActions { get; private set; } = null; public static ConfigEntry<bool> EnableShellEjection { get; private set; } = null; public static ConfigEntry<bool> EnableNightSights { get; private set; } = null; public static ConfigEntry<float> WeaponAudioVolume { get; private set; } = null; public static void Initialize(ConfigFile config) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Expected O, but got Unknown //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Expected O, but got Unknown //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Expected O, but got Unknown //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Expected O, but got Unknown //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Expected O, but got Unknown //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Expected O, but got Unknown //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Expected O, but got Unknown //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Expected O, but got Unknown Preset = config.Bind<BalancePreset>("01. General", "BalancePreset", BalancePreset.VanillaBalanced, "Overall tuning profile. VanillaBalanced matches R.E.P.O.'s default shop economy. TacticalAction gives +25% ammo and gentler recoil. HardcoreHorror reduces ammo by 20% and raises prices by 20%. Custom uses per-weapon values verbatim."); EnableShopPresenceBoost = config.Bind<bool>("01. General", "EnableShopPresenceBoost", true, "Gently improves the odds that Blackridge firearms roll onto standard shop shelves without altering run progression or crowding out upgrades."); ShopPresenceBoostSlots = config.Bind<int>("01. General", "ShopPresenceBoostWeight", 1, new ConfigDescription("Extra shop pool weight added for Blackridge weapons when EnableShopPresenceBoost is enabled.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 3), Array.Empty<object>())); EnableStrengthSwayStabilizer = config.Bind<bool>("02. Handling", "EnableStrengthSwayStabilizer", true, "Dampens excessive aim oscillation caused by high Strength upgrades when aiming Blackridge firearms."); StabilizerDamping = config.Bind<float>("02. Handling", "StabilizerStrength", 0.78f, new ConfigDescription("How strongly angular sway is damped while aiming (0.0 = off, 1.0 = rock steady).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); ApplyStabilizerToVanillaGuns = config.Bind<bool>("02. Handling", "ApplyStabilizerToVanillaGuns", false, "Optional: also apply the high-strength aim sway stabilizer to vanilla R.E.P.O. firearms."); EnableAnimatedActions = config.Bind<bool>("03. Visuals & Audio", "EnableAnimatedActions", true, "Animate reciprocating bolts, slides, bolt-action cycling, and pump forends when firing."); EnableShellEjection = config.Bind<bool>("03. Visuals & Audio", "EnableShellEjection", true, "Eject physical spinning brass shell casings and 12-gauge shotgun hulls from ejection ports."); EnableNightSights = config.Bind<bool>("03. Visuals & Audio", "EnableNightSights", true, "Enable glowing tritium iron-sight pips, crimson red-dot reticle, and emerald scope glint."); WeaponAudioVolume = config.Bind<float>("03. Visuals & Audio", "WeaponAudioVolume", 0.85f, new ConfigDescription("Master volume multiplier for Blackridge firearm gunshots and mechanical action sounds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1.5f), Array.Empty<object>())); foreach (WeaponDefinition item in WeaponCatalog.All) { string text = "Weapon - " + item.ConfigSectionName; _weapons[item.Id] = new WeaponConfigEntries { Enabled = config.Bind<bool>(text, "Enabled", true, "Allow " + item.DisplayName + " to register and spawn in the shop."), PriceMultiplier = config.Bind<float>(text, "PriceMultiplier", item.PriceMultiplier, new ConfigDescription("Shop price relative to vanilla Handgun (1.0 = Handgun price).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.25f, 5f), Array.Empty<object>())), Damage = config.Bind<int>(text, "DamagePerHit", item.EnemyDamage, new ConfigDescription($"Enemy damage dealt per projectile ({item.PelletsPerShot} projectile(s) per shot).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(5, 1000), Array.Empty<object>())), ShotsPerCharge = config.Bind<int>(text, "ShotsPerFullBattery", item.ShotsPerCharge, new ConfigDescription("Total shots fired from a 100% charged battery.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 120), Array.Empty<object>())), FireCooldown = config.Bind<float>(text, "FireCooldownSeconds", item.ShootCooldown, new ConfigDescription("Minimum delay in seconds between shots or bursts.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 3f), Array.Empty<object>())), Spread = config.Bind<float>(text, "SpreadDegrees", item.Spread, new ConfigDescription("Random shot dispersion in degrees.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 18f), Array.Empty<object>())), RecoilForce = config.Bind<float>(text, "RecoilForce", item.RecoilForce, new ConfigDescription("Physical kickback impulse applied to the weapon when firing.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 25f), Array.Empty<object>())), MaxInShop = config.Bind<int>(text, "MaxAmountInShop", item.MaxAmountInShop, new ConfigDescription("Maximum copies of this weapon that can appear in a single shop visit.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 4), Array.Empty<object>())) }; } } public static WeaponConfigEntries GetWeapon(string id) { return _weapons[id]; } public static float GetEffectivePriceMultiplier(WeaponDefinition def) { float value = _weapons[def.Id].PriceMultiplier.Value; return Preset.Value switch { BalancePreset.TacticalAction => value * 0.9f, BalancePreset.HardcoreHorror => value * 1.2f, _ => value, }; } public static int GetEffectiveShots(WeaponDefinition def) { int value = _weapons[def.Id].ShotsPerCharge.Value; return Preset.Value switch { BalancePreset.TacticalAction => Mathf.Max(1, Mathf.RoundToInt((float)value * 1.25f)), BalancePreset.HardcoreHorror => Mathf.Max(1, Mathf.RoundToInt((float)value * 0.8f)), _ => value, }; } public static float GetEffectiveRecoil(WeaponDefinition def) { float value = _weapons[def.Id].RecoilForce.Value; return Preset.Value switch { BalancePreset.TacticalAction => value * 0.82f, BalancePreset.HardcoreHorror => value * 1.15f, _ => value, }; } } } namespace BlackridgeArmory.Assets { internal static class AudioLoader { private const string AudioPrefix = "BlackridgeArmory.Assets.Audio."; private static readonly Dictionary<string, AudioClip> Cache = new Dictionary<string, AudioClip>(); public static AudioClip? LoadWav(string fileName) { if (Cache.TryGetValue(fileName, out AudioClip value)) { return value; } string text = "BlackridgeArmory.Assets.Audio." + fileName; using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(text); if (stream == null) { Plugin.Log.LogWarning((object)("Embedded WAV audio missing: " + text)); return null; } try { using BinaryReader binaryReader = new BinaryReader(stream); if (new string(binaryReader.ReadChars(4)) != "RIFF") { throw new InvalidDataException("Not a RIFF file"); } binaryReader.ReadInt32(); if (new string(binaryReader.ReadChars(4)) != "WAVE") { throw new InvalidDataException("Not a WAVE file"); } int num = 1; int num2 = 44100; int num3 = 16; byte[] array = null; while (stream.Position + 8 <= stream.Length) { string text2 = new string(binaryReader.ReadChars(4)); int num4 = binaryReader.ReadInt32(); if (num4 < 0 || stream.Position + num4 > stream.Length) { break; } if (text2 == "fmt ") { long position = stream.Position; short num5 = binaryReader.ReadInt16(); num = binaryReader.ReadInt16(); num2 = binaryReader.ReadInt32(); binaryReader.ReadInt32(); binaryReader.ReadInt16(); num3 = binaryReader.ReadInt16(); if (num5 != 1) { throw new InvalidDataException($"Unsupported WAV format tag {num5}"); } stream.Position = position + num4; } else { if (text2 == "data") { array = binaryReader.ReadBytes(num4); break; } stream.Position += num4; } if ((num4 & 1) == 1 && stream.Position < stream.Length) { stream.Position++; } } if (array == null || array.Length == 0 || num3 != 16) { throw new InvalidDataException("Invalid PCM16 WAV payload in " + fileName); } int num6 = array.Length / 2; int num7 = num6 / Math.Max(1, num); float[] array2 = new float[num6]; for (int i = 0; i < num6; i++) { short num8 = BitConverter.ToInt16(array, i * 2); array2[i] = (float)num8 / 32768f; } AudioClip val = AudioClip.Create(Path.GetFileNameWithoutExtension(fileName), num7, num, num2, false); val.SetData(array2, 0); Cache[fileName] = val; return val; } catch (Exception ex) { Plugin.Log.LogError((object)("Failed to decode WAV '" + fileName + "': " + ex.Message)); return null; } } } internal static class MaterialLibrary { private const string TexturePrefix = "BlackridgeArmory.Assets.Textures."; private static readonly Dictionary<int, Material> Materials = new Dictionary<int, Material>(); private static readonly Dictionary<string, Texture2D> Textures = new Dictionary<string, Texture2D>(); private static bool _initialized; public static void Initialize(Material? donorMaterial) { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) if (!_initialized) { Shader val = (((Object)(object)donorMaterial != (Object)null) ? donorMaterial.shader : null); if ((Object)(object)val == (Object)null) { val = Shader.Find("Standard") ?? Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Sprites/Default"); } if ((Object)(object)val == (Object)null) { Plugin.Log.LogError((object)"Could not resolve a valid Unity shader for Blackridge Armory materials."); return; } Materials[0] = CreateMaterial("BR_BluedSteel", val, donorMaterial, "tex_blued_steel.png", new Color(0.88f, 0.9f, 0.94f, 1f), 0.82f, 0.62f); Materials[1] = CreateMaterial("BR_MattePolymer", val, donorMaterial, "tex_polymer_matte.png", new Color(0.9f, 0.91f, 0.93f, 1f), 0.08f, 0.28f); Materials[2] = CreateMaterial("BR_WoodLaminate", val, donorMaterial, "tex_wood_laminate.png", new Color(1f, 0.96f, 0.92f, 1f), 0.05f, 0.48f); Materials[3] = CreateMaterial("BR_BrushedChrome", val, donorMaterial, "tex_chrome_brushed.png", new Color(0.98f, 0.99f, 1f, 1f), 0.92f, 0.8f); Materials[4] = CreateMaterial("BR_OliveChassis", val, donorMaterial, "tex_olive_chassis.png", new Color(0.95f, 0.98f, 0.92f, 1f), 0.06f, 0.26f); Materials[5] = CreateMaterial("BR_Bakelite", val, donorMaterial, "tex_bakelite.png", new Color(1f, 0.94f, 0.88f, 1f), 0.08f, 0.56f); bool value = ArmoryConfig.EnableNightSights.Value; Materials[6] = CreateMaterial("BR_EmissiveGreen", val, donorMaterial, (string?)null, new Color(0.18f, 0.95f, 0.45f, 1f), 0.25f, 0.88f, (Color?)(value ? new Color(0.25f, 2.2f, 0.85f, 1f) : new Color(0.05f, 0.25f, 0.1f, 1f))); Materials[7] = CreateMaterial("BR_EmissiveRed", val, donorMaterial, (string?)null, new Color(0.98f, 0.18f, 0.16f, 1f), 0.2f, 0.85f, (Color?)(value ? new Color(2.4f, 0.25f, 0.2f, 1f) : new Color(0.3f, 0.04f, 0.04f, 1f))); Materials[8] = CreateMaterial("BR_Brass", val, donorMaterial, "tex_brass.png", new Color(1f, 0.96f, 0.84f, 1f), 0.88f, 0.78f); Materials[9] = CreateMaterial("BR_ShotgunHull", val, donorMaterial, "tex_shotgun_hull.png", new Color(1f, 0.92f, 0.92f, 1f), 0.06f, 0.44f); _initialized = true; } } public static Material[] ResolveMaterials(int[] materialIds) { Material[] array = (Material[])(object)new Material[materialIds.Length]; for (int i = 0; i < materialIds.Length; i++) { if (!Materials.TryGetValue(materialIds[i], out Material value)) { value = Materials[0]; } array[i] = value; } return array; } private static Material CreateMaterial(string name, Shader shader, Material? donor, string? textureFile, Color tint, float metallic, float smoothness, Color? emission = null) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) Material val = (((Object)(object)donor != (Object)null) ? new Material(donor) : new Material(shader)); ((Object)val).name = name; val.shader = shader; if (val.HasProperty("_BumpMap")) { val.SetTexture("_BumpMap", (Texture)null); } if (val.HasProperty("_MetallicGlossMap")) { val.SetTexture("_MetallicGlossMap", (Texture)null); } if (val.HasProperty("_EmissionMap")) { val.SetTexture("_EmissionMap", (Texture)null); } if (val.HasProperty("_OcclusionMap")) { val.SetTexture("_OcclusionMap", (Texture)null); } if (val.HasProperty("_DetailAlbedoMap")) { val.SetTexture("_DetailAlbedoMap", (Texture)null); } Texture2D val2 = ((textureFile != null) ? LoadTexture(textureFile) : null); if (val.HasProperty("_MainTex")) { val.SetTexture("_MainTex", (Texture)(object)val2); } if (val.HasProperty("_BaseMap")) { val.SetTexture("_BaseMap", (Texture)(object)val2); } if (val.HasProperty("_Color")) { val.SetColor("_Color", tint); } if (val.HasProperty("_BaseColor")) { val.SetColor("_BaseColor", tint); } if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", metallic); } if (val.HasProperty("_Glossiness")) { val.SetFloat("_Glossiness", smoothness); } if (val.HasProperty("_Smoothness")) { val.SetFloat("_Smoothness", smoothness); } if (emission.HasValue && val.HasProperty("_EmissionColor")) { val.EnableKeyword("_EMISSION"); val.SetColor("_EmissionColor", emission.Value); val.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)1; } else if (val.HasProperty("_EmissionColor")) { val.DisableKeyword("_EMISSION"); val.SetColor("_EmissionColor", Color.black); } return val; } private static Texture2D? LoadTexture(string fileName) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown if (Textures.TryGetValue(fileName, out Texture2D value)) { return value; } string text = "BlackridgeArmory.Assets.Textures." + fileName; using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(text); if (stream == null) { Plugin.Log.LogWarning((object)("Embedded texture missing: " + text)); return null; } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); byte[] array = memoryStream.ToArray(); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true) { name = Path.GetFileNameWithoutExtension(fileName), wrapMode = (TextureWrapMode)0, filterMode = (FilterMode)1, anisoLevel = 4 }; if (!ImageConversion.LoadImage(val, array, true)) { Plugin.Log.LogWarning((object)("Failed to decode PNG texture: " + fileName)); Object.Destroy((Object)(object)val); return null; } Textures[fileName] = val; return val; } } internal readonly struct LoadedMesh { public Mesh Mesh { get; } public int[] MaterialIds { get; } public LoadedMesh(Mesh mesh, int[] materialIds) { Mesh = mesh; MaterialIds = materialIds; } } internal static class MeshLoader { private const string ResourcePrefix = "BlackridgeArmory.Assets.Meshes."; private static readonly Dictionary<string, LoadedMesh> Cache = new Dictionary<string, LoadedMesh>(); public static LoadedMesh Load(string meshFileName) { //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Expected O, but got Unknown if (Cache.TryGetValue(meshFileName, out var value)) { return value; } string text = "BlackridgeArmory.Assets.Meshes." + meshFileName; using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(text); if (stream == null) { throw new FileNotFoundException("Embedded mesh resource not found: " + text); } using BinaryReader binaryReader = new BinaryReader(stream); byte[] array = binaryReader.ReadBytes(4); if (array.Length != 4 || array[0] != 66 || array[1] != 82 || array[2] != 77 || array[3] != 49) { throw new InvalidDataException("Invalid .brmesh header in " + meshFileName); } int num; int num2; Vector3[] array2; Vector3[] array3; Vector2[] array4; checked { num = (int)binaryReader.ReadUInt32(); num2 = (int)binaryReader.ReadUInt32(); array2 = (Vector3[])(object)new Vector3[num]; array3 = (Vector3[])(object)new Vector3[num]; array4 = (Vector2[])(object)new Vector2[num]; } for (int i = 0; i < num; i++) { float num3 = binaryReader.ReadSingle(); float num4 = binaryReader.ReadSingle(); float num5 = binaryReader.ReadSingle(); float num6 = binaryReader.ReadSingle(); float num7 = binaryReader.ReadSingle(); float num8 = binaryReader.ReadSingle(); float num9 = binaryReader.ReadSingle(); float num10 = binaryReader.ReadSingle(); array2[i] = new Vector3(num3, num4, num5); array3[i] = new Vector3(num6, num7, num8); array4[i] = new Vector2(num9, num10); } Mesh val = new Mesh { name = Path.GetFileNameWithoutExtension(meshFileName), indexFormat = (IndexFormat)(num > 65000), vertices = array2, normals = array3, uv = array4, subMeshCount = num2 }; int[] array5 = new int[num2]; for (int j = 0; j < num2; j++) { checked { array5[j] = (int)binaryReader.ReadUInt32(); int num11 = (int)binaryReader.ReadUInt32(); int[] array6 = new int[num11]; for (int k = 0; k < num11; k = unchecked(k + 1)) { array6[k] = (int)binaryReader.ReadUInt32(); } val.SetTriangles(array6, j, false); } } val.RecalculateBounds(); val.RecalculateTangents(); LoadedMesh loadedMesh = new LoadedMesh(val, array5); Cache[meshFileName] = loadedMesh; return loadedMesh; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }