Decompiled source of Hourglass Mage v0.9.32
SpellBrigadeHourglassMage.dll
Decompiled 4 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.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.Json; using System.Threading.Tasks; using BepInEx; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using BepInEx.Unity.IL2CPP.Utils; using FMOD.Studio; using FMODUnity; using HarmonyLib; using Il2CppInterop.Common; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.Injection; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppInterop.Runtime.Runtime; using Il2CppInterop.Runtime.Runtime.VersionSpecific.MethodInfo; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Il2CppSystem.Reflection; using SpellBrigadeHourglassMage.Core; using SpellBrigadeHourglassMage.Game; using SpellBrigadeHourglassMage.Spell; using TMPro; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Localization; using UnityEngine.Localization.Settings; using UnityEngine.Localization.Tables; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; using UnityEngine.VFX; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("SpellBrigadeHourglassMage")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.9.32.0")] [assembly: AssemblyInformationalVersion("0.9.32+62a3e299f5504f6ba690686df8caf5f795316636")] [assembly: AssemblyProduct("SpellBrigadeHourglassMage")] [assembly: AssemblyTitle("SpellBrigadeHourglassMage")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.9.32.0")] [module: UnverifiableCode] namespace SpellBrigadeHourglassMage { public enum RigMode { Own, Eugenie } public enum DialStyleMode { Game, Painted, BrassSepia, Classic, Shrine } public enum SelfTestScopeMode { Full, LastGrainOnly, TickProcs, WoundOnly, Soak } public enum SlowedLookMode { GoldRim, Sand } public enum VertexColorMode { None, White, Black } internal static class ModConfig { public static ConfigEntry<float> HpThreshold; public static ConfigEntry<float> Duration; public static ConfigEntry<float> Cooldown; public static ConfigEntry<float> Radius; public static bool RadiusMigrated; public static bool DurationMigrated; public static ConfigEntry<float> SlowFactor; public static ConfigEntry<bool> SlowProjectiles; public static ConfigEntry<float> BubbleIntensity; public static ConfigEntry<float> FaceOpacity; public static ConfigEntry<bool> ShowHudMarker; public static ConfigEntry<VertexColorMode> VertexColors; public static ConfigEntry<bool> SlowedEnemyEffect; public static ConfigEntry<bool> DebugHotkey; public static ConfigEntry<bool> CaptureOnHotkey; public static ConfigEntry<bool> VisualSelfTest; public static ConfigEntry<bool> SelfTestAutoRun; public static ConfigEntry<int> SelfTestWatchdogMinutes; public static ConfigEntry<int> SelfTestCharacter; public static ConfigEntry<int> SelfTestStartLevel; public static ConfigEntry<int> SelfTestSkin; public static ConfigEntry<bool> SelfTestSingleTarget; public static ConfigEntry<bool> SelfTestMatrix; public static ConfigEntry<int> SelfTestMatrixPasses; public static ConfigEntry<string> SelfTestMatrixElements; public static ConfigEntry<string> SelfTestGrants; public static ConfigEntry<string> SelfTestVariants; public static ConfigEntry<bool> SelfTestBurstCaptures; public static ConfigEntry<bool> SelfTestIconCaptures; public static ConfigEntry<bool> SelfTestReleaseCheck; public static ConfigEntry<bool> SkinCaptures; public static ConfigEntry<string> SkinCaptureTour; public static ConfigEntry<RigMode> Rig; public static ConfigEntry<bool> PocketWatchSkin; public static ConfigEntry<bool> CandleSkin; public static ConfigEntry<bool> CuckooSkin; public static ConfigEntry<StatType> PassiveStat; public static ConfigEntry<float> PassiveValue; public static ConfigEntry<DialStyleMode> DialStyle; public static bool DialStyleMigrated; public static ConfigEntry<bool> ShrineBorder; public static ConfigEntry<bool> ShrineStrokes; public static ConfigEntry<bool> TimeGhosts; public static ConfigEntry<SlowedLookMode> SlowedLook; public static ConfigEntry<bool> DialParticles; public static ConfigEntry<bool> ShrinePlateRim; public static ConfigEntry<SelfTestScopeMode> SelfTestScope; public static ConfigEntry<float> SepiaStrength; public static ConfigEntry<bool> FeelShake; public static ConfigEntry<bool> FeelSounds; public static ConfigEntry<bool> FeelHaptics; public static ConfigEntry<bool> FeelSnapshot; public static ConfigEntry<string> SoundSave; public static ConfigEntry<bool> CheatDeath; public static ConfigEntry<float> CheatDeathCooldown; public static ConfigEntry<float> CheatDeathImmunity; public static ConfigEntry<string> SoundActivation; public static ConfigEntry<string> SoundTick; public static ConfigEntry<string> SoundFinalTick; public static ConfigEntry<string> SoundEnd; public static ConfigEntry<string> SoundSnapshot; public static ConfigEntry<bool> UseVfxBundle; public static ConfigEntry<DialPaletteName> DialPalette; public static ConfigEntry<bool> HeadSpring; public static ConfigEntry<float> HeadStiffness; public static ConfigEntry<float> HeadDamping; public static ConfigEntry<float> HeadGain; public static ConfigEntry<float> HeadMaxTilt; public static bool SkinEnabled(int skinId) { return skinId switch { 1001 => PocketWatchSkin.Value, 1002 => CandleSkin.Value, 1003 => CuckooSkin.Value, _ => Skins.IsOurs(skinId), }; } public static void Init(ConfigFile cfg) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Expected O, but got Unknown //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Expected O, but got Unknown //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Expected O, but got Unknown //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Expected O, but got Unknown //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Expected O, but got Unknown //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Expected O, but got Unknown //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Expected O, but got Unknown //IL_06e2: Unknown result type (might be due to invalid IL or missing references) //IL_06ec: Expected O, but got Unknown //IL_082a: Unknown result type (might be due to invalid IL or missing references) //IL_0834: Expected O, but got Unknown HpThreshold = cfg.Bind<float>("LastGrain", "HpThreshold", 0.3f, new ConfigDescription("Health fraction below which the bubble opens (0.30 = 30 %).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 0.95f), Array.Empty<object>())); Duration = cfg.Bind<float>("LastGrain", "Duration", new LastGrainSettings().Duration, new ConfigDescription("Seconds the bubble stays open.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 30f), Array.Empty<object>())); if (Math.Abs(Duration.Value - 4f) < 0.001f) { Duration.Value = new LastGrainSettings().Duration; DurationMigrated = true; } Cooldown = cfg.Bind<float>("LastGrain", "Cooldown", 45f, new ConfigDescription("Seconds before the bubble can open again (counted from when it closes).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 600f), Array.Empty<object>())); Radius = cfg.Bind<float>("LastGrain", "Radius", new LastGrainSettings().Radius, new ConfigDescription("Bubble radius in metres (the game's units). The dial and the slowed area both use it.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 20f), Array.Empty<object>())); if (Math.Abs(Radius.Value - 6f) < 0.001f) { Radius.Value = new LastGrainSettings().Radius; RadiusMigrated = true; } SlowFactor = cfg.Bind<float>("LastGrain", "SlowFactor", 0.7f, new ConfigDescription("How much enemies inside are slowed: 0.7 = they move, shoot and fire projectiles at 30 % speed. Uses the game's own slow-down (the same one quicksand and the slow bushes use), applied by the host; bosses and some elites resist part of it.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 0.95f), Array.Empty<object>())); SlowProjectiles = cfg.Bind<bool>("LastGrain", "SlowProjectiles", true, "Also slow enemy projectiles inside the bubble (by the same factor)."); CheatDeath = cfg.Bind<bool>("LastGrain", "CheatDeath", true, "0.9.29: Last Grain's save: a hit that would take your Hourglass Mage to 0 health leaves 1 instead, opens the bubble at once (even while it recharges) and makes you immune for a moment. Then it recharges on its own timer (CheatDeathCooldown). The one-hit curse still kills."); CheatDeathCooldown = cfg.Bind<float>("LastGrain", "CheatDeathCooldown", 180f, new ConfigDescription("Seconds before the cheat-death save is ready again (separate from Last Grain's own Cooldown).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 1800f), Array.Empty<object>())); CheatDeathImmunity = cfg.Bind<float>("LastGrain", "CheatDeathImmunity", 0.5f, new ConfigDescription("Seconds of immunity right after a save (so the next hit of the same swarm doesn't finish you).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>())); BubbleIntensity = cfg.Bind<float>("Visual", "BubbleIntensity", 1f, new ConfigDescription("How strongly the clock dial is drawn overall (face, numerals, hands, rim, sparkles): 0 = invisible, 1 = normal.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>())); FaceOpacity = cfg.Bind<float>("Visual", "FaceOpacity", 0.7f, new ConfigDescription("Opacity of the clock's violet face on the ground. Lower it if it hides ground hazards; the numerals, hands and rim stay visible.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); ShowHudMarker = cfg.Bind<bool>("Visual", "ShowHudMarker", true, "Show the Last Grain marker on your health bar (like Spud's Frenzy marker) when you play the Hourglass Mage."); VertexColors = cfg.Bind<VertexColorMode>("Visual", "VertexColors", VertexColorMode.None, "Vertex colours given to the model. The game's wizard shader uses the mesh's vertex colour as an effect mask; if the model looks wrong in game (too dark, glowing, flat), try White or Black."); SlowedEnemyEffect = cfg.Bind<bool>("Visual", "SlowedEnemyEffect", true, "Sand around every enemy the bubble is slowing (visual only, shown on every player's screen)."); DialStyle = cfg.Bind<DialStyleMode>("Visual", "DialStyle", DialStyleMode.BrassSepia, "BrassSepia (0.8.0): a painted brass clock with chunky markers and one long hand over an old-photo sepia interior (framed by the shrine border, Visual.ShrineBorder). Shrine (0.9.x): the shrine border alone. Classic: the glowing game-shader dial of 0.5-0.7.11 (Game is the same). Painted: the 0.4.x painted dial."); if (DialStyle.Value == DialStyleMode.Game || DialStyle.Value == DialStyleMode.Shrine) { DialStyle.Value = DialStyleMode.BrassSepia; DialStyleMigrated = true; } ShrineBorder = cfg.Bind<bool>("Visual", "ShrineBorder", true, "0.9.2: the shrine border around Last Grain's dial: one ring of painted brass plates with gold glowing gaps, the game's magic-circle edge and a low gold wall."); ShrineStrokes = cfg.Bind<bool>("Visual", "ShrineStrokes", false, "DialStyle Shrine only: the 0.9.1 brushed ticks and hand."); SlowedLook = cfg.Bind<SlowedLookMode>("Visual", "SlowedLook", SlowedLookMode.GoldRim, "0.9.3: how the enemies a Last Grain bubble slows look: GoldRim (a pulsing gold rim light, always gold) or Sand (the 0.8.x sand)."); DialParticles = cfg.Bind<bool>("Visual", "DialParticles", false, "0.9.6: the 0.8.x sand inside Last Grain (orbiting sand, suck-in, unfold burst, tick flash, rim sparkles). Off: only the clock, the border, the rims and the cogs inside."); ShrinePlateRim = cfg.Bind<bool>("Visual", "ShrinePlateRim", false, "0.9.6: a gold outline around each border plate (off: the gold is only in the gaps)."); TimeGhosts = cfg.Bind<bool>("Visual", "TimeGhosts", false, "Gold afterimages behind slowed enemies instead of the sand (0.9.1 experiment, off: a replacement for the sand is being designed)."); SepiaStrength = cfg.Bind<float>("Visual", "SepiaStrength", 0.7f, new ConfigDescription("BrassSepia: how strongly the ground inside the dial turns old-photo sepia (0 = not at all).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); FeelShake = cfg.Bind<bool>("Feel", "ScreenShake", true, "A small screen shake when your Last Grain opens and closes (never for other players' bubbles)."); FeelSounds = cfg.Bind<bool>("Feel", "Sounds", true, "Game sounds for Last Grain: activation, a tick every second, the end (other players' at half volume)."); FeelHaptics = cfg.Bind<bool>("Feel", "Haptics", true, "A short controller rumble when your Last Grain opens."); FeelSnapshot = cfg.Bind<bool>("Feel", "Snapshot", false, "Also run the game's 'dark sludge' audio snapshot (muffled sound) while your bubble is open."); SoundActivation = cfg.Bind<string>("Feel", "ActivationSound", "bell spawn", "FMOD event for the activation: a full event path (event:/...) or words that must all appear in the path (picked from the game's banks; logged)."); SoundTick = cfg.Bind<string>("Feel", "TickSound", "timertick", "FMOD event for each tick (words or a full path; the final-seconds variant is skipped)."); SoundFinalTick = cfg.Bind<string>("Feel", "FinalTickSound", "timertick finalseconds", "FMOD event for the ticks in the last 3 seconds."); SoundEnd = cfg.Bind<string>("Feel", "EndSound", "bell detonate", "FMOD event for the end of the bubble."); SoundSave = cfg.Bind<string>("Feel", "SaveSound", "shatter", "0.9.29: FMOD event for the cheat-death save (words or a full path); nothing matching = silent."); SoundSnapshot = cfg.Bind<string>("Feel", "SnapshotSound", "snapshot darksludge", "FMOD snapshot used when Feel.Snapshot is on."); DialPalette = cfg.Bind<DialPaletteName>("Visual", "DialPalette", DialPaletteName.SunlitGold, "Colours of the clock dial (game style): SunlitGold (A), AmberSand (B), FrozenTime (C), Minimal (D, rim and hands only), SandVortex (E, mostly sand), Classic (the 0.5-0.6.2 violet look). Previews: docs/concepts/last-grain/options_v2."); UseVfxBundle = cfg.Bind<bool>("Visual", "UseVfxBundle", true, "Game style only: use the mod's Unity-made effects (HourglassVfx.bundle: particle sand, sparkles, bursts). Off = the 0.5.0 dial built in code."); Rig = cfg.Bind<RigMode>("Model", "Rig", RigMode.Own, "Own: the Hourglass Mage's own skeleton with its own Idle, Run and Flip animations. Eugenie: the 0.2.0 fallback, the hourglass mesh on Eugenie's skeleton with her animations (use it if the own rig misbehaves). Restart the game after changing."); PocketWatchSkin = cfg.Bind<bool>("Model", "PocketWatchSkin", true, "Offer Horatio's second skin, the Pocket Watch (ticking clock hands that rewind on Last Grain). Off = only the Sandglass (a saved Pocket Watch choice falls back to it). Everyone in a co-op lobby needs the same setting, like the same mod version. Restart the game after changing."); CandleSkin = cfg.Bind<bool>("Model", "CandleSkin", true, "Offer the Candle Clock skin (a wax candle with a flickering flame that flares on Last Grain). Same setting for every co-op player. Restart after changing."); CuckooSkin = cfg.Bind<bool>("Model", "CuckooSkin", true, "Offer the Cuckoo Clock skin (ticking dial hands, a bird that pops out on Last Grain and level-ups). Same setting for every co-op player. Restart after changing."); HeadSpring = cfg.Bind<bool>("Model", "HeadSpring", true, "The heavy glass leans and wobbles with Horatio's real movement (starting, stopping, turning) and settles."); HeadStiffness = cfg.Bind<float>("Model", "HeadSpringStiffness", 90f, "Spring constant: higher = quicker, snappier wobble."); HeadDamping = cfg.Bind<float>("Model", "HeadSpringDamping", 9f, "Damping: higher settles sooner; 19 = no overshoot at all."); HeadGain = cfg.Bind<float>("Model", "HeadSpringGain", 0.35f, "Degrees of lean per m/s² of acceleration."); HeadMaxTilt = cfg.Bind<float>("Model", "HeadSpringMaxTilt", 4f, "Largest lean in degrees, at most 4 (the hourglass rocks on its base; more would lift the rim off the body)."); DebugHotkey = cfg.Bind<bool>("Debug", "Hotkey", false, "For testing: Ctrl+G opens the bubble on your own Hourglass Mage right away (cooldown and health ignored); Ctrl+F12 saves a screenshot any time (menu, select screen, run) into BepInEx/HourglassCaptures."); VisualSelfTest = cfg.Bind<bool>("Debug", "VisualSelfTest", false, "Developer check: once you're in a run as Horatio (solo or host), plays a scripted look at Last Grain and every Borrowed Time element, saves captures into BepInEx/HourglassCaptures/selftest_<time>, logs frame times, then QUITS the game. Leave off."); SelfTestAutoRun = cfg.Bind<bool>("Debug", "SelfTestAutoRun", false, "Developer check, with VisualSelfTest on: walks the menus into a solo run by itself (Play solo, then ready with the selected character), so the self-test runs unattended. Leave off."); SelfTestWatchdogMinutes = cfg.Bind<int>("Debug", "SelfTestWatchdogMinutes", 4, new ConfigDescription("With VisualSelfTest on: if the self-test hasn't finished this many minutes after the game started, it logs it and quits the game (0 = never).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 120), Array.Empty<object>())); PassiveStat = cfg.Bind<StatType>("Model", "PassiveStat", (StatType)10, "0.9.21: Horatio's passive stat, like the vanilla wizards' (Reginald Luck +2, MoonMage XPGain +3, ...). Restart after changing."); PassiveValue = cfg.Bind<float>("Model", "PassiveValue", 3f, "0.9.21: the passive stat's value, in the game's own units (XPGain +3 = MoonMage's). 0 = no passive. Restart after changing."); SelfTestCharacter = cfg.Bind<int>("Debug", "SelfTestCharacter", -1, "Developer check (balance), with SelfTestAutoRun: the wizard the run is played as (a vanilla CharacterId: 0 Reginald, 6 Hatty, 9 Smithy, ...); -1 = Horatio. The save's selection is put back."); SelfTestSkin = cfg.Bind<int>("Debug", "SelfTestSkin", -1, "Developer check (balance), with SelfTestCharacter: the vanilla wizard's skin for the run (a SkinId; a Prestige skin starts with the prestige spell). -1 = the save's. The save's skin is put back."); SelfTestGrants = cfg.Bind<string>("Debug", "SelfTestGrants", "", "Developer check (balance), Soak scope: Borrowed Time's red upgrades granted for the soak, comma-separated (204 Overkill, 205 Chain, 206 Haste, 207 +1 cog). Empty = none."); SelfTestVariants = cfg.Bind<string>("Debug", "SelfTestVariants", "", "Developer check (balance), Soak scope, Test Kit 0.3.24+: red variants granted to the starting attack (slot 0), 'Name=count|Name=count'. The attack's variant list is always logged. A leading '~' grants them only after the first control window (that window is the no-reds reference). Empty = none."); SelfTestBurstCaptures = cfg.Bind<bool>("Debug", "SelfTestBurstCaptures", false, "Developer check (visual), Soak scope: 20 s into the soak, 16 full-screen captures 0.25 s apart plus close-ups of split bolts, each logged with the flying bolts (ours, splits, ones still showing the Orb) and the pop shakes so far."); SelfTestReleaseCheck = cfg.Bind<bool>("Debug", "SelfTestReleaseCheck", false, "Developer check (visual), Soak scope: 0.9.29's release checks: Last Grain close-ups with an Earth-infused spell (the dial must stay translucent), a second bubble, then (after any icon captures) the cheat-death save: two lethal hits, god mode off for that step only."); SelfTestIconCaptures = cfg.Bind<bool>("Debug", "SelfTestIconCaptures", false, "Developer check (visual), Soak scope: Borrowed Time's icon with Fire, Ice and Fire+Lightning: the HUD spell slot, a level-up card and the red (variant) store, each captured while open (with the UI)."); SelfTestMatrix = cfg.Bind<bool>("Debug", "SelfTestMatrix", false, "Developer check (balance), Soak scope: instead of one 75 s soak, every element and pair in turn for 30 s (the cogs, their ticks and pops forced to it), logged with its run time, so the Test Kit's damage log gives Borrowed Time's damage per element."); SelfTestMatrixPasses = cfg.Bind<int>("Debug", "SelfTestMatrixPasses", 2, new ConfigDescription("Developer check (balance), with SelfTestMatrix: how many times the whole element list is measured (each window after a fresh no-element control).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), Array.Empty<object>())); SelfTestMatrixElements = cfg.Bind<string>("Debug", "SelfTestMatrixElements", "", "Developer check (balance), with SelfTestMatrix: only these elements (comma-separated element numbers); empty = all."); SelfTestSingleTarget = cfg.Bind<bool>("Debug", "SelfTestSingleTarget", false, "Developer check (balance), Soak scope: during the 75 s soak only one enemy is kept (the nearest; the others are despawned as they come), so the damage log measures single-target damage. Off: the Test Kit's horde, a pack fight."); SelfTestStartLevel = cfg.Bind<int>("Debug", "SelfTestStartLevel", 0, "Developer check (balance), Soak scope: raises the party to this level first (XP, as the Test Kit's +1 level does; level-ups auto-picked), then soaks 75 s. 0 = from the start."); SelfTestScope = cfg.Bind<SelfTestScopeMode>("Debug", "SelfTestScope", SelfTestScopeMode.Full, "What the visual self-test covers: Full (Last Grain, every Borrowed Time element and combo, the red upgrades), LastGrainOnly (about 30 s: Last Grain's shots, then it quits) TickProcs (one wound per element and combo for 3.5 s each, logging the tick procs; no captures) or WoundOnly (about 30 s: cogs at 0 / 50 / 100 % for ten elements, and a full cog's flicker over 3 frames) or Soak (no captures: 75 s of the run as it plays, for the Test Kit's damage log, then it quits)."); CaptureOnHotkey = cfg.Bind<bool>("Debug", "CaptureOnHotkey", false, "With Hotkey on: Ctrl+G (Last Grain) and Ctrl+K (Borrowed Time, Spell.DebugWoundKey) also save ONE screenshot (2 s into the bubble, 1.5 s after the pin). Off by default: the game build has no ScreenCapture, so a shot re-renders the cameras and hitches for a moment."); SkinCaptures = cfg.Bind<bool>("Debug", "SkinCaptures", false, "For testing the skins: saves screenshots into BepInEx/HourglassCaptures/skins whenever a Horatio skin model shows up (select screen, lobby, run): 1.5 s and 4 s after it appears and 1 s into its Select. Leave off."); SkinCaptureTour = cfg.Bind<string>("Debug", "SkinCaptureTour", "", "For testing the skins without anyone at the keyboard: \"menus,1002\" walks into a solo game, shows every Horatio skin in the lobby and on the select screen, then plays a short run as skin 1002, saving screenshots into BepInEx/HourglassCaptures/tour, and quits the game. It changes your selected character for the tour and puts it back. Leave empty."); } public static LastGrainSettings Settings() { return new LastGrainSettings { HpThreshold = HpThreshold.Value, Duration = Duration.Value, Cooldown = Cooldown.Value, Radius = Radius.Value, SlowFactor = SlowFactor.Value }; } } internal static class ModLog { private static ManualLogSource? _log; private static StreamWriter? _file; private static readonly HashSet<string> Once = new HashSet<string>(); private static readonly Dictionary<string, float> Throttle = new Dictionary<string, float>(); public const string CleanExit = "clean exit"; public static string FilePath => Path.Combine(Paths.BepInExRootPath, "SpellBrigadeHourglassMage.log"); public static string PreviousFilePath => Path.Combine(Paths.BepInExRootPath, "SpellBrigadeHourglassMage.prev.log"); public static string? PreviousCrashStep { get; private set; } public static void Init(ManualLogSource log) { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Expected O, but got Unknown _log = log; bool flag = default(bool); try { if (File.Exists(FilePath)) { File.Copy(FilePath, PreviousFilePath, overwrite: true); string text = null; string[] array = File.ReadAllLines(FilePath); foreach (string text2 in array) { int num = text2.IndexOf(" STEP ", StringComparison.Ordinal); if (num >= 0) { string text3 = text2; int num2 = num + 7; text = text3.Substring(num2, text3.Length - num2).Trim(); } } if (text != null && text != "clean exit") { PreviousCrashStep = text; } } } catch (Exception ex) { BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(30, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Could not read the previous "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(FilePath); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } log.LogWarning(val); } try { _file = new StreamWriter(new FileStream(FilePath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)) { AutoFlush = true }; _file.WriteLine($"SpellBrigadeHourglassMage {"0.9.32"} log, started {DateTime.Now:yyyy-MM-dd HH:mm:ss}"); if (PreviousCrashStep != null) { _file.WriteLine("Previous session did not exit cleanly; its last step was: " + PreviousCrashStep + " (log kept as SpellBrigadeHourglassMage.prev.log)"); } } catch (Exception ex2) { BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(17, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Could not open "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(FilePath); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex2.Message); } log.LogWarning(val); } } public static void Info(string msg) { ManualLogSource? log = _log; if (log != null) { log.LogInfo((object)msg); } ToFile("INFO ", msg); } public static void Warn(string msg) { ManualLogSource? log = _log; if (log != null) { log.LogWarning((object)msg); } ToFile("WARN ", msg); } public static void Error(string msg) { ManualLogSource? log = _log; if (log != null) { log.LogError((object)msg); } ToFile("ERROR", msg); } public static void Debug(string msg) { ManualLogSource? log = _log; if (log != null) { log.LogDebug((object)msg); } ToFile("DEBUG", msg); } public static void Step(string msg) { ToFile("STEP ", msg); } public static void StepOnce(string key, string msg) { if (Once.Add("step:" + key)) { Step(msg); } } public static void InfoOnce(string key, string msg) { if (Once.Add(key)) { Info(msg); } } public static void WarnOnce(string key, string msg) { if (Once.Add(key)) { Warn(msg); } } public static void ErrorThrottled(string key, Exception ex, float now, float seconds = 10f) { if (!Throttle.TryGetValue(key, out var value) || !(now - value < seconds)) { Throttle[key] = now; Error($"[{key}] {ex.GetType().Name}: {ex.Message}\n{ex.StackTrace}"); } } private static void ToFile(string level, string msg) { if (_file == null) { return; } try { lock (_file) { _file.WriteLine($"{DateTime.Now:HH:mm:ss.fff} {level} {msg}"); } } catch { } } } [BepInPlugin("com.stefanws0.spellbrigadehourglassmage", "SpellBrigadeHourglassMage", "0.9.32")] public class Plugin : BasePlugin { public const string Guid = "com.stefanws0.spellbrigadehourglassmage"; public const string Name = "SpellBrigadeHourglassMage"; public const string Version = "0.9.32"; public override void Load() { //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown ModLog.Init(((BasePlugin)this).Log); ModLog.Step("Load: config"); ModConfig.Init(((BasePlugin)this).Config); if (ModConfig.RadiusMigrated) { ModLog.Info($"Config: LastGrain.Radius moved from the old default 6 m to {ModConfig.Radius.Value:0.#} m (the dial is 30 % bigger since 0.7.2)."); } if (ModConfig.DurationMigrated) { ModLog.Info($"Config: LastGrain.Duration moved from the old default 4 s to {ModConfig.Duration.Value:0.#} s (50 % longer since 0.7.5)."); } ModelAssets.Load(); ModLog.Step("Load: registering HourglassAnimator"); ClassInjector.RegisterTypeInIl2Cpp<HourglassAnimator>(); Harmony val = new Harmony("com.stefanws0.spellbrigadehourglassmage"); ModLog.Step("Load: Borrowed Time"); BorrowedTime.Init(((BasePlugin)this).Config, val); CheatDeathHook.Install(val); ProjectilePatches.Prepare(val); foreach (Type item in new Type[5] { typeof(RepositoryPatches), typeof(NetworkSetup), typeof(MenuPatches), typeof(LobbyPatches), typeof(SavePatches) }.Concat((!ModConfig.VisualSelfTest.Value || !ModConfig.SelfTestMatrix.Value) ? ((IEnumerable<Type>)Type.EmptyTypes) : ((IEnumerable<Type>)new Type[1] { typeof(LevelFreezePatch) }))) { ModLog.Step("Load: patching " + item.Name); try { val.CreateClassProcessor(item).Patch(); } catch (Exception ex) { ModLog.Error("Patch group " + item.Name + " failed: " + ex.Message); } } ModLog.Step("Load: registering HourglassRunner"); ((BasePlugin)this).AddComponent<HourglassRunner>(); ((BasePlugin)this).AddComponent<BorrowedTimeRunner>(); BannerSwitch.Attach(((BasePlugin)this).AddComponent<BannerGui>()); ModLog.Step("Load: done"); ModLog.Info($"{"SpellBrigadeHourglassMage"} {"0.9.32"} loaded. Adds the Hourglass Mage (CharacterId {1000}). " + "Every player in a co-op lobby needs this mod: the game refuses joins between players with different prefab lists."); } } } namespace SpellBrigadeHourglassMage.Spell { internal static class AllyWounds { internal sealed class Refs { public GameplayPlayer Player; public ulong Client; public StuckCog? Cog; public ElementType Element; public ElementColors Look; } private static readonly WoundBook<Refs> Book = new WoundBook<Refs>(); private static readonly Dictionary<(ulong Target, ulong Source), float> LastTick = new Dictionary<(ulong, ulong), float>(); private static int _logged; private const float Height = 2.2f; public static int Planted; public static int Pops; public static int Count => Book.Count; public static void OnHit(ulong target, ulong source, float lost, ElementType element, bool bolt, float now) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) if (!WoundSystem.IsHost || !SpellConfig.AllyCog.Value || target == source || !(lost > 0f)) { return; } GameplayPlayer player = FindPlayer(target); PlayerHealthContainer val = (((Object)(object)player != (Object)null) ? player.HealthContainer : null); if ((Object)(object)player == (Object)null || (Object)(object)val == (Object)null || ((HealthContainer)val).CurrentHealth <= 0f) { return; } BorrowedTimeSettings settings = WoundSystem.Settings; long enemy = (long)target; bool flag = Book.Has(enemy); if (bolt) { (Wound<Refs> Wound, bool New) tuple = Book.Stick(enemy, source, now, WoundSystem.DurationFor(source), settings.WoundMaxDuration, ((HealthContainer)val).MaxHealth, () => new Refs { Player = player, Client = target, Element = element, Look = ElementColorsGame.For(element) }); Wound<Refs> item = tuple.Wound; bool item2 = tuple.New; Vector3 val2 = Above(player); if (item2) { Planted++; item.TickDamage = WoundSystem.TickDamageFor(source); item.Payload.Cog = StuckCog.Create(null, val2, element, item.Payload.Look); BoltTrail.SparkBurst(val2, element, 12, SpellConfig.StuckSizeMin.Value); BurstFx.Play(val2, SpellConfig.StuckSizeMin.Value * 0.7f, strong: false, item.Payload.Look); item.Payload.Cog?.Hit(); CogSync.HostStickAt(CogSync.NetId((NetworkBehaviour)(object)player), element, val2); ModLog.Info(FormattableString.Invariant($"Borrowed Time: friendly fire: a cog of client {source} stuck in player {target} ({lost:0} health lost, {item.Duration:0.#} s, element {element}).")); } else { int size = item.Size; item.Size = CogSize.Grow(item.Size, WoundSystem.MaxSize(item.Owner)); if (item.Size > size) { item.Payload.Cog?.Hit(); CogSync.HostTickAt(CogSync.NetId((NetworkBehaviour)(object)player), item.Payload.Element, WoundSystem.FillOf(item), dot: false); } } SpellSound.Stick(val2); } if (!flag) { return; } Wound<Refs> wound = Book.Get(enemy); if (wound != null && (!LastTick.TryGetValue((target, source), out var value) || !(now - value < 0.1f))) { LastTick[(target, source)] = now; if (LastTick.Count > 256) { LastTick.Clear(); } float weight = CoopRules.TickWeight(source, wound.Owner, SpellConfig.OtherPlayerTickWeight.Value); if (Book.Record(enemy, lost, settings.Mode, settings.WoundRecord, settings.MaxTicks, weight)) { wound.Payload.Cog?.Hit(); CogSync.HostTickAt(CogSync.NetId((NetworkBehaviour)(object)player), wound.Payload.Element, WoundSystem.FillOf(wound), dot: false); } } } public static void Tick(float now) { //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) if (!WoundSystem.IsHost || !SpellConfig.AllyCog.Value) { if (Book.Count > 0) { Clear(); } } else { if (Book.Count == 0) { return; } BorrowedTimeSettings settings = WoundSystem.Settings; List<long> list = null; foreach (Wound<Refs> item in Book.All) { GameplayPlayer player = item.Payload.Player; PlayerHealthContainer val = (((Object)(object)player != (Object)null && !((Il2CppObjectBase)player).WasCollected) ? player.HealthContainer : null); if ((Object)(object)val == (Object)null || ((HealthContainer)val).CurrentHealth <= 0f || (Object)(object)FindPlayer(item.Payload.Client) == (Object)null) { (list ?? (list = new List<long>())).Add(item.Enemy); } } if (list != null) { foreach (long item2 in list) { Wound<Refs> wound = Book.Remove(item2); if (wound != null) { Vector3 at = ((wound.Payload.Cog != null) ? wound.Payload.Cog.Position : Vector3.zero); wound.Payload.Cog?.Pop(); CogSync.HostPopAt(((Object)(object)wound.Payload.Player != (Object)null && !((Il2CppObjectBase)wound.Payload.Player).WasCollected) ? CogSync.NetId((NetworkBehaviour)(object)wound.Payload.Player) : ulong.MaxValue, wound.Payload.Element, at, 0.5f, paid: false, shake: false); } } } float deltaTime = Time.deltaTime; foreach (Wound<Refs> item3 in Book.All) { bool flag = LastGrainSystem.IsInAnyBubble(((Component)item3.Payload.Player).transform.position); if (flag) { item3.Start += deltaTime; } item3.Frozen = flag; } if (settings.DotMode != WoundDotMode.PopOnly) { foreach (Wound<Refs> item4 in Book.All) { if (!(now >= item4.NextDot)) { continue; } item4.NextDot = now + Math.Max(0.05f, settings.DotInterval); if (now - item4.Start < 0.05f) { continue; } float num = WoundSystem.DotAmountOf(item4, item4.Payload.Element); if (!(num <= 0f)) { CogSync.SendAllyStrike(item4.Payload.Client, item4.Owner, num, (ElementType)0, pop: false, CogSize.CritBonus(item4.Size, SpellConfig.CritPerSize.Value)); CogSync.HostTickAt(CogSync.NetId((NetworkBehaviour)(object)item4.Payload.Player), item4.Payload.Element, WoundSystem.FillOf(item4), dot: true); if ((Object)(object)item4.Payload.Player != (Object)null) { SpellSound.Hit(((Component)item4.Payload.Player).transform.position); } } } } foreach (Wound<Refs> item5 in Book.TakeDue(now)) { Pop(item5); } } } private static void Pop(Wound<Refs> w) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_0069: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) Refs payload = w.Payload; float num = WoundSystem.PopAmountOf(w, payload.Element, arcCog: false); Vector3 val = ((payload.Cog != null) ? payload.Cog.Position : Above(payload.Player)); float radius = payload.Cog?.Radius ?? 0.5f; payload.Cog?.Pop(); bool flag = BoltTrail.SparkBurst(val + Vector3.up * 0.4f, payload.Element, 14, radius); BurstFx.Play(val, 1f, num > 0f, payload.Look, !flag); SpellSound.Pop(val); CogSync.HostPopAt(CogSync.NetId((NetworkBehaviour)(object)payload.Player), payload.Element, val, radius, num > 0f, shake: false); Pops++; if (num > 0f) { CogSync.SendAllyStrike(payload.Client, w.Owner, num, payload.Element, pop: true, CogSize.CritBonus(w.Size, SpellConfig.CritPerSize.Value)); } if (_logged++ < 8) { ModLog.Info(FormattableString.Invariant($"Borrowed Time: friendly fire: the cog in player {payload.Client} popped for {num:0.#} ({w.Ticks} ticks / {w.Recorded:0} recorded).")); } } public static void LateTick(float now) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) if (Book.Count == 0) { return; } float deltaTime = Time.deltaTime; foreach (Wound<Refs> item in Book.All) { GameplayPlayer player = item.Payload.Player; if (item.Payload.Cog != null && !((Object)(object)player == (Object)null) && !((Il2CppObjectBase)player).WasCollected) { item.Payload.Cog.Update(WoundSystem.FillOf(item), now, deltaTime, Above(player)); } } } public static void Snapshot(List<CogEvent> into) { //IL_005a: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) if (!WoundSystem.IsHost) { return; } foreach (Wound<Refs> item in Book.All) { GameplayPlayer player = item.Payload.Player; StuckCog cog = item.Payload.Cog; if (cog != null && !((Object)(object)player == (Object)null) && !((Il2CppObjectBase)player).WasCollected) { Vector3 position = cog.Position; Vector3 val = position - ((Component)player).transform.position; into.Add(new CogEvent { Kind = CogEventKind.State, Enemy = CogSync.NetId((NetworkBehaviour)(object)player), Element = (ushort)item.Payload.Element, Fill = CogEvent.FillByte(WoundSystem.FillOf(item)), OffX = val.x, OffY = val.y, OffZ = val.z, X = position.x, Y = position.y, Z = position.z }); } } } public static void Clear() { foreach (Wound<Refs> item in Book.Clear()) { item.Payload.Cog?.Vanish(); } LastTick.Clear(); } public static void ApplyStrike(ulong target, ulong owner, float damage, ElementType element, bool pop, float critBonus) { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || target != singleton.LocalClientId || damage <= 0f) { return; } GameplayPlayer val = FindPlayer(target); PlayerHealthContainer val2 = (((Object)(object)val != (Object)null) ? val.HealthContainer : null); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null || ((HealthContainer)val2).CurrentHealth <= 0f) { return; } Hitbox componentInChildren = ((Component)val).GetComponentInChildren<Hitbox>(); if ((Object)(object)componentInChildren == (Object)null) { ModLog.WarnOnce("bt-ally-hitbox", "Borrowed Time: this player has no hitbox; ally cogs can't hit it."); return; } GameplayPlayerIdentity? obj = Horatios.Get(owner); IPlayerStats val3 = ((obj != null) ? obj.Stats : null); PlayerSpellDamageInfo val4 = ((val3 != null) ? new PlayerSpellDamageInfo(owner, Horatios.Host, val3) : new PlayerSpellDamageInfo(owner, Horatios.Host)); ((DamageInfo)val4).Damage = damage; ((DamageInfo)val4).Element = element; val4.SpellId = WoundSystem.WoundTag; ((PlayerDamageInfo)val4).CriticalChance = CogSize.AddChance(((PlayerDamageInfo)val4).CriticalChance, critBonus); float currentHealth = ((HealthContainer)val2).CurrentHealth; componentInChildren.Hit((DamageInfo)(object)val4); if (_logged++ < 8) { ModLog.Info(FormattableString.Invariant(FormattableStringFactory.Create("Borrowed Time: friendly fire: a cog of client {0} {1} on this player: {2:0.#} sent, {3:0.#} lost.", owner, pop ? "popped" : "ticked", damage, currentHealth - ((HealthContainer)val2).CurrentHealth))); } } private static GameplayPlayer? FindPlayer(ulong client) { GameplayPlayerManager instance = Singleton<GameplayPlayerManager>.Instance; if ((Object)(object)instance == (Object)null || instance.AlivePlayers == null) { return null; } List<GameplayPlayer> alivePlayers = instance.AlivePlayers; int i = 0; for (int count = alivePlayers.Count; i < count; i++) { GameplayPlayer val = alivePlayers[i]; if ((Object)(object)val != (Object)null && !((Il2CppObjectBase)val).WasCollected && ((NetworkBehaviour)val).OwnerClientId == client) { return val; } } return null; } private static Vector3 Above(GameplayPlayer p) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) return ((Component)p).transform.position + Vector3.up * (2.2f + SpellConfig.CogGap.Value); } } internal static class AllyHitHook { private const string Label = "PlayerHealthContainer.RemoveHealthOnOwner(float, DamageInfo) [ally cogs]"; private static readonly Dictionary<ulong, float> LastRecord = new Dictionary<ulong, float>(); private static int _logged; public static bool Installed { get; private set; } public static void Install(Harmony harmony) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_00a0: Expected O, but got Unknown try { MethodInfo method = typeof(PlayerHealthContainer).GetMethod("RemoveHealthOnOwner", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[2] { typeof(float), typeof(DamageInfo) }, null); if (method == null || !NativeCode.CanPatch(method, "PlayerHealthContainer.RemoveHealthOnOwner(float, DamageInfo) [ally cogs]", out string why)) { ModLog.Warn("Borrowed Time: not patching PlayerHealthContainer.RemoveHealthOnOwner(float, DamageInfo) [ally cogs]; no friendly-fire cogs."); return; } harmony.Patch((MethodBase)method, new HarmonyMethod(AccessTools.Method(typeof(AllyHitHook), "Prefix", (Type[])null, (Type[])null)), new HarmonyMethod(AccessTools.Method(typeof(AllyHitHook), "Postfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Installed = true; ModLog.Info($"Borrowed Time: friendly-fire cog hook on {"PlayerHealthContainer.RemoveHealthOnOwner(float, DamageInfo) [ally cogs]"} ({why})."); } catch (Exception ex) { ModLog.Warn($"Borrowed Time: could not patch {"PlayerHealthContainer.RemoveHealthOnOwner(float, DamageInfo) [ally cogs]"} ({ex.Message}); no friendly-fire cogs."); } } private static void Prefix(PlayerHealthContainer __instance, out float __state) { __state = -1f; try { if ((Object)(object)__instance != (Object)null && SpellConfig.AllyCog.Value && Horatios.Count > 0) { __state = ((HealthContainer)__instance).CurrentHealth; } } catch { __state = -1f; } } private static void Postfix(PlayerHealthContainer __instance, DamageInfo damageSource, float __state) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) if (__state < 0f || (Object)(object)__instance == (Object)null || damageSource == null) { return; } try { float num = __state - ((HealthContainer)__instance).CurrentHealth; if (!(num > 0f)) { return; } PlayerDamageInfo val = ((Il2CppObjectBase)damageSource).TryCast<PlayerDamageInfo>(); if (val == null) { return; } PlayerSpellDamageInfo val2 = ((Il2CppObjectBase)damageSource).TryCast<PlayerSpellDamageInfo>(); ulong ownerClientId = val.OwnerClientId; ulong ownerClientId2 = ((NetworkBehaviour)__instance).OwnerClientId; bool isHostSpell = val2 != null && val2.Spell == Horatios.Host; AllyRules.HitKind hitKind = AllyRules.Classify(fromPlayer: true, ownerClientId, ownerClientId2, isHostSpell, Horatios.IsHoratio(ownerClientId), WoundSystem.IsWoundHit(val2), num); if (_logged++ < 5) { ModLog.Info(FormattableString.Invariant(FormattableStringFactory.Create("Borrowed Time: friendly fire on this player: {0:0.#} from client {1} ({2}) -> {3}.", num, ownerClientId, (val2 != null) ? ((object)val2.Spell/*cast due to .constrained prefix*/).ToString() : "no spell", hitKind))); } if (hitKind == AllyRules.HitKind.None) { return; } float time = Time.time; if (hitKind == AllyRules.HitKind.Record) { if (LastRecord.TryGetValue(ownerClientId, out var value) && time - value < 0.1f) { return; } LastRecord[ownerClientId] = time; } CogSync.SendAllyHit(ownerClientId2, ownerClientId, num, ((DamageInfo)val).Element, hitKind == AllyRules.HitKind.Bolt); } catch (Exception ex) { ModLog.ErrorThrottled("bt-ally-hook", ex, Time.realtimeSinceStartup, 30f); } } } internal static class BoltTrail { private const string Prefix = "HourglassMage_BoltTrail_"; private static readonly Dictionary<int, (GameObject? Trail, GameObject? Sparks)> Templates = new Dictionary<int, (GameObject, GameObject)>(); private static int _logged; public const float SparkSize = 0.5f; private const float BladeRadius = 0.98f; private static readonly Dictionary<IntPtr, float> SparkVanillaScale = new Dictionary<IntPtr, float>(); private static readonly Dictionary<IntPtr, (float S0, float S1, float V0, float V1)> SparkVanilla = new Dictionary<IntPtr, (float, float, float, float)>(); private static int _fitLogged; private static readonly Dictionary<int, GameObject?> SparkTemplates = new Dictionary<int, GameObject>(); private static readonly Dictionary<(int, float, float, float), Material> Tinted = new Dictionary<(int, float, float, float), Material>(); private static readonly string[] TintColours = new string[3] { "_Color", "_color", "_BaseColor" }; private static readonly string[] TintEmission = new string[2] { "_EmissionColor", "_EmmisionColor" }; public static void Show(Transform bolt, ElementType element, ElementColors colours, Dictionary<int, GameObject> made) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Expected I4, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) int num = (int)element; foreach (KeyValuePair<int, GameObject> item in made) { if ((Object)(object)item.Value != (Object)null && item.Key != num && item.Value.activeSelf) { item.Value.SetActive(false); } } if (!made.TryGetValue(num, out GameObject value) || (Object)(object)value == (Object)null) { value = (made[num] = Make(bolt, element, colours)); } if (!value.activeSelf) { value.SetActive(true); } foreach (TrailRenderer componentsInChild in value.GetComponentsInChildren<TrailRenderer>(true)) { componentsInChild.Clear(); } } public static void Clear(Dictionary<int, GameObject> made) { foreach (KeyValuePair<int, GameObject> item in made) { if (!((Object)(object)item.Value != (Object)null) || !item.Value.activeSelf) { continue; } foreach (TrailRenderer componentsInChild in item.Value.GetComponentsInChildren<TrailRenderer>(true)) { componentsInChild.Clear(); } } } public static void Hide(Dictionary<int, GameObject> made) { foreach (KeyValuePair<int, GameObject> item in made) { if ((Object)(object)item.Value != (Object)null && item.Value.activeSelf) { item.Value.SetActive(false); } } } private static GameObject Make(Transform bolt, ElementType element, ElementColors colours) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected I4, but got Unknown //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected I4, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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) GameObject val = new GameObject("HourglassMage_BoltTrail_" + (int)element); val.transform.SetParent(bolt, false); (GameObject? Trail, GameObject? Sparks) tuple = Template(element); GameObject item = tuple.Trail; GameObject item2 = tuple.Sparks; bool flag = !ElementLook.Split((int)element).HasValue && (int)element != 0 && !colours.IsGold; try { if ((Object)(object)item != (Object)null) { GameObject obj = Object.Instantiate<GameObject>(item, val.transform, false); ((Object)obj).name = "Trail"; obj.transform.localPosition = Vector3.zero; Strip(obj); foreach (TrailRenderer componentsInChild in obj.GetComponentsInChildren<TrailRenderer>(true)) { componentsInChild.widthMultiplier = 1f; componentsInChild.startWidth = 1.1f * SpellConfig.BoltSize.Value; componentsInChild.endWidth = 0f; componentsInChild.time = 0.4f; if (flag) { Tint((Renderer)(object)componentsInChild, colours.Trail); } if (SpellConfig.SoftTrail.Value) { Soften(componentsInChild, colours); } } } if ((Object)(object)item2 != (Object)null) { CogSparks(val.transform, element, colours, SpellConfig.BoltSize.Value * SpellConfig.BoltVisualScale.Value / 2f); } } catch (Exception ex) { ModLog.ErrorThrottled("bt-trail", ex, Time.unscaledTime, 30f); } if (_logged++ < 10) { ModLog.Info($"Borrowed Time: bolt trail for {element}: {(((Object)(object)item != (Object)null) ? ("Sawblade '" + ((Object)item.transform.root).name + "' Trail") : "no trail")}, {(((Object)(object)item2 != (Object)null) ? "Ps_SparksLoop" : "no sparks")}{(flag ? (", tinted " + colours.Name) : "")}."); } return val; } private static (GameObject? Trail, GameObject? Sparks) Template(ElementType element) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Expected I4, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) int num = (int)element; if (Templates.TryGetValue(num, out (GameObject, GameObject) value)) { return value; } (GameObject, GameObject) tuple = (null, null); try { SpellData spellData = CharacterInfoDisplay.GetSpellData((SpellType)24); SpellConfiguration val = ((spellData != null) ? spellData.Configuration : null); SpellPrefabContainer val2 = (((Object)(object)val != (Object)null) ? val.PrefabContainer : null); if (val2 != null) { bool flag = num == 0 || ElementLook.Split(num).HasValue; GameObject val3 = null; try { val3 = val2.GetPrefab((ElementType)(flag ? ((int)element) : 0)); } catch (Exception) { } if (val3 == null) { val3 = val2.DefaultPrefab; } if ((Object)(object)val3 != (Object)null) { tuple = (Find(val3.transform, "Trail"), Find(val3.transform, "Ps_SparksLoop")); } } } catch (Exception ex2) { ModLog.WarnOnce("bt-trail-src", "Borrowed Time: the Sawblade's trail isn't reachable (" + ex2.Message + "); the cog flies without one."); } Templates[num] = tuple; return tuple; } public static GameObject? CogSparks(Transform parent, ElementType element, ElementColors colours, float radius, bool mirrored = false) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected I4, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) GameObject item = Template(element).Sparks; if ((Object)(object)item == (Object)null) { return null; } try { GameObject val = Object.Instantiate<GameObject>(item, parent, false); ((Object)val).name = "Sparks"; val.transform.localPosition = Vector3.zero; Strip(val); val.transform.localScale = new Vector3(mirrored ? (-1f) : 1f, 1f, 1f); foreach (ParticleSystem componentsInChild in val.GetComponentsInChildren<ParticleSystem>(true)) { componentsInChild.main.simulationSpace = (ParticleSystemSimulationSpace)0; } FitSparks(val, radius, item.transform.lossyScale.x); if (!ElementLook.Split((int)element).HasValue && (int)element != 0 && !colours.IsGold) { foreach (ParticleSystemRenderer componentsInChild2 in val.GetComponentsInChildren<ParticleSystemRenderer>(true)) { Tint((Renderer)(object)componentsInChild2, colours.Spark); } } return val; } catch (Exception ex) { ModLog.ErrorThrottled("bt-sparks", ex, Time.unscaledTime, 30f); return null; } } public static void FollowSpin(GameObject? s, Transform? spin) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)s == (Object)null) && !((Object)(object)spin == (Object)null)) { s.transform.rotation = spin.rotation; } } private static void Scale(ParticleSystem ps, float size, float speed) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Invalid comparison between Unknown and I4 //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Invalid comparison between Unknown and I4 MainModule main = ps.main; if (!SparkVanilla.TryGetValue(((Il2CppObjectBase)ps).Pointer, out (float, float, float, float) value)) { MinMaxCurve startSize = main.startSize; MinMaxCurve startSpeed = main.startSpeed; value = (((int)startSize.mode == 3) ? (startSize.constantMin, startSize.constantMax, 0f, 0f) : (startSize.constant, startSize.constant, 0f, 0f)); value = (((int)startSpeed.mode == 3) ? (value.Item1, value.Item2, startSpeed.constantMin, startSpeed.constantMax) : (value.Item1, value.Item2, startSpeed.constant, startSpeed.constant)); SparkVanilla[((Il2CppObjectBase)ps).Pointer] = value; } MinMaxCurve startSize2 = main.startSize; startSize2.mode = (ParticleSystemCurveMode)3; startSize2.constantMin = value.Item1 * size; startSize2.constantMax = value.Item2 * size; main.startSize = startSize2; MinMaxCurve startSpeed2 = main.startSpeed; startSpeed2.mode = (ParticleSystemCurveMode)3; startSpeed2.constantMin = value.Item3 * speed; startSpeed2.constantMax = value.Item4 * speed; main.startSpeed = startSpeed2; } public static void FitSparks(GameObject s, float radius, float vanillaScale = -1f) { //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)s == (Object)null) { return; } if (vanillaScale > 0f) { SparkVanillaScale[((Il2CppObjectBase)s).Pointer] = vanillaScale; } else if (!SparkVanillaScale.TryGetValue(((Il2CppObjectBase)s).Pointer, out vanillaScale)) { vanillaScale = 1.084f; } Transform parent = s.transform.parent; float num = (((Object)(object)parent != (Object)null) ? Mathf.Max(0.0001f, parent.lossyScale.x) : 1f); float num2 = ((s.transform.localScale.x < 0f) ? (-1f) : 1f); s.transform.localScale = new Vector3(num2, 1f, 1f) / num; float num3 = radius / 0.98f; foreach (ParticleSystem componentsInChild in s.GetComponentsInChildren<ParticleSystem>(true)) { MainModule main = componentsInChild.main; Scale(componentsInChild, vanillaScale * num3 * 0.5f, num3); if (_fitLogged++ < 6) { ModLog.Info(FormattableString.Invariant($"Borrowed Time: sparks '{((Object)((Component)componentsInChild).gameObject).name}' fitted to a {radius:0.##} m cog: size {main.startSize.constantMin:0.###}-{main.startSize.constantMax:0.###} m, speed {main.startSpeed.constantMin:0.###}-{main.startSpeed.constantMax:0.###} m/s, world scale {((Component)componentsInChild).transform.lossyScale.x:0.###}.")); } componentsInChild.shape.radius = radius; componentsInChild.emission.rateOverTimeMultiplier = 10f; try { componentsInChild.noise.strengthMultiplier = num3; } catch (Exception) { } } } public static bool SparkBurst(Vector3 at, ElementType element, int count, float radius = 0.5f) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Expected I4, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) try { int num = (int)element; if (!SparkTemplates.TryGetValue(num, out GameObject value)) { SpellData spellData = CharacterInfoDisplay.GetSpellData((SpellType)24); object obj; if (spellData == null) { obj = null; } else { SpellConfiguration configuration = spellData.Configuration; obj = ((configuration != null) ? configuration.PrefabContainer : null); } SpellPrefabContainer val = (SpellPrefabContainer)obj; bool flag = num == 0 || ElementLook.Split(num).HasValue; GameObject val2 = null; try { val2 = ((val != null) ? val.GetPrefab((ElementType)(flag ? ((int)element) : 0)) : null); } catch (Exception) { } if (val2 == null) { val2 = ((val != null) ? val.DefaultPrefab : null); } value = (((Object)(object)val2 != (Object)null) ? Find(val2.transform, "Ps_DespawnEffect") : null); SparkTemplates[num] = value; } if ((Object)(object)value == (Object)null) { return false; } GameObject val3 = Object.Instantiate<GameObject>(value); ((Object)val3).name = "HourglassMage_PopSparks"; val3.transform.position = at; val3.transform.localScale = Vector3.one; Strip(val3); float num2 = radius / 0.98f; foreach (ParticleSystem componentsInChild in val3.GetComponentsInChildren<ParticleSystem>(true)) { Scale(componentsInChild, num2 * 0.5f, num2); componentsInChild.shape.radius = 0.2f * num2; componentsInChild.Play(); componentsInChild.Emit(count); } Object.Destroy((Object)(object)val3, 1.5f); return true; } catch (Exception ex2) { ModLog.ErrorThrottled("bt-popsparks", ex2, Time.unscaledTime, 60f); return false; } } private static GameObject? Find(Transform t, string name) { if (((Object)t).name == name) { return ((Component)t).gameObject; } for (int i = 0; i < t.childCount; i++) { GameObject val = Find(t.GetChild(i), name); if ((Object)(object)val != (Object)null) { return val; } } return null; } private static void Strip(GameObject go) { foreach (MonoBehaviour componentsInChild in go.GetComponentsInChildren<MonoBehaviour>(true)) { if ((Object)(object)componentsInChild != (Object)null) { Object.Destroy((Object)(object)componentsInChild); } } } private static void Soften(TrailRenderer tr, ElementColors colours) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) Material sharedMaterial = ((Renderer)tr).sharedMaterial; Texture2D tex = null; if ((Object)(object)sharedMaterial != (Object)null && sharedMaterial.HasProperty(Props.Id("_MainTex"))) { Texture texture = sharedMaterial.GetTexture(Props.Id("_MainTex")); tex = ((texture != null) ? ((Il2CppObjectBase)texture).TryCast<Texture2D>() : null); } Rgb rgb = colours.Trail.Normalized(); Material val = Fx.TexturedMaterial("HourglassMage_SoftTrail", tex, new Color(rgb.R, rgb.G, rgb.B, 0.5f)); if (!((Object)(object)val == (Object)null)) { ((Renderer)tr).material = val; tr.startWidth = 0.8f * SpellConfig.BoltSize.Value; } } private static void Tint(Renderer r, Rgb c) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) Material sharedMaterial = r.sharedMaterial; if ((Object)(object)sharedMaterial == (Object)null) { return; } (int, float, float, float) key = (((Object)sharedMaterial).GetInstanceID(), c.R, c.G, c.B); if (Tinted.TryGetValue(key, out Material value) && (Object)(object)value != (Object)null) { r.sharedMaterial = value; return; } Material val = new Material(sharedMaterial) { name = ((Object)sharedMaterial).name + "_HourglassMage" }; ((Object)val).hideFlags = (HideFlags)61; Rgb rgb = c.Normalized(); string[] tintColours = TintColours; foreach (string name in tintColours) { if (val.HasProperty(Props.Id(name))) { Color color = val.GetColor(Props.Id(name)); float num = Mathf.Max(color.r, Mathf.Max(color.g, color.b)); val.SetColor(Props.Id(name), new Color(rgb.R * num, rgb.G * num, rgb.B * num, color.a)); } } tintColours = TintEmission; foreach (string name2 in tintColours) { if (val.HasProperty(Props.Id(name2))) { Color color2 = val.GetColor(Props.Id(name2)); float num2 = Mathf.Max(color2.r, Mathf.Max(color2.g, color2.b)); val.SetColor(Props.Id(name2), new Color(rgb.R * num2, rgb.G * num2, rgb.B * num2, color2.a)); } } Tinted[key] = val; r.sharedMaterial = val; } } internal static class BorrowedTime { public static SpellType? InitialSpell { get { //IL_0011: Unknown result type (might be due to invalid IL or missing references) if (!Horatios.Active) { return null; } return Horatios.Host; } } public static void Init(ConfigFile cfg, Harmony harmony) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) SpellConfig.Init(cfg); Horatios.Init(); if (!Horatios.Active) { ModLog.Info("Borrowed Time is off in the config; Horatio keeps Eugenie's spell."); return; } DamageHook.Install(harmony); AllyHitHook.Install(harmony); DamagePopupSync.Install(harmony); ProcSync.Install(harmony); StructureRegistry.Install(harmony); DotGuard.Install(harmony); CogHitGuard.Install(harmony); VariantDetailsGuard.Install(harmony); SpellUi.Install(harmony); SpellIconHook.Install(harmony); EndScreenHook.Install(harmony); ProjectileLook.Install(harmony); ModLog.Info($"Borrowed Time ready: built on {Horatios.Host}; clocks {(DamageHook.Installed ? "on" : "OFF (damage hook refused)")}."); } } public class BorrowedTimeRunner : MonoBehaviour { public BorrowedTimeRunner(IntPtr ptr) : base(ptr) { } public void Update() { float realtimeSinceStartup = Time.realtimeSinceStartup; float time = Time.time; RunnerSteps.Real = realtimeSinceStartup; RunnerSteps.Now = time; Run("bt-horatios", RunnerSteps.BtHoratios, realtimeSinceStartup); Run("bt-ui", RunnerSteps.BtUi, realtimeSinceStartup); Run("bt-icons", RunnerSteps.BtIcons, realtimeSinceStartup); Run("bt-wounds", RunnerSteps.BtWounds, realtimeSinceStartup); Run("bt-allywounds", RunnerSteps.BtAllyWounds, realtimeSinceStartup); Run("bt-bursts", RunnerSteps.BtBursts, realtimeSinceStartup); Run("bt-popping", RunnerSteps.BtPopping, realtimeSinceStartup); Run("bt-gears", RunnerSteps.BtGears, realtimeSinceStartup); Run("bt-selftest", RunnerSteps.BtSelfTest, realtimeSinceStartup); Run("bt-upgrades", RunnerSteps.BtUpgrades, realtimeSinceStartup); Run("bt-cogsync", RunnerSteps.BtCogSync, realtimeSinceStartup); BannerSwitch.Sync(); } public void LateUpdate() { float realtimeSinceStartup = Time.realtimeSinceStartup; Run("bt-cogs", RunnerSteps.BtCogs, realtimeSinceStartup); Run("bt-allywounds-late", RunnerSteps.BtAllyLate, realtimeSinceStartup); Run("bt-cogsync-late", RunnerSteps.BtCogSyncLate, realtimeSinceStartup); Run("bt-hitsound", RunnerSteps.BtHitSound, realtimeSinceStartup); Run("bt-procs", RunnerSteps.BtProcs, realtimeSinceStartup); } private static void Run(string key, Action a, float real) { try { a(); } catch (Exception ex) { ModLog.ErrorThrottled(key, ex, real); } } } public class BannerGui : MonoBehaviour { public BannerGui(IntPtr ptr) : base(ptr) { } public void OnGUI() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) string banner = WoundUpgrades.Banner; if (banner.Length != 0) { GUI.Label(new Rect((float)Screen.width / 2f - 400f, 40f, 800f, 30f), banner); } } } internal static class BannerSwitch { private static BannerGui? _gui; private static bool _on; public static void Attach(BannerGui gui) { _gui = gui; _on = false; ((Behaviour)gui).enabled = false; } public static void Sync() { bool flag = WoundUpgrades.Banner.Length > 0; if (flag != _on && !((Object)(object)_gui == (Object)null)) { _on = flag; ((Behaviour)_gui).enabled = flag; } } } internal static class BurstFx { private sealed class Burst { public GameObject Root; public Transform Ring; public Transform Ring2; public Transform Flash; public Material? RingMat; public Material? FlashMat; public ParticleSystem Sand; public Vector3 Pos; public float Radius; public float Start; public bool Strong; public bool RingIsQuad; public Color RingTint; public Color RingGlow; public Color FlashTint; public Color FlashGlow; public bool Busy; } private const float Life = 0.35f; private const float FlashHot = 0.1f; private const float FlashFade = 0.35f; private const float End = 0.45f; private const float RingBoost = 3f; private static readonly List<Burst> Pool = new List<Burst>(); private static GameObject? _holder; private static readonly Color RingTint = new Color(1f, 0.78f, 0.25f, 1f); private static readonly Color RingGlow = new Color(3.5f, 2.5f, 0.2f, 1f); private static readonly Color FlashTint = new Color(1f, 0.86f, 0.45f, 1f); private static readonly Color FlashGlow = new Color(3f, 2.3f, 0.5f, 1f); private static Mesh? _ringMesh; public static void Play(Vector3 pos, float radius, bool strong, ElementColors? look = null, bool sparks = true) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Expected O, but got Unknown //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Expected O, but got Unknown //IL_0257: Unknown result type (might be due to invalid IL or missing references) if (SpellConfig.Intensity.Value <= 0f) { return; } try { Burst burst = null; foreach (Burst item in Pool) { if (!item.Busy && (Object)(object)item.Root != (Object)null) { burst = item; break; } } if (burst == null) { burst = New(); } if (burst != null) { burst.Busy = true; burst.Pos = pos; burst.Radius = Mathf.Max(0.8f, radius); burst.Start = Time.time; burst.Strong = strong; if ((object)look == null) { look = ElementLook.Gold; } if (look.IsGold) { Burst burst2 = burst; Burst burst3 = burst; Burst burst4 = burst; Burst burst5 = burst; Color ringTint = RingTint; Color ringGlow = RingGlow * 3f; Color flashTint = FlashTint; Color flashGlow = FlashGlow; burst2.RingTint = ringTint; burst3.RingGlow = ringGlow; burst4.FlashTint = flashTint; burst5.FlashGlow = flashGlow; } else { Rgb c = look.Base; burst.RingTint = ElementColorsGame.ToColor(c); burst.RingGlow = ElementColorsGame.ToColor(look.Core1.Normalized(10.5f)); burst.FlashTint = ElementColorsGame.ToColor(c.Lerp(new Rgb(1f, 1f, 1f), 0.4f)); burst.FlashGlow = ElementColorsGame.ToColor(look.Core1.Normalized(3f)); } Color val = (Color)(look.IsGold ? new Color(1.5f, 1.15f, 0.4f, 1f) : ElementColorsGame.ToColor(look.Spark.Normalized(1.5f))); burst.Root.transform.position = pos + Vector3.up * 0.12f; burst.Root.SetActive(true); MainModule main = burst.Sand.main; main.startSpeed = new MinMaxCurve(strong ? 3.2f : 1.6f); main.startColor = new MinMaxGradient(val); ((Component)burst.Sand).transform.localPosition = new Vector3(0f, 0.6f, 0f); if (!burst.Sand.isPlaying) { burst.Sand.Play(); } if (sparks) { burst.Sand.Emit(14); } Update(burst, Time.time); } } catch (Exception ex) { ModLog.ErrorThrottled("bt-burstfx", ex, Time.unscaledTime, 30f); } } public static void Tick(float now) { foreach (Burst item in Pool) { if (item.Busy && (Object)(object)item.Root != (Object)null) { Update(item, now); } } } private static void Update(Burst b, float now) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) float num = now - b.Start; float num2 = num / 0.35f; if (num >= 0.45f) { if (b.Sand.particleCount == 0 || num2 > 3f) { b.Busy = false; b.Root.SetActive(false); } b.Ring.localScale = Vector3.zero; b.Ring2.localScale = Vector3.zero; b.Flash.localScale = Vector3.zero; return; } float num3 = SpellConfig.Intensity.Value * (b.Strong ? 1f : 0.5f); float num4; float num5; if (num2 < 1f) { (num4, num5) = WoundMath.Ring(num); } else { num4 = 0f; num5 = 0f; } float num6 = (b.RingIsQuad ? (num4 * 2f) : num4); b.Ring.localScale = new Vector3(num6, num6, 1f); float num7 = num6 * 0.93f; b.Ring2.localScale = new Vector3(num7, num7, 1f); float num8 = num5 * num3; float num9 = ((num < 0.1f) ? 1f : 0f); float num10 = Mathf.Clamp01((num - 0.1f) / 0.35f); float num11 = b.Radius * (0.6f + 0.6f * Mathf.Clamp01(num / 0.45f)); b.Flash.localScale = new Vector3(num11, num11, 1f); float num12 = (1f - num10) * num3; Color val = Color.Lerp(b.FlashTint, Color.white, num9); Color glow = ((num9 > 0f) ? WhiteHot(b.FlashGlow) : b.FlashGlow); if (GameVfx.Available) { GameVfx.SetGlow(b.RingMat, b.RingTint, b.RingGlow, num8); GameVfx.SetGlow(b.FlashMat, val, glow, num12 * 0.8f); } else { Fx.SetColor(b.RingMat, new Color(b.RingTint.r, b.RingTint.g, b.RingTint.b, num8)); Fx.SetColor(b.FlashMat, new Color(val.r, val.g, val.b, num12 * 0.6f)); } } private static Color WhiteHot(Color glow) { //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) //IL_000c: 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) float num = Mathf.Max(glow.r, Mathf.Max(glow.g, glow.b)); return new Color(num, num, num, 1f); } private static Burst? New() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) if (Pool.Count >= 24) { return null; } if ((Object)(object)_holder == (Object)null) { _holder = new GameObject("HourglassMage_BorrowedTimeBursts"); Object.DontDestroyOnLoad((Object)(object)_holder); } Burst burst = new Burst { Root = new GameObject("Burst") }; burst.Root.transform.SetParent(_holder.transform, false); bool available = GameVfx.Available; Texture val = (Texture)(object)(GameVfx.Texture("ps_circle_soft") ?? TextureFiles.Texture("Grain.png", mipmaps: true, (TextureWrapMode)1)); Texture val2 = (Texture)(object)(GameVfx.Texture("ps_circle_soft_outline") ?? GameVfx.Texture("ps_circle_soft")); burst.RingMat = ((available && (Object)(object)val2 != (Object)null) ? GameVfx.Glow("BT_BurstRing", val2, RingTint, RingGlow, 3105) : null); Burst burst2 = burst; if (burst2.RingMat == null) { burst2.RingMat = Fx.TexturedMaterial("HourglassMage_BT_BurstRing", (Texture2D?)(object)((val2 is Texture2D) ? val2 : null), Color.white, 3105); } burst.FlashMat = (available ? GameVfx.Glow("BT_BurstFlash", val, FlashTint, FlashGlow, 3104) : null); burst2 = burst; if (burst2.FlashMat == null) { burst2.FlashMat = Fx.TexturedMaterial("HourglassMage_BT_BurstFlash", (Texture2D?)(object)((val is Texture2D) ? val : null), Color.white, 3104); } if ((Object)(object)val2 != (Object)null) { burst.Ring = Flat("Ring", burst.Root.transform, burst.RingMat); burst.Ring2 = Flat("Ring2", burst.Root.transform, burst.RingMat); } else { if (_ringMesh == null) { _ringMesh = RingMesh(); } burst.Ring = MeshBuild.Part(burst.Root.transform, "Ring", _ringMesh, burst.RingMat, Vector3.zero); burst.Ring.localRotation = Quaternion.Euler(90f, 0f, 0f); burst.Ring2 = MeshBuild.Part(burst.Root.transform, "Ring2", _ringMesh, burst.RingMat, Vector3.zero); burst.Ring2.localRotation = Quaternion.Euler(90f, 0f, 0f); } burst.RingIsQuad = (Object)(object)val2 != (Object)null; burst.Flash = Flat("Flash", burst.Root.transform, burst.FlashMat); burst.Sand = Fx.Sand(burst.Root.transform, "Sand", 0.3f, 0f, 0.9f, 0.16f, new Color(1.5f, 1.15f, 0.4f, 1f), (ParticleSystemShapeType)0, 0.8f, 3f); burst.Sand.emission.rateOverTime = MinMaxCurve.op_Implicit(0f); burst.Sand.Play(); Pool.Add(burst); return burst; } private static Mesh RingMesh() { Mesh obj = MeshBuild.New("HourglassMage_BT_BurstRing"); MeshBuild.Swirl(obj, Solids.Swirl(0.94f, 1f, 1f, 0f, 64, 1)); return obj; } private static Transform Flat(string name, Transform parent, Material? m) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) GameObject obj = Fx.Primitive((PrimitiveType)5, name, parent, m); obj.transform.localRotation = Quaternion.Euler(90f, 0f, 0f); return obj.transform; } public static void Clear() { foreach (Burst item in Pool) { if (!((Object)(object)item.Root == (Object)null)) { item.Busy = false; item.Root.SetActive(false); } } } } internal static class CogGuard { private static readonly List<(WeakReference<CogVisual> Cog, string Tag)> Cogs = new List<(WeakReference<CogVisual>, string)>(); private static int _logged; private static int _sweep; public static int Hits { get; private set; } public static void Register(CogVisual cog, string tag) { Cogs.Add((new WeakReference<CogVisual>(cog), tag)); if (Cogs.Count > 2048) { Cogs.RemoveAll(((WeakReference<CogVisual> Cog, string Tag) c) => !c.Cog.TryGetTarget(out CogVisual target) || (Object)(object)target.Root == (Object)null || ((Il2CppObjectBase)target.Root).WasCollected); } } public static void LateCheck() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) Camera main = Camera.main; if ((Object)(object)main == (Object)null) { return; } Vector3 position = ((Component)main).transform.position; if (++_sweep % 300 == 0) { Cogs.RemoveAll(((WeakReference<CogVisual> Cog, string Tag) c) => !c.Cog.TryGetTarget(out CogVisual target2) || (Object)(object)target2.Root == (Object)null || ((Il2CppObjectBase)target2.Root).WasCollected); } foreach (var (weakReference, text) in Cogs) { if (!weakReference.TryGetTarget(out var target) || (Object)(object)target.Root == (Object)null || ((Il2CppObjectBase)target.Root).WasCollected || !((Component)target.Root).gameObject.activeInHierarchy) { continue; } Renderer bodyRenderer = target.BodyRenderer; if ((Object)(object)bodyRenderer == (Object)null || ((Il2CppObjectBase)bodyRenderer).WasCollected || !bodyRenderer.enabled) { continue; } Bounds bounds = bodyRenderer.bounds; float num = Mathf.Max(((Bounds)(ref bounds)).size.x, ((Bounds)(ref bounds)).size.z); float num2 = Vector3.Distance(position, ((Bounds)(ref bounds)).center); if (GearScale.Suspicious(num, num2)) { Hits++; if (_logged++ < 20) { ModLog.Warn(FormattableString.Invariant($"Cog guard: '{Path(target.Root)}' ({text}) is {num:0.##} m wide, {num2:0.##} m from the camera (world scale {target.Root.lossyScale.x:0.###}, parent {(((Object)(object)target.Root.parent != (Object)null) ? target.Root.parent.lossyScale.x : 1f):0.###}); shrunk to 6 m if wider.")); } if (num > 6f && !float.IsNaN(num)) { Transform root = target.Root; root.localScale *= 6f / num; } } } } private static string Path(Transform t) { string text = ((Object)t).name; for (int i = 0; i < 4; i++) { if (!((Object)(object)t.parent != (Object)null)) { break; } t = t.parent; text = ((Object)t).name + "/" + text; } return text; } } internal static class CogHitGuard { private static int _depth; private static int _bounce; public static bool Active => _depth > 0; public static bool Bounce => _bounce > 0; public static void Install(Harmony harmony) { //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_00dd: Expected O, but got Unknown InstallBounce(harmony); try { MethodInfo method = typeof(CorruptedEnemyAttacker).GetMethod("DealDamageToNotCorruptedEnemiesInRange", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null); string why; if (method == null) { ModLog.Info("Borrowed Time: CorruptedEnemyAttacker.DealDamageToNotCorruptedEnemiesInRange isn't in this game version; the element check alone keeps its hits from sticking cogs."); } else if (!NativeCode.CanPatch(method, "CorruptedEnemyAttacker.DealDamageToNotCorruptedEnemiesInRange", out why)) { ModLog.Info($"Borrowed Time: {"CorruptedEnemyAttacker.DealDamageToNotCorruptedEnemiesInRange"} can't be patched ({why}); the element check alone keeps its hits from sticking cogs."); } else { harmony.Patch((MethodBase)method, new HarmonyMethod(AccessTools.Method(typeof(CogHitGuard), "Enter", (Type[])null, (Type[])null)), new HarmonyMethod(AccessTools.Method(typeof(CogHitGuard), "Leave", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ModLog.Step($"Borrowed Time: {"CorruptedEnemyAttacker.DealDamageToNotCorruptedEnemiesInRange"} marked as no cog hit ({why})"); } } catch (Exception ex) { ModLog.Info($"Borrowed Time: couldn't mark {"CorruptedEnemyAttacker.DealDamageToNotCorruptedEnemiesInRange"} ({ex.Message}); the element check alone keeps its hits from sticking cogs."); } } private static void InstallBounce(Harmony harmony) { //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Expected O, but got Unknown //IL_0117: Expected O, but got Unknown try { Type type = null; Type[] nestedTypes = typeof(ElectricityDistributor).GetNestedTypes(BindingFlags.Public | BindingFlags.NonPublic); foreach (Type type2 in nestedTypes) { if (type2.Name.Contains("PerformRicochets")) { type = type2; } } MethodInfo methodInfo = type?.GetMethod("MoveNext", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null); string why; if (methodInfo == null) { ModLog.Info("Borrowed Time: no ElectricityDistributor ricochet coroutine in this game version; Lightning bounces may stick cogs."); } else if (!NativeCode.CanPatch(methodInfo, "ElectricityDistributor ricochet coroutine", out why)) { ModLog.Info($"Borrowed Time: {"ElectricityDistributor ricochet coroutine"} can't be patched ({why}); Lightning bounces may stick cogs."); } else { harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(AccessTools.Method(typeof(CogHitGuard), "EnterBounce", (Type[])null, (Type[])null)), new HarmonyMethod(AccessTools.Method(typeof(CogHitGuard), "LeaveBounce", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ModLog.Step($"Borrowed Time: {"ElectricityDistributor ricochet coroutine"} marked as Lightning bounces ({why})"); } } catch (Exception ex) { ModLog.Info($"Borrowed Time: couldn't mark the {"ElectricityDistributor ricochet coroutine"} ({ex.Message}); Lightning bounces may stick cogs."); } } private static void EnterBounce() { _bounce++; } private static void LeaveBounce() { if (_bounce > 0) { _bounce--; } } private static void Enter() { _depth++; } private static void Leave() { if (_depth > 0) { _depth--; } } public static void EndFrame() { _depth = 0; _bounce = 0; } } internal static class CogSync { private const string HelloName = "SpellBrigadeHourglassMage.CogHello"; private const string StateName = "SpellBrigadeHourglassMage.CogState"; private const string AllyHitName = "SpellBrigadeHourglassMage.AllyHit"; private const string AllyStrikeName = "SpellBrigadeHourglassMage.AllyStrike"; private const int UnreliableMax = 1100; private const float CheckEvery = 0.1f; private const float GoneAfter = 0.75f; private static IntPtr _registeredPtr = IntPtr.Zero; private static bool _helloSent; private static readonly HashSet<ulong> ModClients = new HashSet<ulong>(); private static readonly List<CogEvent> Pending = new List<CogEvent>(); private static readonly List<CogEvent> PendingTicks = new List<CogEvent>(); private static readonly List<CogEvent> State = new List<CogEvent>(); private static readonly CogSnapshotGate Gate = new CogSnapshotGate(); private static float _nextCheck; private static float _nextTicks; private const float TicksEvery = 0.1f; private static int _loggedSends; private static int _loggedReceives; private static long _bytes; private static long _messages; private static float _bytesSince = -1f; private static readonly CogRegistry<StuckCog> Cogs = new CogRegistry<StuckCog> { PopGuard = 1f }; private static readonly NetIdIndex<NetworkBehaviour> ById = new NetIdIndex<NetworkBehaviour>(); private static readonly Dictionary<ulong, float> MissingSince = new Dictionary<ulong, float>(); private static readonly Dictionary<ulong, float> Shown = new Dictionary<ulong, float>(); private static int _indexFrame = -1; private const float IndexEvery = 0.25f; private static float _indexAt = -10f; public static bool IsClient { get; private set; } private static CogSyncMode Mode => SpellConfig.CogSyncModeSetting?.Value ?? CogSyncMode.Delta; public static bool HasClients => ModClients.Count > 0; public static ulong NetId(NetworkBehaviour b) { NetworkObject networkObject = b.NetworkObject; if (!((Object)(object)networkObject != (Object)null)) { return b.NetworkObjectId; } return networkObject.NetworkObjectId; } public static void HostStick(Enemy? enemy, ElementType element, Vector3 at) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)enemy == (Object)null)) { HostStickAt(NetId((NetworkBehaviour)(object)enemy), element, at); } } public static void HostStickAt(ulong id, ElementType element, Vector3 at) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) if (ModClients.Count != 0) { Pending.Add(new CogEvent { Kind = CogEventKind.Stick, Enemy = id, Element = (ushort)element, X = at.x, Y = at.y, Z = at.z }); Gate.Announce(id, 0); } } public static void HostPop(Enemy? enemy, ElementType element, Vector3 at, float radius, bool paid, bool shake) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) HostPopAt(((Object)(object)enemy != (Object)null) ? NetId((NetworkBehaviour)(object)enemy) : ulong.MaxValue, element, at, radius, paid, shake); } public static void HostPopAt(ulong id, ElementType element, Vector3 at, float radius, bool paid, bool shake) { //IL_002c: Unknown result type (