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 BeggarAndBouncer v1.0.0
BeggarAndBouncer.dll
Decompiled 14 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using Microsoft.CodeAnalysis; using On.RoR2; using R2API; using RoR2; using UnityEngine; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("BeggarAndBouncer")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+24240699214055d0a6ae9e3b6ae922fce0c5d7a6")] [assembly: AssemblyProduct("BeggarAndBouncer")] [assembly: AssemblyTitle("BeggarAndBouncer")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 BeggarAndBouncer { [BepInPlugin("com.deltalines.beggarandbouncer", "The Beggar & The Bouncer", "0.2.9")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { [CompilerGenerated] private static class <>O { public static hook_GetInteractability <0>__GooberGetInteractability; public static hook_OnInteractionBegin <1>__GooberOnInteractionBegin; } public const string Guid = "com.deltalines.beggarandbouncer"; public const string Version = "0.2.9"; internal static Plugin Instance; private static readonly Vector3 BeggarPosition = new Vector3(-57.21f, -24.94f, -0.89f); private static readonly Vector3 BouncerPosition = new Vector3(-73.66f, -24.94f, 8.61f); private const string PardonToken = "BB_BOUNCER_PARDONED"; private const string BouncerTitle = "BB_BOUNCER_TITLE"; private const string BeggarTitle = "BB_BEGGAR_TITLE"; private ConfigEntry<int> beggarBase; private ConfigEntry<int> beggarLimit; private ConfigEntry<int> guaranteedEvery; private ConfigEntry<int> bouncerBase; private ConfigEntry<float> beggarMultiplier; private ConfigEntry<float> bouncerMultiplier; private ConfigEntry<float> winChance; private ConfigEntry<bool> detailedLogging; private ConfigEntry<bool> enableFlavorText; private GameObject beggarPrefab; private GameObject bouncerPrefab; private PurchaseInteraction beggar; private PurchaseInteraction bouncer; private GameObject kickOutShop; private int gamblesThisVisit; private int pardonsThisRun; private Run lastRun; private bool pardonedThisVisit; private float updateClock; private bool seenBazaar; private string[] beggarThanksTokens; private string[] beggarGiftsTokens; private string[] bouncerPardonTokens; private static GameObject pickupVisualSource; private static bool pickupSourceChecked; private void Awake() { //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Expected O, but got Unknown //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Expected O, but got Unknown Instance = this; beggarBase = ((BaseUnityPlugin)this).Config.Bind<int>("Beggar", "StartingCost", 1, "Lunar Coins for the first gamble."); beggarMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Beggar", "CostMultiplier", 2f, "Each gamble costs ceil(start * multiplier^previousAttempts)."); beggarLimit = ((BaseUnityPlugin)this).Config.Bind<int>("Beggar", "MaxAttemptsPerVisit", 15, "Shared maximum gambles each visit to the Bazaar."); guaranteedEvery = ((BaseUnityPlugin)this).Config.Bind<int>("Beggar", "GuaranteeEveryAttempts", 5, "Guarantee a reward on every Nth attempt. 0 disables guarantees."); winChance = ((BaseUnityPlugin)this).Config.Bind<float>("Beggar", "OrdinaryWinChance", 0.05f, "Chance of receiving a reward on non-guaranteed gambles, 0 to 1."); bouncerBase = ((BaseUnityPlugin)this).Config.Bind<int>("Bouncer", "StartingPardonCost", 10, "Lunar Coins required for the first pardon."); bouncerMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Bouncer", "PardonCostMultiplier", 2.5f, "Each successive pardon costs ceil(start * multiplier^previousPardons)."); detailedLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "VerboseLogging", false, "Extra interaction and prize logging."); enableFlavorText = ((BaseUnityPlugin)this).Config.Bind<bool>("Dialogue", "EnableFlavorText", true, "Broadcast character dialogue after successful Lunar Coin purchases."); if (Mathf.Approximately(winChance.Value, 0.25f) || Mathf.Approximately(winChance.Value, 0.15f) || Mathf.Approximately(winChance.Value, 0.1f)) { winChance.Value = 0.05f; ((BaseUnityPlugin)this).Logger.LogInfo((object)"[BeggarBouncer] Migrated prior default gamble odds to 5%."); } if (Mathf.Approximately(beggarMultiplier.Value, 1.5f)) { beggarMultiplier.Value = 2f; ((BaseUnityPlugin)this).Logger.LogInfo((object)"[BeggarBouncer] Migrated prior default Beggar cost multiplier to 2x."); } LanguageAPI.Add("BB_BEGGAR_TITLE", "The Beggar"); LanguageAPI.Add("BB_BEGGAR_CONTEXT", "Gamble with the Beggar"); LanguageAPI.Add("BB_BOUNCER_TITLE", "The Bouncer"); LanguageAPI.Add("BB_BOUNCER_CONTEXT", "Bribe the Bouncer"); LanguageAPI.Add("BB_BOUNCER_PARDONED", "The Bouncer (Paid)"); LanguageAPI.Add("BB_BEGGAR_EMPTY", "The Beggar has nothing left to offer"); string[] lines = new string[6] { "The Beggar: Oh, how kind! Thank you!", "The Beggar: Thank you, stranger! Maybe one day I'll have enough to get past that fellow over there.", "The Beggar: The big one won't let me inside. Says I don't have enough coins. Can you imagine?", "The Beggar: Oh, another coin! Don't tell the Bouncer. He'll probably want it.", "The Beggar: The blue fellow says I'm not welcome. I don't think I've done anything wrong...", "The Beggar: Another coin? You're too generous!" }; string[] lines2 = new string[5] { "The Beggar: Found this near that purple portal down below. Don't know what it does, but it's yours!", "The Beggar: The Bouncer wouldn't take this as payment. Maybe you'll find a use for it.", "The Beggar: I went exploring down below. Found something strange. Here, take it!", "The Beggar: Those purple things give me the creeps. This one followed me home!", "The Beggar: They won't let me sell these inside, so I suppose you can have one." }; string[] lines3 = new string[5] { "The Bouncer: The boss says you're allowed back in. Behave yourself this time.", "The Bouncer: You're lucky the boss is feeling generous. Don't push it.", "The Bouncer: You're back in. Keep your weapons to yourself this time.", "The Bouncer: You're back in. And no, your little friend over there still isn't welcome.", "The Bouncer: Consider this your final warning. Again." }; beggarThanksTokens = RegisterLines("BB_THANKS", lines); beggarGiftsTokens = RegisterLines("BB_GIFT", lines2); bouncerPardonTokens = RegisterLines("BB_PARDON", lines3); TryBuildPrefabs(); object obj = <>O.<0>__GooberGetInteractability; if (obj == null) { hook_GetInteractability val = GooberGetInteractability; <>O.<0>__GooberGetInteractability = val; obj = (object)val; } PurchaseInteraction.GetInteractability += (hook_GetInteractability)obj; object obj2 = <>O.<1>__GooberOnInteractionBegin; if (obj2 == null) { hook_OnInteractionBegin val2 = GooberOnInteractionBegin; <>O.<1>__GooberOnInteractionBegin = val2; obj2 = (object)val2; } PurchaseInteraction.OnInteractionBegin += (hook_OnInteractionBegin)obj2; SceneManager.sceneLoaded += OnSceneLoaded; ((MonoBehaviour)this).StartCoroutine(InitializeExistingScene()); ((BaseUnityPlugin)this).Logger.LogInfo((object)"[BeggarBouncer] v0.2.9 loaded. Registered entrance interaction prefabs."); } private void OnDestroy() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown SceneManager.sceneLoaded -= OnSceneLoaded; object obj = <>O.<0>__GooberGetInteractability; if (obj == null) { hook_GetInteractability val = GooberGetInteractability; <>O.<0>__GooberGetInteractability = val; obj = (object)val; } PurchaseInteraction.GetInteractability -= (hook_GetInteractability)obj; object obj2 = <>O.<1>__GooberOnInteractionBegin; if (obj2 == null) { hook_OnInteractionBegin val2 = GooberOnInteractionBegin; <>O.<1>__GooberOnInteractionBegin = val2; obj2 = (object)val2; } PurchaseInteraction.OnInteractionBegin -= (hook_OnInteractionBegin)obj2; } private static Interactability GooberGetInteractability(orig_GetInteractability orig, PurchaseInteraction self, Interactor activator) { //IL_0003: 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_000b: Invalid comparison between Unknown and I4 //IL_0025: 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) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) Interactability val = orig.Invoke(self, activator); if ((int)val == 2 || !Object.op_Implicit((Object)(object)self) || !self.Networkavailable || !Object.op_Implicit((Object)(object)activator)) { return val; } if (!Object.op_Implicit((Object)(object)((Component)self).GetComponent<GooberMarker>())) { return val; } NetworkUser val2 = Util.LookUpBodyNetworkUser(((Component)activator).gameObject); if (!Object.op_Implicit((Object)(object)val2)) { return val; } if ((ulong)val2.lunarCoins < (ulong)Math.Max(0, self.cost)) { return (Interactability)2; } return val; } private static void GooberOnInteractionBegin(orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator) { if (NetworkServer.active && Object.op_Implicit((Object)(object)self) && Object.op_Implicit((Object)(object)((Component)self).GetComponent<GooberMarker>())) { if (!self.Networkavailable || !Object.op_Implicit((Object)(object)activator)) { return; } NetworkUser val = Util.LookUpBodyNetworkUser(((Component)activator).gameObject); if (!Object.op_Implicit((Object)(object)val) || (ulong)val.lunarCoins < (ulong)Math.Max(0, self.cost)) { return; } } orig.Invoke(self, activator); } private static string[] RegisterLines(string prefix, string[] lines) { string[] array = new string[lines.Length]; for (int i = 0; i < lines.Length; i++) { array[i] = prefix + "_" + i; LanguageAPI.Add(array[i], lines[i]); } return array; } private void AnnounceRandomLine(string[] tokens) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown if (NetworkServer.active && enableFlavorText.Value && tokens != null && tokens.Length != 0) { Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage { baseToken = tokens[Random.Range(0, tokens.Length)] }); } } private void TryBuildPrefabs() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) try { beggarPrefab = MakePrefab("BB_Beggar_Interactable", isBeggar: true, new Color(0.63f, 0.23f, 0.96f)); bouncerPrefab = MakePrefab("BB_Bouncer_Interactable", isBeggar: false, new Color(0.22f, 0.58f, 1f)); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("[BeggarBouncer] Prefab construction failed: " + ex)); } } private GameObject MakePrefab(string name, bool isBeggar, Color color) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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_0101: Unknown result type (might be due to invalid IL or missing references) GameObject val = PrefabAPI.CreateEmptyPrefab(name); PurchaseInteraction obj = val.AddComponent<PurchaseInteraction>(); obj.costType = GetLunarCoinCostType(); obj.cost = 1; obj.contextToken = (isBeggar ? "BB_BEGGAR_CONTEXT" : "BB_BOUNCER_CONTEXT"); obj.NetworkdisplayNameToken = (isBeggar ? "BB_BEGGAR_TITLE" : "BB_BOUNCER_TITLE"); GameObject val2 = new GameObject("GooberInteractionTrigger"); val2.transform.SetParent(val.transform, false); SphereCollider obj2 = val2.AddComponent<SphereCollider>(); ((Collider)obj2).isTrigger = true; obj2.radius = 1.8f; val2.AddComponent<EntityLocator>().entity = val; GameObject val3 = new GameObject("GooberAura"); val3.transform.SetParent(val.transform, false); val3.transform.localPosition = Vector3.down * 2.3f; Light obj3 = val3.AddComponent<Light>(); obj3.type = (LightType)2; obj3.range = 6.5f; obj3.intensity = 4f; obj3.color = color; GooberMarker gooberMarker = val.AddComponent<GooberMarker>(); gooberMarker.isBeggar = isBeggar; gooberMarker.statuePosition = (isBeggar ? BeggarPosition : BouncerPosition); return val; } private CostTypeIndex GetLunarCoinCostType() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (!Enum.TryParse<CostTypeIndex>("LunarCoin", out CostTypeIndex result)) { throw new InvalidOperationException("CostTypeIndex.LunarCoin is missing in this game version."); } return result; } private IEnumerator InitializeExistingScene() { yield return (object)new WaitForSeconds(2f); if (IsBazaar()) { yield return SpawnWhenReady(); } } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (((Scene)(ref scene)).name.IndexOf("bazaar", StringComparison.OrdinalIgnoreCase) >= 0) { ((MonoBehaviour)this).StartCoroutine(SpawnWhenReady()); } } private IEnumerator SpawnWhenReady() { yield return (object)new WaitForSeconds(2.5f); if (!IsBazaar() || !NetworkServer.active || Object.op_Implicit((Object)(object)beggar) || Object.op_Implicit((Object)(object)bouncer)) { yield break; } if (!Object.op_Implicit((Object)(object)beggarPrefab) || !Object.op_Implicit((Object)(object)bouncerPrefab)) { ((BaseUnityPlugin)this).Logger.LogError((object)"[BeggarBouncer] Interactable prefabs weren't initialized."); yield break; } gamblesThisVisit = 0; pardonedThisVisit = false; kickOutShop = FindKickOutObject(); if (!Object.op_Implicit((Object)(object)kickOutShop)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"[BeggarBouncer] SceneInfo/KickOutOfShop not found. Pardon will not be offered."); } beggar = SpawnGoober(beggarPrefab, BeggarPosition, CalculateCost(beggarBase.Value, beggarMultiplier.Value, 0)); bouncer = SpawnGoober(bouncerPrefab, BouncerPosition, CalculateCost(bouncerBase.Value, bouncerMultiplier.Value, pardonsThisRun)); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[BeggarBouncer] Spawned Beggar=" + ((Object)(object)beggar != (Object)null) + " Bouncer=" + ((Object)(object)bouncer != (Object)null) + " sealed=" + (Object.op_Implicit((Object)(object)kickOutShop) && kickOutShop.activeSelf) + ". Visit gambling counter reset.")); } private PurchaseInteraction SpawnGoober(GameObject prefab, Vector3 statuePos, int price) { //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_000c: 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) //IL_0016: Unknown result type (might be due to invalid IL or missing references) try { GameObject val = Object.Instantiate<GameObject>(prefab, statuePos + Vector3.up * 1.25f, Quaternion.identity); PurchaseInteraction component = val.GetComponent<PurchaseInteraction>(); component.Networkcost = price; component.SetAvailable(true); NetworkServer.Spawn(val); return component; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("[BeggarBouncer] Spawn failed: " + ex)); return null; } } private static bool IsBazaar() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).IsValid()) { return ((Scene)(ref activeScene)).name.IndexOf("bazaar", StringComparison.OrdinalIgnoreCase) >= 0; } return false; } private static GameObject FindKickOutObject() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); Transform[] array = Resources.FindObjectsOfTypeAll<Transform>(); foreach (Transform val in array) { if (Object.op_Implicit((Object)(object)val) && ((Component)val).gameObject.scene == activeScene && ((Object)val).name == "KickOutOfShop" && Object.op_Implicit((Object)(object)val.parent) && ((Object)val.parent).name == "SceneInfo") { return ((Component)val).gameObject; } } return null; } private void Update() { if ((Object)(object)Run.instance != (Object)(object)lastRun) { lastRun = Run.instance; pardonsThisRun = 0; if (Object.op_Implicit((Object)(object)Run.instance)) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"[BeggarBouncer] New run; pardon escalation reset."); } } if (!IsBazaar()) { if (seenBazaar) { beggar = null; bouncer = null; kickOutShop = null; } seenBazaar = false; return; } seenBazaar = true; updateClock += Time.deltaTime; if (updateClock < 0.3f) { return; } updateClock = 0f; if (!Object.op_Implicit((Object)(object)kickOutShop)) { kickOutShop = FindKickOutObject(); } if (Object.op_Implicit((Object)(object)bouncer) && bouncer.NetworkdisplayNameToken == "BB_BOUNCER_PARDONED" && Object.op_Implicit((Object)(object)kickOutShop) && kickOutShop.activeSelf) { kickOutShop.SetActive(false); } if (NetworkServer.active) { if (Object.op_Implicit((Object)(object)bouncer)) { bool available = Object.op_Implicit((Object)(object)kickOutShop) && kickOutShop.activeSelf && !pardonedThisVisit; bouncer.SetAvailable(available); } if (Object.op_Implicit((Object)(object)beggar)) { beggar.SetAvailable(gamblesThisVisit < Math.Max(1, beggarLimit.Value)); } } } internal void ApplyClientPardon() { if (IsBazaar()) { if (!Object.op_Implicit((Object)(object)kickOutShop)) { kickOutShop = FindKickOutObject(); } if (Object.op_Implicit((Object)(object)kickOutShop) && kickOutShop.activeSelf) { kickOutShop.SetActive(false); } } } internal void OnGooberPurchased(bool isBeggar, PurchaseInteraction interaction, Interactor buyer) { if (!NetworkServer.active) { return; } try { if (isBeggar) { ProcessBeggarPurchase(interaction); } else { ProcessBouncerPurchase(interaction); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("[BeggarBouncer] Purchase handler failed: " + ex)); } } private void ProcessBouncerPurchase(PurchaseInteraction pi) { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) if (!pardonedThisVisit) { if (!Object.op_Implicit((Object)(object)kickOutShop) || !kickOutShop.activeSelf) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"[BeggarBouncer] Bouncer purchase occurred without an active kickout barrier."); return; } pardonedThisVisit = true; pardonsThisRun++; pi.NetworkdisplayNameToken = "BB_BOUNCER_PARDONED"; pi.SetAvailable(false); kickOutShop.SetActive(false); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[BeggarBouncer] Bouncer PAID. Barrier deactivated, Newt's hurtbox and hostility left untouched. Pardons this run=" + pardonsThisRun)); PlayUseEffect(((Component)pi).transform.position, new Color(0.22f, 0.58f, 1f)); AnnounceRandomLine(bouncerPardonTokens); } } private unsafe void ProcessBeggarPurchase(PurchaseInteraction pi) { //IL_0075: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_00a3: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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_00d1: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) int num = Math.Max(1, beggarLimit.Value); if (gamblesThisVisit >= num) { return; } gamblesThisVisit++; bool flag = guaranteedEvery.Value > 0 && gamblesThisVisit % guaranteedEvery.Value == 0; bool num2 = flag || Random.value < Mathf.Clamp01(winChance.Value); bool flag2 = false; if (num2) { PickupIndex val = RollItem(); if (val != PickupIndex.none) { Vector3 val2 = BouncerPosition - BeggarPosition; Vector3 normalized = ((Vector3)(ref val2)).normalized; Vector3 val3 = BeggarPosition + Vector3.up * 2f + normalized * 0.4f; PickupDropletController.CreatePickupDroplet(val, val3, normalized * 9f + Vector3.up * 10f); flag2 = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)("[BeggarBouncer] Beggar attempt " + gamblesThisVisit + " WIN (guaranteed=" + flag + ") pickup=" + ((object)(*(PickupIndex*)(&val))/*cast due to .constrained prefix*/).ToString())); } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)"[BeggarBouncer] Beggar succeeded but all reward pools were empty."); } } else if (detailedLogging.Value) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("[BeggarBouncer] Beggar attempt " + gamblesThisVisit + " lost.")); } PlayUseEffect(((Component)pi).transform.position, new Color(0.63f, 0.23f, 0.96f)); AnnounceRandomLine(flag2 ? beggarGiftsTokens : beggarThanksTokens); if (gamblesThisVisit >= num) { pi.SetAvailable(false); } else { pi.Networkcost = CalculateCost(beggarBase.Value, beggarMultiplier.Value, gamblesThisVisit); } } private static PickupIndex RollItem() { //IL_000e: 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_0109: Unknown result type (might be due to invalid IL or missing references) Run instance = Run.instance; if (!Object.op_Implicit((Object)(object)instance)) { return PickupIndex.none; } List<PickupIndex> availableVoidTier1DropList = instance.availableVoidTier1DropList; List<PickupIndex> availableVoidTier2DropList = instance.availableVoidTier2DropList; List<PickupIndex> availableVoidTier3DropList = instance.availableVoidTier3DropList; int num; List<PickupIndex> list; if ((availableVoidTier1DropList == null || availableVoidTier1DropList.Count <= 0) && (availableVoidTier2DropList == null || availableVoidTier2DropList.Count <= 0)) { if (availableVoidTier3DropList != null) { num = ((availableVoidTier3DropList.Count > 0) ? 1 : 0); if (num != 0) { goto IL_005e; } } else { num = 0; } list = instance.availableTier1DropList; goto IL_005f; } num = 1; goto IL_005e; IL_005e: list = availableVoidTier1DropList; goto IL_005f; IL_005f: List<PickupIndex> list2 = list; List<PickupIndex> list3 = ((num != 0) ? availableVoidTier2DropList : instance.availableTier2DropList); List<PickupIndex> list4 = ((num != 0) ? availableVoidTier3DropList : instance.availableTier3DropList); int num2 = Random.Range(0, 100); List<PickupIndex> list5 = ((num2 < 60) ? list2 : ((num2 < 90) ? list3 : list4)); if (list5 == null || list5.Count == 0) { list5 = new List<PickupIndex>[3] { list2, list3, list4 }.FirstOrDefault((List<PickupIndex> x) => x != null && x.Count > 0); } if (list5 == null || list5.Count <= 0) { return PickupIndex.none; } return list5[Random.Range(0, list5.Count)]; } private static int CalculateCost(int startingCost, float multiplier, int previousUses) { double num = (double)Math.Max(1, startingCost) * Math.Pow(Math.Max(1f, multiplier), Math.Max(0, previousUses)); if (double.IsInfinity(num) || double.IsNaN(num) || num > 2147483647.0) { return int.MaxValue; } return Math.Max(1, (int)Math.Ceiling(num)); } private static void PlayUseEffect(Vector3 pos, Color color) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown try { GameObject val = LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/ShrineUseEffect"); if (Object.op_Implicit((Object)(object)val)) { EffectManager.SpawnEffect(val, new EffectData { origin = pos, rotation = Quaternion.identity, scale = 1.6f, color = Color32.op_Implicit(color) }, true); } } catch { } } private static GameObject GetPickupVisualSource() { if (Object.op_Implicit((Object)(object)pickupVisualSource)) { return pickupVisualSource; } if (pickupSourceChecked) { return null; } pickupSourceChecked = true; string[] array = new string[2] { "Prefabs/NetworkedObjects/GenericPickup", "Prefabs/GenericPickup" }; foreach (string text in array) { try { pickupVisualSource = LegacyResourcesAPI.Load<GameObject>(text); if (Object.op_Implicit((Object)(object)pickupVisualSource)) { if (Object.op_Implicit((Object)(object)Instance)) { ((BaseUnityPlugin)Instance).Logger.LogInfo((object)("[BeggarBouncer] Visual prefab: " + text)); } return pickupVisualSource; } } catch (Exception ex) { if (Object.op_Implicit((Object)(object)Instance)) { ((BaseUnityPlugin)Instance).Logger.LogWarning((object)("[BeggarBouncer] Pickup prefab load: " + ex.Message)); } } } try { Type type = Type.GetType("UnityEngine.AddressableAssets.Addressables, Unity.Addressables"); if (type == null) { type = (from a in AppDomain.CurrentDomain.GetAssemblies() select a.GetType("UnityEngine.AddressableAssets.Addressables", throwOnError: false)).FirstOrDefault((Type t) => t != null); } if (type != null) { MethodInfo methodInfo = type.GetMethods(BindingFlags.Static | BindingFlags.Public).FirstOrDefault((MethodInfo m) => m.Name == "LoadAssetAsync" && m.IsGenericMethodDefinition && m.GetParameters().Length == 1 && m.GetParameters()[0].ParameterType == typeof(object)); if (methodInfo != null) { object obj = methodInfo.MakeGenericMethod(typeof(GameObject)).Invoke(null, new object[1] { "RoR2/Base/Common/GenericPickup.prefab" }); object? obj2 = obj.GetType().GetMethod("WaitForCompletion", Type.EmptyTypes).Invoke(obj, null); pickupVisualSource = (GameObject)((obj2 is GameObject) ? obj2 : null); if (Object.op_Implicit((Object)(object)pickupVisualSource)) { if (Object.op_Implicit((Object)(object)Instance)) { ((BaseUnityPlugin)Instance).Logger.LogInfo((object)"[BeggarBouncer] Visual prefab: RoR2/Base/Common/GenericPickup.prefab"); } return pickupVisualSource; } } } } catch (Exception ex2) { if (Object.op_Implicit((Object)(object)Instance)) { ((BaseUnityPlugin)Instance).Logger.LogWarning((object)("[BeggarBouncer] Addressables pickup lookup failed: " + ex2.Message)); } } if (Object.op_Implicit((Object)(object)Instance)) { ((BaseUnityPlugin)Instance).Logger.LogWarning((object)"[BeggarBouncer] Cannot find GenericPickup visual prefab. Retaining colored lights only."); } return null; } private static Transform FindPickupLoops(GameObject source, string systemName) { Transform[] componentsInChildren = source.GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if (!(((Object)val).name != systemName)) { Transform val2 = val.Find("Loops"); if (Object.op_Implicit((Object)(object)val2)) { return val2; } } } return null; } internal static bool TryInstallPickupAura(GameObject root, bool isBeggar) { //IL_00c5: 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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: 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) if (!Object.op_Implicit((Object)(object)root)) { return false; } Transform val = root.transform.Find("GooberAura"); if (!Object.op_Implicit((Object)(object)val)) { return false; } if (Object.op_Implicit((Object)(object)val.Find("PickupStyleAura"))) { return true; } try { GameObject val2 = GetPickupVisualSource(); if (!Object.op_Implicit((Object)(object)val2)) { return false; } string text = (isBeggar ? "VoidSystem" : "LunarSystem"); Transform val3 = FindPickupLoops(val2, text); if (!Object.op_Implicit((Object)(object)val3)) { if (Object.op_Implicit((Object)(object)Instance)) { ((BaseUnityPlugin)Instance).Logger.LogWarning((object)("[BeggarBouncer] " + text + "/Loops not found in GenericPickup. Colored light retained.")); } return false; } GameObject val4 = Object.Instantiate<GameObject>(((Component)val3).gameObject, val, false); ((Object)val4).name = "PickupStyleAura"; val4.transform.localPosition = Vector3.zero; val4.transform.localRotation = Quaternion.identity; val4.transform.localScale = new Vector3(4.25f, 4.75f, 4.25f); MonoBehaviour[] componentsInChildren = val4.GetComponentsInChildren<MonoBehaviour>(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Behaviour)componentsInChildren[i]).enabled = false; } Collider[] componentsInChildren2 = val4.GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { componentsInChildren2[i].enabled = false; } Transform[] componentsInChildren3 = val4.GetComponentsInChildren<Transform>(true); for (int i = 0; i < componentsInChildren3.Length; i++) { ((Component)componentsInChildren3[i]).gameObject.SetActive(true); } int num = 0; ParticleSystem[] componentsInChildren4 = val4.GetComponentsInChildren<ParticleSystem>(true); foreach (ParticleSystem val5 in componentsInChildren4) { ParticleSystemRenderer component = ((Component)val5).GetComponent<ParticleSystemRenderer>(); if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)((Renderer)component).sharedMaterial) && Object.op_Implicit((Object)(object)((Renderer)component).sharedMaterial.shader) && !((Renderer)component).sharedMaterial.shader.isSupported) { ((Renderer)component).enabled = false; continue; } MainModule main = val5.main; ((MainModule)(ref main)).loop = true; ((MainModule)(ref main)).scalingMode = (ParticleSystemScalingMode)0; val5.Clear(true); val5.Play(true); num++; } if (Object.op_Implicit((Object)(object)Instance)) { ((BaseUnityPlugin)Instance).Logger.LogInfo((object)("[BeggarBouncer] Installed " + text + "/Loops for " + (isBeggar ? "Beggar" : "Bouncer") + " (particle systems=" + num + ").")); } return true; } catch (Exception ex) { if (Object.op_Implicit((Object)(object)Instance)) { ((BaseUnityPlugin)Instance).Logger.LogWarning((object)("[BeggarBouncer] Exact pickup aura failed; colored light retained: " + ex)); } return false; } } internal static Renderer FindNearestStatueRenderer(Vector3 position) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: 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) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); Renderer result = null; float num = 4f; Renderer[] array = Resources.FindObjectsOfTypeAll<Renderer>(); foreach (Renderer val in array) { if (Object.op_Implicit((Object)(object)val) && !(((Component)val).gameObject.scene != activeScene) && !(((Object)((Component)val).gameObject).name != "mdlNewtStatue")) { float num2 = Vector3.Distance(position, ((Component)val).transform.position); if (num2 < num) { num = num2; result = val; } } } return result; } } public sealed class GooberMarker : MonoBehaviour { public bool isBeggar; public Vector3 statuePosition; private PurchaseInteraction interaction; private float retry; private int auraInstallAttempts; private void Start() { interaction = ((Component)this).GetComponent<PurchaseInteraction>(); if (Object.op_Implicit((Object)(object)interaction)) { ((UnityEvent<Interactor>)(object)interaction.onPurchase).AddListener((UnityAction<Interactor>)OnPurchased); } AttachHighlight(); TryInitAura(); } private void TryInitAura() { if (auraInstallAttempts < 10) { auraInstallAttempts++; if (Plugin.TryInstallPickupAura(((Component)this).gameObject, isBeggar)) { auraInstallAttempts = 10; } } } private void OnPurchased(Interactor activator) { if (Object.op_Implicit((Object)(object)Plugin.Instance) && Object.op_Implicit((Object)(object)interaction)) { Plugin.Instance.OnGooberPurchased(isBeggar, interaction, activator); } } private void Update() { if (Object.op_Implicit((Object)(object)interaction) && !isBeggar && interaction.NetworkdisplayNameToken == "BB_BOUNCER_PARDONED" && Object.op_Implicit((Object)(object)Plugin.Instance)) { Plugin.Instance.ApplyClientPardon(); } retry += Time.deltaTime; if (retry >= 2f) { retry = 0f; AttachHighlight(); TryInitAura(); } } private void AttachHighlight() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) Highlight component = ((Component)this).GetComponent<Highlight>(); if (Object.op_Implicit((Object)(object)component) && !Object.op_Implicit((Object)(object)component.targetRenderer)) { Renderer val = Plugin.FindNearestStatueRenderer(statuePosition); if (Object.op_Implicit((Object)(object)val)) { component.targetRenderer = val; } } } } }