using 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+1ba125aa4268242fe8422e21a56fbb2f315aa48f")] [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] [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; } } } 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; public Animator anim; private RaycastHit revolverLineHit; private RaycastHit[] revolverSphereHits; public Transform revolverSpawnTransform; public static Dictionary> BiomeSpawnPools = new Dictionary> { { (BiomeType)0, new List(7) { (SpawnPool)64, (SpawnPool)32768, (SpawnPool)65536, (SpawnPool)1024, (SpawnPool)32768, (SpawnPool)65536, (SpawnPool)1024 } }, { (BiomeType)1, new List(7) { (SpawnPool)256, (SpawnPool)2048, (SpawnPool)32768, (SpawnPool)65536, (SpawnPool)2048, (SpawnPool)32768, (SpawnPool)65536 } }, { (BiomeType)2, new List(7) { (SpawnPool)512, (SpawnPool)4096, (SpawnPool)32768, (SpawnPool)65536, (SpawnPool)4096, (SpawnPool)32768, (SpawnPool)65536 } }, { (BiomeType)6, new List(7) { (SpawnPool)4194304, (SpawnPool)16777216, (SpawnPool)32768, (SpawnPool)65536, (SpawnPool)16777216, (SpawnPool)32768, (SpawnPool)65536 } }, { (BiomeType)3, new List(6) { (SpawnPool)8192, (SpawnPool)32768, (SpawnPool)65536, (SpawnPool)8192, (SpawnPool)32768, (SpawnPool)65536 } } }; public void Start() { revolver = ((Component)this).GetComponent(); anim = ((Component)revolver).GetComponent(); } public unsafe 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_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_0386: 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(); 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_revolversfx.ogg" }); } else if (num != 2 && num != 4 && revolver.shotsLeft > 0) { BiomeType currentBiome = Singleton.Instance.GetCurrentBiome(); Logger.LogInfo((object)("The current biome is " + ((object)(*(BiomeType*)(¤tBiome))/*cast due to .constrained prefix*/).ToString())); revolver.useOnce(); Array values = Enum.GetValues(typeof(SpawnPool)); List 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_revolversfx.ogg" }); revolver.TriggerFlag(); 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_revolversfx.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_revolversfx.ogg" }); } else { ((MonoBehaviourPun)Character.localCharacter).photonView.RPC("PlaySoundGlobal", (RpcTarget)0, new object[2] { viewID, "Au_Empty_revolversfx.ogg" }); } } private Item FindItemToSpawnNotRevolver(SpawnPool poolToChooseFrom) { //IL_0001: 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) Item component = LootData.GetRandomItem(poolToChooseFrom, false).GetComponent(); while (component.GetName() == "Revolver") { component = LootData.GetRandomItem(poolToChooseFrom, false).GetComponent(); } 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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, RevolverConfig.revolverDamage.Value, false, true, true); ((Component)Character.localCharacter).GetComponent().ShootSelfT(RevolverConfig.revolverBlowback.Value, 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 Animator anim; public static Dictionary> BiomeSpawnPools = new Dictionary> { { (BiomeType)0, new List(7) { (SpawnPool)64, (SpawnPool)32768, (SpawnPool)65536, (SpawnPool)1024, (SpawnPool)32768, (SpawnPool)65536, (SpawnPool)1024 } }, { (BiomeType)1, new List(7) { (SpawnPool)256, (SpawnPool)2048, (SpawnPool)32768, (SpawnPool)65536, (SpawnPool)2048, (SpawnPool)32768, (SpawnPool)65536 } }, { (BiomeType)2, new List(7) { (SpawnPool)512, (SpawnPool)4096, (SpawnPool)32768, (SpawnPool)65536, (SpawnPool)4096, (SpawnPool)32768, (SpawnPool)65536 } }, { (BiomeType)6, new List(7) { (SpawnPool)4194304, (SpawnPool)16777216, (SpawnPool)32768, (SpawnPool)65536, (SpawnPool)16777216, (SpawnPool)32768, (SpawnPool)65536 } }, { (BiomeType)3, new List(6) { (SpawnPool)8192, (SpawnPool)32768, (SpawnPool)65536, (SpawnPool)8192, (SpawnPool)32768, (SpawnPool)65536 } } }; public void Start() { revolver = ((Component)this).GetComponent(); anim = ((Component)revolver).GetComponent(); } public unsafe 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_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_020a: 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_revolversfx.ogg" }); } else if (num != 2 && num != 4 && revolver.shotsLeft > 0) { BiomeType currentBiome = Singleton.Instance.GetCurrentBiome(); revolver.useOnce(); Logger.LogInfo((object)("The current biome is " + ((object)(*(BiomeType*)(¤tBiome))/*cast due to .constrained prefix*/).ToString())); List list = BiomeSpawnPools[currentBiome]; int count = list.Count; int index = Random.Range(0, count); SpawnPool poolToChooseFrom = list[index]; Item val = FindItemToSpawnNotRevolver(poolToChooseFrom); revolver.TriggerFlag(); ((MonoBehaviourPun)Character.localCharacter).photonView.RPC("PlaySoundGlobal", (RpcTarget)0, new object[2] { viewID, "Au_Winner_revolversfx.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_revolversfx.ogg" }); Character.localCharacter.refs.afflictions.AddStatus((STATUSTYPE)0, RevolverConfig.revolverDamage.Value, false, true, true); ((Component)Character.localCharacter).GetComponent().ShootSelfT(RevolverConfig.revolverBlowback.Value, 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_0011: Unknown result type (might be due to invalid IL or missing references) Item component = LootData.GetRandomItem(poolToChooseFrom, false).GetComponent(); while (component.GetName() == "Revolver") { component = LootData.GetRandomItem(poolToChooseFrom, false).GetComponent(); } return component; } } public class Revolver : ItemComponent { private static readonly ManualLogSource Logger = Logger.CreateLogSource("Revolver"); public int shotsLeft; public const DataEntryKey Shots = (DataEntryKey)99; public Revolver revolver; public Animator anim; public void Start() { ((MonoBehaviour)this).StartCoroutine(InitShotsRoutine()); revolver = ((Component)this).GetComponent(); anim = ((Component)revolver).GetComponent(); } private void InitShots() { if (((ItemComponent)this).HasData((DataEntryKey)99)) { shotsLeft = ((ItemComponent)this).GetData((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((DataEntryKey)99).Value = shotsLeft; } [PunRPC] public void RPC_SyncShots(int shots) { shotsLeft = shots; ((ItemComponent)this).GetData((DataEntryKey)99).Value = shotsLeft; Logger.LogInfo((object)("Synced shots to " + shotsLeft + " AND " + ((ItemComponent)this).GetData((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 void TriggerFlag() { base.photonView.RPC("RPC_TriggerFlag", (RpcTarget)0, Array.Empty()); } [PunRPC] public void RPC_TriggerFlag() { anim.SetTrigger("ShowFlag"); } public void SetTurnToSelf(bool turnVal) { base.photonView.RPC("RPC_SetTurnToSelf", (RpcTarget)0, new object[1] { turnVal }); } [PunRPC] public void RPC_SetTurnToSelf(bool turnVal) { anim.SetBool("TurnToSelf", turnVal); if (turnVal) { anim.SetFloat("TurnFloat", 0.75f); } else { anim.SetFloat("TurnFloat", -0.75f); } } } public class RevolverBonkable : MonoBehaviour { private static readonly ManualLogSource Logger = Logger.CreateLogSource("RevolverBonkable"); private Item item; public float minBonkVelocity = 20f; public float ragdollTime = 1f; public float bonkForce = 200f; public float bonkRange = 0.5f; public float lastBonkedTime; private float bonkCooldown = 1f; private void Awake() { item = ((Component)this).GetComponent(); } private void OnCollisionEnter(Collision coll) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (((MonoBehaviourPun)item).photonView.IsMine && (int)item.itemState == 0 && Object.op_Implicit((Object)(object)item.rig)) { Vector3 relativeVelocity = coll.relativeVelocity; if (((Vector3)(ref relativeVelocity)).magnitude > minBonkVelocity) { Bonk(coll); Logger.LogInfo((object)"BONKING FIRED OFF"); } } } private void Bonk(Collision coll) { //IL_007c: 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_00b3: 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) //IL_00c3: 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) Character componentInParent = coll.gameObject.GetComponentInParent(); Logger.LogInfo((object)"IN BONKING FUNC"); if (Object.op_Implicit((Object)(object)componentInParent) && Time.time > lastBonkedTime + bonkCooldown) { Logger.LogInfo((object)"FIRE OFF BONK"); componentInParent.Fall(ragdollTime, 0f); for (int i = 0; i < Plugin.bonk.Count; i++) { Plugin.bonk[i].Play(((Component)this).transform.position); } lastBonkedTime = Time.time; Vector3 relativeVelocity = coll.relativeVelocity; componentInParent.AddForceAtPosition(-((Vector3)(ref relativeVelocity)).normalized * bonkForce, ((ContactPoint)(ref coll.contacts[0])).point, bonkRange); } } } 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(); 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 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 SFXInstances = new Dictionary(); internal static List bonk = new List(); 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)delegate(PeakBundle peakBundle) { peakBundle.Mod.RegisterContent(); UnityItemContent val2 = peakBundle.LoadAsset("Revolver"); GameObject itemPrefab = val2.ItemPrefab; itemPrefab.AddComponent(); Action_Revolver_Self action_Revolver_Self = itemPrefab.AddComponent(); Action_Revolver_Others action_Revolver_Others = itemPrefab.AddComponent(); ((ItemAction)action_Revolver_Others).OnCastFinished = true; RevolverBonkable revolverBonkable = itemPrefab.AddComponent(); }); LocalizedText.mainTable["NAME_REVOLVER"] = new List(15) { "Revolver", "Revolver", "Revolver", "Revolver", "Revolver", "Revolver", "Revolver", "Revolver", "Revolver", "Revolver", "Revolver", "Revolver", "Revolver", "Revolver", "Revolver" }; LocalizedText.mainTable["SHOOT SELF"] = new List(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(); LoadBonkAudio(); } private void LoadCustomAudio() { string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string[] files = Directory.GetFiles(directoryName, "*_revolversfx.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 void LoadBonkAudio() { string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string[] files = Directory.GetFiles(directoryName, "*_bonksfx.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(LoadBonkAudio(fileName)); } } private IEnumerator LoadBonkAudio(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) { SFX_Instance shotSFX = ScriptableObject.CreateInstance(); shotSFX.clips = (AudioClip[])(object)new AudioClip[1] { DownloadHandlerAudioClip.GetContent(webRequest) }; shotSFX.settings = new SFX_Settings { volume = 1f, range = 500f, cooldown = 1f }; bonk.Add(shotSFX); } } finally { ((IDisposable)webRequest)?.Dispose(); } } 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(); 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 maxRevolverShots; public static ConfigEntry revolverDamage; public static ConfigEntry revolverBlowback; public static void AllRevolverConfigs(ConfigFile revolverConfigFile) { maxRevolverShots = revolverConfigFile.Bind("Revolver", "Max Shots", 4, "The maximum number of shots a revolver can have."); revolverDamage = revolverConfigFile.Bind("Revolver", "Revolver Damage", 0.5f, "The amount of damage you/a friend takes upon an unsuccessful shot of the revolver. Make this a value somewhere between 0.0 for no damage, to 1.0 for maximum damage!"); revolverBlowback = revolverConfigFile.Bind("Revolver", "Revolver Blowback", 0.25f, "How far back you/a friend goes flying upon an unsuccessful shot of the revolver. Make this a value somewhere between 0.0 for no blowback, to 1.0 for a lot of blowback! You can of course go higher, but beware it has not been tested :) "); } } } 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) { if (!__instance.character.input.usePrimaryIsPressed) { ((Component)__instance.character.data.currentItem).GetComponent().SetTurnToSelf(turnVal: true); } else { ((Component)__instance.character.data.currentItem).GetComponent().SetTurnToSelf(turnVal: false); } __instance.character.data.currentItem.StartUseSecondary(); } if (__instance.character.input.useSecondaryIsPressed) { if (!__instance.character.input.usePrimaryIsPressed) { ((Component)__instance.character.data.currentItem).GetComponent().SetTurnToSelf(turnVal: true); } else { ((Component)__instance.character.data.currentItem).GetComponent().SetTurnToSelf(turnVal: false); } __instance.character.data.currentItem.ContinueUseSecondary(); } if (__instance.character.input.useSecondaryWasReleased) { ((Component)__instance.character.data.currentItem).GetComponent().SetTurnToSelf(turnVal: false); __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.scrollBackwardWasPressed) { __instance.character.data.currentItem.ScrollButtonBackwardPressed(); } if (__instance.character.input.scrollForwardWasPressed) { __instance.character.data.currentItem.ScrollButtonForwardPressed(); } if (__instance.character.input.scrollBackwardIsPressed) { __instance.character.data.currentItem.ScrollButtonBackwardHeld(); } if (__instance.character.input.scrollForwardIsPressed) { __instance.character.data.currentItem.ScrollButtonForwardHeld(); } 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()).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(); } } [HarmonyPatch(typeof(Character))] internal static class CharacterAwake { [HarmonyPatch("Awake")] [HarmonyPostfix] private static void AddSFXManagerForRevolver(Character __instance) { ((Component)__instance).gameObject.AddComponent(); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }