Decompiled source of Rogue Gambling v0.2.11
plugins/RoguelikeUpgrades.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Security.Cryptography; using System.Text; using BepInEx; using BepInEx.Configuration; using Extensions; using HarmonyLib; using Mirror; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace RoguelikeUpgrades; public enum Rarity { Common, Rare, Legendary } public sealed class Card { public readonly string Id; public readonly string Name; public readonly string Description; public readonly Rarity Rarity; public readonly bool Unique; public Card(string id, string name, Rarity rarity, bool unique, string description) { Id = id; Name = name; Rarity = rarity; Unique = unique; Description = description; } } public static class Catalog { public static readonly Card[] All = new Card[12] { new Card("TaxTheRich", "Tax the Rich", Rarity.Common, unique: true, "Teammates' profits fill your bet credit: 10% until it reaches the cheapest game's max bet, then 4%. Bets spend credit first. Slots more than one tier above your floor are locked."), new Card("TheGrinder", "The Grinder", Rarity.Common, unique: true, "Winning payouts +30%. You can bet only 10% of each machine's normal maximum, with a $1 minimum cap. Your teammates keep their own limits."), new Card("SteadyPace", "Steady Pace", Rarity.Common, unique: false, "Walk and sprint 10% faster for each copy of this card."), new Card("HouseMargin", "House Margin", Rarity.Common, unique: false, "Winning payouts increase by 5% for each copy of this card."), new Card("Downsizing", "Downsizing", Rarity.Rare, unique: true, "Become 10% smaller and gain +10% winning payouts. Also boosts Deep Pockets if you have it."), new Card("BlindMansBluff", "Blind Man's Bluff", Rarity.Rare, unique: true, "Winning payouts +40%, but helpful odds, counts and game hints are hidden. Your actual odds of winning stay the same."), new Card("PocketChange", "Pocket Change", Rarity.Rare, unique: true, "A piggy bank appears at your feet each casino run. Only you can pick it up. Drop it and smash it with a bat to add 2% of the current debt to the shared bank, credited to you."), new Card("DeepPockets", "Deep Pockets", Rarity.Rare, unique: false, "Each copy makes you 15% smaller and adds the same amount to winning payouts. Both stop increasing at 40% size. With Downsizing, gain another +0.5% payout for every 1% smaller you are."), new Card("AdrenalineRush", "Adrenaline Rush", Rarity.Rare, unique: false, "Walk and sprint 25% faster per copy. Each copy also reduces your maximum bet by 15% of its original limit."), new Card("TimeIsMoney", "Time is Money", Rarity.Legendary, unique: true, "Winning payouts +20%. The timer disappears with less than 30 seconds left. Try to bet with less than 15 seconds left and the bet is cancelled: you lose a random available body part and get knocked down."), new Card("HeavyWeaponry", "Heavy Weaponry", Rarity.Legendary, unique: true, "During casino runs, hit a teammate with a bat or quota gun to restore their last used item after it breaks or is consumed. It appears at their feet and can only be restored once. Hits cause no harm. You cannot buy items."), new Card("Overdrive", "Overdrive", Rarity.Legendary, unique: false, "Winning payouts +50% per copy. Money-change popups and the player contribution display are hidden from you.") }; public static Card Get(string id) { Card[] all = All; foreach (Card card in all) { if (card.Id == id) { return card; } } throw new ArgumentException("Unknown card: " + id); } } public sealed class PlayerUpgrades { private readonly Dictionary<string, int> stacks = new Dictionary<string, int>(); public double BetCredit { get; private set; } public double SpeedMultiplier => 1.0 + 0.1 * (double)Count("SteadyPace") + 0.25 * (double)Count("AdrenalineRush"); public double Scale => Math.Max(0.4, (Has("Downsizing") ? 0.9 : 1.0) - 0.15 * (double)Count("DeepPockets")); public int Count(string id) { if (!stacks.TryGetValue(id, out var value)) { return 0; } return value; } public bool Has(string id) { return Count(id) > 0; } public bool Grant(string id) { Card card = Catalog.Get(id); if (card.Unique && Has(id)) { return false; } stacks[id] = checked(Count(id) + 1); return true; } public double PayoutMultiplier(bool blindRestrictionsActive) { return 1.0 + (Has("DeepPockets") ? ((Has("Downsizing") ? 0.9 : 1.0) - Scale) : 0.0) + 0.05 * (double)Count("HouseMargin") + 0.5 * (double)Count("Overdrive") + (Has("TheGrinder") ? 0.3 : 0.0) + (Has("Downsizing") ? 0.1 : 0.0) + (Has("TimeIsMoney") ? 0.2 : 0.0) + ((Has("BlindMansBluff") && blindRestrictionsActive) ? 0.4 : 0.0) + ((Has("Downsizing") && Has("DeepPockets")) ? ((1.0 - Scale) * 0.5) : 0.0); } public double MaxBet(double nativeMax, double quota) { Validate(nativeMax); Validate(quota); double num = (Has("TheGrinder") ? Math.Min(nativeMax, Math.Max(1.0, nativeMax * 0.1)) : nativeMax); return num * Math.Max(0.0, 1.0 - 0.15 * (double)Count("AdrenalineRush")); } public void TeammateWon(double netWinnings, double cheapestGameMaxBet) { Validate(netWinnings); Validate(cheapestGameMaxBet); if (Has("TaxTheRich")) { double num = Math.Min(netWinnings, Math.Max(0.0, cheapestGameMaxBet - BetCredit) / 0.1); BetCredit = Math.Min(double.MaxValue, BetCredit + num * 0.1 + (netWinnings - num) * 0.04); } } public double CommitBet(double bet) { Validate(bet); double num = Math.Min(bet, BetCredit); BetCredit -= num; return bet - num; } public bool IsLateBetForbidden(double seconds, bool timerEnabled) { if (timerEnabled && Has("TimeIsMoney")) { return seconds < 15.0; } return false; } public bool HideTimer(double seconds, bool timerEnabled) { if (timerEnabled && Has("TimeIsMoney")) { return seconds < 30.0; } return false; } public double PiggyReward(double quota) { Validate(quota); if (!Has("PocketChange")) { return 0.0; } return quota * 0.02; } private static void Validate(double n) { if (double.IsNaN(n) || double.IsInfinity(n) || n < 0.0) { throw new ArgumentOutOfRangeException("n"); } } } public sealed class CardDealer { private readonly Random random; private readonly double common; private readonly double rare; private readonly double total; public CardDealer(Random random, double common, double rare, double legendary) { if (random == null) { throw new ArgumentNullException("random"); } if (!Valid(common) || !Valid(rare) || !Valid(legendary) || common + rare + legendary <= 0.0 || double.IsInfinity(common + rare + legendary)) { throw new ArgumentException("Invalid rarity weights"); } this.random = random; this.common = common; this.rare = rare; total = common + rare + legendary; } private static bool Valid(double n) { if (!double.IsNaN(n) && !double.IsInfinity(n)) { return n >= 0.0; } return false; } public Card[] Deal(PlayerUpgrades player) { Card[] array = new Card[3]; for (int i = 0; i < 3; i++) { double num = random.NextDouble() * total; Rarity rarity = ((!(num < common)) ? ((num < common + rare) ? Rarity.Rare : Rarity.Legendary) : Rarity.Common); List<Card> list = new List<Card>(); Card[] all = Catalog.All; foreach (Card card in all) { if (card.Rarity == rarity) { list.Add(card); } } Card card2 = list[random.Next(list.Count)]; if (card2.Unique && player.Has(card2.Id)) { list.RemoveAll((Card c) => c.Unique); card2 = list[random.Next(list.Count)]; } array[i] = card2; } return array; } } public sealed class UpgradeProgress { private readonly Dictionary<ulong, int> earned = new Dictionary<ulong, int>(); public int Available { get; private set; } public UpgradeProgress() { Available = 1; } public void NextRun() { Available++; } public int Missing(ulong player) { earned.TryGetValue(player, out var value); return Math.Max(0, Available - value); } public bool Earn(ulong player) { if (Missing(player) == 0) { return false; } earned.TryGetValue(player, out var value); earned[player] = value + 1; return true; } public int Earned(ulong player) { earned.TryGetValue(player, out var value); return value; } public void RestoreAvailable(int count) { if (count < 1) { throw new ArgumentOutOfRangeException("count"); } Available = count; } public void RestoreEarned(ulong player, int count) { if (count < 0 || count > Available) { throw new ArgumentOutOfRangeException("count"); } earned[player] = count; } } public sealed class SelectionRound { private readonly Dictionary<uint, Card[]> offers = new Dictionary<uint, Card[]>(); private readonly HashSet<uint> locked = new HashSet<uint>(); public readonly int Epoch; public bool Complete => locked.Count == offers.Count; public SelectionRound(int epoch) { Epoch = epoch; } public void Add(uint id, Card[] offer) { if (offer == null || offer.Length != 3) { throw new ArgumentException("Three cards required"); } if (offers.ContainsKey(id)) { throw new InvalidOperationException("Offer already dealt"); } offers.Add(id, (Card[])offer.Clone()); } public bool Choose(uint sender, uint claimedPlayer, int epoch, int index, PlayerUpgrades state) { if (sender != claimedPlayer || epoch != Epoch || index < 0 || index > 2 || locked.Contains(sender) || !offers.ContainsKey(sender)) { return false; } if (!state.Grant(offers[sender][index].Id)) { return false; } locked.Add(sender); return true; } public void Remove(uint id) { offers.Remove(id); locked.Remove(id); } } public struct UpgradePacket : NetworkMessage { public string Json; } [Serializable] public sealed class Wire { public string kind; public int epoch; public uint player; public int index; public string[] cards; public string amount; public uint item; public string steamId; } [BepInPlugin("local.gwyf.roguelikeupgrades", "Rogue Gambling", "0.2.11")] public sealed class Plugin : BaseUnityPlugin { private sealed class BoxExit { public PlayerController Player; public Bounds Bounds; } internal static Plugin Instance; private readonly Dictionary<uint, PlayerUpgrades> states = new Dictionary<uint, PlayerUpgrades>(); private readonly Dictionary<ulong, PlayerUpgrades> sessions = new Dictionary<ulong, PlayerUpgrades>(); internal RuntimeEffects Effects; private uint lastHello; private readonly Dictionary<uint, List<string>> granted = new Dictionary<uint, List<string>>(); private readonly HashSet<ulong> startingRolls = new HashSet<ulong>(); private readonly Dictionary<uint, BoxExit> boxExits = new Dictionary<uint, BoxExit>(); private readonly Dictionary<uint, Card[]> unsentStartingOffers = new Dictionary<uint, Card[]>(); private static readonly double LegendaryWeight = 100.0 * (1.0 - Math.Pow(0.88, 1.0 / 3.0)); private readonly CardDealer dealer = new CardDealer(new Random(), (100.0 - LegendaryWeight) * 2.0 / 3.0, (100.0 - LegendaryWeight) / 3.0, LegendaryWeight); private UpgradeProgress progress = new UpgradeProgress(); private readonly Dictionary<uint, SelectionRound> pendingRounds = new Dictionary<uint, SelectionRound>(); private int epoch; private bool serverRegistered; private bool clientRegistered; private bool wasConnected; private bool sawRun; private readonly ActiveCardsPanel activeCards = new ActiveCardsPanel(); private EscapeMenu escapeMenu; private readonly CardScreen screen = new CardScreen(); private Card[] localOffer; private int localEpoch; private float scanAt; private Harmony harmony; private SavedCards savedCards; private bool syncConfirmed; private float nextHello; private readonly Dictionary<uint, Card[]> pendingOffers = new Dictionary<uint, Card[]>(); private static readonly FieldInfo Settings = AccessTools.Field(typeof(PlayerController), "_ps"); private readonly Dictionary<PlayerController, PlayerSettings> originals = new Dictionary<PlayerController, PlayerSettings>(); private readonly Dictionary<Transform, Vector3> baseScales = new Dictionary<Transform, Vector3>(); internal UpgradeProgress Progress => progress; internal IEnumerable<KeyValuePair<ulong, PlayerUpgrades>> SavedSessions { get { foreach (KeyValuePair<ulong, PlayerUpgrades> pair in sessions) { KeyValuePair<ulong, PlayerUpgrades> keyValuePair = pair; if (keyValuePair.Key > uint.MaxValue) { yield return pair; } } } } internal bool Choosing => screen.Visible; internal bool CanStart { get { foreach (NetworkConnectionToClient value in NetworkServer.connections.Values) { if ((Object)(object)((NetworkConnection)value).identity != (Object)null && ((NetworkConnection)value).isReady && progress.Missing(RuntimeEffects.Key(((NetworkConnection)value).identity.netId)) > 0) { return false; } } return pendingRounds.Count == 0; } } internal void RestoreSavedPlayer(ulong id, PlayerUpgrades state, int earned) { sessions[id] = state; progress.RestoreEarned(id, earned); if (earned > 0) { startingRolls.Add(id); } } private void Awake() { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown Instance = this; savedCards = new SavedCards(this); Effects = new RuntimeEffects(this); Writer<UpgradePacket>.write = delegate(NetworkWriter w, UpgradePacket m) { NetworkWriterExtensions.WriteString(w, m.Json); }; Reader<UpgradePacket>.read = (NetworkReader r) => new UpgradePacket { Json = NetworkReaderExtensions.ReadString(r) }; harmony = new Harmony("local.gwyf.roguelikeupgrades"); harmony.PatchAll(typeof(Plugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Roguelike alpha loaded. All players must install the plugin; all twelve cards enabled."); } internal PlayerUpgrades State(uint id) { ulong key = RuntimeEffects.Key(id); if (sessions.TryGetValue(key, out var value)) { states[id] = value; return value; } if (!states.TryGetValue(id, out value)) { value = new PlayerUpgrades(); states[id] = value; } sessions[key] = value; return value; } internal static UpgradePacket Packet(Wire wire) { return new UpgradePacket { Json = JsonUtility.ToJson((object)wire) }; } internal static void SendAll(Wire wire) { NetworkServer.SendToAll<UpgradePacket>(Packet(wire), 0, false); } internal void SendOwner(uint id, Wire wire) { foreach (NetworkConnectionToClient value in NetworkServer.connections.Values) { if ((Object)(object)((NetworkConnection)value).identity != (Object)null && ((NetworkConnection)value).identity.netId == id) { ((NetworkConnection)value).Send<UpgradePacket>(Packet(wire), 0); break; } } } internal void Log(string text) { ((BaseUnityPlugin)this).Logger.LogInfo((object)text); } private void SyncAll(NetworkConnectionToClient connection) { foreach (NetworkConnectionToClient value3 in NetworkServer.connections.Values) { if ((Object)(object)((NetworkConnection)value3).identity == (Object)null) { continue; } uint netId = ((NetworkConnection)value3).identity.netId; PlayerUpgrades playerUpgrades = State(netId); List<string> list = new List<string>(); Card[] all = Catalog.All; foreach (Card card in all) { for (int j = 0; j < playerUpgrades.Count(card.Id); j++) { list.Add(card.Id); } } ((NetworkConnection)connection).Send<UpgradePacket>(Packet(new Wire { kind = "state", player = netId, steamId = RuntimeEffects.Key(netId).ToString(), cards = list.ToArray() }), 0); } Effects.Sync(connection); ((NetworkConnection)connection).Send<UpgradePacket>(Packet(new Wire { kind = "synced", player = (((Object)(object)((NetworkConnection)connection).identity != (Object)null) ? ((NetworkConnection)connection).identity.netId : 0u) }), 0); if ((Object)(object)((NetworkConnection)connection).identity != (Object)null) { uint netId2 = ((NetworkConnection)connection).identity.netId; if (pendingRounds.TryGetValue(netId2, out var _) && pendingOffers.TryGetValue(netId2, out var value2)) { SendOffer(connection, netId2, value2); } } } private void LateUpdate() { screen.Tick(); UpdateActiveCards(); if (Effects != null) { Effects.Tick(); } } private void UpdateActiveCards() { if ((Object)(object)NetworkClient.localPlayer == (Object)null || screen.Visible) { activeCards.Hide(); return; } if ((Object)(object)escapeMenu == (Object)null) { escapeMenu = Object.FindAnyObjectByType<EscapeMenu>(); } if ((Object)(object)escapeMenu == (Object)null || !((Behaviour)escapeMenu).isActiveAndEnabled || !(bool)AccessTools.Field(typeof(EscapeMenu), "_isOpen").GetValue(escapeMenu)) { activeCards.Hide(); return; } states.TryGetValue(NetworkClient.localPlayer.netId, out var value); activeCards.Show(escapeMenu, value); } private void Update() { //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Invalid comparison between Unknown and I4 //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) if (NetworkServer.active && !serverRegistered) { NetworkServer.RegisterHandler<UpgradePacket>((Action<NetworkConnectionToClient, UpgradePacket>)OnServer, true); serverRegistered = true; } if (NetworkClient.active && !clientRegistered) { NetworkClient.RegisterHandler<UpgradePacket>((Action<UpgradePacket>)OnClient, true); clientRegistered = true; } if (!NetworkServer.active) { serverRegistered = false; } if (!NetworkClient.active) { clientRegistered = false; } bool flag = NetworkClient.active || NetworkServer.active; if (wasConnected && !flag) { RestorePlayers(); Effects.Reset(); lastHello = 0u; syncConfirmed = false; nextHello = 0f; pendingOffers.Clear(); sessions.Clear(); states.Clear(); granted.Clear(); startingRolls.Clear(); boxExits.Clear(); unsentStartingOffers.Clear(); pendingRounds.Clear(); progress = new UpgradeProgress(); localOffer = null; screen.Hide(); activeCards.Destroy(); escapeMenu = null; screen.SetReadout(null); sawRun = false; savedCards.Reset(); } wasConnected = flag; if (NetworkServer.active) { savedCards.Load(); } if (NetworkClient.active && NetworkClient.ready && (Object)(object)NetworkClient.localPlayer != (Object)null) { if (NetworkClient.localPlayer.netId != lastHello) { lastHello = NetworkClient.localPlayer.netId; syncConfirmed = false; nextHello = 0f; } if (!syncConfirmed && Time.unscaledTime >= nextHello) { nextHello = Time.unscaledTime + 2f; Wire wire = new Wire(); wire.kind = "hello"; NetworkClient.Send<UpgradePacket>(Packet(wire), 0); } } GameManager val = Object.FindAnyObjectByType<GameManager>(); if (NetworkServer.active && (Object)(object)val != (Object)null) { if ((int)val.state == 1) { sawRun = true; } if (sawRun && (int)val.state == 0) { sawRun = false; BeginRound(); } } if (NetworkServer.active && (Object)(object)val != (Object)null && (int)val.state == 0) { CheckBoxExits(); } if (!(Time.unscaledTime >= scanAt)) { return; } scanAt = Time.unscaledTime + 0.5f; ApplyPlayers(); UpdateReadout(); if (!NetworkServer.active) { return; } List<uint> list = new List<uint>(); foreach (uint key in granted.Keys) { if (!NetworkServer.spawned.ContainsKey(key)) { list.Add(key); } } foreach (uint item in list) { pendingRounds.Remove(item); pendingOffers.Remove(item); granted.Remove(item); states.Remove(item); } CheckPendingUpgrades(); } private Card[] DealOffer(uint id) { PlayerUpgrades playerUpgrades = State(id); string value = Effects.TestOffers.Value; if (!string.IsNullOrWhiteSpace(value)) { string[] array = value.Split(new char[1] { ',' }); if (array.Length == 3) { try { Card[] array2 = new Card[3]; for (int i = 0; i < 3; i++) { Card card = Catalog.Get(array[i].Trim()); if (card.Unique && playerUpgrades.Has(card.Id)) { List<Card> list = new List<Card>(); Card[] all = Catalog.All; foreach (Card card2 in all) { if (!card2.Unique && card2.Rarity == card.Rarity) { list.Add(card2); } } card = list[Random.Range(0, list.Count)]; } array2[i] = card; } return array2; } catch (ArgumentException ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Invalid test offer: " + ex.Message)); } } } return dealer.Deal(playerUpgrades); } private void SendOffer(NetworkConnectionToClient c, uint id, Card[] offer) { ((NetworkConnection)c).Send<UpgradePacket>(Packet(new Wire { kind = "offer", epoch = pendingRounds[id].Epoch, player = id, cards = new string[3] { offer[0].Id, offer[1].Id, offer[2].Id } }), 0); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Upgrade offer sent to player " + id + " (round " + epoch + ").")); } private void BeginRound() { progress.NextRun(); savedCards.Save(); CheckPendingUpgrades(); } private void CheckPendingUpgrades() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) GameManager instance = NetworkSingleton<GameManager>.Instance; if (!NetworkServer.active || (Object)(object)instance == (Object)null || (int)instance.state != 0) { return; } foreach (NetworkConnectionToClient value in NetworkServer.connections.Values) { if (!((Object)(object)((NetworkConnection)value).identity == (Object)null) && ((NetworkConnection)value).isReady) { uint netId = ((NetworkConnection)value).identity.netId; ulong num = RuntimeEffects.Key(netId); if (startingRolls.Contains(num) && progress.Missing(num) != 0 && !pendingRounds.ContainsKey(netId)) { OfferPending(value); } } } } private void OfferPending(NetworkConnectionToClient c) { uint netId = ((NetworkConnection)c).identity.netId; Card[] array = DealOffer(netId); SelectionRound selectionRound = new SelectionRound(++epoch); selectionRound.Add(netId, array); pendingRounds[netId] = selectionRound; pendingOffers[netId] = array; if (!granted.ContainsKey(netId)) { granted[netId] = new List<string>(); } SendOffer(c, netId, array); Log("Catch-up choices remaining for player " + netId + ": " + progress.Missing(RuntimeEffects.Key(netId)) + "."); } internal void WatchBoxExit(SpawnBoxPlayerRagdollTrigger box, PlayerController player) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00b3: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active || (Object)(object)player == (Object)null) { return; } PlayerProfile component = ((Component)player).GetComponent<PlayerProfile>(); if (!((Object)(object)component != (Object)null) || component.steamId == 0) { _ = ((NetworkBehaviour)player).netId; } else { _ = component.steamId; } if (boxExits.ContainsKey(((NetworkBehaviour)player).netId)) { return; } Bounds bounds = default(Bounds); ((Bounds)(ref bounds))..ctor(((Component)player).transform.position, new Vector3(3f, 3f, 3f)); bool flag = false; Collider[] componentsInChildren = ((Component)box).GetComponentsInChildren<Collider>(true); foreach (Collider val in componentsInChildren) { Bounds bounds2 = val.bounds; Vector3 size = ((Bounds)(ref bounds2)).size; if (((Vector3)(ref size)).sqrMagnitude != 0f) { if (!flag) { bounds = val.bounds; flag = true; } else { ((Bounds)(ref bounds)).Encapsulate(val.bounds); } } } ((Bounds)(ref bounds)).Expand(0.2f); boxExits[((NetworkBehaviour)player).netId] = new BoxExit { Player = player, Bounds = bounds }; } private void CheckBoxExits() { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) List<uint> list = new List<uint>(); foreach (KeyValuePair<uint, BoxExit> boxExit in boxExits) { PlayerController player = boxExit.Value.Player; if ((Object)(object)player == (Object)null) { list.Add(boxExit.Key); } else { if (player.IsLocked || (int)player.State != 0 || ((Bounds)(ref boxExit.Value.Bounds)).Contains(((Component)player).transform.position)) { continue; } NetworkConnectionToClient connectionToClient = ((NetworkBehaviour)player).connectionToClient; if (connectionToClient != null && !((Object)(object)((NetworkConnection)connectionToClient).identity == (Object)null) && ((NetworkConnection)connectionToClient).isReady) { PlayerProfile component = ((Component)player).GetComponent<PlayerProfile>(); ulong num = (((Object)(object)component != (Object)null && component.steamId != 0) ? component.steamId : ((NetworkBehaviour)player).netId); startingRolls.Add(num); if (!pendingRounds.ContainsKey(((NetworkConnection)connectionToClient).identity.netId) && progress.Missing(num) > 0) { OfferPending(connectionToClient); } list.Add(boxExit.Key); } } } foreach (uint item in list) { boxExits.Remove(item); } } private void OnServer(NetworkConnectionToClient c, UpgradePacket packet) { try { Wire wire = JsonUtility.FromJson<Wire>(packet.Json); if (wire != null && wire.kind == "hello") { SyncAll(c); } else { if (wire == null || wire.kind != "choose" || (Object)(object)((NetworkConnection)c).identity == (Object)null) { return; } uint netId = ((NetworkConnection)c).identity.netId; if (!pendingRounds.TryGetValue(netId, out var value) || !value.Choose(netId, wire.player, wire.epoch, wire.index, State(netId))) { return; } pendingRounds.Remove(netId); pendingOffers.Remove(netId); progress.Earn(RuntimeEffects.Key(netId)); savedCards.Save(); granted[netId].Clear(); Card[] all = Catalog.All; foreach (Card card in all) { for (int j = 0; j < State(netId).Count(card.Id); j++) { granted[netId].Add(card.Id); } } ((BaseUnityPlugin)this).Logger.LogInfo((object)("Player " + netId + " accepted upgrades: " + string.Join(", ", granted[netId].ToArray()) + "; size=" + State(netId).Scale.ToString("P0") + "; speed=" + State(netId).SpeedMultiplier.ToString("F2") + "x; payout=" + State(netId).PayoutMultiplier(blindRestrictionsActive: true).ToString("F2") + "x.")); Wire wire2 = new Wire(); wire2.kind = "state"; wire2.epoch = epoch; wire2.player = netId; wire2.steamId = RuntimeEffects.Key(netId).ToString(); wire2.cards = granted[netId].ToArray(); NetworkServer.SendToAll<UpgradePacket>(Packet(wire2), 0, false); if (progress.Missing(RuntimeEffects.Key(netId)) > 0) { OfferPending(c); return; } ((NetworkConnection)c).Send<UpgradePacket>(Packet(new Wire { kind = "complete", epoch = wire.epoch, player = netId }), 0); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Invalid upgrade packet: " + ex.Message)); } } private void OnClient(UpgradePacket packet) { try { Wire wire = JsonUtility.FromJson<Wire>(packet.Json); if (wire == null) { return; } if (wire.kind == "synced") { syncConfirmed = (Object)(object)NetworkClient.localPlayer != (Object)null && wire.player == NetworkClient.localPlayer.netId; } else { if (Effects.Handle(wire)) { return; } if (wire.kind == "offer") { if (wire.epoch != localEpoch || localOffer == null || !screen.Visible) { localEpoch = wire.epoch; localOffer = new Card[3] { Catalog.Get(wire.cards[0]), Catalog.Get(wire.cards[1]), Catalog.Get(wire.cards[2]) }; screen.Show(localOffer, Select); } } else if (wire.kind == "locked" && wire.epoch == localEpoch) { localOffer = null; screen.Waiting(); } else if (wire.kind == "complete" && wire.epoch == localEpoch) { localOffer = null; screen.Hide(); } else if (wire.kind == "state" && !NetworkServer.active) { PlayerUpgrades playerUpgrades = new PlayerUpgrades(); string[] cards = wire.cards; foreach (string id in cards) { playerUpgrades.Grant(id); } states[wire.player] = playerUpgrades; ulong result; ulong key = ((ulong.TryParse(wire.steamId, out result) && result != 0) ? result : RuntimeEffects.Key(wire.player)); sessions[key] = playerUpgrades; Log("Received active cards for player " + wire.player + ": " + wire.cards.Length + "."); } } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Invalid host upgrade packet: " + ex.Message)); } } private void Select(int index) { if ((Object)(object)NetworkClient.localPlayer != (Object)null) { Wire wire = new Wire(); wire.kind = "choose"; wire.epoch = localEpoch; wire.player = NetworkClient.localPlayer.netId; wire.index = index; NetworkClient.Send<UpgradePacket>(Packet(wire), 0); } } private void UpdateReadout() { //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)NetworkClient.localPlayer == (Object)null) { screen.SetReadout(null); return; } uint netId = NetworkClient.localPlayer.netId; if (!states.TryGetValue(netId, out var value)) { screen.SetReadout(null); return; } bool flag = false; Card[] all = Catalog.All; foreach (Card card in all) { if (value.Has(card.Id)) { flag = true; break; } } if (!flag) { screen.SetReadout(null); return; } PlayerController component = ((Component)NetworkClient.localPlayer).GetComponent<PlayerController>(); Vector3 value2; string text = (((Object)(object)component != (Object)null && baseScales.TryGetValue(((Component)component).transform, out value2) && Math.Abs(value2.x) > 0.0001f) ? (((Component)component).transform.localScale.x / value2.x).ToString("P0") : "..."); screen.SetReadout("Size " + text + " | Speed " + value.SpeedMultiplier.ToString("F2") + "x\nPayout +" + ((value.PayoutMultiplier(blindRestrictionsActive: true) - 1.0) * 100.0).ToString("F0") + "% | Luck Base" + (value.Has("TaxTheRich") ? ("\nCredit " + MoneyFormatter.FormatWithDollar(Effects.Credit(netId), false)) : "") + (string.IsNullOrEmpty(Effects.NoticeText) ? "" : ("\n" + Effects.NoticeText))); } private void ApplyPlayers() { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) PlayerController[] array = Object.FindObjectsByType<PlayerController>((FindObjectsSortMode)0); foreach (PlayerController val in array) { PlayerUpgrades playerUpgrades = State(((NetworkBehaviour)val).netId); bool flag = false; Card[] all = Catalog.All; foreach (Card card in all) { if (playerUpgrades.Has(card.Id)) { flag = true; break; } } if (!flag) { continue; } if (!originals.TryGetValue(val, out var value)) { value = (PlayerSettings)Settings.GetValue(val); if ((Object)(object)value == (Object)null) { continue; } originals[val] = value; Settings.SetValue(val, Object.Instantiate<PlayerSettings>(value)); } PlayerSettings val2 = (PlayerSettings)Settings.GetValue(val); val2.maxSpeed = value.maxSpeed * (float)playerUpgrades.SpeedMultiplier; val2.sprintMaxSpeed = value.sprintMaxSpeed * (float)playerUpgrades.SpeedMultiplier; if (!baseScales.TryGetValue(((Component)val).transform, out var value2)) { value2 = ((Component)val).transform.localScale; baseScales[((Component)val).transform] = value2; } ((Component)val).transform.localScale = value2 * (float)playerUpgrades.Scale; } } private void RestorePlayers() { //IL_00ba: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<PlayerController, PlayerSettings> original in originals) { if ((Object)(object)original.Key != (Object)null) { object? value = Settings.GetValue(original.Key); Object val = (Object)((value is Object) ? value : null); Settings.SetValue(original.Key, original.Value); if (val != (Object)null && val != (Object)(object)original.Value) { Object.Destroy(val); } } } foreach (KeyValuePair<Transform, Vector3> baseScale in baseScales) { if ((Object)(object)baseScale.Key != (Object)null) { baseScale.Key.localScale = baseScale.Value; } } originals.Clear(); baseScales.Clear(); } private void OnDestroy() { if (Effects != null) { Effects.Reset(); } activeCards.Destroy(); screen.Destroy(); CardArtwork.Release(); RestorePlayers(); if (harmony != null) { harmony.UnpatchSelf(); } if (serverRegistered) { NetworkServer.UnregisterHandler<UpgradePacket>(); } if (clientRegistered) { NetworkClient.UnregisterHandler<UpgradePacket>(); } Instance = null; } } [HarmonyPatch(typeof(SpawnBoxPlayerRagdollTrigger), "WakePlayerUp")] internal static class StartingRoll { private static void Prefix(SpawnBoxPlayerRagdollTrigger __instance) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown if (!((Object)(object)Plugin.Instance == (Object)null) && NetworkServer.active) { PlayerController player = (PlayerController)AccessTools.Field(typeof(SpawnBoxPlayerRagdollTrigger), "assignedPlayer").GetValue(__instance); Plugin.Instance.WatchBoxExit(__instance, player); } } } [HarmonyPatch(typeof(GameManager), "StartDay")] internal static class Gate { private static bool Prefix() { if (!((Object)(object)Plugin.Instance == (Object)null) && NetworkServer.active) { return Plugin.Instance.CanStart; } return true; } } [HarmonyPatch(typeof(GameBase), "Payout")] internal static class WinScope { internal struct Scope { public uint Winner; public bool Paid; public BigNumber Payout; } [ThreadStatic] internal static uint Winner; [ThreadStatic] internal static bool Paid; [ThreadStatic] internal static BigNumber ActualPayout; private static void Prefix(GameBase __instance, double __0, out Scope __state) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) __state = new Scope { Winner = Winner, Paid = Paid, Payout = ActualPayout }; Winner = 0u; Paid = false; ActualPayout = BigNumber.Zero; if (NetworkServer.active && __0 > 1.0) { PlayerProfile val = RuntimeEffects.Profile(__instance); if ((Object)(object)val != (Object)null) { Winner = ((NetworkBehaviour)val).netId; } } } private static Exception Finalizer(Exception __exception, Scope __state) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Winner = __state.Winner; Paid = __state.Paid; ActualPayout = __state.Payout; return __exception; } } [HarmonyPatch(typeof(MoneyManager), "TryChangeBalance")] internal static class Payout { internal struct Attempt { public uint Player; public BigNumber CreditSpent; public bool Win; public BigNumber Payout; } private static bool Prefix(MoneyManager __instance, ref BigNumber __0, PlayerProfile __1, ChangeType __2, ref bool __result, out Attempt __state) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_00c0: Invalid comparison between Unknown and I4 //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_00fc: 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) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) __state = default(Attempt); if ((Object)(object)Plugin.Instance == (Object)null || !NetworkServer.active || (Object)(object)__1 == (Object)null) { return true; } uint netId = ((NetworkBehaviour)__1).netId; if ((int)__2 == 0 && __0 < BigNumber.Zero && Plugin.Instance.State(netId).Has("TaxTheRich")) { BigNumber stake = -__0; if (NativeFinance.CreditBet(stake, Plugin.Instance.Effects.Credit(netId), __instance.balance, out var charge, out var spent)) { __state.Player = netId; __state.CreditSpent = spent; __0 = -charge; if (((BigNumber)(ref charge)).IsZero) { __result = true; return false; } } } if (netId == WinScope.Winner && (int)__2 == 1 && __0 > BigNumber.Zero) { __0 = BigNumber.Min(__0 * Plugin.Instance.State(netId).PayoutMultiplier(blindRestrictionsActive: true), BigNumber.Max(BigNumber.Zero, BigNumber.MaxValue - __instance.balance)); __state.Win = true; __state.Payout = __0; } return true; } private static void Postfix(bool __result, Attempt __state) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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) if (!((Object)(object)Plugin.Instance == (Object)null)) { if (__result && __state.CreditSpent > BigNumber.Zero) { Plugin.Instance.Effects.SetCredit(__state.Player, Plugin.Instance.Effects.Credit(__state.Player) - __state.CreditSpent); } if (__state.Win) { WinScope.Paid = true; WinScope.ActualPayout = (__result ? __state.Payout : BigNumber.Zero); } } } } [HarmonyPatch(typeof(PlayerInteract), "OnInteractEvent")] internal static class BlockWorldClick { private static bool Prefix(PlayerInteract __instance) { if (!((Object)(object)Plugin.Instance == (Object)null) && ((NetworkBehaviour)__instance).isLocalPlayer) { return !Plugin.Instance.Choosing; } return true; } } [HarmonyPatch(typeof(MoneyDisplayAndFeedbacks), "SpawnMoneyChangeText")] internal static class HideTicker { private static bool Prefix() { if (!((Object)(object)Plugin.Instance == (Object)null) && !((Object)(object)NetworkClient.localPlayer == (Object)null)) { return !Plugin.Instance.State(NetworkClient.localPlayer.netId).Has("Overdrive"); } return true; } } [HarmonyPatch(typeof(PlayerHead), "OnLook")] internal static class BlockCardMouse { private static void Prefix(PlayerHead __instance, ref Vector2 __0) { //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) if ((Object)(object)Plugin.Instance != (Object)null && ((NetworkBehaviour)__instance).isLocalPlayer && Plugin.Instance.Choosing) { __0 = Vector2.zero; } } } [HarmonyPatch(typeof(PlayerHead), "GetInput")] internal static class BlockCardLookInput { private static bool Prefix(PlayerHead __instance) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Plugin.Instance == (Object)null || !((NetworkBehaviour)__instance).isLocalPlayer || !Plugin.Instance.Choosing) { return true; } AccessTools.Field(typeof(PlayerHead), "_lookInput").SetValue(__instance, Vector2.zero); return false; } } [HarmonyPatch(typeof(PlayerHead), "RotateHead")] internal static class BlockCardRotation { private static bool Prefix(PlayerHead __instance) { if (!((Object)(object)Plugin.Instance == (Object)null) && ((NetworkBehaviour)__instance).isLocalPlayer) { return !Plugin.Instance.Choosing; } return true; } } public sealed class CardScreen { private GameObject root; private TMP_Text heading; private TMP_Text status; private Button[] buttons; private TMP_Text[] labels; private Image[] icons; private Action<int> choose; private GameObject readoutRoot; private TMP_Text readout; private CursorLockMode oldLock; private bool oldVisible; public bool Visible { get { if ((Object)(object)root != (Object)null) { return root.activeSelf; } return false; } } public void Show(Card[] cards, Action<int> select) { //IL_001d: 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) if ((Object)(object)root == (Object)null) { Build(); } if (!Visible) { oldLock = Cursor.lockState; oldVisible = Cursor.visible; } root.SetActive(true); choose = select; heading.text = "CHOOSE YOUR UPGRADE"; status.text = "One upgrade per run. Your choice lasts for this session."; for (int i = 0; i < 3; i++) { ((Component)buttons[i]).gameObject.SetActive(true); ((Selectable)buttons[i]).interactable = true; Card card = cards[i]; Sprite val = CardArtwork.Icon(card.Id); icons[i].sprite = val; ((Component)icons[i]).gameObject.SetActive((Object)(object)val != (Object)null); Place(labels[i].rectTransform, 0f, ((Object)(object)val != (Object)null) ? (-50) : 0, 310f, ((Object)(object)val != (Object)null) ? 230 : 380); string text = (((Object)(object)CardArtwork.Background != (Object)null) ? ((card.Rarity == Rarity.Common) ? "19612A" : ((card.Rarity == Rarity.Rare) ? "124B89" : "64248F")) : ((card.Rarity == Rarity.Common) ? "85C98A" : ((card.Rarity == Rarity.Rare) ? "7AB4F4" : "C8A1EE"))); labels[i].text = "<color=#" + text + "><size=18>" + card.Rarity.ToString().ToUpperInvariant() + "</size></color>\n<b><size=24>" + card.Name + "</size></b>\n<size=16>" + card.Description + "</size>\n\n<size=16>SELECT</size>"; } Unlock(); } public void Waiting() { if (!((Object)(object)root == (Object)null)) { heading.text = "UPGRADE LOCKED IN"; status.text = "Waiting for everyone to choose..."; Button[] array = buttons; foreach (Button val in array) { ((Component)val).gameObject.SetActive(false); } } } public void Hide() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (Visible) { root.SetActive(false); Cursor.lockState = oldLock; Cursor.visible = oldVisible; } } public void Tick() { if (Visible) { Unlock(); } } public void SetReadout(string text) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(text)) { if ((Object)(object)readoutRoot != (Object)null) { readoutRoot.SetActive(false); } return; } if ((Object)(object)readoutRoot == (Object)null) { readoutRoot = new GameObject("RoguelikeUpgradeReadout", new Type[3] { typeof(RectTransform), typeof(Canvas), typeof(CanvasScaler) }); Object.DontDestroyOnLoad((Object)(object)readoutRoot); Canvas component = readoutRoot.GetComponent<Canvas>(); component.renderMode = (RenderMode)0; component.sortingOrder = 31999; CanvasScaler component2 = readoutRoot.GetComponent<CanvasScaler>(); component2.uiScaleMode = (ScaleMode)1; component2.referenceResolution = new Vector2(1920f, 1080f); component2.matchWidthOrHeight = 0.5f; TMP_Text val = null; GameUI val2 = Object.FindAnyObjectByType<GameUI>(); if ((Object)(object)val2 != (Object)null) { val = ((Component)val2).GetComponentInChildren<TMP_Text>(true); } if ((Object)(object)val == (Object)null && (Object)(object)heading != (Object)null) { val = heading; } readout = Text("UpgradeStats", readoutRoot.transform, val); readout.fontSize = 20f; readout.alignment = (TextAlignmentOptions)1025; RectTransform rectTransform = readout.rectTransform; Vector2 val3 = (rectTransform.pivot = Vector2.zero); Vector2 anchorMin = (rectTransform.anchorMax = val3); rectTransform.anchorMin = anchorMin; rectTransform.anchoredPosition = new Vector2(24f, 24f); rectTransform.sizeDelta = new Vector2(650f, 110f); } readoutRoot.SetActive(true); readout.text = text; } private void Unlock() { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } private void Build() { //IL_0086: 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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Expected O, but got Unknown //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_0357: 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) //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Unknown result type (might be due to invalid IL or missing references) //IL_0435: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_047e: Expected O, but got Unknown //IL_04cb: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Unknown result type (might be due to invalid IL or missing references) //IL_054c: Unknown result type (might be due to invalid IL or missing references) //IL_058d: Unknown result type (might be due to invalid IL or missing references) TMP_Text val = null; GameUI val2 = Object.FindAnyObjectByType<GameUI>(); if ((Object)(object)val2 != (Object)null) { val = ((Component)val2).GetComponentInChildren<TMP_Text>(true); } if ((Object)(object)val == (Object)null) { TMP_Text[] array = Resources.FindObjectsOfTypeAll<TMP_Text>(); foreach (TMP_Text val3 in array) { Scene scene = ((Component)val3).gameObject.scene; if (((Scene)(ref scene)).IsValid() && (Object)(object)val3.font != (Object)null) { val = val3; break; } } } Button val4 = null; Button[] array2 = Resources.FindObjectsOfTypeAll<Button>(); foreach (Button val5 in array2) { Scene scene2 = ((Component)val5).gameObject.scene; if (((Scene)(ref scene2)).IsValid() && (Object)(object)((Selectable)val5).image != (Object)null && (Object)(object)((Selectable)val5).image.sprite != (Object)null) { val4 = val5; break; } } root = new GameObject("RoguelikeUpgradeCanvas", new Type[4] { typeof(RectTransform), typeof(Canvas), typeof(CanvasScaler), typeof(GraphicRaycaster) }); Object.DontDestroyOnLoad((Object)(object)root); Canvas component = root.GetComponent<Canvas>(); component.renderMode = (RenderMode)0; component.sortingOrder = 32000; CanvasScaler component2 = root.GetComponent<CanvasScaler>(); component2.uiScaleMode = (ScaleMode)1; component2.referenceResolution = new Vector2(1920f, 1080f); component2.matchWidthOrHeight = 0.5f; Image val6 = Node("Backdrop", root.transform).AddComponent<Image>(); ((Graphic)val6).color = new Color(0f, 0f, 0f, 0.88f); Stretch(((Component)val6).GetComponent<RectTransform>()); heading = Text("Heading", root.transform, val); Place(heading.rectTransform, 0f, 380f, 1700f, 80f); heading.fontSize = 44f; status = Text("Status", root.transform, val); Place(status.rectTransform, 0f, -380f, 1700f, 60f); status.fontSize = 24f; buttons = (Button[])(object)new Button[3]; labels = (TMP_Text[])(object)new TMP_Text[3]; icons = (Image[])(object)new Image[3]; for (int k = 0; k < 3; k++) { GameObject val7 = Node("UpgradeCard" + k, root.transform); Place(val7.GetComponent<RectTransform>(), (k - 1) * 570, 0f, 540f, 648f); Image val8 = val7.AddComponent<Image>(); ((Graphic)val8).color = (Color)(((Object)(object)val4 != (Object)null) ? ((Graphic)((Selectable)val4).image).color : new Color(0.13f, 0.16f, 0.15f, 1f)); if ((Object)(object)CardArtwork.Background != (Object)null) { val8.sprite = CardArtwork.Background; val8.type = (Type)0; val8.preserveAspect = false; ((Graphic)val8).color = Color.white; } else if ((Object)(object)val4 != (Object)null) { val8.sprite = ((Selectable)val4).image.sprite; val8.type = ((Selectable)val4).image.type; } Button val9 = val7.AddComponent<Button>(); ((Selectable)val9).targetGraphic = (Graphic)(object)val8; if ((Object)(object)CardArtwork.Background != (Object)null) { ColorBlock colors = ((Selectable)val9).colors; ((ColorBlock)(ref colors)).normalColor = Color.white; ((ColorBlock)(ref colors)).highlightedColor = new Color(1f, 1f, 0.9f, 1f); ((ColorBlock)(ref colors)).pressedColor = new Color(0.85f, 0.8f, 0.65f, 1f); ((ColorBlock)(ref colors)).selectedColor = Color.white; ((ColorBlock)(ref colors)).disabledColor = new Color(0.65f, 0.65f, 0.65f, 1f); ((Selectable)val9).colors = colors; } else if ((Object)(object)val4 != (Object)null) { ((Selectable)val9).colors = ((Selectable)val4).colors; ((Selectable)val9).transition = (Transition)1; } int index = k; ((UnityEvent)val9.onClick).AddListener((UnityAction)delegate { Button[] array3 = buttons; foreach (Button val12 in array3) { ((Selectable)val12).interactable = false; } if (choose != null) { choose(index); } }); buttons[k] = val9; Image val10 = Node("Icon", val7.transform).AddComponent<Image>(); Place(((Component)val10).GetComponent<RectTransform>(), 0f, 135f, 125f, 125f); val10.preserveAspect = true; ((Graphic)val10).color = Color.white; ((Graphic)val10).raycastTarget = false; ((Component)val10).gameObject.SetActive(false); icons[k] = val10; TMP_Text val11 = Text("Text", val7.transform, val); if ((Object)(object)CardArtwork.Background != (Object)null) { Place(val11.rectTransform, 0f, 0f, 310f, 380f); ((Graphic)val11).color = new Color(0.17f, 0.08f, 0.025f, 1f); val11.fontSharedMaterial = ((TMP_Asset)val11.font).material; } else { Stretch(val11.rectTransform); } val11.margin = new Vector4(8f, 8f, 8f, 8f); val11.fontSize = 24f; val11.enableAutoSizing = true; val11.fontSizeMin = 16f; val11.fontSizeMax = 24f; ((Graphic)val11).raycastTarget = false; labels[k] = val11; } root.SetActive(false); } private static GameObject Node(string name, Transform parent) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parent, false); return val; } private static TMP_Text Text(string name, Transform parent, TMP_Text sample) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI val = Node(name, parent).AddComponent<TextMeshProUGUI>(); if ((Object)(object)sample != (Object)null) { ((TMP_Text)val).font = sample.font; ((TMP_Text)val).fontSharedMaterial = sample.fontSharedMaterial; ((Graphic)val).color = ((Graphic)sample).color; } else { ((Graphic)val).color = Color.white; } ((TMP_Text)val).alignment = (TextAlignmentOptions)514; ((TMP_Text)val).richText = true; ((Graphic)val).raycastTarget = false; return (TMP_Text)(object)val; } private static void Place(RectTransform r, float x, float y, float w, float h) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_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_001b: 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_002a: 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) Vector2 val = (r.pivot = new Vector2(0.5f, 0.5f)); Vector2 anchorMin = (r.anchorMax = val); r.anchorMin = anchorMin; r.anchoredPosition = new Vector2(x, y); r.sizeDelta = new Vector2(w, h); } private static void Stretch(RectTransform r) { //IL_0001: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) r.anchorMin = Vector2.zero; r.anchorMax = Vector2.one; Vector2 offsetMin = (r.offsetMax = Vector2.zero); r.offsetMin = offsetMin; } public void Destroy() { Hide(); if ((Object)(object)root != (Object)null) { Object.Destroy((Object)(object)root); } if ((Object)(object)readoutRoot != (Object)null) { Object.Destroy((Object)(object)readoutRoot); } root = null; readoutRoot = null; } } public sealed class CardHover : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, ISelectHandler, IDeselectHandler, IEventSystemHandler { public Action Enter; public Action Exit; public void OnPointerEnter(PointerEventData e) { if (Enter != null) { Enter(); } } public void OnPointerExit(PointerEventData e) { if (Exit != null) { Exit(); } } public void OnSelect(BaseEventData e) { if (Enter != null) { Enter(); } } public void OnDeselect(BaseEventData e) { if (Exit != null) { Exit(); } } } public sealed class ActiveCardsPanel { private GameObject root; private TMP_Text description; private Transform rows; private string signature; private readonly List<GameObject> entries = new List<GameObject>(); private TMP_Text sample; private Button native; public void Hide() { if ((Object)(object)root != (Object)null) { root.SetActive(false); } } public void Show(EscapeMenu menu, PlayerUpgrades state) { //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)root == (Object)null) { Build(menu); } root.SetActive(true); string text = ""; Card[] all = Catalog.All; foreach (Card card in all) { object obj = text; text = string.Concat(obj, card.Id, ":", state?.Count(card.Id) ?? 0, ";"); } if (text == signature) { return; } signature = text; foreach (GameObject entry in entries) { entry.SetActive(false); Object.Destroy((Object)(object)entry); } entries.Clear(); description.text = "Hover over a card to see its description."; int num = 0; Card[] all2 = Catalog.All; foreach (Card card2 in all2) { int num2 = state?.Count(card2.Id) ?? 0; if (num2 != 0) { GameObject val = Node(card2.Id, rows); RectTransform component = val.GetComponent<RectTransform>(); Vector2 val2 = (component.pivot = new Vector2(0f, 1f)); Vector2 anchorMin = (component.anchorMax = val2); component.anchorMin = anchorMin; component.anchoredPosition = new Vector2((float)(8 + num % 3 * 136), (float)(-(num / 3) * 126)); component.sizeDelta = new Vector2(120f, 120f); Color effectColor = ((card2.Rarity == Rarity.Common) ? new Color(0.3f, 0.65f, 0.35f) : ((card2.Rarity == Rarity.Rare) ? new Color(0.3f, 0.5f, 0.85f) : new Color(0.6f, 0.35f, 0.85f))); Image val5 = val.AddComponent<Image>(); ((Graphic)val5).color = new Color(effectColor.r, effectColor.g, effectColor.b, 0.2f); Outline val6 = val.AddComponent<Outline>(); ((Shadow)val6).effectColor = effectColor; ((Shadow)val6).effectDistance = new Vector2(2f, 2f); Button val7 = val.AddComponent<Button>(); ((Selectable)val7).targetGraphic = (Graphic)(object)val5; Sprite val8 = CardArtwork.Icon(card2.Id); if ((Object)(object)val8 != (Object)null) { Image val9 = Node("Icon", val.transform).AddComponent<Image>(); Position(((Graphic)val9).rectTransform, 8f, -8f, 104f, 104f); val9.sprite = val8; val9.preserveAspect = true; ((Graphic)val9).color = Color.white; ((Graphic)val9).raycastTarget = false; } else { TMP_Text val10 = Text(val.transform, "PendingIcon"); Fill(val10.rectTransform); val10.fontSize = 17f; val10.alignment = (TextAlignmentOptions)514; val10.margin = new Vector4(8f, 8f, 8f, 8f); val10.text = card2.Name; } if (num2 > 1) { TMP_Text val11 = Text(val.transform, "Stacks"); Position(val11.rectTransform, 78f, -5f, 36f, 24f); val11.fontSize = 20f; val11.alignment = (TextAlignmentOptions)260; val11.text = "x" + num2; } Card current2 = card2; CardHover cardHover = val.AddComponent<CardHover>(); cardHover.Enter = delegate { description.text = "<b>" + current2.Name + "</b>\n" + current2.Description; }; cardHover.Exit = delegate { description.text = "Hover over a card to see its description."; }; entries.Add(val); num++; } } if (num == 0) { GameObject val12 = Node("NoCards", rows); TMP_Text val13 = (TMP_Text)(object)val12.AddComponent<TextMeshProUGUI>(); Style(val13); val13.fontSize = 21f; Fill(val13.rectTransform); val13.text = "No active upgrades yet."; entries.Add(val12); } } private void Build(EscapeMenu menu) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_008e: 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) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) signature = null; entries.Clear(); CanvasGroup val = (CanvasGroup)AccessTools.Field(typeof(EscapeMenu), "_canvasGroup").GetValue(menu); Transform val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform : ((Component)menu).transform); sample = ((Component)val2).GetComponentInChildren<TMP_Text>(true); native = ((Component)val2).GetComponentInChildren<Button>(true); root = Node("RoguelikeActiveCards", val2); RectTransform component = root.GetComponent<RectTransform>(); Vector2 val3 = (component.pivot = new Vector2(1f, 0.5f)); Vector2 anchorMin = (component.anchorMax = val3); component.anchorMin = anchorMin; component.anchoredPosition = new Vector2(-28f, 0f); component.sizeDelta = new Vector2(448f, 790f); Image val6 = root.AddComponent<Image>(); Image component2 = ((Component)val2).GetComponent<Image>(); if ((Object)(object)component2 != (Object)null) { val6.sprite = component2.sprite; val6.type = component2.type; ((Graphic)val6).color = ((Graphic)component2).color; } else { ((Graphic)val6).color = new Color(0.08f, 0.1f, 0.09f, 0.96f); } TMP_Text val7 = Text(root.transform, "Heading"); val7.text = "ACTIVE CARDS"; val7.fontSize = 30f; val7.alignment = (TextAlignmentOptions)4097; Position(val7.rectTransform, 20f, -18f, 408f, 45f); GameObject val8 = Node("Cards", root.transform); Position(val8.GetComponent<RectTransform>(), 20f, -74f, 408f, 510f); rows = val8.transform; description = Text(root.transform, "Description"); description.fontSize = 21f; description.alignment = (TextAlignmentOptions)257; description.enableAutoSizing = true; description.fontSizeMin = 17f; description.fontSizeMax = 21f; Position(description.rectTransform, 20f, -603f, 408f, 165f); root.SetActive(false); } private TMP_Text Text(Transform parent, string name) { TextMeshProUGUI val = Node(name, parent).AddComponent<TextMeshProUGUI>(); Style((TMP_Text)(object)val); return (TMP_Text)(object)val; } private void Style(TMP_Text text) { //IL_0044: 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)(object)sample != (Object)null) { text.font = sample.font; text.fontSharedMaterial = sample.fontSharedMaterial; ((Graphic)text).color = ((Graphic)sample).color; } else { ((Graphic)text).color = Color.white; } text.richText = true; ((Graphic)text).raycastTarget = false; } private static GameObject Node(string name, Transform parent) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parent, false); return val; } private static void Position(RectTransform rect, float x, float y, float width, float height) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_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_001b: 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_002a: 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) Vector2 val = (rect.pivot = new Vector2(0f, 1f)); Vector2 anchorMin = (rect.anchorMax = val); rect.anchorMin = anchorMin; rect.anchoredPosition = new Vector2(x, y); rect.sizeDelta = new Vector2(width, height); } private static void Fill(RectTransform rect) { //IL_0001: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) rect.anchorMin = Vector2.zero; rect.anchorMax = Vector2.one; Vector2 offsetMin = (rect.offsetMax = Vector2.zero); rect.offsetMin = offsetMin; } public void Destroy() { if ((Object)(object)root != (Object)null) { Object.Destroy((Object)(object)root); } root = null; signature = null; entries.Clear(); } } internal static class NativeFinance { internal static BigNumber Limit(BigNumber native, BigNumber quota, PlayerUpgrades state) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (state.Has("TheGrinder")) { native = BigNumber.Min(native, BigNumber.Max(BigNumber.One, native * 0.1)); } return native * Math.Max(0.0, 1.0 - 0.15 * (double)state.Count("AdrenalineRush")); } internal static BigNumber EarnCredit(BigNumber balance, BigNumber winnings, BigNumber threshold) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_000d: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_002c: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) BigNumber val = BigNumber.Min(winnings, BigNumber.Max(BigNumber.Zero, threshold - balance) / 0.1); return BigNumber.Min(BigNumber.MaxValue, balance + val * 0.1 + (winnings - val) * 0.04); } internal static bool CreditBet(BigNumber stake, BigNumber credit, BigNumber bank, out BigNumber charge, out BigNumber spent) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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) spent = BigNumber.Min(stake, credit); charge = stake - spent; return charge <= bank; } } internal sealed class RuntimeEffects { private sealed class UsedItem { internal uint NetId; internal uint AssetId; internal bool AlreadyRestored; } private readonly Plugin plugin; private readonly Dictionary<ulong, BigNumber> credit = new Dictionary<ulong, BigNumber>(); private readonly Dictionary<ulong, UsedItem> lastUsedItems = new Dictionary<ulong, UsedItem>(); private readonly Dictionary<uint, uint> pigs = new Dictionary<uint, uint>(); private readonly HashSet<int> pigInstances = new HashSet<int>(); private readonly HashSet<uint> pigVisuals = new HashSet<uint>(); private readonly HashSet<ulong> spawnedThisRun = new HashSet<ulong>(); private readonly Dictionary<Behaviour, bool> masked = new Dictionary<Behaviour, bool>(); private readonly HashSet<Behaviour> wanted = new HashSet<Behaviour>(); private readonly Dictionary<GameObject, bool> objectMasks = new Dictionary<GameObject, bool>(); private readonly HashSet<GameObject> wantedObjects = new HashSet<GameObject>(); private GameBase[] games = (GameBase[])(object)new GameBase[0]; private GameState? previousScene; private float nextScan; private bool warnedPigPrefab; internal string NoticeText; private float noticeUntil; internal readonly ConfigEntry<int> TaxSlotLevelOffset; internal readonly ConfigEntry<string> TestOffers; internal void RememberUsedItem(Item item, bool pressed) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 if (pressed && NetworkServer.active && !((Object)(object)NetworkSingleton<GameManager>.Instance == (Object)null) && (int)NetworkSingleton<GameManager>.Instance.state == 1 && !((Object)(object)item == (Object)null) && !((Object)(object)item.NetworkHolder == (Object)null) && !(item is DebtBag) && !IsPig(item)) { NetworkIdentity component = ((Component)item).GetComponent<NetworkIdentity>(); if ((Object)(object)component != (Object)null && component.assetId != 0) { lastUsedItems[Key(((NetworkBehaviour)item.NetworkHolder).netId)] = new UsedItem { NetId = ((NetworkBehaviour)item).netId, AssetId = component.assetId, AlreadyRestored = ((Object)(object)((Component)item).GetComponent<HeavyWeaponryRestoredItem>() != (Object)null) }; } } } private void RestoreUsedItem(PlayerController victim) { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) ulong key = Key(((NetworkBehaviour)victim).netId); if (!lastUsedItems.TryGetValue(key, out var value)) { Tell(((NetworkBehaviour)victim).netId, "Heavy Weaponry: no used item to restore yet."); return; } if (value.AlreadyRestored) { Tell(((NetworkBehaviour)victim).netId, "Heavy Weaponry: restored items cannot be restored again."); return; } if (NetworkServer.spawned.ContainsKey(value.NetId)) { Tell(((NetworkBehaviour)victim).netId, "Heavy Weaponry: your last used item still exists."); return; } if (!NetworkClient.prefabs.TryGetValue(value.AssetId, out var value2) || (Object)(object)value2 == (Object)null || (Object)(object)value2.GetComponent<Item>() == (Object)null) { Tell(((NetworkBehaviour)victim).netId, "Heavy Weaponry: item prefab unavailable."); return; } GameObject val = Object.Instantiate<GameObject>(value2, ((Component)victim).transform.position + ((Component)victim).transform.forward * 0.8f + Vector3.up * 0.3f, Quaternion.identity); val.AddComponent<HeavyWeaponryRestoredItem>(); NetworkServer.Spawn(val, (NetworkConnectionToClient)null); lastUsedItems.Remove(key); Tell(((NetworkBehaviour)victim).netId, "Heavy Weaponry: your last used item was restored at your feet."); plugin.Log("Heavy Weaponry restored item asset " + value.AssetId + " for player " + ((NetworkBehaviour)victim).netId + "."); } internal RuntimeEffects(Plugin p) { plugin = p; TaxSlotLevelOffset = ((BaseUnityPlugin)p).Config.Bind<int>("Balance", "TaxSlotLevelOffset", 1, "Tax the Rich blocks slot machines above current floor plus this offset."); TestOffers = ((BaseUnityPlugin)p).Config.Bind<string>("Testing", "OfferCards", "", "Optional exact three comma-separated card IDs for private testing. Leave blank for normal random offers."); } internal static object Field(object obj, string name) { if (obj != null) { return AccessTools.Field(obj.GetType(), name).GetValue(obj); } return null; } internal static PlayerProfile Profile(GameBase game) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown return (PlayerProfile)Field(game, "interactingPlayer"); } internal static ulong Key(uint id) { IDictionary<uint, NetworkIdentity> dictionary = (NetworkServer.active ? NetworkServer.spawned : NetworkClient.spawned); if (dictionary.TryGetValue(id, out var value) && (Object)(object)value != (Object)null) { PlayerProfile component = ((Component)value).GetComponent<PlayerProfile>(); if ((Object)(object)component != (Object)null && component.steamId != 0) { return component.steamId; } } return id; } internal BigNumber Credit(uint id) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (!credit.TryGetValue(Key(id), out var value)) { return BigNumber.Zero; } return value; } internal void SetCredit(uint id, BigNumber value) { //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_0012: Unknown result type (might be due to invalid IL or missing references) credit[Key(id)] = BigNumber.Max(BigNumber.Zero, value); if (NetworkServer.active) { plugin.SendOwner(id, new Wire { kind = "credit", player = id, amount = ((BigNumber)(ref value)).ToSaveString() }); } } internal bool IsPig(Item item) { if ((Object)(object)item != (Object)null) { if (!pigInstances.Contains(((Object)item).GetInstanceID())) { return pigs.ContainsKey(((NetworkBehaviour)item).netId); } return true; } return false; } internal bool MayPickup(Item item, uint player) { if (pigs.TryGetValue(((NetworkBehaviour)item).netId, out var value)) { return value == player; } return true; } internal bool SlotBlocked(GameBase game, PlayerUpgrades state) { GameManager instance = NetworkSingleton<GameManager>.Instance; if (state.Has("TaxTheRich") && game is Slots && (Object)(object)instance != (Object)null) { return (int)Field(game, "casinoLevel") > instance.currentFloor + TaxSlotLevelOffset.Value; } return false; } internal void Tell(uint player, string text) { if (NetworkServer.active) { plugin.SendOwner(player, new Wire { kind = "notice", player = player, amount = text }); } else { NoticeText = text; noticeUntil = Time.unscaledTime + 4f; } } internal bool Handle(Wire wire) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (wire.kind == "credit") { credit[Key(wire.player)] = BigNumber.Parse(wire.amount); return true; } if (wire.kind == "pig") { pigs[wire.item] = wire.player; return true; } if (wire.kind == "pigGone") { pigs.Remove(wire.item); pigVisuals.Remove(wire.item); return true; } if (wire.kind == "resetItem") { if (NetworkClient.spawned.TryGetValue(wire.item, out var value)) { Item component = ((Component)value).GetComponent<Item>(); if ((Object)(object)component != (Object)null && (Object)(object)component.NetworkHolder != (Object)null && ((NetworkBehaviour)component.NetworkHolder).isLocalPlayer) { ResetCooldown(component); } } return true; } if (wire.kind == "notice") { NoticeText = wire.amount; noticeUntil = Time.unscaledTime + 4f; return true; } return false; } internal void Sync(NetworkConnectionToClient connection) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((NetworkConnection)connection).identity == (Object)null) { return; } uint netId = ((NetworkConnection)connection).identity.netId; Wire wire = new Wire { kind = "credit", player = netId }; BigNumber val = Credit(netId); wire.amount = ((BigNumber)(ref val)).ToSaveString(); ((NetworkConnection)connection).Send<UpgradePacket>(Plugin.Packet(wire), 0); foreach (KeyValuePair<uint, uint> pig in pigs) { ((NetworkConnection)connection).Send<UpgradePacket>(Plugin.Packet(new Wire { kind = "pig", player = pig.Value, item = pig.Key }), 0); } } internal void Tick() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Invalid comparison between Unknown and I4 //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Invalid comparison between Unknown and I4 //IL_0078: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active && !NetworkClient.active) { return; } GameManager val = Object.FindAnyObjectByType<GameManager>(); if ((Object)(object)val == (Object)null) { return; } if (previousScene != (GameState?)val.state) { if ((int)val.state == 1) { spawnedThisRun.Clear(); } else if (NetworkServer.active) { ClearPigs(); lastUsedItems.Clear(); } previousScene = val.state; } if (Time.unscaledTime >= nextScan) { nextScan = Time.unscaledTime + 0.25f; games = Object.FindObjectsByType<GameBase>((FindObjectsSortMode)0); if (NetworkServer.active && (int)val.state == 1 && games.Length > 0) { SpawnPigs(); } ApplyPigVisuals(); } CollectMasks(val); foreach (KeyValuePair<Behaviour, bool> item in masked) { if ((Object)(object)item.Key != (Object)null) { item.Key.enabled = false; } } foreach (KeyValuePair<GameObject, bool> objectMask in objectMasks) { if ((Object)(object)objectMask.Key != (Object)null) { objectMask.Key.SetActive(false); } } if (Time.unscaledTime > noticeUntil) { NoticeText = null; } } private void CollectMasks(GameManager gm) { wanted.Clear(); wantedObjects.Clear(); if ((Object)(object)NetworkClient.localPlayer != (Object)null) { PlayerUpgrades playerUpgrades = plugin.State(NetworkClient.localPlayer.netId); if (playerUpgrades.Has("BlindMansBluff")) { GameBase[] array = games; foreach (GameBase val in array) { if (Field(val, "casinoHelperTexts") is TMP_Text[] array2) { TMP_Text[] array3 = array2; foreach (TMP_Text val2 in array3) { if ((Object)(object)val2 != (Object)null) { wanted.Add((Behaviour)(object)val2); } } } if (val is HiLoGame) { object obj = Field(val, "hiLoSlider"); HiLoSlider val3 = (HiLoSlider)((obj is HiLoSlider) ? obj : null); if ((Object)(object)val3 != (Object)null) { MaskField(val3, "dicePercentageText"); } } if (val is Minesweeper) { MaskField(val, "multiplierText"); MaskField(val, "minesCountText"); MaskField(val, "potentialWinningText"); } } } GameUI val4 = Object.FindAnyObjectByType<GameUI>(); if ((Object)(object)val4 != (Object)null) { if (playerUpgrades.HideTimer(gm.RoundTimerRemaining, gm.RoundTimerEnabled)) { MaskField(val4, "timerText"); } if (playerUpgrades.Has("Overdrive")) { object obj2 = Field(val4, "contributionsHolder"); GameObject val5 = (GameObject)((obj2 is GameObject) ? obj2 : null); if ((Object)(object)val5 != (Object)null) { wantedObjects.Add(val5); } } } } List<Behaviour> list = new List<Behaviour>(); foreach (KeyValuePair<Behaviour, bool> item in masked) { if ((Object)(object)item.Key == (Object)null || !wanted.Contains(item.Key)) { if ((Object)(object)item.Key != (Object)null) { item.Key.enabled = item.Value; } list.Add(item.Key); } } foreach (Behaviour item2 in list) { masked.Remove(item2); } foreach (Behaviour item3 in wanted) { if (!masked.ContainsKey(item3)) { masked[item3] = item3.enabled; } } List<GameObject> list2 = new List<GameObject>(); foreach (KeyValuePair<GameObject, bool> objectMask in objectMasks) { if ((Object)(object)objectMask.Key == (Object)null || !wantedObjects.Contains(objectMask.Key)) { if ((Object)(object)objectMask.Key != (Object)null) { objectMask.Key.SetActive(objectMask.Value); } list2.Add(objectMask.Key); } } foreach (GameObject item4 in list2) { objectMasks.Remove(item4); } foreach (GameObject wantedObject in wantedObjects) { if (!objectMasks.ContainsKey(wantedObject)) { objectMasks[wantedObject] = wantedObject.activeSelf; } } } private void MaskField(object instance, string name) { object obj = Field(instance, name); Behaviour val = (Behaviour)((obj is Behaviour) ? obj : null); if ((Object)(object)val != (Object)null) { wanted.Add(val); } } internal BigNumber CheapestMax() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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) GameBase val = null; BigNumber val2 = BigNumber.MaxValue; BetLimits.Raw = true; try { GameBase[] array = games; foreach (GameBase val3 in array) { if (!((Object)(object)val3 == (Object)null)) { BigNumber minBet = val3.MinBet; if (minBet < val2 || (minBet == val2 && (Object)(object)val != (Object)null && val3.MaxBet < val.MaxBet)) { val2 = minBet; val = val3; } } } return ((Object)(object)val != (Object)null) ? val.MaxBet : BigNumber.Zero; } finally { BetLimits.Raw = false; } } internal void RecordWin(BigNumber stake, BigNumber payout, PlayerProfile winner) { //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) //IL_001b: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_0091: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active || (Object)(object)winner == (Object)null || payout <= stake) { return; } BigNumber threshold = CheapestMax(); foreach (NetworkConnectionToClient value in NetworkServer.connections.Values) { if (!((Object)(object)((NetworkConnection)value).identity == (Object)null) && ((NetworkConnection)value).identity.netId != ((NetworkBehaviour)winner).netId) { uint netId = ((NetworkConnection)value).identity.netId; if (plugin.State(netId).Has("TaxTheRich")) { SetCredit(netId, NativeFinance.EarnCredit(Credit(netId), payout - stake, threshold)); } } } } internal bool SupportHit(Item weapon, PlayerController victim) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 if (!NetworkServer.active || (Object)(object)NetworkSingleton<GameManager>.Instance == (Object)null || (int)NetworkSingleton<GameManager>.Instance.state != 1 || (Object)(object)weapon == (Object)null || (Object)(object)weapon.NetworkHolder == (Object)null || (Object)(object)victim == (Object)null || ((NetworkBehaviour)victim).netId == ((NetworkBehaviour)weapon.NetworkHolder).netId || !plugin.State(((NetworkBehaviour)weapon.NetworkHolder).netId).Has("HeavyWeaponry")) { return false; } RestoreUsedItem(victim); Tell(((NetworkBehaviour)weapon.NetworkHolder).netId, "Heavy Weaponry: teammate item restoration checked."); return true; } private static void ResetCooldown(Item item) { FieldInfo fieldInfo = AccessTools.Field(((object)item).GetType(), "_lastShootTime"); if (fieldInfo != null && fieldInfo.FieldType == typeof(float)) { fieldInfo.SetValue(item, Time.time - 3600f); } fieldInfo = AccessTools.Field(((object)item).GetType(), "_lastChargeTime"); if (fieldInfo != null && fieldInfo.FieldType == typeof(float)) { fieldInfo.SetValue(item, Time.time - 3600f); } fieldInfo = AccessTools.Field(((object)item).GetType(), "CooldownTimer"); if (fieldInfo != null && fieldInfo.FieldType == typeof(float)) { fieldInfo.SetValue(item, 0f); } } internal void Punish(PlayerInteract interact) { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) PlayerController component = ((Component)interact).GetComponent<PlayerController>(); PlayerOrgans component2 = ((Component)interact).GetComponent<PlayerOrgans>(); OrganManager instance = NetworkSingleton<OrganManager>.Instance; if ((Object)(object)component == (Object)null) { return; } if ((Object)(object)instance != (Object)null && (Object)(object)component2 != (Object)null) { PlayerOrganData organData = instance.GetOrganData(component2); if (organData != null) { List<OrganType> list = new List<OrganType>(); if (organData.leftEye) { list.Add((OrganType)0); } if (organData.rightEye) { list.Add((OrganType)1); } if (organData.body) { list.Add((OrganType)2); } if (organData.mouth) { list.Add((OrganType)3); } if (list.Count > 0) { instance.ServerToggleOrgan(component2, list[Random.Range(0, list.Count)], false); } } } component.ServerKnockback(Vector3.up * 2f, Vector3.zero); Tell(((NetworkBehaviour)component).netId, "Time is Money: late bet voided."); } private void SpawnPigs() { //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) foreach (NetworkConnectionToClient value in NetworkServer.connections.Values) { if ((Object)(object)((NetworkConnection)value).identity == (Object)null || !((NetworkConnection)value).isReady) { continue; } uint netId = ((NetworkConnection)value).identity.netId; ulong item = Key(netId); if (spawnedThisRun.Contains(item) || !plugin.State(netId).Has("PocketChange")) { continue; } PlayerController component = ((Component)((NetworkConnection)value).identity).GetComponent<PlayerController>(); if ((Object)(object)component == (Object)null || component.IsLocked) { continue; } GameObject val = null; foreach (GameObject value2 in NetworkClient.prefabs.Values) { if ((Object)(object)value2 != (Object)null && (Object)(object)value2.GetComponent<DebtBag>() != (Object)null) { val = value2; break; } } if ((Object)(object)val == (Object)null) { if (!warnedPigPrefab) { warnedPigPrefab = true; plugin.Log("Pocket Change: no registered DebtBag prefab yet; will retry."); } continue; } GameObject val2 = Object.Instantiate<GameObject>(val, ((Component)component).transform.position + ((Component)component).transform.forward * 0.8f + Vector3.up * 0.3f, Quaternion.identity); DebtBag component2 = val2.GetComponent<DebtBag>(); pigInstances.Add(((Object)component2).GetInstanceID()); NetworkServer.Spawn(val2, (NetworkConnectionToClient)null); component2.ServerSetMoney(BigNumber.Zero); pigs[((NetworkBehaviour)component2).netId] = netId; spawnedThisRun.Add(item); Wire wire = new Wire(); wire.kind = "pig"; wire.player = netId; wire.item = ((NetworkBehaviour)component2).netId; Plugin.SendAll(wire); plugin.Log("Pocket Change pig spawned for player " + netId + " (item " + ((NetworkBehaviour)component2).netId + ")."); } } internal unsafe bool Smash(Item item) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Invalid comparison between Unknown and I4 //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active || !IsPig(item)) { return false; } if ((Object)(object)NetworkSingleton<GameManager>.Instance == (Object)null || (Object)(object)NetworkSingleton<MoneyManager>.Instance == (Object)null || (int)NetworkSingleton<GameManager>.Instance.state != 1) { return true; } uint netId = ((NetworkBehaviour)item).netId; if (!pigs.TryGetValue(netId, out var value)) { return true; } NetworkIdentity value2; PlayerProfile val = ((NetworkServer.spawned.TryGetValue(value, out value2) && (Object)(object)value2 != (Object)null) ? ((Component)value2).GetComponent<PlayerProfile>() : null); if ((Object)(object)item.NetworkHolder != (Object)null) { PlayerInventory networkHolder = item.NetworkHolder; item.ServerDrop(); networkHolder.ServerRemoveItem(item); } pigs.Remove(netId); pigInstances.Remove(((Object)item).GetInstanceID()); pigVisuals.Remove(netId); BigNumber val2 = NetworkSingleton<GameManager>.Instance.currentQuota * 0.02; NetworkSingleton<MoneyManager>.Instance.TryChangeBalance(val2, val, (ChangeType)2); Wire wire = new Wire(); wire.kind = "pigGone"; wire.item = netId; Plugin.SendAll(wire); NetworkServer.Destroy(((Component)item).gameObject); plugin.Log("Pocket Change smashed: bank +" + ((object)(*(BigNumber*)(&val2))/*cast due to .constrained prefix*/).ToString() + "; credited owner " + value + (((Object)(object)val == (Object)null) ? " (owner no longer connected)" : "")); return true; } private void ClearPigs() { List<uint> list = new List<uint>(pigs.Keys); foreach (uint item in list) { if (NetworkServer.spawned.TryGetValue(item, out var value) && (Object)(object)value != (Object)null) { Item component = ((Component)value).GetComponent<Item>(); if ((Object)(object)component != (Object)null) { pigInstances.Remove(((Object)component).GetInstanceID()); } NetworkServer.Destroy(((Component)value).gameObject); } Wire wire = new Wire(); wire.kind = "pigGone"; wire.item = item; Plugin.SendAll(wire); } pigs.Clear(); pigVisuals.Clear(); } private void ApplyPigVisuals() { //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Expected O, but got Unknown //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missin