Decompiled source of UltimateAscent v1.6.8
plugins\UltimateAscent\UltimateAscent.dll
Decompiled 20 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Peak; using Peak.Afflictions; using Peak.Island; using Photon.Pun; using Photon.Realtime; using TMPro; using UltimateAscent.Compat; using UltimateAscent.Core; using UltimateAscent.Features; using UltimateAscent.Features.Fixes; using UltimateAscent.Features.Weather; using UnityEngine; using UnityEngine.Audio; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; using Zorro.Core; using Zorro.Core.Serizalization; using Zorro.Settings; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("Zorro.Core.Runtime")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("UltimateAscent")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.6.8.0")] [assembly: AssemblyInformationalVersion("1.6.8+7c4defada99cf36cb91d5a79c190456df83bd13b")] [assembly: AssemblyProduct("UltimateAscent")] [assembly: AssemblyTitle("UltimateAscent")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.6.8.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace UltimateAscent { [BepInPlugin("UltimateAscent", "Ultimate Ascent", "1.6.8")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInIncompatibility("MoreAscents")] [BepInIncompatibility("13dastardlyascents")] public sealed class Plugin : BaseUnityPlugin { public const string Guid = "UltimateAscent"; public const string Name = "Ultimate Ascent"; public const string Version = "1.6.8"; internal static ManualLogSource Log; internal static Plugin Instance; internal static bool Ready; internal static ConfigEntry<bool> UnlockAll; internal static ConfigEntry<int> ExtendedProgress; internal static ConfigEntry<int> DefaultAscent; internal static ConfigEntry<bool> WrapAround; internal static ConfigEntry<bool> BoardingPassExtras; internal static ConfigEntry<bool> VerboseLogging; internal static ConfigEntry<bool> MapBiomes; internal static ConfigEntry<bool>[] AscentSwitches; internal static ConfigEntry<bool> HotCampfires; internal static ConfigEntry<bool> ColdNights; internal static ConfigEntry<bool> NewItems; internal static ConfigEntry<bool> SixSlotBackpack; internal static ConfigEntry<bool> SixSlotBackpackMultiplayer; internal static ConfigEntry<bool> Ascent8; internal static ConfigEntry<bool> MoreWildFood; internal static ConfigEntry<bool> NewMobs; internal static ConfigEntry<bool> EffectIcons; private Harmony harmony; private void Awake() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown //IL_00d7: 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) Log = ((BaseUnityPlugin)this).Logger; Instance = this; BindConfig(); if (!AscentCatalog.EnsureDefault()) { Log.LogError((object)"Ultimate Ascent is disabled because its ascents could not be added to the game."); return; } harmony = new Harmony("UltimateAscent"); int num = 0; int num2 = 0; Type[] typesFromAssembly = AccessTools.GetTypesFromAssembly(Assembly.GetExecutingAssembly()); foreach (Type type in typesFromAssembly) { if (type.GetCustomAttributes(typeof(HarmonyPatch), inherit: false).Any()) { try { harmony.CreateClassProcessor(type).Patch(); num++; } catch (Exception ex) { num2++; Log.LogError((object)("Patch " + type.FullName + " could not be applied; that rule is off. " + ex.GetBaseException().Message)); } } } GameObject val = new GameObject("UltimateAscentRuntime"); Object.DontDestroyOnLoad((Object)val); ((Object)val).hideFlags = (HideFlags)61; val.AddComponent<Runtime>(); ZombieDagger.Listen(); GloomCrows.Listen(); A22_Episodes.Listen(); SnakeParalysis.Listen(); A17_Hazards.Listen(); ClownFlyTrap.Listen(); WindDebris.Listen(); SpruceNeedles.Listen(); HostWarps.Listen(); SceneManager.activeSceneChanged += OnActiveSceneChanged; Rules.OnActiveSceneChanged(SceneManager.GetActiveScene()); Ready = true; Log.LogInfo((object)(string.Format("{0} {1} loaded: ascents {2}-{3} added, {4} patch classes applied", "Ultimate Ascent", "1.6.8", 9, 25, num) + ((num2 > 0) ? $", {num2} failed." : ".") + (Tfa.Present ? " True Final Ascent detected." : ""))); } private static void RefreshOpenPass(string setting) { try { BoardingPass val = (((Object)(object)GUIManager.instance != (Object)null) ? GUIManager.instance.boardingPass : null); if ((Object)(object)val != (Object)null && ((MenuWindow)val).isOpen) { val.UpdateAscent(); } } catch (Exception ex) { Log.LogWarning((object)(setting + ": the open boarding pass could not be refreshed: " + ex.Message)); } } private void BindConfig() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Expected O, but got Unknown DefaultAscent = ((BaseUnityPlugin)this).Config.Bind<int>("Boarding Pass", "Default Ascent", 0, new ConfigDescription("The ascent the boarding pass shows when you first open it after arriving at the airport. -1 = Tenderfoot, 0 = Peak (the game's normal choice, also leaves True Final Ascent's own start option alone), 1-25 = that ascent. Values above your highest unlocked ascent pick the highest unlocked one.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 25), Array.Empty<object>())); WrapAround = ((BaseUnityPlugin)this).Config.Bind<bool>("Boarding Pass", "Wrap Around", true, "The ascent arrows wrap around: left from Tenderfoot jumps to the end of the list (True Final Ascent's FINAL ASCENT if installed, otherwise your highest unlocked ascent), right from the end of the list goes back to Tenderfoot."); BoardingPassExtras = ((BaseUnityPlugin)this).Config.Bind<bool>("Boarding Pass", "Boarding Pass Extras", true, "The mod's additions to the boarding pass: the Blind Mode and Hot Mode boxes in its header and the map picker on its ascent card. Off: none of them shows, Blind Mode and Hot Mode stay off (your ticks are kept for when this is on again) and every climb is on today's map. Each player's own; in multiplayer the host's Blind Mode and Hot Mode count for everyone."); BoardingPassExtras.SettingChanged += delegate { RefreshOpenPass("Boarding Pass Extras"); }; MapBiomes = ((BaseUnityPlugin)this).Config.Bind<bool>("Boarding Pass", "Map Biomes", false, "The map picker shows each map's biomes after its number, by the first letters of their names: MAP 90 (STMC) is Shore, Tropics, Mesa and Caldera (R: Roots, A: Alpine, G: the Gloom). Today's map shows its number only. Each player's own."); MapBiomes.SettingChanged += delegate { RefreshOpenPass("Map Biomes"); }; UnlockAll = ((BaseUnityPlugin)this).Config.Bind<bool>("Unlocks", "Unlock All Ascents", false, "Makes ascents 9-25 selectable on the boarding pass without beating them in order. Turning it off again brings back your normal progress."); ExtendedProgress = ((BaseUnityPlugin)this).Config.Bind<int>("Unlocks", "Highest Unlocked Ascent", 0, new ConfigDescription("Progress through ascents 9-25, saved by the mod (the game's own Steam stat stops at ascent 8). Beating ascent N unlocks N+1. 0 means only the vanilla progress counts.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 26), Array.Empty<object>())); HotCampfires = ((BaseUnityPlugin)this).Config.Bind<bool>("Ascents", "Hot Campfires", true, "From ascent 17 campfires are extremely hot: anything cooked on a campfire, over lava or by an explosion is charred to ruin on the very first cooking cycle. Off: cooking goes as in the game on every ascent; the rest of ascent 17 stays (lighting a campfire still takes off only 10 petrification). Only the host's settings count."); HotCampfires.SettingChanged += delegate { HostOptions.Invalidate(); }; ColdNights = ((BaseUnityPlugin)this).Config.Bind<bool>("Ascents", "Cold Nights", true, "Nights make you cold: the game's rule from ascent 5, until the third part of the climb (harsher from ascent 18, and longer in the Alpine). Off: the night itself no longer makes you cold, on every ascent; cold from anything else (storms, snow, water, the Alpine) stays. Custom runs keep their own Cold Night setting. Only the host's settings count."); ColdNights.SettingChanged += delegate { HostOptions.Invalidate(); }; Ascent8 = ((BaseUnityPlugin)this).Config.Bind<bool>("Ascents", "Ascent 8", true, "The game's own ascent 8: from it the flares at the peak no longer call the rescue helicopter, and a climb is won only in the Nadir. Off: on every ascent from 8 the flares at the peak call the helicopter again, as below ascent 8 (the Nadir can still be visited). The other ascents keep their rules. Only the host's settings count."); Ascent8.SettingChanged += delegate { HostOptions.Invalidate(); }; AscentSwitches = new ConfigEntry<bool>[26]; for (int num = 9; num <= 25; num++) { AscentSwitches[num] = ((BaseUnityPlugin)this).Config.Bind<bool>("Ascents", "Ascent " + num, true, AscentCatalog.Description(num) + " Off: this ascent's own rule is left out; the other ascents keep theirs (ascent 25 with Ascent 20 off plays without Bing Bong's rule). Only the host's settings count."); AscentSwitches[num].SettingChanged += delegate { HostOptions.Invalidate(); }; } NewItems = ((BaseUnityPlugin)this).Config.Bind<bool>("Items", "New Items", true, "The mod's new items spawn in regular runs from ascent 9: the Climbing Chalk, the Lightweight Parasol (the Roots parasol), the Auto-Parachute, the Warp Compass, the Toxic Drink, the Vanilla Wafers (half of the Scout Cookies), the Cherry Lollipop (half of the Big Lollipops), the Torch in suitcases (half as often as the Lantern), the wild Wonderberry, Green Clusterberry and Weird Shroom, and the Stones and Sticks on the ground. Off: none of them spawns in regular runs; the regular Parasol spawns wherever the Lightweight Parasol would, the Scout Cookies and the Big Lollipop keep all their spawns, and Torches hang only in the Mesa's Tomb. Custom runs keep their own switches for the items on the Custom Run screen (the Cherry Lollipop and the Vanilla Wafers have their own there); the wild foods, Stones and Sticks (not on that screen) follow this switch there too. Only the host's settings count."); NewItems.SettingChanged += delegate { HostOptions.Invalidate(); }; SixSlotBackpack = ((BaseUnityPlugin)this).Config.Bind<bool>("Items", "Six-Slot Backpack", true, "Single-player only, on every ascent: the Backpack holds six items instead of four, with four pouches on its sides and its own icon. Off: the game's four-slot Backpack, as in multiplayer (where it always is). A change applies to backpacks that appear after it; one already in your hands or on your back stays as it is until the next run."); SixSlotBackpackMultiplayer = ((BaseUnityPlugin)this).Config.Bind<bool>("Items", "Six-Slot Backpack in Multiplayer", false, "Multiplayer only, on every ascent: the Backpack lying by the crashed plane at the start of the beach is a Six-Slot Backpack (six items, four pouches on its sides, its own icon); every other backpack stays the game's four-slot one. Scout's Generosity clones it only for 100 petrification, which is death. Only the host's settings count."); MoreWildFood = ((BaseUnityPlugin)this).Config.Bind<bool>("Items", "More Wild Food in Multiplayer", false, "Only in a run that starts with more than one player in the lobby, on every ascent: every berry bush, palm, vine and mushroom patch grows half as much food again as the game gives it (the extra food lies beside the game's own). It is decided as the run starts: players joining later do not bring it, players leaving do not end it; alone in your lobby, or solo, the game's amounts. Off: the game's amounts. Only the host's settings count."); NewMobs = ((BaseUnityPlugin)this).Config.Bind<bool>("Mobs", "New Mobs", true, "The mod's new creatures live in regular runs on every ascent: crabs on the beach, snakes in the Tropics and mountain goats in the Alps. Below ascent 17 all they do to you is half as strong (half the injury, poison and knockback; knocked down or paralysed half as long) and snakes chase a third slower. Off: none of them appears (a change mid-climb leaves those already out). Custom runs have a switch for each among the Custom Run screen's threats instead (on by default), and there they are half as strong. Only the host's settings count."); NewMobs.SettingChanged += delegate { HostOptions.Invalidate(); }; EffectIcons = ((BaseUnityPlugin)this).Config.Bind<bool>("Interface", "Effect Icons", true, "The icons above the stamina bar for the mod's new effects: the Climbing Chalk's chalked hand and a tree snake's paralysis drop (with its time left). Off: neither shows; the effects still work. Each player's own."); VerboseLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "Verbose Logging", false, "Writes extra diagnostic lines to the BepInEx log."); } private static void OnActiveSceneChanged(Scene previous, Scene next) { //IL_0000: 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) Rules.OnActiveSceneChanged(next); RunLifecycle.OnSceneChanged(next); } private void OnDestroy() { SceneManager.activeSceneChanged -= OnActiveSceneChanged; } internal static void Debug(string message) { if (VerboseLogging != null && VerboseLogging.Value) { Log.LogInfo((object)message); } } } } namespace UltimateAscent.Features { internal static class A09_FogAndKiln { [HarmonyPatch(typeof(OrbFogHandler), "Move")] private static class FogSpeed { internal struct State { internal bool changed; internal float original; internal float applied; } private static void Prefix(OrbFogHandler __instance, out State __state) { __state = default(State); if (__instance.speed > 0f && __instance.speed <= 0.4f && Active(__instance)) { __state = new State { changed = true, original = __instance.speed, applied = __instance.speed * 2f }; __instance.speed = __state.applied; } } private static Exception Finalizer(OrbFogHandler __instance, State __state, Exception __exception) { if (__state.changed && __instance.speed == __state.applied) { __instance.speed = __state.original; } return __exception; } } [HarmonyPatch(typeof(OrbFogHandler), "TimeToMove")] private static class FogWait { private static void Postfix(OrbFogHandler __instance, ref bool __result) { if (Active(__instance)) { __result = __instance.currentWaitTime > 20f; } } } [HarmonyPatch(typeof(LavaRising), "Update")] private static class FasterRisingHazards { private static void Prefix(LavaRising __instance) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Invalid comparison between Unknown and I4 //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Invalid comparison between Unknown and I4 //IL_00fb: 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) if (!Rules.Enabled(9) || !Map.Ready || Map.CurrentSegment != __instance.requiredSegment) { return; } bool num = (int)__instance.risingFieldType == 0 && Map.InVolcanoKiln; bool flag = (int)__instance.risingFieldType == 1 && Map.InCitadel; bool flag2 = (int)__instance.risingFieldType == 2 && Map.InNadir; if (!num && !flag && !flag2) { return; } float num2 = Overrides.Original(__instance, "travelTime", __instance.travelTime); if (!(num2 <= 0f) && !float.IsNaN(num2) && !float.IsInfinity(num2)) { float num3 = (flag2 ? (num2 / 2.5f) : (num2 * 700f / 1200f)); if (!flag2 && __instance.initialWaitTime != 30f) { Overrides.Set(__instance, "initialWaitTime", Mathf.Min(30f, Overrides.Original(__instance, "initialWaitTime", __instance.initialWaitTime))); } if (__instance.travelTime != num3) { Overrides.Set(__instance, "travelTime", num3); Plugin.Debug($"Ascent 9: {__instance.risingFieldType} in {__instance.requiredSegment} now rises in {num3:F0} s."); } } } } private const float FogWaitSeconds = 20f; internal const float RiseSeconds = 700f; internal const float GameRiseSeconds = 1200f; private const int CalderaFogId = 3; internal static bool BeforeTheVolcano { get { Place currentPlace = Map.CurrentPlace; if ((uint)currentPlace <= 4u) { return true; } return false; } } internal static bool Active(OrbFogHandler handler) { if (!Rules.Enabled(9) || !Ascents.fogEnabled || (Object)(object)handler == (Object)null || (Object)(object)handler.sphere == (Object)null || handler.origins == null) { return false; } int currentID = handler.currentID; if (currentID < 0 || currentID >= handler.origins.Length || (Object)(object)handler.origins[currentID] == (Object)null || handler.origins[currentID].disableFog) { return false; } if (!Tfa.FinalAscentActive) { if (currentID < 3) { return BeforeTheVolcano; } return false; } return true; } } [HarmonyPatch(typeof(Spawner), "SpawnItems")] internal static class A10_LightLuggage { internal static bool Lightens(Spawner spawner) { if (!Rules.Enabled(10) || (Object)(object)spawner == (Object)null) { return false; } string name = ((Object)((Component)spawner).gameObject).name; if (!(spawner is RespawnChest) && spawner is Luggage && (name.StartsWith("LuggageBig") || name.StartsWith("LuggageEpic"))) { return !Tfa.Spawned((Component)(object)spawner); } return false; } private static void Prefix(Spawner __instance, ref List<Transform> spawnSpots) { if (spawnSpots != null && spawnSpots.Count >= 2 && Lightens(__instance) && Random.Range(0, 2) == 0) { spawnSpots = new List<Transform> { spawnSpots[0] }; } } } internal static class A11_RuleZero { private readonly struct Scout { internal readonly int Id; internal readonly Vector3 Position; internal double Progress => Position.y + Math.Abs(Position.z); internal Scout(int id, Vector3 position) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) Id = id; Position = position; } } [HarmonyPatch(typeof(Scoutmaster), "VerifyTarget")] private static class GivesUpNearOthers { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); List<int> list2 = new List<int>(); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Ldc_R4 && list[i].operand is float num && num == 15f) { list2.Add(i); } } if (list2.Count != 1) { Plugin.Log.LogWarning((object)$"Scoutmaster: the game's 15 m give-up distance was found {list2.Count} times; it stays the game's."); return list; } list[list2[0]] = CodeInstructionExtensions.MoveLabelsFrom(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(A11_RuleZero), "GiveUpDistance", (Type[])null, (Type[])null)), list[list2[0]]); return list; } } [HarmonyPatch(typeof(Character), "RPCA_Die")] private static class CurseOnDeath { private static void Prefix(Character __instance, out bool __state) { __state = (Object)(object)__instance.data != (Object)null && __instance.data.dead; } private static void Postfix(Character __instance, bool __state) { if (!__state) { Died(__instance); } } } [HarmonyPatch(typeof(Character), "FinishZombifying")] private static class CurseOnZombified { private static void Prefix(Character __instance, out bool __state) { __state = (Object)(object)__instance.data != (Object)null && __instance.data.dead; } private static void Postfix(Character __instance, bool __state) { if (!__state) { Died(__instance); } } } [HarmonyPatch(typeof(CharacterInteractible), "GetEaten")] private static class Cannibalism { private static void Postfix(Character eater) { //IL_001b: 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_0028: Unknown result type (might be due to invalid IL or missing references) if (Rules.Enabled(11) && (Object)(object)eater != (Object)null && eater.IsLocal) { STATUSTYPE type = (STATUSTYPE)3; ExactStatus.Add(eater.refs.afflictions, type, A15_StrongerAilments.FromAscent15(type, 0.5f), "cannibalism"); eater.refs.afflictions.AddStatus((STATUSTYPE)5, 0.15f, false, true, true, false, false); } } } [HarmonyPatch(typeof(Scoutmaster), "IThrow")] private static class CurseOnThrow { private static void Prefix(Scoutmaster __instance) { if (Rules.Enabled(11) && Rules.Owns(__instance.currentTarget) && !Tfa.ScoutmasterEvent) { __instance.currentTarget.refs.afflictions.AddStatus((STATUSTYPE)5, 0.04f, false, true, true, false, false); } } } private const float CheckInterval = 5f; private const float ForceSeconds = 30f; private const float HazardForceSeconds = 70f; internal const float CannibalPoison = 0.5f; internal const float CannibalCurse = 0.25f; internal const float GameCannibalCurse = 0.1f; internal const float CompanionRadius = 35f; private const double CompanionRadiusSq = 1225.0; private const double LeadDistance = 150.0; private static readonly List<Scout> scouts = new List<Scout>(16); private static Scoutmaster huntingScout; private static int huntedId; private static float nextCheck; private const float GameGiveUpDistance = 15f; private const float LeaveGrace = 1.5f; internal static bool Hunting => (Object)(object)huntingScout != (Object)null; internal static void Reset() { huntingScout = null; huntedId = 0; nextCheck = 0f; } internal static void Tick() { if (!Rules.Enabled(11) || !Rules.IsHost || LoadingScreenHandler.loading || Time.time < nextCheck) { return; } nextCheck = Time.time + 5f; if (Tfa.ScoutmasterEvent) { if ((Object)(object)huntingScout != (Object)null) { Character currentTarget = huntingScout.currentTarget; if ((Object)(object)currentTarget != (Object)null && (Object)(object)((MonoBehaviourPun)currentTarget).photonView != (Object)null && ((MonoBehaviourPun)currentTarget).photonView.ViewID == huntedId && !huntingScout.isThrowing) { huntingScout.SetCurrentTarget((Character)null, 0f); } huntingScout = null; } return; } CollectScouts(); if ((Object)(object)huntingScout != (Object)null) { Character currentTarget2 = huntingScout.currentTarget; if ((Object)(object)currentTarget2 == (Object)null || (Object)(object)((MonoBehaviourPun)currentTarget2).photonView == (Object)null || ((MonoBehaviourPun)currentTarget2).photonView.ViewID != huntedId) { huntingScout = null; } else if (!huntingScout.isThrowing && ShouldRelease()) { huntingScout.SetCurrentTarget((Character)null, 0f); huntingScout = null; } } else { Scoutmaster val = default(Scoutmaster); if (Scoutmaster.AllScoutmasters.Count >= 2 || !Scoutmaster.GetPrimaryScoutmaster(ref val) || (Object)(object)val.currentTarget != (Object)null || val.isThrowing || val.preventSpawning) { return; } int num = PickTarget(); if (num > 0) { PhotonView val2 = PhotonView.Find(num); Character val3 = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent<Character>() : null); if (!((Object)(object)val3 == (Object)null)) { val.SetCurrentTarget(val3, Rules.Enabled(17) ? 70f : 30f); huntingScout = val; huntedId = num; Plugin.Debug("Rule zero: the Scoutmaster now hunts " + val3.characterName + "."); } } } } private static void CollectScouts() { //IL_0072: Unknown result type (might be due to invalid IL or missing references) scouts.Clear(); foreach (Character allCharacter in Character.AllCharacters) { if (!((Object)(object)allCharacter == (Object)null) && !allCharacter.isBot && !allCharacter.isScoutmaster && !((Object)(object)allCharacter.data == (Object)null) && allCharacter.data.fullyConscious && !((Object)(object)((MonoBehaviourPun)allCharacter).photonView == (Object)null)) { scouts.Add(new Scout(((MonoBehaviourPun)allCharacter).photonView.ViewID, allCharacter.Center)); } } } private static bool HasCompanion(Scout target) { //IL_0024: 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) //IL_0034: Unknown result type (might be due to invalid IL or missing references) foreach (Scout scout in scouts) { if (scout.Id != target.Id) { Vector3 val = scout.Position - target.Position; if ((double)((Vector3)(ref val)).sqrMagnitude < 1225.0) { return true; } } } return false; } private static int PickTarget() { int num = -1; double num2 = double.NegativeInfinity; foreach (Scout scout in scouts) { if (HasCompanion(scout)) { continue; } foreach (Scout scout2 in scouts) { if (scout2.Id != scout.Id && scout.Progress > scout2.Progress + 150.0 && (scout.Progress > num2 || (scout.Progress == num2 && scout.Id < num))) { num2 = scout.Progress; num = scout.Id; } } } return num; } private static bool ShouldRelease() { if (scouts.Count < 2) { return true; } foreach (Scout scout in scouts) { if (scout.Id == huntedId) { return HasCompanion(scout); } } return true; } internal static float GiveUpDistance() { return 35f; } private static void Died(Character dead) { if (!Rules.Enabled(11) || dead.isBot || dead.isScoutmaster || LateJoiners.JustArrived(dead)) { return; } Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null || (Object)(object)localCharacter == (Object)(object)dead || localCharacter.data.dead || !PlayerStays(dead)) { return; } int num = 0; foreach (Character allCharacter in Character.AllCharacters) { if ((Object)(object)allCharacter != (Object)null && !allCharacter.isBot && !allCharacter.isScoutmaster) { num++; } } float curse = ((num <= 2) ? 0.12f : ((num <= 4) ? 0.08f : ((num <= 6) ? 0.04f : 0.02f))); ((MonoBehaviour)localCharacter).StartCoroutine(CurseIfStillHere(localCharacter, dead, curse)); } private static IEnumerator CurseIfStillHere(Character local, Character dead, float curse) { yield return (object)new WaitForSeconds(1.5f); if ((Object)(object)local != (Object)null && !local.data.dead && (Object)(object)dead != (Object)null && PlayerStays(dead)) { local.refs.afflictions.AddStatus((STATUSTYPE)5, curse, false, true, true, false, false); } } private static bool PlayerStays(Character scout) { if (!PhotonNetwork.InRoom || (Object)(object)((MonoBehaviourPun)scout).photonView == (Object)null) { return true; } Player player = PhotonNetwork.CurrentRoom.GetPlayer(((MonoBehaviourPun)scout).photonView.OwnerActorNr, false); if (player != null) { return !player.IsInactive; } return false; } } internal static class A12_Drowsy { [HarmonyPatch(typeof(CharacterGrabbing), "Reach")] private static class HelpingIsTiring { private static void Postfix(CharacterGrabbing __instance) { //IL_0059: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) Character character = __instance.character; if (!Rules.Enabled(12) || !Rules.Owns(character) || Time.time - lastHelpTime < 1f) { return; } foreach (Character allCharacter in Character.AllCharacters) { if (!((Object)(object)allCharacter == (Object)null) && !((Object)(object)allCharacter == (Object)(object)character) && !(Vector3.Distance(character.Center, allCharacter.Center) > 4f) && !(Vector3.Angle(character.data.lookDirection, allCharacter.Center - character.Center) > 60f) && CharacterGrabbing.TargetCanBeHelped(allCharacter, character)) { lastHelpTime = Time.time; STATUSTYPE type = (STATUSTYPE)6; ExactStatus.Add(character.refs.afflictions, type, A15_StrongerAilments.FromAscent15(type, 0.1f), "help"); break; } } } } [HarmonyPatch(typeof(Bodypart), "SnapToAnim")] private static class NoFallCancel { internal struct Motion { internal Rigidbody rig; internal Vector3 linear; internal Vector3 angular; } private static void Prefix(Bodypart __instance, out Motion __state) { //IL_0061: 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_0073: Unknown result type (might be due to invalid IL or missing references) __state = default(Motion); if (Rules.Enabled(12)) { Character character = (((Object)(object)__instance.character != (Object)null) ? __instance.character : ((Component)__instance).GetComponentInParent<Character>()); Rigidbody rig = __instance.rig; if (Rules.Owns(character) && !((Object)(object)rig == (Object)null) && !rig.isKinematic) { __state = new Motion { rig = rig, linear = rig.linearVelocity, angular = rig.angularVelocity }; } } } private static void Postfix(Motion __state) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__state.rig != (Object)null && !__state.rig.isKinematic) { __state.rig.linearVelocity = __state.linear; __state.rig.angularVelocity = __state.angular; } } } internal const float FallDrowsiness = 0.6f; internal const float HelpDrowsyPerSecond = 0.1f; private static float lastHelpTime = -10f; internal static void FallAsleep(Character character) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (Rules.Owns(character)) { STATUSTYPE type = (STATUSTYPE)6; ExactStatus.Add(character.refs.afflictions, type, A15_StrongerAilments.FromAscent15(type, 0.6f), "fall"); } } internal static float AilmentSum(CharacterAfflictions afflictions) { return afflictions.GetCurrentStatus((STATUSTYPE)3) + afflictions.GetCurrentStatus((STATUSTYPE)6) + afflictions.GetCurrentStatus((STATUSTYPE)0) + afflictions.GetCurrentStatus((STATUSTYPE)1) + afflictions.GetCurrentStatus((STATUSTYPE)2) + afflictions.GetCurrentStatus((STATUSTYPE)8); } } internal static class A13_ButterFingers { private sealed class Clear { internal Character character; internal PhotonView item; internal Collider[] itemColliders; internal float since; } [HarmonyPatch(typeof(CharacterItems), "DropItemFromSlotRPC")] private static class SlotDrop { private static void Prefix(CharacterItems __instance, out int __state) { __state = __instance.droppedItems.Count; } private static void Postfix(CharacterItems __instance, int __state) { Track(__instance, __state); } } [HarmonyPatch(typeof(CharacterItems), "DropItemRpc")] private static class HandDrop { private static void Prefix(CharacterItems __instance, out int __state) { __state = __instance.droppedItems.Count; } private static void Postfix(CharacterItems __instance, int __state) { Track(__instance, __state); } } private const float ClearSeconds = 1f; private const float MaxClearSeconds = 60f; internal static bool KeepClear = true; private static readonly List<Clear> clears = new List<Clear>(); internal static int Clearing => clears.Count; internal static void DropEverything(Character character) { if (Rules.Owns(character) && !((Object)(object)character.refs?.items == (Object)null) && !character.data.dead) { character.refs.items.DropAllItems(true); } } internal static void Reset() { clears.Clear(); } internal static void Tick() { for (int num = clears.Count - 1; num >= 0; num--) { Clear clear = clears[num]; List<Collider> list = (((Object)(object)clear.character != (Object)null) ? clear.character.refs.ragdoll.colliderList : null); if ((Object)(object)clear.item == (Object)null || list == null) { clears.RemoveAt(num); } else { float num2 = Time.time - clear.since; if (num2 >= 60f || (num2 >= 1f && !Overlap(clear.itemColliders, list))) { Ignore(clear.itemColliders, list, ignore: false); clears.RemoveAt(num); } } } } private static void Ignore(Collider[] item, List<Collider> body, bool ignore) { foreach (Collider item2 in body) { if ((Object)(object)item2 == (Object)null) { continue; } foreach (Collider val in item) { if ((Object)(object)val != (Object)null) { Physics.IgnoreCollision(item2, val, ignore); } } } } private static bool Overlap(Collider[] item, List<Collider> body) { //IL_001f: 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) //IL_005b: Unknown result type (might be due to invalid IL or missing references) foreach (Collider val in item) { if ((Object)(object)val == (Object)null || !val.enabled) { continue; } Bounds bounds = val.bounds; ((Bounds)(ref bounds)).Expand(0.1f); foreach (Collider item2 in body) { if ((Object)(object)item2 != (Object)null && item2.enabled && ((Bounds)(ref bounds)).Intersects(item2.bounds)) { return true; } } } return false; } private static void Track(CharacterItems items, int before) { if (!KeepClear || !PhotonNetwork.IsMasterClient || !Rules.Enabled(13) || (Object)(object)items == (Object)null || (Object)(object)items.character == (Object)null) { return; } for (int i = before; i < items.droppedItems.Count; i++) { PhotonView val = items.droppedItems[i]; if ((Object)(object)val == (Object)null) { continue; } Clear clear = new Clear { character = items.character, item = val, itemColliders = ((Component)val).GetComponentsInChildren<Collider>(true), since = Time.time }; Ignore(clear.itemColliders, items.character.refs.ragdoll.colliderList, ignore: true); if ((Object)(object)GameUtils.instance != (Object)null) { GameUtils.instance.ignoredCollidersCache.RemoveAll((IgnoredCollidersEntry entry) => Array.IndexOf(clear.itemColliders, entry.colliderA) >= 0 || Array.IndexOf(clear.itemColliders, entry.colliderB) >= 0); } clears.Add(clear); } } } internal static class A14_Gems { [HarmonyPatch(typeof(Action_SuperJumpAmulet), "RunAction")] private static class Initiative { private static void Prefix(Action_SuperJumpAmulet __instance) { TuneInitiative(__instance); } } [HarmonyPatch(typeof(Action_ApplyAffliction), "RunAction")] private static class Ambition { private static void Prefix(Action_ApplyAffliction __instance) { TuneAmbition(__instance); } } [HarmonyPatch(typeof(Action_ModifyStatus), "RunAction")] private static class AmbitionCost { private static void Prefix(Action_ModifyStatus __instance) { TuneAmbitionCost(__instance); } } [HarmonyPatch(typeof(Action_HealingGem), "RunAction")] private static class Tenacity { private static void Prefix(Action_HealingGem __instance) { Tune(__instance); } } [HarmonyPatch(typeof(Action_HealingGem), "FeederAction")] private static class TenacityCost { private static void Prefix(Action_HealingGem __instance) { Tune(__instance); } } [HarmonyPatch(typeof(Action_CloneSelectedItem), "RunAction")] private static class Generosity { private static void Prefix(Action_CloneSelectedItem __instance) { TuneGenerosity(__instance); } } internal const float TenacitySeconds = 8f; private static bool On => Rules.Enabled(15); private static float Points(int points) { return (float)points / 100f + 0.0001f; } internal static void Prepare(Item item) { if (On && !((Object)(object)item == (Object)null)) { Action_SuperJumpAmulet[] components = ((Component)item).GetComponents<Action_SuperJumpAmulet>(); for (int i = 0; i < components.Length; i++) { TuneInitiative(components[i]); } Action_ApplyAffliction[] components2 = ((Component)item).GetComponents<Action_ApplyAffliction>(); for (int i = 0; i < components2.Length; i++) { TuneAmbition(components2[i]); } Action_ModifyStatus[] components3 = ((Component)item).GetComponents<Action_ModifyStatus>(); for (int i = 0; i < components3.Length; i++) { TuneAmbitionCost(components3[i]); } Action_HealingGem[] components4 = ((Component)item).GetComponents<Action_HealingGem>(); for (int i = 0; i < components4.Length; i++) { Tune(components4[i]); } Action_CloneSelectedItem[] components5 = ((Component)item).GetComponents<Action_CloneSelectedItem>(); for (int i = 0; i < components5.Length; i++) { TuneGenerosity(components5[i]); } } } private static void TuneInitiative(Action_SuperJumpAmulet amulet) { if (On) { Overrides.Set(amulet, "petrifyPerUse", Points(15)); Affliction affliction = ((Action_ApplyAffliction)amulet).affliction; Affliction_MassSuperJump val = (Affliction_MassSuperJump)(object)((affliction is Affliction_MassSuperJump) ? affliction : null); if (val != null) { Overrides.Set(val, "radius", 6f); Overrides.Set(val, "lowGravTime", 2f); } } } private static void TuneAmbition(Action_ApplyAffliction apply) { if (On) { Affliction affliction = apply.affliction; Affliction_RadiateInfiniteStam val = (Affliction_RadiateInfiniteStam)(object)((affliction is Affliction_RadiateInfiniteStam) ? affliction : null); if (val != null) { Overrides.Set(val, "totalTime", 6f); } } } private static void TuneAmbitionCost(Action_ModifyStatus status) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Invalid comparison between Unknown and I4 if (On && (int)status.statusType == 13 && status.changeAmount > 0f && (Object)(object)((Component)status).GetComponent<AmuletBase>() != (Object)null) { Overrides.Set(status, "changeAmount", Points(35)); } } private static void Tune(Action_HealingGem gem) { if (On) { if (gem.healingAffliction != null) { Overrides.Set(gem.healingAffliction, "maxHealing", 0.4f); } if (gem.invincibilityAffliction != null) { Overrides.Set(gem.invincibilityAffliction, "totalTime", 8f); } Overrides.Set(gem, "healingToPetrifyRatio", 1.5f); Overrides.Set(gem, "minPetrify", Points(20)); Overrides.Set(gem, "maxPetrify", Points(60)); } } private static void TuneGenerosity(Action_CloneSelectedItem clone) { if (On) { Overrides.Set(clone, "petrify", 35); Overrides.Set(clone, "petrifyMystical", 60); } } } internal static class A14_Items { [HarmonyPatch(typeof(Action_RestoreHunger), "RunAction")] private static class RawFood { private static void Postfix(Action_RestoreHunger __instance) { //IL_0099: 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_00a6: Unknown result type (might be due to invalid IL or missing references) Character character = ((ItemActionBase)__instance).character; Item item = ((ItemActionBase)__instance).item; if (On && !((Object)(object)character == (Object)null) && character.IsLocal && !((Object)(object)item == (Object)null) && BurnedItems.CookedLevel(item) == 0) { if ((item.UIData != null && item.UIData.itemName == "Egg") || A14_WorseItems.Ticks.IsTick(item)) { ExactStatus.Add(character.refs.afflictions, (STATUSTYPE)3, A15_StrongerAilments.FromAscent15((STATUSTYPE)3, 0.05f), "raw food"); } else if (NameOf(item) == "Mandrake") { STATUSTYPE type = (STATUSTYPE)10; ExactStatus.Add(character.refs.afflictions, type, A15_StrongerAilments.FromAscent15(type, 0.3f), "raw mandrake"); } } } } [HarmonyPatch(typeof(CharacterAfflictions), "AddSunHeat")] private static class LeakySunscreen { private static bool Prefix(CharacterAfflictions __instance, float amount) { Character character = __instance.character; if (!On || (Object)(object)character == (Object)null || !character.data.wearingSunscreen || Tfa.WeatherRunning) { return true; } Item currentItem = character.data.currentItem; Parasol val = default(Parasol); bool num = (Object)(object)currentItem != (Object)null && ((((Component)currentItem).TryGetComponent<Parasol>(ref val) && val.isOpen) || currentItem.gliderHold); bool flag = RunSettings.IsCustomRun && RunSettings.GetValue((SETTINGTYPE)2400, false) == 0; if (!num && !flag) { __instance.AddStatus((STATUSTYPE)8, amount * 0.25f, false, true, true, false, false); } return false; } } [HarmonyPatch(typeof(Action_ApplyAffliction), "RunAction")] private static class ItemAfflictions { private static void Prefix(Action_ApplyAffliction __instance, out int __state) { __state = 0; if (!On) { return; } string text = NameOf(((ItemActionBase)__instance).item); if (text == "Heat Pack") { Affliction affliction = __instance.affliction; Affliction_AdjustColdOverTime val = (Affliction_AdjustColdOverTime)(object)((affliction is Affliction_AdjustColdOverTime) ? affliction : null); if (val != null) { Overrides.Set(val, "totalTime", 20f); return; } } if (text == "Energy Drink") { energyDrinkScope++; __state = 1; Affliction affliction2 = __instance.affliction; Affliction_FasterBoi val2 = (Affliction_FasterBoi)(object)((affliction2 is Affliction_FasterBoi) ? affliction2 : null); if (val2 != null) { Overrides.Set(val2, "totalTime", EnergyDrinkTime(((ItemActionBase)__instance).item)); Overrides.Set(val2, "climbDelay", 0f); } return; } if (text == "Fortified Milk") { Affliction affliction3 = __instance.affliction; Affliction_Invincibility val3 = (Affliction_Invincibility)(object)((affliction3 is Affliction_Invincibility) ? affliction3 : null); if (val3 != null) { ((Affliction)val3).totalTime = ((BurnedItems.CookedLevel(((ItemActionBase)__instance).item) > 0) ? 20f : 12f); return; } } if (!IsBigLollipop(text)) { return; } if (text == "Cherry Lollipop") { cherryScope++; __state = 2; } Affliction affliction4 = __instance.affliction; Affliction_InfiniteStamina val4 = (Affliction_InfiniteStamina)(object)((affliction4 is Affliction_InfiniteStamina) ? affliction4 : null); if (val4 != null) { Affliction drowsyAffliction = val4.drowsyAffliction; Affliction_AdjustDrowsyOverTime val5 = (Affliction_AdjustDrowsyOverTime)(object)((drowsyAffliction is Affliction_AdjustDrowsyOverTime) ? drowsyAffliction : null); if (val5 != null && val5.statusPerSecond > 0f) { Overrides.Set(val5, "totalTime", 12f); Overrides.Set(val5, "statusPerSecond", 0.07083333f); } } } private static Exception Finalizer(int __state, Exception __exception) { switch (__state) { case 1: energyDrinkScope--; break; case 2: cherryScope--; break; } return __exception; } } [HarmonyPatch(typeof(RopeSpool), "Awake")] private static class ShortSpool { private static void Postfix(RopeSpool __instance) { if (On) { Overrides.Set(__instance, "ropeStartFuel", 25f); __instance.ropeFuel = Mathf.Min(__instance.ropeFuel, 25f); } } } [HarmonyPatch(typeof(RopeSpool), "FixedUpdate")] private static class ShortRopes { private static void Postfix(RopeSpool __instance) { if (On && !((Object)(object)__instance.rope == (Object)null) && ((MonoBehaviourPun)__instance).photonView.IsMine) { float num = Mathf.Max(__instance.minSegments, Mathf.Min(20f, __instance.ropeFuel)); if (__instance.Segments > num) { __instance.Segments = num; __instance.rope.Segments = num; } } } } [HarmonyPatch(typeof(CharacterItems), "DropItemRpc")] private static class HeavyFungi { private static void Prefix(CharacterItems __instance, out Vector2? __state) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) __state = null; Item held = (((Object)(object)__instance.character != (Object)null) ? __instance.character.data.currentItem : null); int num = (((Object)(object)held == (Object)null) ? (-1) : Array.FindIndex(HeavyFungus, ((string prefab, float heavier) entry) => ((Object)((Component)held).gameObject).name.StartsWith(entry.prefab, StringComparison.Ordinal))); if (On && num >= 0) { __state = new Vector2(__instance.minThrowForce, __instance.maxThrowForce); __instance.minThrowForce /= HeavyFungus[num].heavier; __instance.maxThrowForce /= HeavyFungus[num].heavier; } } private static Exception Finalizer(CharacterItems __instance, Vector2? __state, Exception __exception) { //IL_000c: 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) if (__state.HasValue) { __instance.minThrowForce = __state.Value.x; __instance.maxThrowForce = __state.Value.y; } return __exception; } } [HarmonyPatch(typeof(CharacterAfflictions), "UpdateWeight")] private static class BeanThornStatus { private static void Postfix(CharacterAfflictions __instance) { Character character = __instance.character; if (beanThorns.Count > 0 && (Object)(object)character != (Object)null && character.IsLocal && !character.data.isSkeleton) { __instance.SetStatus((STATUSTYPE)9, __instance.GetCurrentStatus((STATUSTYPE)9) + 0.025f * (float)beanThorns.Count, true); } } } [HarmonyPatch(typeof(MagicBean), "GetVineDistance")] private static class ShorterBeanVine { private static void Postfix(MagicBean __instance, ref float __result) { if (On && (Object)(object)__instance.plantPrefab != (Object)null) { __result = Mathf.Min(__result, __instance.plantPrefab.maxLength * 0.75f); } } } [HarmonyPatch(typeof(CharacterItems), "HammerClimbingSpike")] private static class CrackingPitons { private static void Prefix(CharacterItems __instance, RaycastHit hit, out GameObject __state) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) __state = null; ClimbingSpikeComponent currentClimbingSpikeComponent = __instance.currentClimbingSpikeComponent; if (On && !((Object)(object)currentClimbingSpikeComponent == (Object)null) && !((Object)(object)crackingPiton == (Object)null)) { __state = currentClimbingSpikeComponent.hammeredVersionPrefab; currentClimbingSpikeComponent.hammeredVersionPrefab = crackingPiton; placedPitons.RemoveAll(((Vector3 point, float time) p) => Time.time - p.time > 10f); placedPitons.Add((((RaycastHit)(ref hit)).point, Time.time)); } } private static Exception Finalizer(CharacterItems __instance, GameObject __state, Exception __exception) { if ((Object)(object)__state != (Object)null && (Object)(object)__instance.currentClimbingSpikeComponent != (Object)null) { __instance.currentClimbingSpikeComponent.hammeredVersionPrefab = __state; } return __exception; } } [HarmonyPatch(typeof(ShittyPiton), "Start")] private static class SturdierPitons { private static void Postfix(ShittyPiton __instance) { int num = placedPitons.FindIndex(delegate((Vector3 point, float time) p) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = p.point - ((Component)__instance).transform.position; return ((Vector3)(ref val)).sqrMagnitude < 0.01f; }); if (num >= 0) { placedPitons.RemoveAt(num); ShittyPiton obj = __instance; obj.totalSecondsOfHang *= 1.3f; __instance.cracksToBreak = 5; } } } [HarmonyPatch(typeof(Action_CallScoutmaster), "RunAction")] private static class LongerBugleHunt { private static void Prefix(Action_CallScoutmaster __instance) { if (On) { Overrides.Set(__instance, "forcedChaseTime", 180f); } } } [HarmonyPatch(typeof(Item), "GetName")] private static class LightweightParasolName { private static void Postfix(Item __instance, ref string __result) { if (IsLightweightParasol(__instance)) { __result = LocalizedText.GetText("NAME_LIGHTWEIGHT PARASOL", true); } } } [HarmonyPatch(typeof(Item), "get_CarryWeight")] private static class ItemWeights { private static void Postfix(Item __instance, ref int __result) { if (IsLightweightParasol(__instance)) { __result = (On ? 2 : 0); } else if (On) { switch (NameOf(__instance)) { case "Ancient Idol": __result = 20; break; case "Balloon": case "Balloon Bunch": __result = 0; break; } } } } [HarmonyPatch(typeof(Item), "Awake")] private static class WeakerLanterns { private static void Postfix(Item __instance) { if (!On) { return; } float num; switch (NameOf(__instance)) { default: num = 0f; break; case "Faerie Lantern": num = 0.025f; break; case "Lantern": case "Torch": num = 0.02f; break; } float num2 = num; if (num2 <= 0f) { return; } StatusField[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<StatusField>(true); foreach (StatusField val in componentsInChildren) { if (((StatusFieldBase)val).statusAmountPerSecond < 0f) { ((StatusFieldBase)val).statusAmountPerSecond = 0f - num2; } } } } [HarmonyPatch(typeof(CharacterAfflictions), "UpdateWeight")] private static class BalloonWeight { private static void Postfix(CharacterAfflictions __instance) { Character character = __instance.character; if (!On || (Object)(object)character == (Object)null || !character.IsLocal || (Object)(object)character.player == (Object)null) { return; } float num = 0f; foreach (ItemSlot item in CountedSlots(character.player)) { string text = ((item != null && !item.IsEmpty() && (Object)(object)item.prefab != (Object)null) ? NameOf(item.prefab) : null); if (text == "Balloon") { num += 0.02f; } else if (text == "Balloon Bunch") { num += 0.08f; } } if (!(num <= 0f)) { int num2 = 7; __instance.currentStatuses[num2] = Mathf.Max(0f, __instance.currentStatuses[num2] - num); character.ClampStamina(); GUIManager.instance.bar.ChangeBar(); __instance.PushStatuses((Player)null); } } private static IEnumerable<ItemSlot> CountedSlots(Player player) { ItemSlot[] itemSlots = player.itemSlots; for (int i = 0; i < itemSlots.Length; i++) { yield return itemSlots[i]; } BackpackSlot backpackSlot = player.backpackSlot; BackpackData val = default(BackpackData); if (!((ItemSlot)backpackSlot).IsEmpty() && ((ItemSlot)backpackSlot).data.TryGetDataEntry<BackpackData>((DataEntryKey)7, ref val)) { itemSlots = val.itemSlots; for (int i = 0; i < itemSlots.Length; i++) { yield return itemSlots[i]; } } yield return player.GetItemSlot((byte)250); } } [HarmonyPatch(typeof(JetpackItem), "AddFuel")] private static class LessJetpackFuel { private static void Prefix(ref float addedFuel) { if (On) { addedFuel *= 0.65f; } } } [HarmonyPatch(typeof(CharacterBackpackHandler), "AddFuelToJetpack")] private static class LessWornJetpackFuel { private static void Prefix(ref float addedFuel) { if (On) { addedFuel *= 0.65f; } } } [HarmonyPatch(typeof(CollisionModifier), "Collide")] private static class TiringBouncePad { private static void Prefix(CollisionModifier __instance) { if (On && __instance.useBounceCoroutine && ((Object)__instance).name == "Bounce") { Overrides.Set(__instance, "staminaBackOnBounce", 0.025f); } } } [HarmonyPatch(typeof(CharacterAfflictions), "ApplyStatusesFromFloatArray")] private static class CursedCheckpoint { private static void Postfix(CharacterAfflictions __instance) { if (A14_WorseItems.CheckpointScope.Depth > 0 && On && Rules.Owns(__instance.character)) { __instance.AddStatus((STATUSTYPE)5, A15_StrongerAilments.Raw((STATUSTYPE)5, 0.1f), false, true, true, false, false); } } } [HarmonyPatch(typeof(Character), "TryCheckpoint")] private static class CheckpointPullsBeanThorns { private static void Postfix(Character __instance, bool __result) { if (__result && On && Rules.Owns(__instance)) { ClearBeanThorns(__instance.refs.afflictions); } } } [HarmonyPatch(typeof(Snowball), "Update")] private static class MeltingSnowball { private static void Postfix(Snowball __instance) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Invalid comparison between Unknown and I4 Item item = ((ItemComponent)__instance).item; if (!On || (Object)(object)item == (Object)null || (Object)(object)((MonoBehaviourPun)item).photonView == (Object)null || !((MonoBehaviourPun)item).photonView.IsMine || item.consuming) { return; } FloatItemData data = item.GetData<FloatItemData>((DataEntryKey)10, (Func<FloatItemData>)(() => new FloatItemData { Value = 20f })); Character holderCharacter = item.holderCharacter; if ((int)item.itemState == 1 && (Object)(object)holderCharacter != (Object)null && holderCharacter.IsLocal && data.Value > 0f) { data.Value = Mathf.Max(0f, data.Value - Time.deltaTime); if (data.Value <= 0f) { ((MonoBehaviour)item).StartCoroutine(item.ConsumeDelayed(true)); } } item.SetUseRemainingPercentage(data.Value / 20f); } } [HarmonyPatch(typeof(Bonkable), "Bonk")] private static class SnowballBonk { private static void Prefix(Bonkable __instance, out float? __state) { __state = null; Snowball val = default(Snowball); if (On && ((Component)__instance).TryGetComponent<Snowball>(ref val)) { __state = __instance.ragdollTime; __instance.ragdollTime = 2.0004f; } } private static Exception Finalizer(Bonkable __instance, float? __state, Exception __exception) { if (__state.HasValue) { __instance.ragdollTime = __state.Value; } return __exception; } } [HarmonyPatch(typeof(Character), "RPCA_Fall")] private static class SnowballHit { private static void Prefix(Character __instance, ref float seconds) { if (!(Mathf.Abs(seconds - 2.0004f) > 0.0001f)) { seconds = 2f; if (On && __instance.IsLocal && !__instance.data.dead) { ExactStatus.Add(__instance.refs.afflictions, (STATUSTYPE)2, A15_StrongerAilments.FromAscent15((STATUSTYPE)2, 0.3f), "snowball"); } } } } [HarmonyPatch(typeof(RemoveAfterSeconds), "Start")] private static class ShortRemedyCloud { private static void Postfix(RemoveAfterSeconds __instance) { Transform parent = ((Component)__instance).transform.parent; if (On && (Object)(object)parent != (Object)null && ((Object)parent).name.StartsWith("HealingPuffShroomSpawn", StringComparison.Ordinal)) { __instance.seconds = Mathf.Min(__instance.seconds, 8f); } } } [HarmonyPatch(typeof(GrowOverTime), "Awake")] private static class SmallerAntiZookaBubble { private static void Postfix(GrowOverTime __instance) { AntiSphere val = default(AntiSphere); if (On && ((Object)__instance).name.StartsWith("AntiSphere_Projectile", StringComparison.Ordinal) && ((Component)__instance).TryGetComponent<AntiSphere>(ref val)) { __instance.endScale = 8f; val.lifetime = 40f; } } } [HarmonyPatch(typeof(Campfire), "Awake")] private static class ShortStove { private static void Postfix(Campfire __instance) { if (On && __instance.nameOverride == "NAME_PORTABLE STOVE") { __instance.burnsFor = Mathf.Min(__instance.burnsFor, 30f); } } } [HarmonyPatch(typeof(Character), "ApplyPostReviveStatus")] private static class BookRevive { private static void Postfix(CharacterAfflictions afflictions) { Character val = (((Object)(object)afflictions != (Object)null) ? afflictions.character : null); float num = 0.2f - Ascents.revivalCurse; if (On && (Object)(object)val != (Object)null && val.data.isSkeleton && num > 0f) { afflictions.AddStatus((STATUSTYPE)5, num + 0.0001f, true, true, true, false, false); } } } [HarmonyPatch(typeof(Action_ApplyMassAffliction), "TryAddAfflictionToLocalCharacter")] private static class CursedSkullScope { private static void Prefix(Action_ApplyMassAffliction __instance, out bool __state) { __state = On && ((Action_ApplyAffliction)__instance).affliction is Affliction_ClearAllStatus && NameOf(((ItemActionBase)__instance).item) == "Cursed Skull"; if (__state) { cursedSkullScope++; } } private static Exception Finalizer(bool __state, Exception __exception) { if (__state) { cursedSkullScope--; } return __exception; } } [HarmonyPatch(typeof(CharacterAfflictions), "ClearAllStatus")] private static class SkullCuresCrab { private static void Postfix(CharacterAfflictions __instance) { if (InCursedSkull && Rules.Owns(__instance.character)) { float currentStatus = __instance.GetCurrentStatus((STATUSTYPE)4); if (currentStatus > 0f) { __instance.SetStatus((STATUSTYPE)4, currentStatus * 0.1f, true); } } } } [HarmonyPatch(typeof(Action_ClearAllStatus), "RunAction")] private static class CrabStays { [HarmonyPriority(800)] private static void Prefix(Action_ClearAllStatus __instance, out bool __state) { __state = On && !__instance.otherExclusions.Contains((STATUSTYPE)4); if (__state) { __instance.otherExclusions.Add((STATUSTYPE)4); } } private static Exception Finalizer(Action_ClearAllStatus __instance, bool __state, Exception __exception) { if (__state) { __instance.otherExclusions.Remove((STATUSTYPE)4); } return __exception; } } [HarmonyPatch(typeof(CharacterAfflictions), "DieToRitualDagger")] private static class ZombifyingDagger { private static bool Prefix(CharacterAfflictions __instance) { Character character = __instance.character; CheckpointFlag val = default(CheckpointFlag); if (!On || (Object)(object)character == (Object)null || !character.IsLocal || character.data.zombified || character.WillDoCheckpoint(ref val)) { return true; } ((MonoBehaviourPun)character).photonView.RPC("RPCA_Zombify", (RpcTarget)2, Array.Empty<object>()); return false; } } [HarmonyPatch(typeof(Affliction_Chaos), "OnApplied")] private static class PandoraCrab { private static readonly OpCode[] Stores = new OpCode[6] { OpCodes.Stloc, OpCodes.Stloc_S, OpCodes.Stloc_0, OpCodes.Stloc_1, OpCodes.Stloc_2, OpCodes.Stloc_3 }; private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = list.FindIndex((CodeInstruction instruction) => instruction.opcode == OpCodes.Newobj && instruction.operand is ConstructorInfo constructorInfo && constructorInfo.DeclaringType == typeof(List<STATUSTYPE>)); int num2 = ((num < 0) ? (-1) : list.FindIndex(num, (CodeInstruction instruction) => Array.IndexOf(Stores, instruction.opcode) >= 0)); if (num2 < 0) { throw new InvalidOperationException("Pandora's list of statuses was not found; Pandora's Lunchbox gives no crab."); } list.InsertRange(num2, (IEnumerable<CodeInstruction>)(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Dup, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(A14_Items), "AddCrab", (Type[])null, (Type[])null)) }); int num3 = 0; for (int num4 = 1; num4 + 1 < list.Count; num4++) { OpCode opcode = list[num4 - 1].opcode; bool flag = opcode == OpCodes.Ldloc || opcode == OpCodes.Ldloc_S || opcode == OpCodes.Ldloc_0 || opcode == OpCodes.Ldloc_1 || opcode == OpCodes.Ldloc_2 || opcode == OpCodes.Ldloc_3; if (list[num4].opcode == OpCodes.Ldc_I4_5 && flag && list[num4 + 1].opcode.FlowControl == FlowControl.Cond_Branch) { list.Insert(num4, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(A14_Items), "HalvedLikeCurse", (Type[])null, (Type[])null))); num3++; num4++; } } if (num3 != 1) { throw new InvalidOperationException($"Pandora's curse halving was not found ({num3} matches); Pandora's Lunchbox gives no crab."); } return list; } } private const STATUSTYPE Poison = (STATUSTYPE)3; private const STATUSTYPE Crab = (STATUSTYPE)4; private const STATUSTYPE Cold = (STATUSTYPE)2; private const STATUSTYPE Curse = (STATUSTYPE)5; private const STATUSTYPE Thorns = (STATUSTYPE)9; internal const float RawFoodPoison = 0.05f; internal const string EggName = "Egg"; internal const float SunscreenLeak = 0.25f; internal const float HeatPackSeconds = 20f; internal const string HeatPackName = "Heat Pack"; private const float BugleChaseSeconds = 180f; private const float BouncePadStamina = 0.025f; internal const string RootsParasolPrefab = "Parasol_Roots Variant"; internal const string LightweightParasolKey = "NAME_LIGHTWEIGHT PARASOL"; internal const string EnergyDrinkName = "Energy Drink"; internal const string BigLollipopName = "Big Lollipop"; internal const string FortifiedMilkName = "Fortified Milk"; internal const float MilkSeconds = 12f; internal const float MilkSecondsCooked = 20f; internal const float EnergyDrinkWalking = 0.3f; internal const float EnergyDrinkCrash = 0.5f; internal const float EnergyDrinkSeconds = 6f; internal const float EnergyDrinkCookedSeconds = 8f; internal const float LollipopDrowsiness = 0.85f; internal const float LollipopDrowsySeconds = 12f; private const float SpoolRope = 25f; private const float LongestRope = 20f; private static readonly (string prefab, float heavier)[] HeavyFungus = new(string, float)[3] { ("ShelfShroom", 1.5f), ("CloudFungus", 1.5f), ("WarpFungus", 1.35f) }; private const float BeanVineLength = 0.75f; internal const float BeanThornEvery = 3f; private const float BeanThornSeconds = 30f; private const float SnowballCold = 0.3f; private const float SnowballKnockdown = 2f; private const float HeldSnowballCold = 0.025f; internal const float SnowballSeconds = 20f; private const float SnowballKnockdownMarked = 2.0004f; internal const string MandrakeName = "Mandrake"; internal const float MandrakeSpores = 0.3f; internal const string RemedyCloudParent = "HealingPuffShroomSpawn"; internal const float RemedyCloudSeconds = 8f; private const string AntiZookaBubble = "AntiSphere_Projectile"; private const float AntiZookaBubbleDiameter = 8f; private const float AntiZookaBubbleSeconds = 40f; private const string StoveName = "NAME_PORTABLE STOVE"; private const float StoveSeconds = 30f; private const float BookReviveCurse = 0.2f; private const string AncientIdolName = "Ancient Idol"; private const string LanternName = "Lantern"; private const string FaerieLanternName = "Faerie Lantern"; internal const float LanternWarmth = 0.02f; internal const float FaerieLanternHealing = 0.025f; private const int AncientIdolWeight = 20; internal const int WorseLightweightParasolWeight = 2; private const string BalloonName = "Balloon"; private const string BalloonBunchName = "Balloon Bunch"; private const float BalloonLift = 0.02f; private const float BalloonBunchLift = 0.08f; private const string CrackingPitonPrefab = "0_Items/ClimbingSpikeHammered_Shitty"; private const string PlacedPitonName = "UA_PitonCracking"; private const float PitonSturdiness = 1.3f; private const int PitonCracks = 5; private const float CheckpointCurse = 0.1f; private const string CursedSkullName = "Cursed Skull"; internal const float CursedSkullResidue = 0.1f; [ThreadStatic] private static int energyDrinkScope; [ThreadStatic] private static int cherryScope; [ThreadStatic] private static int cursedSkullScope; private static readonly Queue<float> beanThorns = new Queue<float>(); private static float beanVineSeconds; private static readonly List<(Vector3 point, float time)> placedPitons = new List<(Vector3, float)>(); private static GameObject crackingPiton; internal const float JetpackFuelShare = 0.65f; private static bool On => Rules.Enabled(15); internal static bool LightweightParasolExists { get { if (!NewItems.RegularRun) { return CustomRunItems.InCustomRun; } return true; } } internal static bool InEnergyDrink => energyDrinkScope > 0; internal static bool InCherryLollipop => cherryScope > 0; internal static bool InCursedSkull => cursedSkullScope > 0; internal static bool SunscreenLeaks => On; internal static bool IsRootsParasol(Item item) { if ((Object)(object)item != (Object)null) { return ((Object)((Component)item).gameObject).name.StartsWith("Parasol_Roots Variant", StringComparison.Ordinal); } return false; } internal static bool IsLightweightParasol(Item item) { if (LightweightParasolExists) { return IsRootsParasol(item); } return false; } internal static bool IsBigLollipop(string name) { if (!(name == "Big Lollipop")) { return name == "Cherry Lollipop"; } return true; } internal static float EnergyDrinkTime(Item drink) { if (BurnedItems.CookedLevel(drink) <= 0) { return 6f; } return 8f; } internal static string NameOf(Item item) { if (!((Object)(object)item != (Object)null) || item.UIData == null) { return null; } return item.UIData.itemName; } internal static void Tick() { Character localCharacter = Character.localCharacter; if (!On || (Object)(object)localCharacter == (Object)null || localCharacter.data.dead) { ClearBeanThorns(null); return; } CharacterAfflictions afflictions = localCharacter.refs.afflictions; Item currentItem = localCharacter.data.currentItem; Snowball val = default(Snowball); if ((Object)(object)currentItem != (Object)null && ((Component)currentItem).TryGetComponent<Snowball>(ref val)) { ExactStatus.Add(afflictions, (STATUSTYPE)2, A15_StrongerAilments.FromAscent15((STATUSTYPE)2, 0.025f * Time.deltaTime), "held snowball"); } bool flag = false; int num = 0; float time = Time.time; while (beanThorns.Count > 0 && time - beanThorns.Peek() >= 30f) { beanThorns.Dequeue(); flag = true; } if (!localCharacter.data.isInvincible && !localCharacter.data.isSkeleton && OnBeanVine(localCharacter)) { beanVineSeconds += Time.deltaTime; while (beanVineSeconds >= 3f) { beanVineSeconds -= 3f; beanThorns.Enqueue(time); num++; } } if (flag || num > 0) { afflictions.UpdateWeight(); } if (num > 0) { float num2 = (float)num * 0.025f; afflictions.StatusSFX((STATUSTYPE)9, num2); if ((Object)(object)localCharacter == (Object)(object)Character.observedCharacter) { GUIManager.instance.AddStatusFX((STATUSTYPE)9, num2); } afflictions.PlayParticle((STATUSTYPE)9); } } internal static bool OnBeanVine(Character character) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) if (character.data.isClimbing) { Collider collider = ((RaycastHit)(ref character.data.climbHit)).collider; if ((Object)(object)collider != (Object)null) { return (Object)(object)((Component)collider).GetComponentInParent<MagicBeanVine>() != (Object)null; } return false; } if (!character.data.isGrounded) { return false; } RaycastHit[] array = Physics.RaycastAll(character.Center, Vector3.down, 2f, ~((LayerMask)(ref HelperFunctions.CharacterMask)).value, (QueryTriggerInteraction)1); for (int i = 0; i < array.Length; i++) { RaycastHit val = array[i]; if ((Object)(object)((RaycastHit)(ref val)).collider != (Object)null && (Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<MagicBeanVine>() != (Object)null) { return true; } } return false; } private static void ClearBeanThorns(CharacterAfflictions afflictions) { beanVineSeconds = 0f; if (beanThorns.Count != 0) { beanThorns.Clear(); if ((Object)(object)afflictions != (Object)null) { afflictions.UpdateWeight(); } } } internal static void BuildPlacedPiton() { Item val2 = default(Item); ClimbingSpikeComponent val3 = default(ClimbingSpikeComponent); GameObject val = ((ItemDatabase.TryGetItem("ClimbingSpike", ref val2) && (Object)(object)val2 != (Object)null && ((Component)val2).TryGetComponent<ClimbingSpikeComponent>(ref val3)) ? val3.hammeredVersionPrefab : null); GameObject val4 = Resources.Load<GameObject>("0_Items/ClimbingSpikeHammered_Shitty"); DefaultPool val5 = ModItems.GamePool(); if ((Object)(object)val == (Object)null || (Object)(object)val4 == (Object)null || val5 == null) { Plugin.Log.LogWarning((object)"Ascent 15: the piton or the Alps' cracking piton was not found; placed pitons stay the game's."); return; } GameObject val6 = ModItems.Keep(val4, "UA_PitonCracking"); string[] array = new string[2] { "ClimbingSpike/Ring", "ClimbingSpike/Spike" }; Renderer val9 = default(Renderer); Renderer val10 = default(Renderer); foreach (string text in array) { Transform val7 = val.transform.Find(text); Transform val8 = val6.transform.Find(text); if ((Object)(object)val7 != (Object)null && (Object)(object)val8 != (Object)null && ((Component)val7).TryGetComponent<Renderer>(ref val9) && ((Component)val8).TryGetComponent<Renderer>(ref val10)) { val10.sharedMaterials = val9.sharedMaterials; } } val5.ResourceCache["0_Items/UA_PitonCracking"] = val6; crackingPiton = val6; } internal static void Reset() { placedPitons.Clear(); ClearBeanThorns(null); } private static void AddCrab(List<STATUSTYPE> statuses) { if (On) { statuses.Add((STATUSTYPE)4); } } private static STATUSTYPE HalvedLikeCurse(STATUSTYPE status) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0004: Unknown result type (might be due to invalid IL or missing references) if ((int)status != 4) { return status; } return (STATUSTYPE)5; } } internal static class A14_Shroomberries { [HarmonyPatch(typeof(Action_RandomMushroomEffect), "RunAction")] private static class Effects { private static bool Prefix(Action_RandomMushroomEffect __instance) { Character character = ((ItemActionBase)__instance).character; if (!On || (Object)(object)character == (Object)null) { return true; } int effect; if (__instance.useDebugEffect) { effect = __instance.debugEffect; } else { MushroomManager instance = MushroomManager.instance; if ((Object)(object)instance == (Object)null) { return false; } int num = __instance.mushroomTypeIndex % instance.mushroomEffects.Length; effect = instance.mushroomEffects[num]; character.AddExtraStamina((float)instance.mushroomStamAmt[num] * 0.05f); } ((MonoBehaviour)character).StartCoroutine(Run(character, effect, __instance.fartForce)); return false; } } [HarmonyPatch(typeof(AOE), "Explode")] private static class Burst { private static void Prefix(AOE __instance) { if (On && IsSporeBurst(__instance)) { __instance.range = 12.5f; __instance.fallTime = 4f; } } } private const string SporeBurst = "VFX_SporeExploExploEdibleSpawn"; private const string SporeBurstNoKnockback = "VFX_SporeExploExploEdibleSpawn_NoKnockback"; private const float LowGravitySeconds = 8f; private const float InvincibleSeconds = 5f; private const float Healing = 0.0751f; private const float ExtraSpores = 0.3f; private const float GameExtraSpores = 0.25f; private const float BlindSeconds = 120f; private const float KnockdownSeconds = 12f; private const float NumbSeconds = 120f; private const float BurstRange = 12.5f; private const float BurstKnockdownSeconds = 4f; private static bool On => Rules.Enabled(15); internal static bool IsSporeBurst(AOE aoe) { if ((Object)(object)aoe != (Object)null && ((Object)aoe).name.StartsWith("VFX_SporeExploExploEdibleSpawn", StringComparison.Ordinal)) { return !((Object)aoe).name.StartsWith("VFX_SporeExploExploEdibleSpawn_NoKnockback", StringComparison.Ordinal); } return false; } private static IEnumerator Run(Character character, int effect, float fartForce) { switch (effect) { case 0: yield return (object)new WaitForSeconds(3f); character.refs.afflictions.AddAffliction((Affliction)new Affliction_InfiniteStamina(4f), false); break; case 1: yield return (object)new WaitForSeconds(3f); character.refs.afflictions.AddAffliction((Affliction)new Affliction_FasterBoi { moveSpeedMod = 0.5f, climbSpeedMod = 1.5f, totalTime = 5f, climbDelay = 1f }, false); break; case 2: yield return (object)new WaitForSeconds(3f); character.refs.afflictions.AddAffliction((Affliction)new Affliction_LowGravity(3, 8f), false); break; case 3: character.refs.afflictions.AddAffliction((Affliction)new Affliction_Invincibility { totalTime = 5f }, false); break; case 4: character.refs.afflictions.AdjustStatus((STATUSTYPE)1, -0.0751f, false); character.refs.afflictions.AdjustStatus((STATUSTYPE)0, -0.0751f, false); character.refs.afflictions.AdjustStatus((STATUSTYPE)3, -0.0751f, false); character.refs.afflictions.ClearPoisonAfflictions(); break; case 5: yield return (object)new WaitForSeconds(3f); GameUtils.instance.SpawnResourceAtPositionNetworked("VFX_SporeExploExploEdibleSpawn", character.Center, (RpcTarget)1); GameUtils.instance.RPC_SpawnResourceAtPosition("VFX_SporeExploExploEdibleSpawn_NoKnockback", character.Center); character.AddForceToBodyPart(character.GetBodypartRig((BodypartType)0), Vector3.zero, Vector3.up * fartForce); break; case 6: yield return (object)new WaitForSeconds(3f); character.refs.afflictions.AddAffliction((Affliction)new Affliction_Blind { totalTime = 120f }, false); break; case 7: yield return (object)new WaitForSeconds(3f); character.Fall(12f, 0f); break; case 8: { STATUSTYPE type = (STATUSTYPE)10; float target = Mathf.Max(0.25f, A15_StrongerAilments.FromAscent15(type, 0.3f)); ExactStatus.Add(character.refs.afflictions, type, target, "shroomberry"); break; } case 9: yield return (object)new WaitForSeconds(3f); character.refs.afflictions.AddAffliction((Affliction)new Affliction_Numb { totalTime = 120f }, false); break; } } } internal static class A14_WorseItems { [HarmonyPatch(typeof(Action_RestoreHunger), "RunAction")] private static class LessFood { private static bool Prefix(Action_RestoreHunger __instance, bool __runOriginal) { if (!__runOriginal) { return false; } if (!On) { return true; } if (!Ticks.IsTick(((ItemActionBase)__instance).item) && (Object)(object)((ItemActionBase)__instance).character != (Object)null) { Feed(((ItemActionBase)__instance).character, __instance.restorationAmount * 0.5f); } return false; } } internal static class Ticks { private static bool looked; private static bool found; private static ushort tickItemId; internal static bool IsTick(Item item) { if ((Object)(object)item == (Object)null) { return false; } if (!looked) { looked = true; GameObject obj = Resources.Load<GameObject>("BugfixOnYou"); Bugfix val = ((obj != null) ? obj.GetComponent<Bugfix>() : null); if ((Object)(object)val != (Object)null && (Object)(object)val.bugItem != (Object)null) { tickItemId = val.bugItem.itemID; found = true; } else { Plugin.Log.LogWarning((object)"Ascent 14: the tick item was not found; eaten ticks keep restoring hunger."); } } if (found) { return item.itemID == tickItemId; } return false; } } [HarmonyPatch(typeof(Action_ModifyStatus), "RunAction")] private static class NoHungerFromTicks { [HarmonyPriority(800)] private static bool Prefix(Action_ModifyStatus __instance) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 if (On && (int)__instance.statusType == 1 && __instance.changeAmount < 0f) { return !Ticks.IsTick(((ItemActionBase)__instance).item); } return true; } } [HarmonyPatch(typeof(Action_GiveExtraStamina), "RunAction")] private static class LessExtraStamina { private static bool Prefix(Action_GiveExtraStamina __instance) { if (!On) { return true; } ((ItemActionBase)__instance).character.AddExtraStamina(__instance.amount * 0.5f); return false; } } [HarmonyPatch(typeof(Action_ModifyStatus), "RunAction")] private static class WeakerMedicine { private static void Prefix(Action_ModifyStatus __instance, out float? __state) { __state = null; float num = CureScale(__instance); if (num != 1f) { __state = __instance.changeAmount; __instance.changeAmount *= num; } } private static Exception Finalizer(Action_ModifyStatus __instance, float? __state, Exception __exception) { if (__state.HasValue) { __instance.changeAmount = __state.Value; } return __exception; } } [HarmonyPatch(typeof(Action_ClearAllStatus), "RunAction")] private static class PartialCureAll { private static bool Prefix(Action_ClearAllStatus __instance) { //IL_0020: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Invalid comparison between Unknown and I4 //IL_0059: 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) if (!On) { return true; } int num = Enum.GetNames(typeof(STATUSTYPE)).Length; for (int i = 0; i < num; i++) { STATUSTYPE val = (STATUSTYPE)i; if (!__instance.defaultExclusions.Contains(val) && (!__instance.excludeCurse || (int)val != 5) && !__instance.otherExclusions.Contains(val)) { ((ItemActionBase)__instance).character.refs.afflictions.SubtractStatus(val, CureAllAmount(val), false, false); } } return false; } } [HarmonyPatch(typeof(Action_RestoreHunger), "RunAction")] private static class PoisonousScorpion { private static void Postfix(Action_RestoreHunger __instance) { //IL_0041: 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_004e: Unknown result type (might be due to invalid IL or missing references) Character character = ((ItemActionBase)__instance).character; if (On && (Object)(object)character != (Object)null && character.IsLocal && (Object)(object)((ItemActionBase)__instance).item != (Object)null && (Object)(object)((Component)((ItemActionBase)__instance).item).GetComponent<Scorpion>() != (Object)null) { STATUSTYPE type = (STATUSTYPE)3; ExactStatus.Add(character.refs.afflictions, type, A15_StrongerAilments.FromAscent15(type, 0.15f), "scorpion"); } } } [HarmonyPatch(typeof(CookingBehavior_DisableScripts), "TriggerBehaviour")] private static class CookingKeepsPoison { private static void Postfix(CookingBehavior_DisableScripts __instance) { if (!On || __instance.scriptsToDisable == null) { return; } MonoBehaviour[] scriptsToDisable = __instance.scriptsToDisable; foreach (MonoBehaviour val in scriptsToDisable) { if ((Object)(object)val != (Object)null && Poisonous(val)) { ((Behaviour)val).enabled = true; } } } } [HarmonyPatch(typeof(Affliction_AdjustDrowsyOverTime), "UpdateEffect")] private static class SleepierLollipop { private static bool Prefix(Affliction_AdjustDrowsyOverTime __instance) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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) if (!On) { return true; } if ((Object)(object)((Affliction)__instance).character != (Object)null && ((Affliction)__instance).character.IsLocal && __instance.statusPerSecond > 0f) { STATUSTYPE type = (STATUSTYPE)6; ExactStatus.Add(((Affliction)__instance).character.refs.afflictions, type, A15_StrongerAilments.FromAscent15(type, __instance.statusPerSecond * Time.deltaTime), "lollipop"); } return false; } } [HarmonyPatch(typeof(Affliction_FasterBoi), "OnApplied")] private static class SlowerEnergyDrink { private static void Prefix(Affliction_FasterBoi __instance) { if (On && !ToxicDrink.IsBoost(__instance)) { bool inEnergyDrink = A14_Items.InEnergyDrink; bool inCherryLollipop = A14_Items.InCherryLollipop; float num = Overrides.Original(__instance, "walk", __instance.moveSpeedMod); float num2 = Overrides.Original(__instance, "climb", __instance.climbSpeedMod); Overrides.Set(__instance, "moveSpeedMod", inEnergyDrink ? num : (inCherryLollipop ? 0.3f : Mathf.Min(num, 0.6f))); Overrides.Set(__instance, "climbSpeedMod", inEnergyDrink ? num2 : Mathf.Min(num2, 0.7f)); if (A14_Items.InEnergyDrink && Rules.Enabled(14)) { Overrides.Set(__instance, "drowsyOnEnd", A15_StrongerAilments.Raw((STATUSTYPE)6, 0.5f)); } } } } [HarmonyPatch(typeof(TiedBalloon), "FixedUpdate")] private static class WeakerBalloon { private static void Prefix(TiedBalloon __instance) { if (On) { Overrides.Set(__instance, "floatForce", 5f); Overrides.Set(__instance, "popHeight", float.PositiveInfinity); Overrides.Set(__instance, "popTime", 30f); } } } [HarmonyPatch(typeof(VineShooter), "Update")] private static class ShorterChain { private static void Prefix(VineShooter __instance) { if (On) { Overrides.Set(__instance, "maxLength", 30f); } } } [HarmonyPatch(typeof(RopeShooter), "Update")] private static class ShorterRopeCannonReach { private static void Prefix(RopeShooter __instance) { float num = Overrides.Original(__instance, "maxLength", __instance.maxLength); Overrides.Set(__instance, "maxLength", On ? 25f : num); } } [HarmonyPatch(typeof(RescueHook), "GetHit")] private static class ShorterRescueClaw { private static void Prefix(RescueHook __instance) { float num = Overrides.Original(__instance, "range", __instance.range); float num2 = Overrides.Original(__instance, "rangeDownward", __instance.rangeDownward); Overrides.Set(__instance, "range", On ? 20f : num); Overrides.Set(__instance, "rangeDownward", On ? 30f : num2); } } [HarmonyPatch(typeof(RopeShooter), "OnPrimaryFinishedCast")] private static class ShorterRope { private static void Prefix(RopeShooter __instance, out float? __state) { __state = null; if (On) { __state = __instance.length; __instance.length *= 0.75f; } } private static Exception Finalizer(RopeShooter __instance, float? __state, Exception __exception) { if (__state.HasValue) { __instance.length = __state.Value; } return __exception; } } [HarmonyPatch(typeof(Action_ReduceUses), "ReduceUsesRPC")] private static class DoubleUseCost { private static bool Prefix(Action_ReduceUses __instance) { if (!On) { return true; } Item item = ((ItemActionBase)__instance).item; OptionableIntItemData data = item.GetData<OptionableIntItemData>((DataEntryKey)2); if (data.HasData && data.Value > 0) { if (data.Value >= 2) { data.Value--; } data.Value--; if (item.totalUses > 0) { item.SetUseRemainingPercentage((float)data.Value / (float)item.totalUses); } Character character = ((ItemActionBase)__instance).character; if (data.Value == 0 && __instance.consumeOnFullyUsed && (Object)(object)character != (Object)null && character.IsLocal && (Object)(object)character.data.currentItem == (Object)(object)item) { ((MonoBehaviour)item).StartCoroutine(item.ConsumeDelayed(false)); } } return false; } } [HarmonyPatch(typeof(Glider), "FixedUpdate")] private static class HungryGlider { private static void Prefix(Glider __instance, out float? __state) { __state = null; if (On) { __state = __instance.stamUse; __instance.stamUse *= 1.5f; } } private static Exception Finalizer(Glider __instance, float? __state, Exception __exception) { if (__state.HasValue) { __instance.stamUse = __state.Value; } return __exception; } } [HarmonyPatch(typeof(Parasol), "FixedUpdate")] private static class WearingParasol { private static void Postfix(Parasol __instance) { Item item = __instance.item; if (!On || (Object)(object)item == (Object)null || (Object)(object)((MonoBehaviourPun)item).photonView == (Object)null || !((MonoBehaviourPun)item).photonView.IsMine || item.consuming || A14_Items.IsLightweightParasol(item)) { return; } FloatItemData data = item.GetData<FloatItemData>((DataEntryKey)10, (Func<FloatItemData>)(() => new FloatItemData { Value = 20f })); Character holderCharacter = item.holderCharacter; if ((Object)(object)holderCharacter != (Object)null && holderCharacter.IsLocal && __instance.isOpen && !holderCharacter.data.isGrounded && data.Value > 0f) { data.Value = Mathf.Max(0f, data.Value - Time.fixedDeltaTime); if (data.Value <= 0f) { ((MonoBehaviour)item).StartCoroutine(item.ConsumeDelayed(true)); } } item.SetUseRemainingPercentage(data.Value / 20f); } } [HarmonyPatch(typeof(RescueHook), "RPCA_LetGo")] private static class RoughRescueHook { private static void Prefix(RescueHook __instance) { if (On) { Character val = null; if (Rules.Owns(__instance.targetPlayer)) { val = __instance.targetPlayer; } else if ((Object)(object)__instance.targetPlayer == (Object)null && Rules.Owns(__instance.playerHoldingItem)) { val = __instance.playerHoldingItem; } if ((Object)(object)val != (Object)null) { val.Fall(2f, 0f); } } } } private sealed class CannonShot { internal readonly HashSet<int> launched = new HashSet<int>(); internal bool punished; } [HarmonyPatch(typeof(ScoutCannon), "RPCA_Light")] private static class CannonLit { private static void Prefix(ScoutCannon __instance) { CannonShot orCreateValue = shots.GetOrCreateValue(__instance); orCreateValue.launched.Clear(); orCreateValue.punished = false; } } [HarmonyPatch(typeof(ScoutCannon), "RPCA_LaunchTarget")] private static class HotCannon { private static void Postfix(ScoutCannon __instance, int targetID) { if (On) { PhotonView val = PhotonView.Find(targetID); Character val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<Character>() : null); if ((Object)(object)val2 != (Object)null && shots.GetOrCreateValue(__instance).launched.Add(targetID) && Rules.Owns(val2)) { val2.refs.afflictions.AddStatus((STATUSTYPE)8, 0.5f, false, true, true, false, false); } } } } [HarmonyPatch(typeof(CharacterItems), "DropItemRpc")] private static class HalfCannonThrow { private static void Prefix(CharacterItems __instance, out Vector2? __state) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) __state = null; Item val = (((Object)(object)__instance.character != (Object)null) ? __instance.character.data.currentItem : null); if (On && !((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).GetComponent<Action_ConstructableScoutCannonScroll>() == (Object)null)) { __state = new Vector2(__instance.minThrowForce, __instance.maxThrowForce); __instance.minThrowForce *= 0.5f; __instance.maxThrowForce *= 0.5f; } } private static Exception Finalizer(CharacterItems __instance, Vector2? __state, Exception __exception) { //IL_000c: 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) if (__state.HasValue) { __instance.minThrowForce = __state.Value.x; __instance.maxThrowForce = __state.Value.y; } return __exception; } } [HarmonyPatch(typeof(StickyItemComponent), "Awake")] private static class WeakerCactusThrow { private static void Postfix(StickyItemComponent __instance) { Item val = default(Item); if (On && __instance is CactusBall && ((Component)__instance).TryGetComponent<Item>(ref val)) { Overrides.Set(val, "throwForceMultiplier", Overrides.Original(val, "throw", val.throwForceMultiplier) / 1.5f); } } } [HarmonyPatch(typeof(ScoutCannon), "RPCA_LaunchItem")] private static class CannonGlitch { private static void Postfix(ScoutCannon __instance, int targetID) { if (!On) { return; } CannonShot orCreateValue = shots.GetOrCreateValue(__instance); PhotonView val = PhotonView.Find(targetID); if (!orCreateValue.punished && orCreateValue.launched.Count != 0 && !((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).GetComponent<Item>() == (Object)null)) { orCreateValue.punished = true; Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter != (Object)null && !localCharacter.data.dead) { localCharacter.refs.afflictions.SetStatus((STATUSTYPE)8, 0f, true); localCharacter.refs.afflictions.AddStatus((STATUSTYPE)4, 200f, false, true, true, false, false); localCharacter.PassOutInstantly(); } } } } [HarmonyPatch(typeof(CharacterAfflictions), "ClearAllStatus")] private static class ClearLeavesResidue { private static void Prefix(CharacterAfflictions __instance, bool excludeCurse, bool excludePetrify, out float[] __state) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) __state = null; if (!On || CheckpointScope.Depth > 0 || StatueRevive.Depth > 0 || !Rules.Owns(__instance.character) || Tfa.Causing) { return; } float num = (A14_Items.InCursedSkull ? 0.1f : 0.25f); __state = new float[12]; for (int i = 0; i < __state.Length; i++) { STATUSTYPE val = (STATUSTYPE)i; if (__instance.StatusIsCurable(val, !excludeCurse, !excludePetrify)) { __state[i] = __instance.GetCurrentStatus(val) * num; } } } private static void Postfix(CharacterAfflictions __instance, float[] __state) { if (__state == null) { return; } bool flag = false; for (int i = 0; i < __state.Length; i++) { if (__state[i] > 0f) { __instance.SetStatus((STATUSTYPE)i, __state[i], false); flag = true; } } if (flag) { __instance.PushStatuses((Player)null); } } } [HarmonyPatch(typeof(Character), "RPCA_ReviveAtPosition")] internal static class StatueRevive { [ThreadStatic] internal static int Depth; private static void Prefix(Character __instance, Vector3 position, int statueSegment, out int __state) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) __state = ((statueSegment > -1 && NearAStatue(position)) ? __instance.data.petrifyAmount : (-1)); if (__state >= 0) { Depth++; } } private static void Postfix(Character __instance, int __state) { KeepPetrification(__instance, __state); } private static Exception Finalizer(int __state, Exception __exception) { if (__state >= 0) { Depth--; } return __exception; } private static bool NearAStatue(Vector3 position) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) RespawnChest[] array = Object.FindObjectsByType<RespawnChest>((FindObjectsSortMode)0); foreach (RespawnChest val in array) { if ((Object)(object)val != (Object)null && Vector3.Distance(((Component)val).transform.position, position) < 20f) { return true; } } return false; } } [HarmonyPatch(typeof(Character), "TryCheckpoint")] internal static class CheckpointScope { [ThreadStatic] internal static int Depth; private static void Prefix(Character __instance, out int __state) { Depth++; __state = __instance.data.petrifyAmount; } private static void Postfix(Character __instance, bool __result, int __state) { if (__result) { KeepPetrification(__instance, __state); } } private static Exception Finalizer(Exception __exception) { Depth--; return __exception; } } [HarmonyPatch(typeof(Character), "ReviveCharacter")] private static class RevivalPenalty { private static void Prefix(Character __instance, out bool __state) { __state = On && Rules.Owns(__instance) && (__instance.data.dead || __instance.data.passedOut || __instance.data.fullyPassedOut); } private static void Postfix(Character __instance, bool applyStatus, bool __state) { if (__state && !applyStatus) { if (!Rules.Enabled(19)) { __instance.refs.afflictions.AddStatus((STATUSTYPE)5, 0.1f, false, true, true, false, false); } __instance.refs.afflictions.AddStatus((STATUSTYPE)1, 0.2f, false, true, true, false, false); } } } [HarmonyPatch(typeof(CharacterAfflictions), "AddStatus")] internal static class FragileSkeletonsAndInvincibility { [ThreadStatic] private static int skeletonScope; internal static bool InSkeletonScope => skeletonScope > 0; private static void Prefix(CharacterAfflictions __instance, STATUSTYPE statusType, ref float amount, ref bool ignoreInvincibility, out bool __state) { //IL_001f: Unknown result type (might be due to invalid IL or missing ref