The BepInEx console will not appear when launching like it does for other games on Thunderstore (you can turn it back on in your BepInEx.cfg file). If your PEAK crashes on startup, add -dx12 to your launch parameters.
Decompiled source of RarityRoulette v1.3.0
spidersgeorg-RarityRoulette.dll
Decompiled 12 hours agousing System; using System.Collections; 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 HarmonyLib; using LastResort; using LastResort.Utils; using Microsoft.CodeAnalysis; using PEAKLib.Core; using PEAKLib.Items.UnityEditor; using Photon.Pun; using Photon.Realtime; using TMPro; using UnityEngine; using UnityEngine.Networking; using Zorro.Core; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("spidersgeorg-RarityRoulette")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("spidersgeorg-RarityRoulette")] [assembly: AssemblyTitle("RarityRoulette")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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] [Microsoft.CodeAnalysis.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] [Microsoft.CodeAnalysis.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; } } } internal class Action_Revolver_Others : ItemAction { public bool consumeOnFullyUsed = true; public float revolverMaxDistance = 500f; public float revolverBulletCollisonSize = 0.25f; private static readonly ManualLogSource Logger = Logger.CreateLogSource("Action_Revolver"); public Revolver revolver; private RaycastHit revolverLineHit; private RaycastHit[] revolverSphereHits; public Transform revolverSpawnTransform; public static Dictionary<BiomeType, List<SpawnPool>> BiomeSpawnPools = new Dictionary<BiomeType, List<SpawnPool>> { { (BiomeType)0, new List<SpawnPool>(7) { (SpawnPool)64, (SpawnPool)32768, (SpawnPool)65536, (SpawnPool)1024, (SpawnPool)32768, (SpawnPool)65536, (SpawnPool)1024 } }, { (BiomeType)1, new List<SpawnPool>(7) { (SpawnPool)256, (SpawnPool)2048, (SpawnPool)32768, (SpawnPool)65536, (SpawnPool)2048, (SpawnPool)32768, (SpawnPool)65536 } }, { (BiomeType)2, new List<SpawnPool>(7) { (SpawnPool)512, (SpawnPool)4096, (SpawnPool)32768, (SpawnPool)65536, (SpawnPool)4096, (SpawnPool)32768, (SpawnPool)65536 } }, { (BiomeType)6, new List<SpawnPool>(7) { (SpawnPool)4194304, (SpawnPool)16777216, (SpawnPool)32768, (SpawnPool)65536, (SpawnPool)16777216, (SpawnPool)32768, (SpawnPool)65536 } }, { (BiomeType)3, new List<SpawnPool>(7) { (SpawnPool)262144, (SpawnPool)8192, (SpawnPool)32768, (SpawnPool)65536, (SpawnPool)8192, (SpawnPool)32768, (SpawnPool)65536 } } }; public void Start() { revolver = ((Component)this).GetComponent<Revolver>(); } public override void RunAction() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_0115: 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_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: 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_037a: Unknown result type (might be due to invalid IL or missing references) int viewID = ((MonoBehaviourPun)Character.localCharacter).photonView.ViewID; revolverSpawnTransform = ((Component)revolver).transform; Physics.Raycast(revolverSpawnTransform.position, ((Component)MainCamera.instance).transform.forward, ref revolverLineHit, revolverMaxDistance, LayerMask.op_Implicit(HelperFunctions.terrainMapMask), (QueryTriggerInteraction)1); if (!Object.op_Implicit((Object)(object)((RaycastHit)(ref revolverLineHit)).collider)) { ((RaycastHit)(ref revolverLineHit)).distance = revolverMaxDistance; ((RaycastHit)(ref revolverLineHit)).point = revolverSpawnTransform.position + ((Component)MainCamera.instance).transform.forward * revolverMaxDistance; } revolverSphereHits = Physics.SphereCastAll(revolverSpawnTransform.position, revolverBulletCollisonSize, ((Component)MainCamera.instance).transform.forward, ((RaycastHit)(ref revolverLineHit)).distance, LayerMask.GetMask(new string[1] { "Character" }), (QueryTriggerInteraction)1); RaycastHit[] array = revolverSphereHits; for (int i = 0; i < array.Length; i++) { RaycastHit val = array[i]; if (!Object.op_Implicit((Object)(object)((RaycastHit)(ref val)).collider)) { continue; } Character componentInParent = ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<Character>(); if (Object.op_Implicit((Object)(object)componentInParent) && (Object)(object)componentInParent != (Object)(object)((ItemActionBase)this).character) { Debug.Log((object)("HIT confirmed " + ((Object)componentInParent).name)); int num = Random.Range(1, 6); Logger.LogInfo((object)("Roulette number is " + num)); if (revolver.shotsLeft <= 0) { Logger.LogInfo((object)"The revolver is empty"); ((MonoBehaviourPun)Character.localCharacter).photonView.RPC("PlaySoundGlobal", (RpcTarget)0, new object[2] { viewID, "Au_Empty.ogg" }); } else if (num != 2 && num != 4 && revolver.shotsLeft > 0) { BiomeType currentBiome = Singleton<MapHandler>.Instance.GetCurrentBiome(); Logger.LogInfo((object)("The current biome is " + ((object)(BiomeType)(ref currentBiome)).ToString())); revolver.useOnce(); Array values = Enum.GetValues(typeof(SpawnPool)); List<SpawnPool> list = BiomeSpawnPools[currentBiome]; int count = list.Count; int index = Random.Range(0, count); SpawnPool poolToChooseFrom = list[index]; Item val2 = FindItemToSpawnNotRevolver(poolToChooseFrom); ((MonoBehaviourPun)Character.localCharacter).photonView.RPC("PlaySoundGlobal", (RpcTarget)0, new object[2] { viewID, "Au_Winner.ogg" }); RevolverImpactOthers(componentInParent, revolverSpawnTransform.position, ((RaycastHit)(ref val)).point, ((Object)val2).name); } else if ((num == 2 || num == 4) && revolver.shotsLeft > 0) { Logger.LogInfo((object)"The player got hit with the YouLose effect"); revolver.useOnce(); ((MonoBehaviourPun)Character.localCharacter).photonView.RPC("PlaySoundGlobal", (RpcTarget)0, new object[2] { viewID, "Au_Revolver.ogg" }); RevolverImpactOthers(componentInParent, revolverSpawnTransform.position, ((RaycastHit)(ref val)).point, "YouLose"); } return; } } if (revolver.shotsLeft > 0) { revolver.useOnce(); ((MonoBehaviourPun)Character.localCharacter).photonView.RPC("PlaySoundGlobal", (RpcTarget)0, new object[2] { viewID, "Au_Revolver.ogg" }); } else { ((MonoBehaviourPun)Character.localCharacter).photonView.RPC("PlaySoundGlobal", (RpcTarget)0, new object[2] { viewID, "Au_Empty.ogg" }); } } private Item FindItemToSpawnNotRevolver(SpawnPool poolToChooseFrom) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) Item component = LootData.GetRandomItem(poolToChooseFrom).GetComponent<Item>(); while (component.GetName() == "Revolver") { component = LootData.GetRandomItem(poolToChooseFrom).GetComponent<Item>(); } return component; } private void RevolverImpactOthers(Character hitCharacter, Vector3 origin, Vector3 endpoint, string itemToSpawnName1) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)hitCharacter)) { ((MonoBehaviourPun)this).photonView.RPC("RPC_RevolverImpactOthers", (RpcTarget)0, new object[4] { ((MonoBehaviourPun)hitCharacter).photonView.Owner, origin, endpoint, itemToSpawnName1 }); } else { ((MonoBehaviourPun)this).photonView.RPC("RPC_RevolverImpactOthers", (RpcTarget)0, new object[4] { null, origin, endpoint, itemToSpawnName1 }); } } [PunRPC] private void RPC_RevolverImpactOthers(Player hitPlayer, Vector3 origin, Vector3 endpoint, string itemToSpawnName2) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) if (hitPlayer != null && hitPlayer.IsLocal) { Logger.LogInfo((object)("RPC_RevolverImpactOthers called with hitPlayer: " + itemToSpawnName2)); if (itemToSpawnName2 == "YouLose") { Character.localCharacter.refs.afflictions.AddStatus((STATUSTYPE)0, 0.5f, false); ((Component)Character.localCharacter).GetComponent<RevolverBlowbackWatcher>().ShootSelfT(0.25f, Character.localCharacter, ((Component)Camera.main).transform.forward); GamefeelHandler.instance.AddPerlinShakeProximity(endpoint, 5f, 0.2f, 15f, 10f); } else { Character.localCharacter.refs.items.SpawnItemInHand(itemToSpawnName2); } } } } public class Action_Revolver_Self : ItemAction { public bool consumeOnFullyUsed = true; private static readonly ManualLogSource Logger = Logger.CreateLogSource("Action_Revolver"); public static Random random = new Random(); public Revolver revolver; public static Dictionary<BiomeType, List<SpawnPool>> BiomeSpawnPools = new Dictionary<BiomeType, List<SpawnPool>> { { (BiomeType)0, new List<SpawnPool>(7) { (SpawnPool)64, (SpawnPool)32768, (SpawnPool)65536, (SpawnPool)1024, (SpawnPool)32768, (SpawnPool)65536, (SpawnPool)1024 } }, { (BiomeType)1, new List<SpawnPool>(7) { (SpawnPool)256, (SpawnPool)2048, (SpawnPool)32768, (SpawnPool)65536, (SpawnPool)2048, (SpawnPool)32768, (SpawnPool)65536 } }, { (BiomeType)2, new List<SpawnPool>(7) { (SpawnPool)512, (SpawnPool)4096, (SpawnPool)32768, (SpawnPool)65536, (SpawnPool)4096, (SpawnPool)32768, (SpawnPool)65536 } }, { (BiomeType)6, new List<SpawnPool>(7) { (SpawnPool)4194304, (SpawnPool)16777216, (SpawnPool)32768, (SpawnPool)65536, (SpawnPool)16777216, (SpawnPool)32768, (SpawnPool)65536 } }, { (BiomeType)3, new List<SpawnPool>(7) { (SpawnPool)262144, (SpawnPool)8192, (SpawnPool)32768, (SpawnPool)65536, (SpawnPool)8192, (SpawnPool)32768, (SpawnPool)65536 } } }; public void Start() { revolver = ((Component)this).GetComponent<Revolver>(); } public override void RunAction() { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_00e7: 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_01d8: 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) int viewID = ((MonoBehaviourPun)Character.localCharacter).photonView.ViewID; int num = Random.Range(1, 6); if (revolver.shotsLeft <= 0) { ((MonoBehaviourPun)Character.localCharacter).photonView.RPC("PlaySoundGlobal", (RpcTarget)0, new object[2] { viewID, "Au_Empty.ogg" }); } else if (num != 2 && num != 4 && revolver.shotsLeft > 0) { BiomeType currentBiome = Singleton<MapHandler>.Instance.GetCurrentBiome(); revolver.useOnce(); Logger.LogInfo((object)("The current biome is " + ((object)(BiomeType)(ref currentBiome)).ToString())); List<SpawnPool> list = BiomeSpawnPools[currentBiome]; int count = list.Count; int index = Random.Range(0, count); SpawnPool poolToChooseFrom = list[index]; Item val = FindItemToSpawnNotRevolver(poolToChooseFrom); ((MonoBehaviourPun)Character.localCharacter).photonView.RPC("PlaySoundGlobal", (RpcTarget)0, new object[2] { viewID, "Au_Winner.ogg" }); Character.localCharacter.refs.items.SpawnItemInHand(((Object)val).name); } else if ((num == 2 || num == 4) && revolver.shotsLeft > 0) { revolver.useOnce(); ((MonoBehaviourPun)Character.localCharacter).photonView.RPC("PlaySoundGlobal", (RpcTarget)0, new object[2] { viewID, "Au_Revolver.ogg" }); Character.localCharacter.refs.afflictions.AddStatus((STATUSTYPE)0, 0.5f, false); ((Component)Character.localCharacter).GetComponent<RevolverBlowbackWatcher>().ShootSelfT(0.25f, Character.localCharacter, ((Component)Camera.main).transform.forward); GamefeelHandler.instance.AddPerlinShakeProximity(((Component)Camera.main).transform.forward, 5f, 0.2f, 15f, 10f); } } private Item FindItemToSpawnNotRevolver(SpawnPool poolToChooseFrom) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) Item component = LootData.GetRandomItem(poolToChooseFrom).GetComponent<Item>(); while (component.GetName() == "Revolver") { component = LootData.GetRandomItem(poolToChooseFrom).GetComponent<Item>(); } return component; } } public class Revolver : ItemComponent { private static readonly ManualLogSource Logger = Logger.CreateLogSource("Revolver"); public int shotsLeft; public const DataEntryKey Shots = 99; public void Start() { ((MonoBehaviour)this).StartCoroutine(InitShotsRoutine()); } private void InitShots() { if (((ItemComponent)this).HasData((DataEntryKey)99)) { shotsLeft = ((ItemComponent)this).GetData<IntItemData>((DataEntryKey)99).Value; } else if (base.photonView.IsMine) { RandomizeShots(); base.photonView.RPC("RPC_SyncShots", (RpcTarget)0, new object[1] { shotsLeft }); } } public void useOnce() { if (shotsLeft > 0) { int num = shotsLeft - 1; base.photonView.RPC("RPC_SyncShots", (RpcTarget)0, new object[1] { num }); } } private void RandomizeShots() { shotsLeft = Random.Range(1, RevolverConfig.maxRevolverShots.Value + 1); ((ItemComponent)this).GetData<IntItemData>((DataEntryKey)99).Value = shotsLeft; } [PunRPC] public void RPC_SyncShots(int shots) { shotsLeft = shots; ((ItemComponent)this).GetData<IntItemData>((DataEntryKey)99).Value = shotsLeft; Logger.LogInfo((object)("Synced shots to " + shotsLeft + " AND " + ((ItemComponent)this).GetData<IntItemData>((DataEntryKey)99).Value)); } public override void OnInstanceDataSet() { ((MonoBehaviour)this).StartCoroutine(InitShotsRoutine()); } private IEnumerator InitShotsRoutine() { while (!Object.op_Implicit((Object)(object)Character.localCharacter)) { yield return null; } InitShots(); } } public class SFXManagerForRevolver : MonoBehaviourPun { private static readonly ManualLogSource Logger = Logger.CreateLogSource("SFXManagerForRevolver"); [PunRPC] public void PlaySoundGlobal(int photonID, string soundToPlay) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) Character val = default(Character); if (Character.GetCharacterWithPhotonID(photonID, ref val)) { SFXManagerForRevolver component = ((Component)val).GetComponent<SFXManagerForRevolver>(); component.PlaySound(val.Center, soundToPlay); } } public void PlaySound(Vector3 pos, string sound) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_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) foreach (KeyValuePair<string, SFX_Instance> sFXInstance in Plugin.SFXInstances) { Logger.LogInfo((object)("SFX Instance: " + sFXInstance.Key)); } Plugin.SFXInstances[sound].Play(pos + Vector3.up * 0.2f + Vector3.forward * 0.1f); } } namespace BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace LastResort { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("spidersgeorg-RarityRoulette", "RarityRoulette", "0.1.0")] public class Plugin : BaseUnityPlugin { internal static Dictionary<string, SFX_Instance> SFXInstances = new Dictionary<string, SFX_Instance>(); public const string Id = "spidersgeorg-RarityRoulette"; internal static ManualLogSource Log { get; private set; } = null; public static Plugin Instance { get; private set; } internal static AssetBundle Bundle { get; set; } internal static ModDefinition Definition { get; set; } public static string Name => "RarityRoulette"; public static string Version => "0.1.0"; private void Awake() { //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Expected O, but got Unknown RevolverConfig.AllRevolverConfigs(((BaseUnityPlugin)this).Config); Log = ((BaseUnityPlugin)this).Logger; BundleLoader.LoadBundleWithName((BaseUnityPlugin)(object)this, "revolver.peakbundle", (Action<PeakBundle>)delegate(PeakBundle peakBundle) { peakBundle.Mod.RegisterContent(); UnityItemContent val2 = peakBundle.LoadAsset<UnityItemContent>("Revolver"); GameObject itemPrefab = val2.ItemPrefab; itemPrefab.AddComponent<Revolver>(); Action_Revolver_Self action_Revolver_Self = itemPrefab.AddComponent<Action_Revolver_Self>(); Action_Revolver_Others action_Revolver_Others = itemPrefab.AddComponent<Action_Revolver_Others>(); ((ItemAction)action_Revolver_Others).OnCastFinished = true; }); LocalizedText.mainTable["NAME_REVOLVER"] = new List<string>(15) { "Revolver", "Revolver", "Revolver", "Revolver", "Revolver", "Revolver", "Revolver", "Revolver", "Revolver", "Revolver", "Revolver", "Revolver", "Revolver", "Revolver", "Revolver" }; LocalizedText.mainTable["SHOOT SELF"] = new List<string>(15) { "Shoot Self", "Shoot Self", "Shoot Self", "Shoot Self", "Shoot Self", "Shoot Self", "Shoot Self", "Shoot Self", "Shoot Self", "Shoot Self", "Shoot Self", "Shoot Self", "Shoot Self", "Shoot Self", "Shoot Self" }; Log.LogInfo((object)("Plugin " + Name + " is loaded!")); Harmony val = new Harmony(Name ?? ""); val.PatchAll(); LoadCustomAudio(); } private void LoadCustomAudio() { string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string[] files = Directory.GetFiles(directoryName, "*.ogg"); if (files.Length == 0) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"No .ogg file found."); return; } string[] array = files; foreach (string fileName in array) { ((MonoBehaviour)this).StartCoroutine(LoadAudio(fileName)); } } private IEnumerator LoadAudio(string fileName) { string url = "file://" + fileName; UnityWebRequest webRequest = UnityWebRequestMultimedia.GetAudioClip(url, (AudioType)14); try { yield return webRequest.SendWebRequest(); if ((int)webRequest.result == 2 || (int)webRequest.result == 3) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("Failed to load .ogg file: " + webRequest.error)); yield break; } SFX_Instance shotSFX = ScriptableObject.CreateInstance<SFX_Instance>(); shotSFX.clips = (AudioClip[])(object)new AudioClip[1] { DownloadHandlerAudioClip.GetContent(webRequest) }; shotSFX.settings = new SFX_Settings { volume = 1f, range = 500f, cooldown = 1f }; ((BaseUnityPlugin)this).Logger.LogInfo((object)("FILE NAME IS " + GetFileNameFromPath(fileName))); SFXInstances[GetFileNameFromPath(fileName)] = shotSFX; } finally { ((IDisposable)webRequest)?.Dispose(); } } private string GetFileNameFromPath(string filePath) { int num = filePath.LastIndexOf('\\'); if (num == -1) { return filePath; } return filePath.Substring(num + 1); } } internal class RevolverBlowbackWatcher : MonoBehaviour { private static readonly ManualLogSource Logger = Logger.CreateLogSource("Revolver"); public float shotTime; private Character characterGettingShot; private Vector3 shotDirection; public void Start() { characterGettingShot = Character.localCharacter; } public void Update() { if (shotTime > 0f) { shotTime -= Time.deltaTime; UpdateShotPhysicsT(); } } public void ShootSelfT(float howLongToFly, Character whoIsGettingShot, Vector3 whichDirectionShooting) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) shotTime = howLongToFly; characterGettingShot = whoIsGettingShot; shotDirection = whichDirectionShooting; } public void UpdateShotPhysicsT() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) Vector3 val = shotDirection * 25f * -1f; characterGettingShot.Fall(0.5f, 0f); characterGettingShot.AddForce(val, 1f, 1f); } } } namespace LastResort.Utils { public class RevolverConfig { public static ConfigEntry<int> maxRevolverShots; public static void AllRevolverConfigs(ConfigFile revolverConfigFile) { maxRevolverShots = revolverConfigFile.Bind<int>("Revolver", "Max Shots", 4, "The maximum number of shots a revolver can have."); } } } namespace LastResort.Patches { [HarmonyPatch(typeof(CharacterItems))] internal class DoUsingPatchForRevolver { [HarmonyPatch("DoUsing")] [HarmonyPrefix] private static bool RevolverDoUsing(CharacterItems __instance) { if (Object.op_Implicit((Object)(object)__instance.character.data.currentItem) && !__instance.character.data.passedOut && !__instance.character.data.fullyPassedOut) { if (__instance.character.input.usePrimaryWasPressed && __instance.character.data.currentItem.CanUsePrimary()) { __instance.character.data.currentItem.StartUsePrimary(); } if (__instance.character.input.usePrimaryIsPressed && __instance.character.data.currentItem.CanUsePrimary()) { __instance.character.data.currentItem.ContinueUsePrimary(); } if (__instance.character.input.usePrimaryWasReleased || (__instance.character.data.currentItem.isUsingPrimary && !__instance.character.data.currentItem.CanUsePrimary())) { __instance.character.data.currentItem.CancelUsePrimary(); } if (!__instance.character.CanDoInput()) { __instance.character.data.currentItem.CancelUsePrimary(); } if (__instance.character.data.currentItem.GetName() == "Revolver") { if (__instance.character.input.useSecondaryIsPressed) { __instance.character.data.currentItem.StartUseSecondary(); } if (__instance.character.input.useSecondaryIsPressed) { __instance.character.data.currentItem.ContinueUseSecondary(); } if (__instance.character.input.useSecondaryWasReleased) { __instance.character.data.currentItem.CancelUseSecondary(); } } else if (__instance.character.data.currentItem.GetName() != "Revolver") { if (__instance.character.input.useSecondaryIsPressed && __instance.character.data.currentItem.CanUseSecondary()) { __instance.character.data.currentItem.StartUseSecondary(); } if (__instance.character.input.useSecondaryIsPressed && __instance.character.data.currentItem.CanUseSecondary()) { __instance.character.data.currentItem.ContinueUseSecondary(); } if (__instance.character.input.useSecondaryWasReleased || (__instance.character.data.currentItem.isUsingSecondary && !__instance.character.data.currentItem.CanUseSecondary())) { __instance.character.data.currentItem.CancelUseSecondary(); } } if (__instance.character.input.scrollButtonLeftWasPressed) { __instance.character.data.currentItem.ScrollButtonLeft(); } if (__instance.character.input.scrollButtonRightWasPressed) { __instance.character.data.currentItem.ScrollButtonRight(); } if (__instance.character.input.scrollInput != 0f) { __instance.character.data.currentItem.Scroll(__instance.character.input.scrollInput); } } return false; } } [HarmonyPatch(typeof(GUIManager))] internal class RevolverGUIPatch { [HarmonyPatch("LateUpdate")] [HarmonyPostfix] private static void AddAlwaysShowSecondaryUse(GUIManager __instance) { if (Object.op_Implicit((Object)(object)Character.localCharacter) && Object.op_Implicit((Object)(object)Character.localCharacter.data.currentItem) && Character.localCharacter.data.currentItem.GetItemName((ItemInstanceData)null) == "Revolver") { ((Component)__instance.itemPromptSecondary).gameObject.SetActive(true); ((TMP_Text)__instance.itemPromptSecondary).text = __instance.GetSecondaryInteractPrompt(Character.localCharacter.data.currentItem); } } } [HarmonyPatch(typeof(Item))] internal class RevolverItemPatch { [HarmonyPatch("ContinueUseSecondary")] [HarmonyPrefix] private static bool ContinueSecondaryCastRevolver(Item __instance) { if (!__instance.isUsingPrimary && __instance.isUsingSecondary && __instance.usingTimePrimary > 0f && __instance.castProgress >= 1f && !__instance.finishedCast) { if (__instance.GetName() == "Revolver") { ((ItemActionBase)((Component)__instance).GetComponent<Action_Revolver_Self>()).RunAction(); } __instance.FinishCastSecondary(); } if (__instance.isUsingPrimary || !__instance.isUsingSecondary) { return false; } if (__instance.usingTimePrimary > 0f) { __instance.castProgress += 1f / __instance.totalSecondaryUsingTime * Time.deltaTime; if (__instance.castProgress >= 1f && __instance.OnSecondaryHeld != null) { __instance.OnSecondaryHeld(); } } else if (__instance.OnSecondaryHeld != null) { __instance.OnSecondaryHeld(); } return false; } } [HarmonyPatch(typeof(Character))] internal class RevolverPatch { [HarmonyPatch("Awake")] [HarmonyPostfix] private static void AddRevolverBlowbackWatcher(Character __instance) { ((Component)__instance).gameObject.AddComponent<RevolverBlowbackWatcher>(); } } [HarmonyPatch(typeof(Character))] internal static class CharacterAwake { [HarmonyPatch("Awake")] [HarmonyPostfix] private static void AddSFXManagerForRevolver(Character __instance) { ((Component)__instance).gameObject.AddComponent<SFXManagerForRevolver>(); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }