Due to update 2.4.3, some mods may no longer function. FixedConfig may be necessary.
Decompiled source of Sandevistan v1.1.0
Sandevistan.dll
Decompiled 2 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using BoplFixedMath; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Events; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Sandevistan")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Sandevistan")] [assembly: AssemblyTitle("Sandevistan")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace SandevistanMod { [BepInPlugin("com.workshop.sandevistan", "Sandevistan", "1.1.0")] public class Plugin : BaseUnityPlugin { public const string Guid = "com.workshop.sandevistan"; public const string AbilityName = "Sandevistan"; internal static ManualLogSource Log; internal static string PluginDir; internal static ConfigEntry<float> CleanSeconds; internal static ConfigEntry<float> MaxTacSeconds; internal static ConfigEntry<float> OwnerSpeed; internal static ConfigEntry<float> OthersSpeed; internal static ConfigEntry<float> CooldownSeconds; internal static ConfigEntry<float> PulseGapMin; internal static ConfigEntry<float> PulseGapMax; internal static ConfigEntry<bool> SlowWorld; private void Awake() { //IL_014b: 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_0156: Expected O, but got Unknown //IL_015b: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; PluginDir = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); CleanSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Tuning", "PsychosisAfterSeconds", 15f, "Seconds of stable Sandevistan before cyberpsychosis starts."); MaxTacSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Tuning", "MaxTacAfterSeconds", 30f, "Seconds after activation when MaxTac arrives and kills you. 0 = never."); OwnerSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Tuning", "YourSpeed", 1.7f, "Your movement speed multiplier."); OthersSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Tuning", "OthersTimeScale", 0.12f, "Everyone and everything that is not yours runs at this fraction of normal speed (players, projectiles, items, debris)."); CooldownSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Tuning", "CooldownSeconds", 15f, "Ability cooldown in seconds. The ability starts every round on this cooldown, and it is also applied if you survive MaxTac (extra life)."); PulseGapMin = ((BaseUnityPlugin)this).Config.Bind<float>("Psychosis", "PulseGapMin", 0.6f, "Shortest gap between random ability presses at the start of psychosis (seconds)."); PulseGapMax = ((BaseUnityPlugin)this).Config.Bind<float>("Psychosis", "PulseGapMax", 1.8f, "Longest gap between random ability presses at the start of psychosis (seconds)."); SlowWorld = ((BaseUnityPlugin)this).Config.Bind<bool>("Tuning", "SlowWorld", true, "Slow time and gravity for every body that is not yours (projectiles, items, debris, other players' gravity) by the OthersSpeed factor."); InputForce.Scan(); SandevistanAbility.Register(); Harmony val = new Harmony("com.workshop.sandevistan"); PatchAll(val); LogicSlow.Apply(val); SceneManager.sceneLoaded += delegate { AbilityRegistry.EnsureRegistered(); }; AbilityRegistry.EnsureRegistered(); Log.LogInfo((object)"Sandevistan 1.1.0 loaded (player time-dilation build)."); } private static void PatchAll(Harmony harmony) { foreach (Type item in from x in typeof(Plugin).Assembly.GetTypes() where x.GetCustomAttributes(typeof(HarmonyPatch), inherit: false).Any() select x) { try { harmony.CreateClassProcessor(item).Patch(); } catch (Exception ex) { Log.LogError((object)("Patch failed for " + item.Name + ": " + ex.Message)); } } } } internal sealed class FieldRef<T, F> { private readonly FieldInfo field; public FieldRef(string name) { field = AccessTools.Field(typeof(T), name); if (field == null) { throw new MissingFieldException(typeof(T).Name, name); } } public F Invoke(T instance) { return (F)field.GetValue(instance); } } internal static class Tuning { public static readonly Fix MaxTacArrival = (Fix)3.2; public static readonly Fix LockedCooldown = (Fix)10000L; public static Fix Clean => F(Plugin.CleanSeconds.Value); public static bool MaxTacEnabled => Plugin.MaxTacSeconds.Value > 0f; public static Fix MaxTacAt => F(Plugin.MaxTacSeconds.Value); public static Fix OwnerSpeed => F(Plugin.OwnerSpeed.Value); public static Fix OthersSpeed => F(Plugin.OthersSpeed.Value); public static Fix Cooldown => F(Plugin.CooldownSeconds.Value); internal static Fix F(float v) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return (Fix)(double)v; } } internal sealed class CustomAbility { public string Name; public string IconFile; public Color PlaceholderColor = Color.white; public Func<NamedSprite, bool> IsTemplate; public Action<GameObject, NamedSprite> Setup; public GameObject Prefab; public Sprite Icon; public bool IsOffensive; internal string TemplateName; internal GameObject TemplateSource; internal bool BuildFailed; } internal static class AbilityRegistry { private static readonly List<CustomAbility> abilities = new List<CustomAbility>(); private static GameObject templateHolder; public static void Add(CustomAbility ability) { abilities.Add(ability); } public static bool IsOurs(string enText) { if (enText != null) { return abilities.Any((CustomAbility a) => string.Equals(a.Name, enText, StringComparison.OrdinalIgnoreCase)); } return false; } public static void EnsureRegistered() { //IL_0135: Unknown result type (might be due to invalid IL or missing references) NamedSpriteList[] array; try { array = Resources.FindObjectsOfTypeAll<NamedSpriteList>(); } catch (Exception ex) { Plugin.Log.LogError((object)("Ability lists not found: " + ex)); return; } if (array == null || array.Length == 0) { return; } foreach (CustomAbility ability in abilities) { if ((Object)(object)ability.Prefab == (Object)null && !ability.BuildFailed) { TryBuild(ability, array); } } NamedSpriteList[] array2 = array; foreach (NamedSpriteList val in array2) { if ((Object)(object)val == (Object)null || val.sprites == null || ((Object)val).name.IndexOf("demo", StringComparison.OrdinalIgnoreCase) >= 0) { continue; } foreach (CustomAbility ability2 in abilities) { if ((Object)(object)ability2.Prefab != (Object)null && val.IndexOf(ability2.Name) < 0 && ContainsTemplate(val, ability2)) { val.sprites.Add(new NamedSprite(ability2.Name, ability2.Icon, ability2.Prefab, ability2.IsOffensive)); Plugin.Log.LogInfo((object)("'" + ability2.Name + "' added to list '" + ((Object)val).name + "' (index " + (val.sprites.Count - 1) + ").")); } } } } private static bool ContainsTemplate(NamedSpriteList list, CustomAbility ability) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) foreach (NamedSprite sprite in list.sprites) { if (sprite.name == ability.TemplateName) { return true; } if ((Object)(object)ability.TemplateSource != (Object)null && (Object)(object)sprite.associatedGameObject == (Object)(object)ability.TemplateSource) { return true; } } return false; } private static void TryBuild(CustomAbility ability, NamedSpriteList[] lists) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) foreach (NamedSpriteList val in lists) { if ((Object)(object)val == (Object)null || val.sprites == null) { continue; } foreach (NamedSprite sprite in val.sprites) { if (!((Object)(object)sprite.associatedGameObject == (Object)null) && ability.IsTemplate(sprite)) { try { Build(ability, sprite); return; } catch (Exception ex) { ability.BuildFailed = true; Plugin.Log.LogError((object)("'" + ability.Name + "' build failed:\n" + ex)); return; } } } } } private static void Build(CustomAbility ability, NamedSprite source) { //IL_0031: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if ((Object)(object)templateHolder == (Object)null) { templateHolder = new GameObject("SandevistanMod_Templates"); templateHolder.SetActive(false); Object.DontDestroyOnLoad((Object)(object)templateHolder); } GameObject val = Object.Instantiate<GameObject>(source.associatedGameObject, templateHolder.transform); ((Object)val).name = ability.Name; ability.Setup(val, source); ability.TemplateName = source.name; ability.TemplateSource = source.associatedGameObject; ability.IsOffensive = source.isOffensiveAbility; ability.Icon = IconLoader.LoadOrPlaceholder(ability.IconFile, ability.PlaceholderColor, source.sprite); ability.Prefab = val; Plugin.Log.LogInfo((object)("'" + ability.Name + "' built from template '" + source.name + "'.")); } } [HarmonyPatch(typeof(SteamManager), "Awake")] internal static class Patch_SteamManager_Awake { private static void Postfix() { AbilityRegistry.EnsureRegistered(); } } [HarmonyPatch(typeof(AbilityGrid), "Awake")] internal static class Patch_AbilityGrid_Awake { private static void Prefix() { AbilityRegistry.EnsureRegistered(); } } [HarmonyPatch(typeof(LocalizationTable), "GetText")] internal static class Patch_LocalizationTable_GetText { private static bool Prefix(string enText, Language lang, ref string __result) { if (!AbilityRegistry.IsOurs(enText)) { return true; } __result = enText; return false; } } internal static class IconLoader { public static Sprite LoadOrPlaceholder(string fileName, Color placeholderColor, Sprite reference) { //IL_002d: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_00fd: Expected O, but got Unknown //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) int num = 128; int height = 128; float num2 = 100f; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0.5f, 0.5f); if ((Object)(object)reference != (Object)null) { Rect rect = reference.rect; num = Mathf.Max(1, (int)((Rect)(ref rect)).width); height = Mathf.Max(1, (int)((Rect)(ref rect)).height); num2 = reference.pixelsPerUnit; ((Vector2)(ref val))..ctor(reference.pivot.x / ((Rect)(ref rect)).width, reference.pivot.y / ((Rect)(ref rect)).height); } Texture2D val2 = null; string text = (string.IsNullOrEmpty(fileName) ? null : Path.Combine(Plugin.PluginDir, "icons", fileName)); byte[] array = null; try { array = ((text != null && File.Exists(text)) ? File.ReadAllBytes(text) : ReadEmbedded(fileName)); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Icon unreadable (" + fileName + "): " + ex.Message)); } if (array != null) { val2 = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(val2, array)) { val2 = null; } else { num2 *= (float)((Texture)val2).width / (float)num; } } if ((Object)(object)val2 == (Object)null) { val2 = Solid(num, height, placeholderColor); } ((Texture)val2).filterMode = (FilterMode)1; ((Texture)val2).wrapMode = (TextureWrapMode)1; ((Object)val2).hideFlags = (HideFlags)32; Sprite obj = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), val, num2); ((Object)obj).name = Path.GetFileNameWithoutExtension(fileName ?? "icon"); ((Object)obj).hideFlags = (HideFlags)32; return obj; } internal static byte[] ReadEmbedded(string fileName) { Assembly assembly = typeof(IconLoader).Assembly; string[] manifestResourceNames = assembly.GetManifestResourceNames(); foreach (string text in manifestResourceNames) { if (fileName == null || !text.EndsWith(fileName, StringComparison.OrdinalIgnoreCase)) { continue; } using Stream stream = assembly.GetManifestResourceStream(text); using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); return memoryStream.ToArray(); } return null; } private static Texture2D Solid(int width, int height, Color color) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown //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) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(width, height, (TextureFormat)4, false); Color32[] array = (Color32[])(object)new Color32[width * height]; Color32 val2 = Color32.op_Implicit(color); for (int i = 0; i < array.Length; i++) { array[i] = val2; } val.SetPixels32(array); val.Apply(); return val; } } internal sealed class SandevistanMark : MonoBehaviour { } internal static class SandevistanAbility { public static void Register() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) AbilityRegistry.Add(new CustomAbility { Name = "Sandevistan", IconFile = "Sandevistan.png", PlaceholderColor = new Color(0.1f, 0.85f, 1f), IsTemplate = (NamedSprite entry) => (Object)(object)entry.associatedGameObject.GetComponent<Invisibility>() != (Object)null, Setup = SetupTemplate }); } private static void SetupTemplate(GameObject template, NamedSprite source) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) InstantAbility component = template.GetComponent<InstantAbility>(); Object.DestroyImmediate((Object)(object)template.GetComponent<Invisibility>()); component.funcOnEnter = new UnityEvent(); component.EffectOnEnter = null; component.AudioOnCast = ""; component.isInvisibilty = false; component.SetCoolDown(Tuning.Cooldown); template.AddComponent<SandevistanMark>(); } } [HarmonyPatch(typeof(InstantAbility), "EnterAbility")] internal static class Patch_InstantAbility_Sandevistan { private static void Postfix(InstantAbility __instance, PlayerInfo playerInfo) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((Component)__instance).GetComponent<SandevistanMark>() != (Object)null) { Sandevistan.Begin(playerInfo.slimeController, __instance, playerInfo.AbilityButtonUsedIndex012); } } } [HarmonyPatch(typeof(InstantAbility), "IsCastable")] internal static class Patch_InstantAbility_SandevistanCastable { private static void Postfix(InstantAbility __instance, Player player, ref bool __result) { if (__result && player != null && Sandevistan.Any && (Object)(object)((Component)__instance).GetComponent<SandevistanMark>() != (Object)null && Sandevistan.Find(player.Id) != null) { __result = false; } } } internal sealed class SandeState { public int PlayerId; public SlimeController Slime; public InstantAbility Ability; public int Button; public Fix Elapsed; public Fix NextPulse; public bool Psycho; public bool MaxTac; public Fix MaxTacT; public bool Ended; public bool LoadoutLogged; public bool Executed; public SandevistanLook Look; } internal sealed class Pulse { public bool Jump; public int Slot; public Fix Remaining; public bool First = true; } internal static class Sandevistan { private static readonly FieldRef<SlimeController, List<AbilityMonoBehaviour>> abilitiesRef = new FieldRef<SlimeController, List<AbilityMonoBehaviour>>("abilities"); private static readonly FieldRef<SlimeController, Fix[]> timersRef = new FieldRef<SlimeController, Fix[]>("abilityCooldownTimers"); private static readonly FieldRef<SlimeController, bool> inAbilityRef = new FieldRef<SlimeController, bool>("isInAbility"); private static readonly List<SandeState> states = new List<SandeState>(); private static readonly Dictionary<int, Pulse> pulses = new Dictionary<int, Pulse>(); public static bool Any => states.Count > 0; public static SandeState Find(int playerId) { for (int i = 0; i < states.Count; i++) { if (states[i].PlayerId == playerId) { return states[i]; } } return null; } public static bool IsOwner(int playerId) { return Find(playerId) != null; } public static bool TryGetPulse(int playerId, out Pulse pulse) { pulse = null; if (pulses.Count > 0) { return pulses.TryGetValue(playerId, out pulse); } return false; } public static void Begin(SlimeController slime, InstantAbility ability, int button) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)slime == (Object)null || ((MonoUpdatable)slime).IsDestroyed) { return; } int playerId = slime.GetPlayerId(); if (Find(playerId) == null) { if ((Object)(object)ability != (Object)null) { ability.SetCoolDown(Tuning.LockedCooldown); } SandeState sandeState = new SandeState { PlayerId = playerId, Slime = slime, Ability = ability, Button = button }; states.Add(sandeState); sandeState.Look = SandevistanLook.Create(sandeState); SandeAudio.Play(SandeAudio.Kind.Activate, 1f, 1f); } } public static Fix SpeedFactor(int playerId) { //IL_000c: 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_001a: Unknown result type (might be due to invalid IL or missing references) if (states.Count == 0) { return Fix.One; } if (Find(playerId) == null) { return Tuning.OthersSpeed; } return Tuning.OwnerSpeed; } public static void Tick(Fix dt) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: 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_01a5: Unknown result type (might be due to invalid IL or missing references) if (GameTime.IsTimeStopped()) { return; } AdvancePulses(dt); for (int num = states.Count - 1; num >= 0; num--) { SandeState sandeState = states[num]; PlayerHandler val = PlayerHandler.Get(); Player val2 = ((val != null) ? val.GetPlayer(sandeState.PlayerId) : null); if (val2 == null || !val2.IsAlive || (Object)(object)sandeState.Slime == (Object)null || ((MonoUpdatable)sandeState.Slime).IsDestroyed) { states.RemoveAt(num); pulses.Remove(sandeState.PlayerId); Finish(sandeState, crashed: false); continue; } sandeState.Elapsed += dt; if (!sandeState.Psycho && sandeState.Elapsed >= Tuning.Clean) { sandeState.Psycho = true; SandeAudio.Play(SandeAudio.Kind.Psychosis, 1f, 1f); sandeState.NextPulse = NextGap(sandeState); if ((Object)(object)sandeState.Look != (Object)null) { sandeState.Look.OnPsychosis(); } } if (Tuning.MaxTacEnabled && !sandeState.MaxTac && sandeState.Elapsed >= Tuning.MaxTacAt) { sandeState.MaxTac = true; SandeAudio.Play(SandeAudio.Kind.Siren, 1f, 1f); if ((Object)(object)sandeState.Look != (Object)null) { sandeState.Look.OnMaxTac(); } } if (sandeState.MaxTac) { sandeState.MaxTacT += dt; if (sandeState.MaxTacT >= Tuning.MaxTacArrival) { states.RemoveAt(num); pulses.Remove(sandeState.PlayerId); Execute(sandeState); continue; } } if (sandeState.Psycho) { PsychosisStep(sandeState, dt); } } if (states.Count == 0) { pulses.Clear(); } } private static void AdvancePulses(Fix dt) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) if (pulses.Count == 0) { return; } List<int> list = null; foreach (KeyValuePair<int, Pulse> pulse in pulses) { pulse.Value.First = false; Pulse value = pulse.Value; value.Remaining -= dt; if (pulse.Value.Remaining <= Fix.Zero) { if (list == null) { list = new List<int>(); } list.Add(pulse.Key); } } if (list == null) { return; } foreach (int item in list) { pulses.Remove(item); } } private static Fix NextGap(SandeState s) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0022: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) Fix val = (Tuning.MaxTacEnabled ? (Tuning.MaxTacAt - Tuning.Clean) : Tuning.F(20f)); Fix val2 = Fix.Min(Fix.One, Fix.Max(Fix.Zero, (s.Elapsed - Tuning.Clean) / Fix.Max(Tuning.F(1f), val))); return Updater.RandomFix(Tuning.F(Plugin.PulseGapMin.Value), Tuning.F(Plugin.PulseGapMax.Value)) * (Fix.One - Tuning.F(0.6f) * val2); } private static void PsychosisStep(SandeState s, Fix dt) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0349: 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) //IL_00f8: 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) if (pulses.ContainsKey(s.PlayerId)) { return; } s.NextPulse -= dt; if (s.NextPulse > Fix.Zero) { return; } if (inAbilityRef.Invoke(s.Slime)) { s.NextPulse = Tuning.F(0.1f); return; } Fix[] array = timersRef.Invoke(s.Slime); List<AbilityMonoBehaviour> list = abilitiesRef.Invoke(s.Slime); int num = list?.IndexOf((AbilityMonoBehaviour)(object)s.Ability) ?? (-1); List<int> list2 = new List<int>(); List<int> list3 = new List<int>(); if (list != null) { for (int i = 0; i < list.Count; i++) { AbilityMonoBehaviour val = list[i]; if (i != num && i != s.Button && !((Object)(object)val == (Object)null) && !((MonoUpdatable)val).IsDestroyed && !((Object)(object)((Component)val).GetComponent<SandevistanMark>() != (Object)null)) { list2.Add(i); if (array != null && i < array.Length && !(array[i] < val.GetCooldown())) { list3.Add(i); } } } } s.NextPulse = NextGap(s); if (!s.LoadoutLogged) { s.LoadoutLogged = true; Plugin.Log.LogInfo((object)("[psychosis] slots=" + (list?.Count ?? (-1)) + " own=" + num + " button=" + s.Button + " candidates=" + list2.Count + " ready=" + list3.Count + " timers=" + ((array != null) ? array.Length : (-1)) + " | hooks: Player methods=" + InputForce.PlayerMethods.Count + ", InputProfile fields=" + InputForce.ProfileFields.Count)); } Fix val2 = Updater.RandomFix(Fix.Zero, Fix.One); int num2 = ((list2.Count == 0 || val2 < Tuning.F(0.25f)) ? 2 : 0); SandeAudio.Play(SandeAudio.Kind.Glitch, 0.9f, 0.7f + 0.6f * Random.value); if (num2 == 2) { pulses[s.PlayerId] = new Pulse { Jump = true, Slot = -1, Remaining = Updater.RandomFix(Tuning.F(0.12f), Tuning.F(0.5f)) }; return; } List<int> list4 = ((list3.Count > 0) ? list3 : list2); int num3 = (int)(long)Updater.RandomFix(Fix.Zero, (Fix)(long)list4.Count); if (num3 >= list4.Count) { num3 = list4.Count - 1; } if (num3 < 0) { num3 = 0; } pulses[s.PlayerId] = new Pulse { Slot = list4[num3], Remaining = Updater.RandomFix(Tuning.F(0.1f), Tuning.F(0.45f)) }; } private static void Execute(SandeState s) { s.Executed = true; SandeAudio.Play(SandeAudio.Kind.Volley, 1f, 1f); Finish(s, crashed: false); if (!((Object)(object)s.Slime == (Object)null) && !((MonoUpdatable)s.Slime).IsDestroyed) { PlayerCollision activePlayerCollision = s.Slime.GetActivePlayerCollision(); if ((Object)(object)activePlayerCollision != (Object)null && !((MonoUpdatable)activePlayerCollision).IsDestroyed) { activePlayerCollision.killPlayer(s.PlayerId, false, true, (CauseOfDeath)0); } } } private static void Finish(SandeState s, bool crashed) { //IL_0056: 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_00c4: Unknown result type (might be due to invalid IL or missing references) s.Ended = true; if (crashed) { SandeAudio.Play(SandeAudio.Kind.Crash, 1f, 1f); } if ((Object)(object)s.Look != (Object)null) { s.Look.End(crashed); } if ((Object)(object)s.Ability == (Object)null || ((MonoUpdatable)s.Ability).IsDestroyed) { return; } s.Ability.SetCoolDown(Tuning.Cooldown); if ((Object)(object)s.Slime != (Object)null && !((MonoUpdatable)s.Slime).IsDestroyed) { Fix[] array = timersRef.Invoke(s.Slime); int num = abilitiesRef.Invoke(s.Slime)?.IndexOf((AbilityMonoBehaviour)(object)s.Ability) ?? (-1); if (array != null && num >= 0 && num < array.Length) { array[num] = Fix.Zero; } } } public static void ResetAll() { foreach (SandeState state in states) { state.Ended = true; try { if ((Object)(object)state.Look != (Object)null) { state.Look.End(crashed: false); } } catch (Exception ex) { Plugin.Log.LogDebug((object)("Cleanup on level change: " + ex.Message)); } } states.Clear(); pulses.Clear(); InputForce.ClearLatches(); WorldSlow.ResetLog(); PlayerSlow.Reset(); } } [HarmonyPatch(typeof(Updater), "TickSimulation")] internal static class Patch_Updater_TickSimulation_Sandevistan { private static void Postfix(Fix deltaTime) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (Sandevistan.Any) { Sandevistan.Tick(deltaTime); } } } [HarmonyPatch(typeof(Updater), "PreLevelLoad")] internal static class Patch_Updater_PreLevelLoad_Sandevistan { private static void Postfix() { Sandevistan.ResetAll(); } } [HarmonyPatch] internal static class Patch_PlayerPhysics_Sandevistan { private struct Saved { public bool Active; public Fix Speed; public Fix Accel; public Fix AirAccel; public bool GravitySet; public Fix PlayerGravity; } private static readonly FieldRef<PlayerPhysics, IPlayerIdHolder> idRef = new FieldRef<PlayerPhysics, IPlayerIdHolder>("playerIdHolder"); private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.Method(typeof(PlayerPhysics), "Move", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(PlayerPhysics), "MachoMove", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(PlayerPhysics), "AirealMovement", (Type[])null, (Type[])null); } [HarmonyPriority(600)] private static void Prefix(PlayerPhysics __instance, out Saved __state) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: 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) __state = default(Saved); if (!Sandevistan.Any) { return; } IPlayerIdHolder val = idRef.Invoke(__instance); if (val == null) { return; } int playerId = val.GetPlayerId(); Fix val2 = Sandevistan.SpeedFactor(playerId); if (val2 < Fix.One && WorldSlow.Covers(playerId)) { val2 = Fix.One; } if (!(val2 == Fix.One)) { __state = new Saved { Active = true, Speed = __instance.Speed, Accel = __instance.accel, AirAccel = __instance.airAccel }; __instance.Speed *= val2; __instance.accel *= Fix.Max(val2, Fix.One); __instance.airAccel *= val2; DetPhysics val3 = DetPhysics.Get(); if (Plugin.SlowWorld.Value && val2 < Fix.One && (Object)(object)val3 != (Object)null) { __state.GravitySet = true; __state.PlayerGravity = val3.playerGravity; val3.playerGravity *= val2; } } } [HarmonyPriority(200)] private static Exception Finalizer(PlayerPhysics __instance, Saved __state, Exception __exception) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) if (__state.Active) { __instance.Speed = __state.Speed; __instance.accel = __state.Accel; __instance.airAccel = __state.AirAccel; if (__state.GravitySet && (Object)(object)DetPhysics.Get() != (Object)null) { DetPhysics.Get().playerGravity = __state.PlayerGravity; } } return __exception; } } internal static class OwnerProbe { private static readonly Dictionary<Type, Func<object, int>> cache = new Dictionary<Type, Func<object, int>>(); private static readonly string[] names = new string[6] { "OwnerId", "ownerId", "ownerID", "owner", "spawnerId", "SpawnerId" }; public static int Of(BoplBody b) { IPlayerIdHolder component = ((Component)b).GetComponent<IPlayerIdHolder>(); if (component != null) { return component.GetPlayerId(); } Item component2 = ((Component)b).GetComponent<Item>(); if ((Object)(object)component2 != (Object)null && component2.OwnerId >= 0) { return component2.OwnerId; } MonoBehaviour[] components = ((Component)b).GetComponents<MonoBehaviour>(); foreach (MonoBehaviour val in components) { if ((Object)(object)val == (Object)null) { continue; } Func<object, int> func = ForType(((object)val).GetType()); if (func != null) { int num = func(val); if (num >= 0) { return num; } } } return -2; } public static int OfBehaviour(Component c) { if ((Object)(object)c == (Object)null) { return -2; } SlimeController val = (SlimeController)(object)((c is SlimeController) ? c : null); if ((Object)(object)val == (Object)null) { val = c.GetComponentInParent<SlimeController>(); } if ((Object)(object)val != (Object)null && !((MonoUpdatable)val).IsDestroyed) { return val.GetPlayerId(); } IPlayerIdHolder component = c.GetComponent<IPlayerIdHolder>(); if (component != null) { return component.GetPlayerId(); } return ForType(((object)c).GetType())?.Invoke(c) ?? (-2); } private static Func<object, int> ForType(Type t) { if (cache.TryGetValue(t, out var value)) { return value; } value = null; Type type = t; while (type != null && value == null && type != typeof(MonoBehaviour)) { string[] array = names; foreach (string name in array) { FieldInfo f = type.GetField(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (f != null && f.FieldType == typeof(int)) { value = (object o) => (int)f.GetValue(o); break; } PropertyInfo pr = type.GetProperty(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (pr != null && pr.PropertyType == typeof(int) && pr.CanRead) { value = (object o) => (int)pr.GetValue(o, null); break; } } if (value != null) { break; } FieldInfo[] fields = type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (!(fieldInfo.FieldType == typeof(PlayerInfo))) { continue; } FieldInfo pid = typeof(PlayerInfo).GetField("playerId", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (pid != null) { FieldInfo holderField = fieldInfo; value = delegate(object o) { object value2 = holderField.GetValue(o); return (value2 != null) ? ((int)pid.GetValue(value2)) : (-2); }; break; } } type = type.BaseType; } cache[t] = value; return value; } } internal static class WorldSlow { private sealed class Entry { public IPhysicsCollider Col; public FixTransform Ft; public Vec2 Pos; public Fix Rot; public Fix Gravity; } private static readonly List<Entry> entries = new List<Entry>(); private static readonly Dictionary<BoplBody, IPhysicsCollider> colCache = new Dictionary<BoplBody, IPhysicsCollider>(); private static Fix factor = Fix.One; private static readonly HashSet<int> covered = new HashSet<int>(); private static readonly HashSet<int> logged = new HashSet<int>(); private static SlimeController[] slimes = (SlimeController[])(object)new SlimeController[0]; private static int slimeScanTick = -999; public static bool Covers(int playerId) { return covered.Contains(playerId); } public static void ResetLog() { logged.Clear(); covered.Clear(); slimes = (SlimeController[])(object)new SlimeController[0]; slimeScanTick = -999; } private static bool Alive(IPhysicsCollider col) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected I4, but got Unknown if (col == null || col.IsDestroyed || (Object)(object)((col is Object) ? col : null) == (Object)null || !col.initHasBeenCalled) { return false; } DetPhysics val = DetPhysics.Get(); if ((Object)(object)val == (Object)null) { return false; } int instanceId = col.GetPhysicsParent().instanceId; return (int)col.shape switch { 0 => val.circles.ContainsParent(instanceId), 1 => val.boxes.ContainsParent(instanceId), 2 => val.roundedRects.ContainsParent(instanceId), _ => false, }; } private static void SetGravity(IPhysicsCollider col, Fix g) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected I4, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) DetPhysics val = DetPhysics.Get(); int instanceId = col.GetPhysicsParent().instanceId; switch ((int)col.shape) { case 0: val.circles.physicsBodies[val.circles.ColliderIndex(instanceId)].gravityScale = g; break; case 1: val.boxes.physicsBodies[val.boxes.ColliderIndex(instanceId)].gravityScale = g; break; case 2: val.roundedRects.physicsBodies[val.roundedRects.ColliderIndex(instanceId)].gravityScale = g; break; } } public static bool IsSlowed(BoplBody b) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)b == (Object)null || ((MonoUpdatable)b).IsDestroyed || !((Behaviour)b).isActiveAndEnabled || b.IsBeingHeld()) { return false; } if (!colCache.TryGetValue(b, out var value) || value == null) { value = ((Component)b).GetComponent<IPhysicsCollider>(); colCache[b] = value; } if (!Alive(value) || value.IsComposite() || Sandevistan.IsOwner(OwnerProbe.Of(b))) { return false; } return value.GetBody().inverseMass > Fix.Zero; } public static void Begin() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0103: 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_014c: 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_0159: 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_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) entries.Clear(); covered.Clear(); if (!Sandevistan.Any || !Plugin.SlowWorld.Value) { return; } factor = Tuning.OthersSpeed; if (factor >= Fix.One || GameTime.IsTimeStopped()) { return; } DetPhysics val = DetPhysics.Get(); if ((Object)(object)val == (Object)null) { return; } val.RemoveDestroyedColliders(); List<MonoUpdatable> updatables = Updater.updatables; for (int i = 0; i < updatables.Count; i++) { MonoUpdatable obj = updatables[i]; BoplBody val2 = (BoplBody)(object)((obj is BoplBody) ? obj : null); if ((Object)(object)val2 == (Object)null || ((MonoUpdatable)val2).IsDestroyed || !((Behaviour)val2).isActiveAndEnabled || val2.IsBeingHeld()) { continue; } if (!colCache.TryGetValue(val2, out var value) || value == null) { value = ((Component)val2).GetComponent<IPhysicsCollider>(); colCache[val2] = value; } if (!Alive(value) || value.IsComposite() || Sandevistan.IsOwner(OwnerProbe.Of(val2))) { continue; } PhysicsBody body = value.GetBody(); if (!(body.inverseMass <= Fix.Zero)) { FixTransform fixTransform = val2.GetFixTransform(); if (!((Object)(object)fixTransform == (Object)null) && !fixTransform.IsDestroyed) { entries.Add(new Entry { Col = value, Ft = fixTransform, Pos = fixTransform.position, Rot = fixTransform.rotation, Gravity = body.gravityScale }); SetGravity(value, body.gravityScale * factor); } } } AddPlayers(); } private static void AddPlayers() { //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: 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_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) int simulationTicks = Updater.SimulationTicks; if (slimes.Length == 0 || simulationTicks < slimeScanTick || simulationTicks - slimeScanTick >= 30) { slimeScanTick = simulationTicks; slimes = Object.FindObjectsOfType<SlimeController>(); } PlayerHandler val = PlayerHandler.Get(); SlimeController[] array = slimes; foreach (SlimeController val2 in array) { if ((Object)(object)val2 == (Object)null || ((MonoUpdatable)val2).IsDestroyed || !((Behaviour)val2).isActiveAndEnabled) { continue; } int playerId = val2.GetPlayerId(); if (Sandevistan.IsOwner(playerId)) { continue; } Player val3 = ((val != null) ? val.GetPlayer(playerId) : null); if (val3 == null || !val3.IsAlive) { continue; } FixTransform val4 = ((Component)val2).GetComponent<FixTransform>(); if ((Object)(object)val4 == (Object)null) { val4 = ((Component)val2).GetComponentInChildren<FixTransform>(); } if ((Object)(object)val4 == (Object)null || val4.IsDestroyed) { if (logged.Add(playerId * 10 + 1)) { Plugin.Log.LogWarning((object)("[slow-player] player " + playerId + ": no FixTransform on the slime, falling back to PlayerPhysics scaling.")); } continue; } bool flag = false; foreach (Entry entry2 in entries) { if ((Object)(object)entry2.Ft == (Object)(object)val4) { flag = true; break; } } if (flag) { covered.Add(playerId); continue; } IPhysicsCollider val5 = ((Component)val2).GetComponent<IPhysicsCollider>(); if (val5 == null) { val5 = ((Component)val2).GetComponentInChildren<IPhysicsCollider>(); } bool flag2 = val5 != null && Alive(val5) && !val5.IsComposite() && val5.GetBody().inverseMass > Fix.Zero; Entry entry = new Entry { Col = (flag2 ? val5 : null), Ft = val4, Pos = val4.position, Rot = val4.rotation, Gravity = (flag2 ? val5.GetBody().gravityScale : Fix.Zero) }; entries.Add(entry); if (flag2) { SetGravity(val5, entry.Gravity * factor); } covered.Add(playerId); if (logged.Add(playerId * 10)) { Plugin.Log.LogInfo((object)("[slow-player] player " + playerId + " dilated: transform=ok collider=" + (flag2 ? ("ok (gravityScale " + (float)entry.Gravity + ")") : "not reachable, position-delta only"))); } } } public static void End() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011b: 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_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: 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_00f0: 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_00fa: Unknown result type (might be due to invalid IL or missing references) if (entries.Count == 0) { return; } Fix val = Fix.PiTimes2 / (Fix)2L; foreach (Entry entry in entries) { try { if (Alive(entry.Col)) { SetGravity(entry.Col, entry.Gravity); } if (!((Object)(object)entry.Ft == (Object)null) && !entry.Ft.IsDestroyed) { Vec2 position = entry.Ft.position; entry.Ft.position = entry.Pos + (position - entry.Pos) * factor; Fix val2 = entry.Ft.rotation - entry.Rot; if (val2 > val) { val2 -= Fix.PiTimes2; } else if (val2 < -val) { val2 += Fix.PiTimes2; } Fix val3 = entry.Rot + val2 * factor; entry.Ft.rotation = (val3 % Fix.PiTimes2 + Fix.PiTimes2) % Fix.PiTimes2; } } catch (Exception ex) { Plugin.Log.LogDebug((object)("[slow-world] restore skipped: " + ex.Message)); } } entries.Clear(); } } internal static class LogicSlow { private static int stampTick = -1; private static readonly Dictionary<int, bool> cache = new Dictionary<int, bool>(); private static int patched; public static void Apply(Harmony harmony) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown HarmonyMethod val = new HarmonyMethod(typeof(LogicSlow).GetMethod("Prefix", BindingFlags.Static | BindingFlags.Public)); val.priority = 600; int num = 0; Type[] types = typeof(MonoUpdatable).Assembly.GetTypes(); foreach (Type type in types) { if (type.IsGenericTypeDefinition || !typeof(MonoUpdatable).IsAssignableFrom(type)) { continue; } MethodInfo method = type.GetMethod("UpdateSim", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(Fix) }, null); if (!(method == null) && !method.IsAbstract && method.GetMethodBody() != null) { try { harmony.Patch((MethodBase)method, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); patched++; } catch (Exception) { num++; } } } Plugin.Log.LogInfo((object)("[slow-world] logic slow hooked into " + patched + " UpdateSim methods (" + num + " failed).")); } public static bool Prefix(MonoUpdatable __instance) { return !ShouldSkip(__instance); } private static bool ShouldSkip(MonoUpdatable m) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (!Sandevistan.Any || !Plugin.SlowWorld.Value || (Object)(object)m == (Object)null) { return false; } if (Tuning.OthersSpeed >= Fix.One || GameTime.IsTimeStopped()) { return false; } int simulationTicks = Updater.SimulationTicks; if (simulationTicks != stampTick) { stampTick = simulationTicks; cache.Clear(); } int instanceID = ((Object)m).GetInstanceID(); if (!cache.TryGetValue(instanceID, out var value)) { BoplBody val = (BoplBody)(object)((m is BoplBody) ? m : null); if ((Object)(object)val == (Object)null) { val = ((Component)m).GetComponent<BoplBody>(); } value = (Object)(object)val != (Object)null && WorldSlow.IsSlowed(val); if (!value) { int playerId = OwnerProbe.OfBehaviour((Component)(object)m); value = PlayerSlow.IsSlowedPlayer(playerId); if (value) { PlayerSlow.NoteGated((Component)(object)m, playerId); } } cache[instanceID] = value; } if (!value) { return false; } bool num = TickRuns(); if (!num) { SlimeController val2 = (SlimeController)(object)((m is SlimeController) ? m : null); if ((Object)(object)val2 != (Object)null) { InputForce.Latch(val2.GetPlayerId()); } } return !num; } public static bool TickRuns() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) Fix othersSpeed = Tuning.OthersSpeed; if (othersSpeed >= Fix.One) { return true; } int simulationTicks = Updater.SimulationTicks; Fix val = Fix.Floor((Fix)(long)(simulationTicks + 1) * othersSpeed); Fix val2 = Fix.Floor((Fix)(long)simulationTicks * othersSpeed); return val != val2; } } internal static class PlayerSlow { private static readonly HashSet<Type> gated = new HashSet<Type>(); public static bool Active { get { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (Sandevistan.Any && Plugin.SlowWorld.Value && Tuning.OthersSpeed < Fix.One) { return !GameTime.IsTimeStopped(); } return false; } } public static bool IsSlowedPlayer(int playerId) { if (playerId >= 0 && Active) { return !Sandevistan.IsOwner(playerId); } return false; } public static void NoteGated(Component c, int playerId) { if (!((Object)(object)c == (Object)null) && gated.Count <= 60 && gated.Add(((object)c).GetType())) { Plugin.Log.LogInfo((object)("[slow-player] gating UpdateSim of " + ((object)c).GetType().Name + " (player " + playerId + ")")); } } public static void Reset() { gated.Clear(); } } [HarmonyPatch(typeof(DetPhysics), "Simulate")] internal static class Patch_DetPhysics_Simulate_Sandevistan { [HarmonyPriority(600)] private static void Prefix() { WorldSlow.Begin(); } [HarmonyPriority(200)] private static Exception Finalizer(Exception __exception) { WorldSlow.End(); return __exception; } } internal static class InputForce { internal enum Kind { Hold, Edge } internal sealed class FieldHook { public FieldInfo Field; public int Slot; public Kind Kind; } internal sealed class Applied { public object Profile; public List<KeyValuePair<FieldInfo, bool>> Old = new List<KeyValuePair<FieldInfo, bool>>(); } internal static readonly Type InputProfileType = AccessTools.Field(typeof(Player), "Inputs").FieldType; internal static FieldInfo JumpHold; internal static FieldInfo JumpEdge; internal static readonly List<FieldInfo> EdgeFields = new List<FieldInfo>(); private static readonly Dictionary<int, HashSet<FieldInfo>> latched = new Dictionary<int, HashSet<FieldInfo>>(); private static readonly FieldRef<Player, object> inputsRef = new FieldRef<Player, object>("Inputs"); internal static readonly List<MethodBase> PlayerMethods = new List<MethodBase>(); internal static readonly List<FieldHook> ProfileFields = new List<FieldHook>(); internal static bool HasJump { get { if (!(JumpHold != null)) { return JumpEdge != null; } return true; } } private static object ProfileOf(int playerId) { PlayerHandler val = PlayerHandler.Get(); Player val2 = ((val != null) ? val.GetPlayer(playerId) : null); if (val2 == null) { return null; } return inputsRef.Invoke(val2); } public static void Latch(int playerId) { if (EdgeFields.Count == 0) { return; } object obj = ProfileOf(playerId); if (obj == null) { return; } foreach (FieldInfo edgeField in EdgeFields) { if ((bool)edgeField.GetValue(obj)) { if (!latched.TryGetValue(playerId, out var value)) { value = new HashSet<FieldInfo>(); latched[playerId] = value; } value.Add(edgeField); } } } public static Applied Replay(int playerId) { if (!latched.TryGetValue(playerId, out var value) || value.Count == 0) { return null; } object obj = ProfileOf(playerId); if (obj == null) { value.Clear(); return null; } Applied applied = new Applied { Profile = obj }; foreach (FieldInfo item in value) { applied.Old.Add(new KeyValuePair<FieldInfo, bool>(item, (bool)item.GetValue(obj))); item.SetValue(obj, true); } value.Clear(); return applied; } public static void ClearLatches() { latched.Clear(); } public static void Scan() { MethodInfo[] methods = typeof(Player).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (methodInfo.Name.StartsWith("AbilityButton", StringComparison.OrdinalIgnoreCase) && methodInfo.ReturnType == typeof(bool)) { ParameterInfo[] parameters = methodInfo.GetParameters(); if (parameters.Length == 1 && parameters[0].ParameterType == typeof(int) && Classify(methodInfo.Name).HasValue) { PlayerMethods.Add(methodInfo); Plugin.Log.LogInfo((object)("[input-scan] Player." + methodInfo.Name + "(int) -> " + Classify(methodInfo.Name).ToString())); } } } List<FieldInfo> list = new List<FieldInfo>(); FieldInfo[] fields = InputProfileType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (fieldInfo.FieldType == typeof(bool) && fieldInfo.Name.IndexOf("abil", StringComparison.OrdinalIgnoreCase) >= 0 && LastDigit(fieldInfo.Name) >= 0 && Classify(fieldInfo.Name).HasValue) { list.Add(fieldInfo); } } bool flag = list.Any((FieldInfo f) => LastDigit(f.Name) == 0); foreach (FieldInfo item in list) { ProfileFields.Add(new FieldHook { Field = item, Slot = LastDigit(item.Name) - ((!flag) ? 1 : 0), Kind = Classify(item.Name).Value }); Plugin.Log.LogInfo((object)("[input-scan] InputProfile." + item.Name + " -> slot " + (LastDigit(item.Name) - ((!flag) ? 1 : 0)) + " " + Classify(item.Name).ToString())); } JumpHold = InputProfileType.GetField("jumpButton_IS_DOWN", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); JumpEdge = InputProfileType.GetField("jumpButton_DOWN_THIS_FRAME", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); fields = InputProfileType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo2 in fields) { string text = fieldInfo2.Name.ToLowerInvariant(); if (fieldInfo2.FieldType == typeof(bool) && (text.Contains("this_frame") || text.Contains("thisframe") || text.Contains("pressed") || text.Contains("released"))) { EdgeFields.Add(fieldInfo2); Plugin.Log.LogInfo((object)("[input-scan] edge latch field " + fieldInfo2.Name)); } } Plugin.Log.LogInfo((object)("[input-scan] InputProfile type: " + InputProfileType.FullName)); fields = InputProfileType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo3 in fields) { Plugin.Log.LogInfo((object)("[input-scan] field " + fieldInfo3.Name + " : " + fieldInfo3.FieldType.Name)); } methods = typeof(Player).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo2 in methods) { if (methodInfo2.Name.IndexOf("bility", StringComparison.OrdinalIgnoreCase) >= 0 || methodInfo2.Name.IndexOf("button", StringComparison.OrdinalIgnoreCase) >= 0 || methodInfo2.Name.IndexOf("input", StringComparison.OrdinalIgnoreCase) >= 0) { Plugin.Log.LogInfo((object)("[input-scan] Player." + methodInfo2.ReturnType.Name + " " + methodInfo2.Name + "(" + string.Join(", ", (from x in methodInfo2.GetParameters() select x.ParameterType.Name).ToArray()) + ")")); } } methods = typeof(SlimeController).GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo3 in methods) { Plugin.Log.LogInfo((object)("[input-scan] SlimeController." + methodInfo3.Name)); } if (PlayerMethods.Count == 0 && ProfileFields.Count == 0) { Plugin.Log.LogWarning((object)"[input-scan] found no ability-button members on Player/InputProfile; psychosis casts will not fire. Send these log lines over."); } } private static int LastDigit(string name) { for (int num = name.Length - 1; num >= 0; num--) { if (char.IsDigit(name[num])) { return name[num] - 48; } } return -1; } internal static Kind? Classify(string name) { string text = name.ToLowerInvariant(); if (text.Contains("release") || text.EndsWith("up") || text.Contains("_up")) { return null; } if (text.Contains("this_frame") || text.Contains("thisframe") || text.Contains("pressed") || text.Contains("began")) { return Kind.Edge; } if (text.Contains("is_down") || text.Contains("isdown") || text.Contains("held")) { return Kind.Hold; } if (text.Contains("down")) { return Kind.Edge; } return null; } public static Applied Apply(object profile, Pulse pulse) { Applied applied = new Applied { Profile = profile }; if (pulse.Jump) { if (JumpHold != null) { applied.Old.Add(new KeyValuePair<FieldInfo, bool>(JumpHold, (bool)JumpHold.GetValue(profile))); JumpHold.SetValue(profile, true); } if (JumpEdge != null && pulse.First) { applied.Old.Add(new KeyValuePair<FieldInfo, bool>(JumpEdge, (bool)JumpEdge.GetValue(profile))); JumpEdge.SetValue(profile, true); } return applied; } foreach (FieldHook profileField in ProfileFields) { if (profileField.Slot == pulse.Slot && (profileField.Kind != Kind.Edge || pulse.First)) { applied.Old.Add(new KeyValuePair<FieldInfo, bool>(profileField.Field, (bool)profileField.Field.GetValue(profile))); profileField.Field.SetValue(profile, true); } } return applied; } public static void Restore(Applied applied) { if (applied == null) { return; } foreach (KeyValuePair<FieldInfo, bool> item in applied.Old) { item.Key.SetValue(applied.Profile, item.Value); } } } [HarmonyPatch] internal static class Patch_Player_AbilityButton { private static IEnumerable<MethodBase> TargetMethods() { return InputForce.PlayerMethods; } private static void Postfix(Player __instance, int __0, ref bool __result, MethodBase __originalMethod) { if (!__result && Sandevistan.Any && Sandevistan.TryGetPulse(__instance.Id, out var pulse) && pulse.Slot == __0) { InputForce.Kind? kind = InputForce.Classify(__originalMethod.Name); if (kind == InputForce.Kind.Hold || (kind == InputForce.Kind.Edge && pulse.First)) { __result = true; } } } } [HarmonyPatch(typeof(SlimeController), "OldUpdate")] internal static class Patch_SlimeController_SandevistanInput { private static readonly FieldRef<Player, object> inputsRef = new FieldRef<Player, object>("Inputs"); [HarmonyPriority(800)] private static bool Prefix(SlimeController __instance, out InputForce.Applied __state) { __state = null; if (!Sandevistan.Any) { return true; } int playerId = __instance.GetPlayerId(); if (PlayerSlow.IsSlowedPlayer(playerId)) { if (!LogicSlow.TickRuns()) { InputForce.Latch(playerId); return false; } __state = InputForce.Replay(playerId); return true; } if (InputForce.ProfileFields.Count == 0 && !InputForce.HasJump) { return true; } if (!Sandevistan.TryGetPulse(playerId, out var pulse)) { return true; } PlayerHandler val = PlayerHandler.Get(); Player val2 = ((val != null) ? val.GetPlayer(playerId) : null); object obj = ((val2 != null) ? inputsRef.Invoke(val2) : null); if (obj != null) { __state = InputForce.Apply(obj, pulse); } return true; } private static Exception Finalizer(InputForce.Applied __state, Exception __exception) { InputForce.Restore(__state); return __exception; } } internal static class SandeAudio { internal enum Kind { Activate, Psychosis, Glitch, Crash, Siren, Volley, Dock } private const int Rate = 44100; private static readonly FieldRef<AudioManager, float> masterRef = new FieldRef<AudioManager, float>("currentMasterVolume"); private static readonly Dictionary<Kind, AudioClip> clips = new Dictionary<Kind, AudioClip>(); private static AudioSource[] pool; private static int next; public static void Play(Kind kind, float volume, float pitch) { try { if (!clips.TryGetValue(kind, out var value) || (Object)(object)value == (Object)null) { value = Build(kind); clips[kind] = value; } if (Ready()) { AudioSource obj = pool[next++ % pool.Length]; obj.clip = value; obj.pitch = pitch; obj.volume = Mathf.Clamp01(volume * GameVolume()); obj.Play(); } } catch (Exception ex) { Plugin.Log.LogDebug((object)("Sound failed: " + ex.Message)); } } private static float GameVolume() { AudioManager val = AudioManager.Get(); if ((Object)(object)val == (Object)null) { return 0.5f; } float num = 1f; try { num = masterRef.Invoke(val); } catch { } return val.sfxVolume * num; } private static bool Ready() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown if (pool != null && (Object)(object)pool[0] != (Object)null) { return true; } GameObject val = new GameObject("SandevistanMod_Audio"); Object.DontDestroyOnLoad((Object)(object)val); pool = (AudioSource[])(object)new AudioSource[8]; for (int i = 0; i < pool.Length; i++) { AudioSource val2 = val.AddComponent<AudioSource>(); val2.playOnAwake = false; val2.spatialBlend = 0f; pool[i] = val2; } return true; } private static AudioClip Build(Kind kind) { Random r = new Random((int)(1337 + kind)); float[] array = kind switch { Kind.Activate => Activate(r), Kind.Psychosis => Psychosis(r), Kind.Glitch => Glitch(r), Kind.Siren => Siren(r), Kind.Volley => Volley(r), Kind.Dock => Dock(r), _ => Crash(r), }; Finish(array); AudioClip obj = AudioClip.Create("Sandevistan_" + kind, array.Length, 1, 44100, false); obj.SetData(array, 0); ((Object)obj).hideFlags = (HideFlags)32; return obj; } private static void Finish(float[] d) { float num = 0.0001f; for (int i = 0; i < d.Length; i++) { d[i] = (float)Math.Tanh((double)d[i] * 1.4); num = Math.Max(num, Math.Abs(d[i])); } float num2 = 0.8f / num; for (int j = 0; j < d.Length; j++) { d[j] *= num2; } } private static double Noise(Random r) { return r.NextDouble() * 2.0 - 1.0; } private static double Saw(double phase) { return 2.0 * (phase - Math.Floor(phase)) - 1.0; } private static float[] Activate(Random r) { int num = 41895; float[] array = new float[num]; double num2 = 0.0; double num3 = 0.0; for (int i = 0; i < num; i++) { double num4 = (double)i / 44100.0; double num5 = Math.Min(1.0, num4 / 0.6); double num6 = 90.0 * Math.Pow(16.0, num5); num2 += num6 / 44100.0; double num7 = 1.0 + 0.3 * Math.Sin(Math.PI * 56.0 * num4); double num8 = Math.Min(1.0, num4 / 0.03) * ((num4 < 0.6) ? 1.0 : Math.Max(0.0, 1.0 - (num4 - 0.6) / 0.35)); double num9 = (0.5 * Saw(num2) + 0.5 * Math.Sin(Math.PI * 2.0 * num2)) * num7 * num8 * 0.45; double num10 = 0.05 + 0.5 * num5; num3 += num10 * (Noise(r) - num3); double num11 = num3 * 1.6 * num8 * (0.3 + num5); double num12 = Math.Sin(Math.PI * 110.0 * num4) * Math.Exp((0.0 - num4) * 14.0) * 0.9; double num13 = ((num4 < 0.012) ? (Noise(r) * (1.0 - num4 / 0.012)) : 0.0); array[i] = (float)(num9 + num11 + num12 + num13); } return array; } private static float[] Psychosis(Random r) { int num = 66150; float[] array = new float[num]; double num2 = 0.0; double num3 = 0.0; double num4 = 0.0; for (int i = 0; i < num; i++) { double num5 = (double)i / 44100.0; num2 += 0.0014058956916099773; num3 += 0.001489795918367347; double num6 = 0.5 * (Saw(num2) + Saw(num3)); if (i % 6 == 0) { num4 = Math.Round(num6 * 12.0) / 12.0; } double num7 = ((Math.Sin(Math.PI * 36.0 * num5) > -0.2) ? 1.0 : 0.25); double num8 = Math.Min(1.0, num5 / 0.08) * Math.Min(1.0, (1.5 - num5) / 0.4); double num9 = 0.0; double[] array2 = new double[4] { 0.0, 0.42, 0.84, 1.2 }; foreach (double num10 in array2) { if (num5 >= num10) { num9 += Math.Sin(Math.PI * 96.0 * (num5 - num10)) * Math.Exp((0.0 - (num5 - num10)) * 16.0) * 1.1; } } double num11 = Noise(r) * 0.12 * ((Math.Sin(Math.PI * 14.0 * num5) > 0.0) ? 1.0 : 0.3) * num8; array[i] = (float)(num4 * 0.5 * num7 * num8 + num9 + num11); } return array; } private static float[] Glitch(Random r) { int num = 9702; float[] array = new float[num]; double num2 = 0.0; double num3 = 800.0; int num4 = 970; for (int i = 0; i < num; i++) { if (i % num4 == 0) { num3 = 300.0 + r.NextDouble() * 2200.0; } num2 += num3 / 44100.0; double num5 = (double)i / 44100.0; double num6 = Math.Round((((num2 - Math.Floor(num2) < 0.5) ? 1.0 : (-1.0)) * 0.6 + Noise(r) * 0.3) * 4.0) / 4.0; array[i] = (float)(num6 * Math.Exp((0.0 - num5) * 9.0) * Math.Min(1.0, num5 / 0.002)); } return array; } private static float[] Siren(Random r) { int num = 149940; float[] array = new float[num]; double num2 = 0.0; double num3 = 0.0; double num4 = 0.0; for (int i = 0; i < num; i++) { double num5 = (double)i / 44100.0; double num6 = Math.Min(1.0, num5 / 0.5) * Math.Min(1.0, (3.4 - num5) / 0.35); double num7 = 1.0 + 0.55 * Math.Sin(Math.PI * 22.0 * num5); num2 += 0.035 * (Noise(r) - num2); double num8 = (num2 * 5.0 + Math.Sin(Math.PI * 124.0 * num5) * 0.35 + Math.Sin(Math.PI * 186.0 * num5) * 0.18) * num7 * num6 * (0.5 + 0.5 * Math.Min(1.0, num5 / 2.0)); double num9 = 0.5 + 0.5 * Math.Sin(Math.PI * 2.0 * num5 / 0.76); double num10 = 620.0 + 260.0 * Math.Min(1.0, Math.Max(0.0, num9 * 3.0 - 1.0)); num3 += num10 / 44100.0; double num11 = (Math.Sin(Math.PI * 2.0 * num3) + 0.35 * Math.Sin(Math.PI * 4.0 * num3) + 0.15 * Saw(num3)) * 0.17 * num6; num4 += 0.2 * (Noise(r) - num4); double num12 = (Noise(r) - num4) * 0.05 * num6; array[i] = (float)(num8 + num11 + num12); } return array; } private static float[] Dock(Random r) { int num = 26460; float[] array = new float[num]; double num2 = 0.0; double num3 = 0.0; for (int i = 0; i < num; i++) { double num4 = (double)i / 44100.0; double num5 = Noise(r); num2 += 0.3 * (num5 - num2); double num6 = (num5 - num2) * Math.Exp((0.0 - num4) * 110.0) * 1.4; double num7 = (Math.Sin(Math.PI * 3800.0 * num4) * 0.45 + Math.Sin(Math.PI * 5700.0 * num4) * 0.2) * Math.Exp((0.0 - num4) * 16.0); num3 += (150.0 + 60.0 * Math.Exp((0.0 - num4) * 10.0)) / 44100.0; double num8 = Saw(num3) * Math.Exp((0.0 - num4) * 8.0) * ((Math.Sin(Math.PI * 76.0 * num4) > -0.3) ? 1.0 : 0.2) * 0.5 + num5 * Math.Exp((0.0 - num4) * 22.0) * 0.25; double num9 = Math.Sin(Math.PI * 124.0 * num4) * Math.Exp((0.0 - num4) * 18.0) * 1.0; array[i] = (float)(num6 + num7 + num8 + num9); } return array; } private static float[] Volley(Random r) { int num = 57330; float[] array = new float[num]; double num2 = 0.0; double num3 = 0.0; double[] array2 = new double[4] { 0.0, 0.07, 0.14, 0.21 }; for (int i = 0; i < num; i++) { double num4 = (double)i / 44100.0; double num5 = 0.0; double[] array3 = array2; foreach (double num6 in array3) { double num7 = num4 - num6; if (num7 >= 0.0) { num5 += Noise(r) * Math.Exp((0.0 - num7) * 70.0) * 0.9 + Math.Sin(Math.PI * 280.0 * num7) * Math.Exp((0.0 - num7) * 30.0) * 0.8; } } double num8 = num4 - 0.28; if (num8 >= 0.0) { num5 += Math.Sin(Math.PI * 2.0 * (48.0 - 20.0 * Math.Min(1.0, num8 * 3.0)) * num8) * Math.Exp((0.0 - num8) * 7.0) * 1.3; num2 += 0.06 * (Noise(r) - num2); num3 += num2; num5 += num2 * 2.2 * Math.Exp((0.0 - num8) * 4.0); } array[i] = (float)num5; } return array; } private static float[] Crash(Random r) { int num = 48510; float[] array = new float[num]; double num2 = 0.0; double num3 = 0.0; for (int i = 0; i < num; i++) { double num4 = (double)i / 44100.0; double num5 = 900.0 * Math.Pow(7.0 / 180.0, Math.Min(1.0, num4 / 0.9)); num2 += num5 / 44100.0; double num6 = Math.Exp((0.0 - num4) * 3.2); double num7 = (0.6 * Math.Sin(Math.PI * 2.0 * num2) + 0.4 * Saw(num2)) * num6 * 0.6; num3 += 0.12 * (Noise(r) - num3); double num8 = num3 * 2.0 * Math.Exp((0.0 - num4) * 7.0); double num9 = Math.Sin(Math.PI * 84.0 * num4) * Math.Exp((0.0 - num4) * 9.0) * 1.0; array[i] = (float)(num7 + num8 + num9); } return array; } } internal sealed class SandevistanLook : MonoBehaviour { private static readonly FieldRef<SlimeController, SpriteRenderer> slimeRenRef = new FieldRef<SlimeController, SpriteRenderer>("spriteRen"); private SandeState state; private SlimeController slime; private SpriteRenderer ren; private Material mat; private Vector3 lastPos; private bool hasLastPos; private float ghostTimer; private bool psycho; private bool ending; private static readonly int ShadowId = Shader.PropertyToID("_ShadowColor"); private static readonly int MainId = Shader.PropertyToID("_MainColor"); private static readonly int ReflId = Shader.PropertyToID("_ReflectionColour"); private bool SlimeVisible { get { if ((Object)(object)ren != (Object)null && ((Renderer)ren).enabled) { return ((Component)ren).gameObject.activeInHierarchy; } return false; } } public static SandevistanLook Create(SandeState s) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) SandevistanLook sandevistanLook = new GameObject("SandevistanLook").AddComponent<SandevistanLook>(); sandevistanLook.state = s; sandevistanLook.slime = s.Slime; sandevistanLook.ren = (((Object)(object)sandevistanLook.slime != (Object)null) ? slimeRenRef.Invoke(sandevistanLook.slime) : null); sandevistanLook.mat = (((Object)(object)sandevistanLook.slime != (Object)null) ? sandevistanLook.slime.GetPlayerMaterial() : null); EquipScene.Create(sandevistanLook.ren); return sandevistanLook; } public void OnPsychosis() { psycho = true; } public void OnMaxTac() { MaxTacScene.Create(state, ren); } public void End(bool crashed) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (!ending) { ending = true; if (crashed && (Object)(object)ren != (Object)null) { SpawnGhost(new Color(1f, 0.1f, 0.15f, 0.9f), Vector3.zero, 0.6f); } Object.Destroy((Object)(object)((Component)this).gameObject, 0.05f); } } private void Update() { //IL_006f: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_0117: 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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: 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) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: 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_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) if (ending) { return; } if (state == null || (Object)(object)slime == (Object)null || ((MonoUpdatable)slime).IsDestroyed || (Object)(object)ren == (Object)null) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } float deltaTime = Time.deltaTime; if (!SlimeVisible || deltaTime <= 0f) { hasLastPos = false; return; } Vector3 position = ((Component)ren).transform.position; float num; if (!hasLastPos) { num = 0f; } else { Vector3 val = position - lastPos; num = ((Vector3)(ref val)).magnitude / deltaTime; } float num2 = num; lastPos = position; hasLastPos = true; if (num2 < 5f || num2 > 400f) { return; } ghostTimer -= deltaTime; if (ghostTimer > 0f) { return; } ghostTimer = 0.03f; if (!psycho) { Color tint = Color.HSVToRGB(Mathf.Lerp(0.47f, 0.8f, Mathf.PingPong(Time.time * 1.3f, 1f)), 1f, 1f); tint.a = 1f; SpawnGhost(tint, Vector3.zero, 0.38f); return; } float value = Random.value; Color tint2 = ((value < 0.45f) ? new Color(1f, 0.05f, 0.25f, 1f) : ((value < 0.75f) ? new Color(1f, 0.15f, 0.9f, 1f) : new Color(1f, 1f, 1f, 1f))); SpawnGhost(tint2, Vector3.zero, 0.4f); if (Random.value < 0.5f) { Vector2 val2 = Random.insideUnitCircle * 0.55f; SpawnGhost(new Color(0f, 1f, 1f, 1f), new Vector3(val2.x, val2.y, 0f), 0.26f); } } private void SpawnGhost(Color tint, Vector3 offset, float life) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_009a: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("SandevistanGhost"); val.transform.SetPositionAndRotation(((Component)ren).transform.position + offset, ((Component)ren).transform.rotation); val.transform.localScale = ((Component)ren).transform.lossyScale; SpriteRenderer obj = val.AddComponent<SpriteRenderer>(); obj.sprite = ren.sprite; obj.flipX = ren.flipX; Material val2 = null; if ((Object)(object)mat != (Object)null) { val2 = new Material(mat); SandevistanGhost.Paint(val2, tint, 1f); } ((Renderer)obj).sharedMaterial = (((Object)(object)val2 != (Object)null) ? val2 : ((Renderer)ren).sharedMaterial); ((Renderer)obj).sortingLayerID = ((Renderer)ren).sortingLayerID; ((Renderer)obj).sortingOrder = ((Renderer)ren).sortingOrder - 3; val.AddComponent<SandevistanGhost>().Init(tint, life, val2); GameObject val3 = new GameObject("SandevistanHalo"); val3.transform.position = ((Component)ren).transform.position + offset; SpriteRenderer obj2 = val3.AddComponent<SpriteRenderer>(); obj2.sprite = Art.Glow(); ((Renderer)obj2).sortingLayerID = ((Renderer)ren).sortingLayerID; ((Renderer)obj2).sortingOrder = ((Renderer)ren).sortingOrder - 4; Bounds bounds = ((Renderer)ren).bounds; float num = Mathf.Clamp(((Bounds)(ref bounds)).size.y, 0.6f, 6f) * 2.1f; val3.transform.localScale = Vector3.one * (num / 0.64f); val3.AddComponent<SandevistanGhost>().InitHalo(tint, life * 1.15f); } } internal sealed class SandevistanGhost : MonoBehaviour { private static readonly int ShadowId = Shader.PropertyToID("_ShadowColor"); private static readonly int MainId = Shader.PropertyToID("_MainColor"); private static readonly int ReflId = Shader.PropertyToID("_ReflectionColour"); private SpriteRenderer sr; private Material ghostMat; private Color tint; private float life = 0.3f; private float t; private Vector3 scale0; private bool halo; public static void Paint(Material m, Color tint, float alpha) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)m == (Object)null)) { if (m.HasProperty(ShadowId)) { m.SetColor(ShadowId, new Color(tint.r * 0.85f, tint.g * 0.85f, tint.b * 0.85f, alpha)); } if (m.HasProperty(MainId)) { m.SetColor(MainId, new Color(tint.r * 1.25f, tint.g * 1.25f, tint.b * 1.25f, alpha)); } if (m.HasProperty(ReflId)) { Color val = Color.Lerp(tint, Color.white, 0.65f); m.SetColor(ReflId, new Color(val.r * 1.3f, val.g * 1.3f, val.b * 1.3f, alpha)); } } } public void InitHalo(Color color, float lifetime) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) halo = true; tint = color; life = Mathf.Max(0.05f, lifetime); } public void Init(Color color, float lifetime, Material material) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) tint = color; life = Mathf.Max(0.05f, lifetime); ghostMat = material; } private void Start() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) sr = ((Component)this).GetComponent<SpriteRenderer>(); scale0 = ((Component)this).transform.localScale; } private void Update() { //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) t += Time.deltaTime; float num = t / life; if (num >= 1f || (Object)(object)sr == (Object)null) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } float num2 = tint.a * Mathf.Pow(1f - num, 0.7f); if (halo) { sr.color = new Color(tint.r, tint.g, tint.b, num2 * 0.55f); ((Component)this).transform.localScale = scale0 * (1f + 0.25f * num); } else { sr.color = new Color(1f, 1f, 1f, num2); Paint(ghostMat, tint, num2); ((Component)this).transform.localScale = scale0 * (1f - 0.12f * num); } } private void OnDestroy() { if ((Object)(object)ghostMat != (Object)null) { Object.Destroy((Object)(object)ghostMat); } } } internal sealed class EquipScene : MonoBehaviour { private const float DockAt = 0.55f; private const float Total = 1.75f; private SpriteRenderer slimeRen; private float u = 1f; private float t; private Vector3 pos; private bool docked; private Sprite spineSprite; private SpriteRenderer chip; private SpriteRenderer chipHalo; private SpriteRenderer flash; private SpriteRenderer ring1; private SpriteRenderer ring2; private SpriteRenderer spine; private readonly SpriteRenderer[] nerves = (SpriteRenderer[])(object)new SpriteRenderer[4]; public static void Create(SpriteRenderer ren) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)ren == (Object)null)) { new GameObject("SandevistanEquip").AddComponent<EquipScene>().Init(ren); } } private void Init(SpriteRenderer ren) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or m