using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Extensions; using HarmonyLib; using Microsoft.CodeAnalysis; using Mirror; using MoreMountains.Tools; using MoreUpgrades.Menu; using Steamworks; using TMPro; using TryConnect; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace MoreUpgrades { public class ExtraDailyTimeUpgrade : Upgrade { public const float SecondsPerUse = 30f; private static readonly FieldRef ValueTextField = AccessTools.FieldRefAccess("valueText"); private bool _hasBeenUsed; private void Start() { TextMeshPro val = ValueTextField.Invoke((Upgrade)(object)this); if ((Object)(object)val != (Object)null) { ((TMP_Text)val).text = $"+{30f:0.#}s"; } } protected override void OnUseItem(bool isPressed) { if (!_hasBeenUsed) { _hasBeenUsed = true; if (((NetworkBehaviour)this).isServer) { ((MonoBehaviour)this).StartCoroutine(UseRoutine()); } } } private IEnumerator UseRoutine() { yield return (object)new WaitForSecondsRealtime(0.5f); GameManager val = Object.FindFirstObjectByType(); if ((Object)(object)val != (Object)null) { GameUpgradeState.ShareAcrossLobby(GamePlayerUpgradeType.ExtraDailyTime, 30f); GrantExtraTime(val, 30f); PluginMain.Log.LogInfo((object)$"Extra Time granted +{30f}s of day duration (state={val.state})."); } else { PluginMain.Log.LogWarning((object)"Extra Time: no GameManager found — skipping."); } ((ConsumableItem)this).DestroyItem(); } internal static void GrantExtraTime(GameManager gameManager, float seconds) { if (NetworkServer.active && !((Object)(object)gameManager == (Object)null) && !(seconds <= 0f)) { gameManager.Network_dayDuration += seconds; } } public override bool Weaved() { return true; } } public class GameFlavoredUpgrade : Upgrade { private static readonly FieldRef AnimField = AccessTools.FieldRefAccess("anim"); private static readonly FieldRef UpgradeSfxField = AccessTools.FieldRefAccess("upgradeSfx"); private static readonly FieldRef ValueTextField = AccessTools.FieldRefAccess("valueText"); [SerializeField] private GamePlayerUpgradeType _upgradeType; [SerializeField] private float _amount; [SerializeField] private bool _configured; private bool _hasBeenUsed; protected GamePlayerUpgradeType UpgradeType => _upgradeType; protected float Amount => _amount; public void Configure(GamePlayerUpgradeType upgradeType, float amount) { _upgradeType = upgradeType; _amount = amount; _configured = true; } private void Start() { TextMeshPro val = ValueTextField.Invoke((Upgrade)(object)this); if ((Object)(object)val != (Object)null) { ((TMP_Text)val).text = (_amount * 100f).ToString("0.#") + "%"; } } protected override void OnUseItem(bool isPressed) { if (!_hasBeenUsed && _configured) { _hasBeenUsed = true; Animator val = AnimField.Invoke((Upgrade)(object)this); if ((Object)(object)val != (Object)null) { val.SetTrigger("Use"); } if (((NetworkBehaviour)this).isServer) { ((MonoBehaviour)this).StartCoroutine(UseRoutine()); } } } private IEnumerator UseRoutine() { yield return (object)new WaitForSecondsRealtime(0.5f); PlayerProfile[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (PlayerProfile val in array) { GameUpgradeState.Add(val.steamId, _upgradeType, _amount); RpcUpgradeChanged(val.steamId, _upgradeType, GameUpgradeState.Get(val.steamId, _upgradeType)); } PluginMain.Log.LogInfo((object)$"Granted {_upgradeType} +{_amount} to the lobby."); SFXComponent val2 = UpgradeSfxField.Invoke((Upgrade)(object)this); if ((Object)(object)val2 != (Object)null) { val2.RpcPlayOneShotWith3DPos(); } ((ConsumableItem)this).DestroyItem(); } [ClientRpc] private void RpcUpgradeChanged(ulong steamId, GamePlayerUpgradeType type, float newTotal) { UpgradeHudSync.OnUpgradeChanged(steamId, type, newTotal); } public override bool Weaved() { return true; } } public enum GamePlayerUpgradeType { SlotsLuck, RouletteLuck, WheelLuck, BlackjackLuck, PokerLuck, BaccaratLuck, CrapsLuck, MinesweeperLuck, CrashLuck, PlinkoLuck, KenoLuck, HiLoLuck, DuckRaceLuck, CrossyRoadLuck, CoinFlipLuck, ExtraShopItems, ExtraDailyTime } internal static class GameTypeMap { private static readonly Dictionary Map = new Dictionary { [(CasinoGameType)12] = GamePlayerUpgradeType.SlotsLuck, [(CasinoGameType)11] = GamePlayerUpgradeType.RouletteLuck, [(CasinoGameType)9] = GamePlayerUpgradeType.WheelLuck, [(CasinoGameType)13] = GamePlayerUpgradeType.WheelLuck, [(CasinoGameType)0] = GamePlayerUpgradeType.BlackjackLuck, [(CasinoGameType)14] = GamePlayerUpgradeType.PokerLuck, [(CasinoGameType)16] = GamePlayerUpgradeType.BaccaratLuck, [(CasinoGameType)1] = GamePlayerUpgradeType.CrapsLuck, [(CasinoGameType)8] = GamePlayerUpgradeType.MinesweeperLuck, [(CasinoGameType)5] = GamePlayerUpgradeType.MinesweeperLuck, [(CasinoGameType)2] = GamePlayerUpgradeType.CrashLuck, [(CasinoGameType)10] = GamePlayerUpgradeType.PlinkoLuck, [(CasinoGameType)7] = GamePlayerUpgradeType.KenoLuck, [(CasinoGameType)4] = GamePlayerUpgradeType.HiLoLuck, [(CasinoGameType)6] = GamePlayerUpgradeType.DuckRaceLuck, [(CasinoGameType)3] = GamePlayerUpgradeType.CrossyRoadLuck, [(CasinoGameType)15] = GamePlayerUpgradeType.CoinFlipLuck }; public static GamePlayerUpgradeType? ToUpgrade(CasinoGameType gameType) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!Map.TryGetValue(gameType, out var value)) { return null; } return value; } } [Serializable] public sealed class GameUpgradeSaveData { [Serializable] public sealed class PlayerEntry { public string steamId = ""; public List upgrades = new List(); } [Serializable] public sealed class ValueEntry { public GamePlayerUpgradeType type; public float value; } public List players = new List(); } internal static class GameUpgradeState { private static readonly ConcurrentDictionary> Values = new ConcurrentDictionary>(); public static float Get(ulong steamId, GamePlayerUpgradeType type) { if (Values.TryGetValue(steamId, out ConcurrentDictionary value) && value.TryGetValue(type, out var value2)) { return value2; } return 0f; } public static void Add(ulong steamId, GamePlayerUpgradeType type, float amount) { Values.GetOrAdd(steamId, (ulong _) => new ConcurrentDictionary()).AddOrUpdate(type, amount, (GamePlayerUpgradeType _, float existing) => existing + amount); } public static void Set(ulong steamId, GamePlayerUpgradeType type, float value) { Values.GetOrAdd(steamId, (ulong _) => new ConcurrentDictionary())[type] = value; } public static void ShareAcrossLobby(GamePlayerUpgradeType type, float amount) { PlayerProfile[] array = Object.FindObjectsByType((FindObjectsSortMode)0); for (int i = 0; i < array.Length; i++) { Add(array[i].steamId, type, amount); } } public static void ResetAll() { Values.Clear(); } public static IEnumerable<(ulong SteamId, GamePlayerUpgradeType Type, float Value)> All() { foreach (KeyValuePair> kvp in Values) { foreach (KeyValuePair item in kvp.Value) { yield return (SteamId: kvp.Key, Type: item.Key, Value: item.Value); } } } } internal static class ItemDescriptionRegistry { private static readonly ConcurrentDictionary DescriptionsBySpawnableId = new ConcurrentDictionary(); private static readonly ConcurrentDictionary NamesBySpawnableId = new ConcurrentDictionary(); public static void Register(int spawnableId, string displayName, string description) { NamesBySpawnableId[spawnableId] = displayName; DescriptionsBySpawnableId[spawnableId] = description; } public static bool TryGetDescription(int spawnableId, out string description) { return DescriptionsBySpawnableId.TryGetValue(spawnableId, out description); } public static bool TryGetName(int spawnableId, out string name) { return NamesBySpawnableId.TryGetValue(spawnableId, out name); } } internal static class ItemRegistrar { private readonly struct OddsUpgradeDefinition { public readonly string Key; public readonly string DisplayName; public readonly string GameLabel; public readonly GamePlayerUpgradeType UpgradeType; public readonly Color Tint; public OddsUpgradeDefinition(string key, string displayName, string gameLabel, GamePlayerUpgradeType upgradeType, Color tint) { //IL_001e: 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) Key = key; DisplayName = displayName; GameLabel = gameLabel; UpgradeType = upgradeType; Tint = tint; } } private const float DefaultOddsBoost = 0.15f; private const string ScrollBundlePath = "Assets/moreupgrades.scroll"; private const string ScrollVisualPrefabName = "scroll"; private static readonly Vector3 ScrollVisualScale = new Vector3(0.8f, 0.8f, 1.15f); private const string PillsBundlePath = "Assets/moreupgrades.pills"; private const string PillsVisualPrefabName = "pills"; private static readonly Vector3 PillsVisualScale = Vector3.one * 0.32f; private static readonly Vector3 PillsVisualEulerAngles = new Vector3(0f, -180f, 0f); private static readonly OddsUpgradeDefinition[] OddsUpgrades = new OddsUpgradeDefinition[15] { new OddsUpgradeDefinition("slots_luck", "Slots Luck", "Slots", GamePlayerUpgradeType.SlotsLuck, HsvColor(0f, 0.85f, 0.9f)), new OddsUpgradeDefinition("roulette_reader", "Roulette Reader", "Roulette", GamePlayerUpgradeType.RouletteLuck, HsvColor(24f, 0.9f, 0.75f)), new OddsUpgradeDefinition("wheel_whisperer", "Wheel Whisperer", "Money Wheel and Wheel of Fortune", GamePlayerUpgradeType.WheelLuck, HsvColor(48f, 0.9f, 0.95f)), new OddsUpgradeDefinition("card_counter", "Card Counter", "Blackjack", GamePlayerUpgradeType.BlackjackLuck, HsvColor(72f, 0.75f, 0.75f)), new OddsUpgradeDefinition("poker_face", "Poker Face", "Poker", GamePlayerUpgradeType.PokerLuck, HsvColor(96f, 0.8f, 0.65f)), new OddsUpgradeDefinition("baccarat_instinct", "Baccarat Instinct", "Baccarat", GamePlayerUpgradeType.BaccaratLuck, HsvColor(120f, 0.75f, 0.6f)), new OddsUpgradeDefinition("loaded_dice", "Loaded Dice", "Craps", GamePlayerUpgradeType.CrapsLuck, HsvColor(144f, 0.85f, 0.7f)), new OddsUpgradeDefinition("steady_hands", "Steady Hands", "Minesweeper and Dragon Tower", GamePlayerUpgradeType.MinesweeperLuck, HsvColor(168f, 0.8f, 0.75f)), new OddsUpgradeDefinition("crash_sense", "Crash Sense", "Crash", GamePlayerUpgradeType.CrashLuck, HsvColor(192f, 0.85f, 0.9f)), new OddsUpgradeDefinition("plinko_precision", "Plinko Precision", "Plinko", GamePlayerUpgradeType.PlinkoLuck, HsvColor(216f, 0.85f, 0.9f)), new OddsUpgradeDefinition("keno_clairvoyance", "Keno Clairvoyance", "Keno", GamePlayerUpgradeType.KenoLuck, HsvColor(240f, 0.75f, 0.85f)), new OddsUpgradeDefinition("hilo_hunch", "Hi-Lo Hunch", "Hi-Lo", GamePlayerUpgradeType.HiLoLuck, HsvColor(264f, 0.8f, 0.8f)), new OddsUpgradeDefinition("duck_whisperer", "Duck Whisperer", "Duck Race", GamePlayerUpgradeType.DuckRaceLuck, HsvColor(288f, 0.85f, 0.85f)), new OddsUpgradeDefinition("crossy_confidence", "Crossy Confidence", "Crossy Road", GamePlayerUpgradeType.CrossyRoadLuck, HsvColor(312f, 0.85f, 0.85f)), new OddsUpgradeDefinition("coin_sense", "Coin Sense", "Coin Flip", GamePlayerUpgradeType.CoinFlipLuck, HsvColor(336f, 0.9f, 0.8f)) }; private static string DurationWord { get { if (!PluginMain.PersistentUpgradesPresent) { return "Boosts (for the rest of today)"; } return "Permanently boosts"; } } private static Color HsvColor(float hueDegrees, float saturation, float value) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) return Color.HSVToRGB(hueDegrees / 360f, saturation, value); } public static void RegisterAll(BaseUnityPlugin plugin) { //IL_0069: 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) SpawnableSO val = TryConnectApi.FindVanillaSpawnable(); if ((Object)(object)val == (Object)null) { PluginMain.Log.LogError((object)"Could not find the vanilla Upgrade spawnable — no items were registered."); return; } OddsUpgradeDefinition[] oddsUpgrades = OddsUpgrades; for (int i = 0; i < oddsUpgrades.Length; i++) { OddsUpgradeDefinition oddsUpgradeDefinition = oddsUpgrades[i]; string description = DurationWord + " your winnings at " + oddsUpgradeDefinition.GameLabel + "."; RegisterGameFlavoredUpgrade(plugin, val, oddsUpgradeDefinition.Key, oddsUpgradeDefinition.DisplayName, description, oddsUpgradeDefinition.UpgradeType, 0.15f, oddsUpgradeDefinition.Tint); } RegisterGameFlavoredUpgrade(plugin, val, "shop_scout", "Shop Scout", DurationWord + " the shop by one extra random item each day.", GamePlayerUpgradeType.ExtraShopItems, 1f, new Color(0.4f, 0.75f, 0.9f)); RegisterExtraDailyTime(plugin, val); RegisterSecondWind(plugin, val); } private static void RegisterGameFlavoredUpgrade(BaseUnityPlugin plugin, SpawnableSO baseSpawnable, string key, string displayName, string description, GamePlayerUpgradeType upgradeType, float amount, Color tint) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) GameObject val = CreateScrollPrefab(plugin, baseSpawnable, key, "CustomPrefab"); GameObject val2 = CreateScrollPrefab(plugin, baseSpawnable, key, "MarkerPrefab"); TryConnectApi.SwapPrefabComponent(val).Configure(upgradeType, amount); TryConnectApi.SwapPrefabComponent(val2).Configure(upgradeType, amount); Register(plugin, key, displayName, description, baseSpawnable, val, val2, tint); } private static void RegisterExtraDailyTime(BaseUnityPlugin plugin, SpawnableSO baseSpawnable) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) Color tint = default(Color); ((Color)(ref tint))..ctor(0.95f, 0.55f, 0.75f); GameObject val = CreateScrollPrefab(plugin, baseSpawnable, "extra_time", "CustomPrefab"); GameObject val2 = CreateScrollPrefab(plugin, baseSpawnable, "extra_time", "MarkerPrefab"); TryConnectApi.SwapPrefabComponent(val); TryConnectApi.SwapPrefabComponent(val2); string description = "Adds 30 seconds to today's gambling timer." + (PluginMain.PersistentUpgradesPresent ? " Carries over to future days too." : ""); Register(plugin, "extra_time", "Extra Time", description, baseSpawnable, val, val2, tint); } private static GameObject CreateScrollPrefab(BaseUnityPlugin plugin, SpawnableSO baseSpawnable, string key, string suffix) { //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) return CreateBundledVisualPrefab(plugin, baseSpawnable, key, suffix, "Assets/moreupgrades.scroll", "scroll", ScrollVisualScale, Vector3.zero); } private static GameObject CreatePillsPrefab(BaseUnityPlugin plugin, SpawnableSO baseSpawnable, string key, string suffix) { //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) return CreateBundledVisualPrefab(plugin, baseSpawnable, key, suffix, "Assets/moreupgrades.pills", "pills", PillsVisualScale, PillsVisualEulerAngles); } private static GameObject CreateBundledVisualPrefab(BaseUnityPlugin plugin, SpawnableSO baseSpawnable, string key, string suffix, string bundlePath, string visualPrefabName, Vector3 visualScale, Vector3 visualEulerAngles) { //IL_0027: 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_002f: Unknown result type (might be due to invalid IL or missing references) GameObject val = TryConnectApi.CreatePrefabTemplate(baseSpawnable, key + "_" + suffix); AssetBundle val2 = TryConnectAssetBundles.LoadRelativeToPlugin(plugin, bundlePath); try { GameObject val3 = TryConnectAssetBundles.LoadAsset(val2, visualPrefabName); TryConnectApi.ReplaceVisualsWithPrefab(val, val3, visualScale, true, Vector3.zero, visualEulerAngles); return val; } finally { val2.Unload(false); } } private static void RegisterSecondWind(BaseUnityPlugin plugin, SpawnableSO baseSpawnable) { GameObject val = CreatePillsPrefab(plugin, baseSpawnable, "second_wind", "CustomPrefab"); GameObject val2 = CreatePillsPrefab(plugin, baseSpawnable, "second_wind", "MarkerPrefab"); TryConnectApi.SwapPrefabComponent(val); TryConnectApi.SwapPrefabComponent(val2); Register(plugin, "second_wind", "Second Wind", "Regenerates one random missing body part. Single use.", baseSpawnable, val, val2, null, 4); } private static void Register(BaseUnityPlugin plugin, string key, string displayName, string description, SpawnableSO baseSpawnable, GameObject customPrefab, GameObject markerPrefab, Color tint) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) Register(plugin, key, displayName, description, baseSpawnable, customPrefab, markerPrefab, tint, 4); } private static void Register(BaseUnityPlugin plugin, string key, string displayName, string description, SpawnableSO baseSpawnable, GameObject customPrefab, GameObject markerPrefab, Color? tint, int replacementChancePercent) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_0066: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00c3: Expected O, but got Unknown //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) int num = TryConnectApi.GenerateSpawnableId(plugin.Info.Metadata.GUID, key); ItemDescriptionRegistry.Register(num, displayName, description); ApplyInteractableName(customPrefab, displayName); ApplyInteractableName(markerPrefab, displayName); TryConnectRegistrationResult val = TryConnectApi.RegisterCustomItem(new TryConnectItemRegistration { OwnerGuid = plugin.Info.Metadata.GUID, Key = key, SpawnableId = num, DisplayName = displayName, Description = description, BaseSpawnable = baseSpawnable, BaseItemComponentType = typeof(Upgrade), CustomPrefab = customPrefab, MarkerPrefab = markerPrefab, ApplyTint = tint.HasValue, Tint = tint.GetValueOrDefault(), ReplacementChancePercent = replacementChancePercent, ExtraBasePrice = 0, ExtraFloorPrice = 0 }); PluginMain.Log.LogInfo((object)$"Registered '{key}': {val}"); TryConnectRegisteredItemInfo val2 = default(TryConnectRegisteredItemInfo); if (TryConnectApi.TryGetRegisteredItem(num, ref val2) && (Object)(object)val2.Spawnable != (Object)null) { ApplySpawnableSo(customPrefab, val2.Spawnable); ApplySpawnableSo(markerPrefab, val2.Spawnable); } else { PluginMain.Log.LogWarning((object)("'" + key + "': could not resolve the registered SpawnableSO — spawnableSo may still point at the wrong item.")); } } private static void ApplySpawnableSo(GameObject prefab, SpawnableSO spawnable) { Item component = prefab.GetComponent(); if (!((Object)(object)component == (Object)null)) { component.spawnableSo = spawnable; } } private static void ApplyInteractableName(GameObject prefab, string displayName) { Item component = prefab.GetComponent(); if ((Object)(object)component == (Object)null) { PluginMain.Log.LogWarning((object)("ApplyInteractableName: '" + ((Object)prefab).name + "' has no Item component — could not set InteractableName.")); return; } string interactableName = ((InteractableBase)component).InteractableName; ((InteractableBase)component).InteractableName = displayName; PluginMain.Log.LogInfo((object)("ApplyInteractableName: '" + ((Object)prefab).name + "'.InteractableName '" + interactableName + "' -> '" + displayName + "'.")); } } [BepInPlugin("com.cristokos.moreupgrades", "MoreUpgrades", "1.0.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class PluginMain : BaseUnityPlugin { public const string PluginGuid = "com.cristokos.moreupgrades"; public const string PluginName = "MoreUpgrades"; public const string PluginVersion = "1.0.2"; private const string TryConnectGuid = "com.Try-4646.TryConnect"; internal const string PersistentUpgradesGuid = "com.cristokos.persistentupgrades"; private Harmony? _harmony; internal static ManualLogSource Log { get; private set; } internal static bool PersistentUpgradesPresent { get; private set; } internal static ConfigEntry UnlockDevConsole { get; private set; } internal static ConfigFile ConfigFile { get; private set; } private void Awake() { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; ConfigFile = ((BaseUnityPlugin)this).Config; UnlockDevConsole = ((BaseUnityPlugin)this).Config.Bind("Debug", "UnlockDevConsole", false, "Unlocks the game's built-in dev console (spawn any item on demand) for testing. Leave off for normal play."); PersistentUpgradesPresent = Chainloader.PluginInfos.ContainsKey("com.cristokos.persistentupgrades"); Log.LogInfo((object)(PersistentUpgradesPresent ? "PersistentUpgrades detected — MoreUpgrades upgrades will be permanent and lobby-shared." : "PersistentUpgrades not detected — MoreUpgrades upgrades will reset daily, like vanilla upgrades.")); _harmony = new Harmony("com.cristokos.moreupgrades"); PatchAllSafely(_harmony); try { ItemRegistrar.RegisterAll((BaseUnityPlugin)(object)this); } catch (Exception arg) { Log.LogError((object)$"ItemRegistrar.RegisterAll threw — some or all items may not have registered: {arg}"); } Log.LogInfo((object)"MoreUpgrades 1.0.2 initialized."); } private static void PatchAllSafely(Harmony harmony) { Type[] typesFromAssembly = AccessTools.GetTypesFromAssembly(typeof(PluginMain).Assembly); foreach (Type type in typesFromAssembly) { try { harmony.CreateClassProcessor(type).Patch(); } catch (Exception arg) { Log.LogError((object)$"Failed to patch '{type.FullName}' — that patch is disabled, everything else continues: {arg}"); } } } private void OnDestroy() { Harmony? harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } public class SecondWindItem : Upgrade { private static readonly Random Random = new Random(); private bool _hasBeenUsed; protected override void OnUseItem(bool isPressed) { if (!_hasBeenUsed) { _hasBeenUsed = true; if (((NetworkBehaviour)this).isServer) { ((MonoBehaviour)this).StartCoroutine(UseRoutine()); } } } private IEnumerator UseRoutine() { yield return (object)new WaitForSecondsRealtime(0.5f); GameManager val = Object.FindFirstObjectByType(); if ((Object)(object)val == (Object)null) { PluginMain.Log.LogWarning((object)"Second Wind: no GameManager found — skipping."); } else if ((int)val.state != 1) { PluginMain.Log.LogWarning((object)$"Second Wind: GameManager.state is '{val.state}', not Game — skipping."); } else { PlayerInventory networkHolder = ((Item)this).NetworkHolder; if ((Object)(object)networkHolder == (Object)null) { PluginMain.Log.LogWarning((object)"Second Wind: NetworkHolder is null — skipping."); } else { PlayerOrgans component = ((Component)networkHolder).GetComponent(); if ((Object)(object)component == (Object)null) { PluginMain.Log.LogWarning((object)"Second Wind: holder has no PlayerOrgans component — skipping."); } else { RegenerateRandomMissingOrgan(component); } } } ((ConsumableItem)this).DestroyItem(); } private static void RegenerateRandomMissingOrgan(PlayerOrgans organs) { //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) OrganManager val = Object.FindFirstObjectByType(); if ((Object)(object)val == (Object)null) { PluginMain.Log.LogWarning((object)"Second Wind: no OrganManager found — skipping."); return; } if (((NetworkBehaviour)organs).connectionToClient == null) { PluginMain.Log.LogWarning((object)"Second Wind: organs.connectionToClient is null — skipping."); return; } if (!val.OrganData.TryGetValue(((NetworkBehaviour)organs).connectionToClient.connectionId, out var value)) { PluginMain.Log.LogWarning((object)$"Second Wind: no OrganData entry for connectionId {((NetworkBehaviour)organs).connectionToClient.connectionId} — skipping."); return; } PluginMain.Log.LogInfo((object)$"Second Wind: current organ state — leftEye={value.leftEye}, rightEye={value.rightEye}, body={value.body}, mouth={value.mouth}."); List list = new List(); if (!value.leftEye) { list.Add((OrganType)0); } if (!value.rightEye) { list.Add((OrganType)1); } if (!value.body) { list.Add((OrganType)2); } if (!value.mouth) { list.Add((OrganType)3); } if (list.Count == 0) { PluginMain.Log.LogInfo((object)"Second Wind: no missing organs — nothing to regenerate."); return; } OrganType val2 = list[Random.Next(list.Count)]; val.ServerToggleOrgan(organs, val2, true); PluginMain.Log.LogInfo((object)$"Second Wind regenerated {val2}."); } public override bool Weaved() { return true; } } } namespace MoreUpgrades.Patches { [HarmonyPatch(typeof(SettingsLayoutRuntimeUI), "ShowTab")] internal static class BulkToggleButtonsPatch { private static readonly FieldInfo? ResetEntryPrefabField = AccessTools.Field(typeof(SettingsLayoutRuntimeUI), "resetEntryPrefab"); private static readonly FieldInfo? LayoutField = AccessTools.Field(typeof(SettingsLayoutRuntimeUI), "layout"); private static readonly FieldInfo? TabContentsField = AccessTools.Field(typeof(SettingsLayoutRuntimeUI), "tabContents"); private static readonly Random Random = new Random(); private static void Postfix(SettingsLayoutRuntimeUI __instance, string tabName) { object? obj = LayoutField?.GetValue(__instance); SettingsLayout val = (SettingsLayout)((obj is SettingsLayout) ? obj : null); if (val == null || val.tabs == null) { return; } List toggleEntries = (from e in val.tabs.Find((Tab t) => string.Equals(t.tabName, tabName, StringComparison.OrdinalIgnoreCase))?.entries?.OfType() where ItemToggleMenu.IsShopToggleKey(((SettingItemBase)e).key) select e).ToList(); if (toggleEntries == null || toggleEntries.Count == 0) { return; } Transform val2 = FindContentRoot(__instance, tabName); object? obj2 = ResetEntryPrefabField?.GetValue(__instance); GameObject val3 = (GameObject)((obj2 is GameObject) ? obj2 : null); if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val3 == (Object)null)) { CreateBulkButton(val3, val2, "\"MoreUpgrades\" — All On", delegate { SetAll(__instance, tabName, toggleEntries, enabled: true); }); CreateBulkButton(val3, val2, "\"MoreUpgrades\" — All Off", delegate { SetAll(__instance, tabName, toggleEntries, enabled: false); }); CreateBulkButton(val3, val2, "\"MoreUpgrades\" — Randomize", delegate { Randomize(__instance, tabName, toggleEntries); }); } } private static Transform? FindContentRoot(SettingsLayoutRuntimeUI runtimeUi, string tabName) { if (!(TabContentsField?.GetValue(runtimeUi) is IEnumerable enumerable)) { return null; } foreach (object item in enumerable) { FieldInfo? field = item.GetType().GetField("tabName"); FieldInfo field2 = item.GetType().GetField("contentRoot"); if (string.Equals(field?.GetValue(item) as string, tabName, StringComparison.OrdinalIgnoreCase)) { object? obj = field2?.GetValue(item); object? obj2 = ((obj is RectTransform) ? obj : null); return (obj2 != null) ? ((Component)obj2).transform : null; } } return null; } private static void CreateBulkButton(GameObject resetPrefab, Transform parent, string label, Action onClick) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown GameObject obj = Object.Instantiate(resetPrefab, parent); ((Object)obj).name = "MoreUpgrades_" + label; TMP_Text componentInChildren = obj.GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.text = label; } Button componentInChildren2 = obj.GetComponentInChildren