using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using BoplFixedMath; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Events; [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("Guadana")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Bopl Battle scythe. Slash a rift, reposition for 3s while invincible, die if you land in a platform.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Guadana")] [assembly: AssemblyTitle("Guadana")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Guadana { public static class AbilityApiClonesFix { private const string Culprit = "AbilityApi"; private static bool done; public static void Ensure() { //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown if (done) { return; } MethodInfo methodInfo = AccessTools.Method(typeof(PlayerCollision), "killPlayer", (Type[])null, (Type[])null); if (methodInfo == null) { done = true; return; } Patches patchInfo = Harmony.GetPatchInfo((MethodBase)methodInfo); if (patchInfo == null || patchInfo.Prefixes == null || patchInfo.Prefixes.Count == 0) { return; } List list = new List(); foreach (Patch prefix in patchInfo.Prefixes) { MethodInfo patchMethod = prefix.PatchMethod; if (!(patchMethod == null) && !(patchMethod.DeclaringType == null) && patchMethod.DeclaringType.FullName.Contains("AbilityApi")) { list.Add(patchMethod); } } if (list.Count == 0) { done = true; return; } Harmony val = new Harmony("guadana.abilityapi.clonefix"); foreach (MethodInfo item in list) { val.Unpatch((MethodBase)methodInfo, item); } done = true; } } public static class GuadanaAbility { public const string AbilityName = "guadaña"; public const string TemplateNameFragment = "invis"; public const string IconTextureName = "GuadanaIcon"; public const int CooldownSeconds = 8; public const int DurationSeconds = 3; public const int TicksPerSecond = 60; public const int DurationTicks = 180; public const int CrackTicks = 40; public const int SlashVisualTicks = 24; public const float HeldWorldSize = 2.4f; public const float HoldDistance = 1.2f; public const float HoldHeight = -0.05f; public const float HeldRotateFixDegrees = -35f; public const float CrackWorldSize = 6.4f; public const float FlySpeed = 31f; public const float IconFill = 0.82f; public const string SlashSound = "dash"; public static Sprite BaseIcon; public static readonly uint InvulnMask = 65536u; public static readonly Fix BoplRadius = (Fix)1.1f; public static readonly Fix PlatformPad = (Fix)0.08f; public static readonly Vector4 CircleExtents = new Vector4(0.04882813f, 0.04882813f, 0.08300781f, 0.9287109f); public static bool IsGuadana(GameObject go) { if ((Object)(object)go == (Object)null || ((Object)go).name == null) { return false; } string text = ((Object)go).name.ToLower(); if (!text.Contains("guadaña")) { return text.Contains("guadana"); } return true; } public static bool IsGuadanaIcon(Sprite sprite) { if ((Object)(object)sprite != (Object)null && (Object)(object)sprite.texture != (Object)null) { return ((Object)sprite.texture).name == "GuadanaIcon"; } return false; } public static Vec2 AimOf(int playerId) { //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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_0051: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) PlayerHandler val = PlayerHandler.Get(); Player val2 = ((val == null) ? null : val.GetPlayer(playerId)); if (val2 == null) { return new Vec2(Fix.One, Fix.Zero); } Vec2 val3 = val2.AimVector(); if (Vec2.Magnitude(val3) > (Fix)0.2f) { return Vec2.Normalized(val3); } return new Vec2(Fix.One, Fix.Zero); } public static Vec2 MouseOf(int playerId) { //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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) PlayerHandler val = PlayerHandler.Get(); Player val2 = ((val == null) ? null : val.GetPlayer(playerId)); if (val2 == null) { return Vec2.zero; } Vector2 mouseWorldPos = val2.mouseWorldPos; return new Vec2((Fix)mouseWorldPos.x, (Fix)mouseWorldPos.y); } public static Vec2 InputOf(int playerId) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) PlayerHandler val = PlayerHandler.Get(); Player val2 = ((val == null) ? null : val.GetPlayer(playerId)); if (val2 == null) { return Vec2.zero; } return val2.InputVector(); } public static float PlayerScale(int playerId) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) PlayerHandler val = PlayerHandler.Get(); Player val2 = ((val == null) ? null : val.GetPlayer(playerId)); if (val2 != null) { return Mathf.Max(0.01f, (float)val2.Scale); } return 1f; } public static Sprite LoadIcon(Sprite template) { //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_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) Texture2D val = LoadTexture("Guadana.AbilityIcon.png"); if ((Object)(object)val == (Object)null) { return null; } int size = 128; float pixelsPerUnit = 100f; if ((Object)(object)template != (Object)null) { Rect rect = template.rect; if (((Rect)(ref rect)).width > 8f) { rect = template.rect; size = Mathf.RoundToInt(((Rect)(ref rect)).width); } pixelsPerUnit = template.pixelsPerUnit; } Texture2D obj = BlitCentered(val, size, 0.82f); ((Object)obj).name = "GuadanaIcon"; ((Texture)obj).filterMode = (FilterMode)1; ((Texture)obj).wrapMode = (TextureWrapMode)1; obj.Apply(false, false); Sprite obj2 = Build(obj, pixelsPerUnit); ((Object)obj2).name = "guadaña"; BaseIcon = obj2; return obj2; } public static Sprite LoadHeldScythe() { Texture2D val = LoadTexture("Guadana.AbilityIcon.png"); if ((Object)(object)val == (Object)null) { return null; } ((Object)val).name = "GuadanaHeld"; return Build(val, (float)((Texture)val).width / 2.4f); } public static Sprite LoadCrackSprite() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0154: 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_0172: Unknown result type (might be due to invalid IL or missing references) int num = 72; int num2 = 220; float num3 = (float)(num - 1) * 0.5f; Texture2D val = new Texture2D(num, num2, (TextureFormat)4, false); for (int i = 0; i < num2; i++) { float num4 = (float)i / (float)(num2 - 1); float num5 = Mathf.Sin(num4 * MathF.PI); num5 = Mathf.Pow(Mathf.Max(0f, num5), 1.15f); if (num5 < 0.035f) { for (int j = 0; j < num; j++) { val.SetPixel(j, i, Color.clear); } continue; } float num6 = Mathf.Sin(num4 * 26f) * 1.6f + Mathf.Sin(num4 * 61f) * 0.7f; float num7 = num5 * 10.5f + num6 * num5 * 0.4f; float num8 = 3.1f; for (int k = 0; k < num; k++) { float num9 = Mathf.Abs((float)k - num3); if (num9 > num7 + num8) { val.SetPixel(k, i, Color.clear); } else if (num9 > num7) { float num10 = 1f - (num9 - num7) / num8; float num11 = Mathf.Pow(Mathf.Clamp01(num10), 0.7f) * num5; Color val2 = Color.Lerp(new Color(0.45f, 0.32f, 0.85f, num11 * 0.8f), new Color(0.95f, 0.93f, 1f, num11), Mathf.Clamp01(num10 * 1.35f)); val.SetPixel(k, i, val2); } else { float num12 = 1f - num9 / Mathf.Max(num7, 0.001f); float num13 = Mathf.Lerp(0.82f, 1f, num12) * Mathf.Clamp01(num5 * 1.4f); Color val3 = Color.Lerp(new Color(0.06f, 0.02f, 0.12f, num13), new Color(0f, 0f, 0f, num13), num12); val.SetPixel(k, i, val3); } } } ((Texture)val).filterMode = (FilterMode)1; ((Texture)val).wrapMode = (TextureWrapMode)1; val.Apply(false, false); ((Object)val).name = "GuadanaCrack"; return Build(val, (float)num2 / 6.4f); } private static Texture2D BlitCentered(Texture2D source, int size, float fill) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(size, size, (TextureFormat)4, false); Color[] pixels = (Color[])(object)new Color[size * size]; val.SetPixels(pixels); int num = Mathf.Max(1, Mathf.RoundToInt((float)size * fill)); Color[] pixels2 = source.GetPixels(); int width = ((Texture)source).width; int height = ((Texture)source).height; float num2 = (float)width / (float)height; int num3 = num; int num4 = num; if (num2 > 1f) { num4 = Mathf.Max(1, Mathf.RoundToInt((float)num / num2)); } else { num3 = Mathf.Max(1, Mathf.RoundToInt((float)num * num2)); } int num5 = (size - num3) / 2; int num6 = (size - num4) / 2; for (int i = 0; i < num4; i++) { int num7 = Mathf.Clamp(i * height / num4, 0, height - 1); for (int j = 0; j < num3; j++) { int num8 = Mathf.Clamp(j * width / num3, 0, width - 1); Color val2 = pixels2[num7 * width + num8]; if (!(val2.a < 0.05f)) { val.SetPixel(num5 + j, num6 + i, val2); } } } return val; } private static Sprite Build(Texture2D texture, float pixelsPerUnit) { //IL_0027: 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) ((Texture)texture).filterMode = (FilterMode)1; ((Texture)texture).wrapMode = (TextureWrapMode)1; return Sprite.Create(texture, new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), new Vector2(0.5f, 0.5f), pixelsPerUnit, 0u, (SpriteMeshType)0); } internal static Texture2D LoadTexture(string resourceName, bool stripBackground = true) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName); if (stream == null) { Plugin.Log.LogError((object)("Guadana: embedded resource '" + resourceName + "' not found.")); return null; } byte[] array; using (MemoryStream memoryStream = new MemoryStream()) { stream.CopyTo(memoryStream); array = memoryStream.ToArray(); } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(val, array)) { Plugin.Log.LogError((object)("Guadana: '" + resourceName + "' failed to decode as a PNG.")); return null; } if (stripBackground) { StripBackground(val); } val.Apply(false, false); return val; } private static void StripBackground(Texture2D texture) { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) int w = ((Texture)texture).width; int h = ((Texture)texture).height; Color[] pixels = texture.GetPixels(); bool[] seen = new bool[pixels.Length]; Queue queue = new Queue(); for (int i = 0; i < w; i++) { Try(i, 0); Try(i, h - 1); } for (int j = 0; j < h; j++) { Try(0, j); Try(w - 1, j); } while (queue.Count > 0) { int num = queue.Dequeue(); pixels[num] = Color.clear; int num2 = num % w; int num3 = num / w; Try(num2 + 1, num3); Try(num2 - 1, num3); Try(num2, num3 + 1); Try(num2, num3 - 1); } texture.SetPixels(pixels); void Try(int x, int y) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (x >= 0 && y >= 0 && x < w && y < h) { int num4 = y * w + x; if (!seen[num4] && IsBackdrop(pixels[num4])) { seen[num4] = true; queue.Enqueue(num4); } } } } private static bool IsBackdrop(Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_002b: 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_0037: Unknown result type (might be due to invalid IL or missing references) if (color.a < 0.08f) { return true; } float num = Mathf.Max(color.r, Mathf.Max(color.g, color.b)); float num2 = Mathf.Min(color.r, Mathf.Min(color.g, color.b)); if (num - num2 < 0.12f) { return num2 > 0.55f; } return false; } } internal static class GuadanaHud { private const float RestScale = 0.7f; private const float FallbackRatio = 0.7f; private static float vanillaWorldSize; public static void RememberIncoming(Sprite sprite) { RememberSprite(sprite); } public static void RememberVanilla(AbilityReadyIndicator indicator) { if ((Object)(object)indicator == (Object)null) { return; } SpriteRenderer spriteRen = indicator.GetSpriteRen(); RememberSprite((spriteRen != null) ? spriteRen.sprite : null); FollowTransform component = ((Component)indicator).GetComponent(); if ((Object)(object)component == (Object)null || (Object)(object)component.Leader == (Object)null) { return; } SlimeController component2 = ((Component)component.Leader).GetComponent(); if ((Object)(object)component2 == (Object)null || component2.AbilityReadyIndicators == null) { return; } for (int i = 0; i < component2.AbilityReadyIndicators.Length; i++) { AbilityReadyIndicator val = component2.AbilityReadyIndicators[i]; if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)indicator)) { SpriteRenderer spriteRen2 = val.GetSpriteRen(); RememberSprite((spriteRen2 != null) ? spriteRen2.sprite : null); } } } public static void Tick(SlimeController slime) { if (!((Object)(object)slime == (Object)null) && slime.AbilityReadyIndicators != null) { for (int i = 0; i < slime.AbilityReadyIndicators.Length; i++) { Apply(slime.AbilityReadyIndicators[i]); } } } public static void Apply(AbilityReadyIndicator indicator) { //IL_007e: 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_0092: 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_00dc: 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) if ((Object)(object)indicator == (Object)null || (Object)(object)GuadanaAbility.BaseIcon == (Object)null) { return; } SpriteRenderer spriteRen = indicator.GetSpriteRen(); if (!((Object)(object)spriteRen == (Object)null) && GuadanaAbility.IsGuadanaIcon(spriteRen.sprite)) { Transform val = ((Component)indicator).transform.Find("GuadanaTeamRing"); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)((Component)val).gameObject); } spriteRen.sprite = GuadanaAbility.BaseIcon; if ((Object)(object)((Renderer)spriteRen).material != (Object)null) { ((Renderer)spriteRen).material.SetVector("_CircleExtents", Vector4.zero); Rect textureRect = GuadanaAbility.BaseIcon.textureRect; Vector2 center = ((Rect)(ref textureRect)).center; center.x /= ((Texture)GuadanaAbility.BaseIcon.texture).width; center.y /= ((Texture)GuadanaAbility.BaseIcon.texture).height; ((Renderer)spriteRen).material.SetVector("_SpriteCenter", Vector4.op_Implicit(center)); } indicator.extraScale = ExtraScale(GuadanaAbility.BaseIcon); } } private static void RememberSprite(Sprite sprite) { //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_001b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)sprite == (Object)null) && !GuadanaAbility.IsGuadanaIcon(sprite)) { Bounds bounds = sprite.bounds; float x = ((Bounds)(ref bounds)).size.x; if (x > 0.01f) { vanillaWorldSize = x; } } } private static float ExtraScale(Sprite sprite) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) Bounds bounds = sprite.bounds; float x = ((Bounds)(ref bounds)).size.x; float num = 0.7f; if (vanillaWorldSize > 0.01f && x > 0.001f) { num = Mathf.Min(num, vanillaWorldSize / x); } return 0.7f * num - 0.7f; } } [HarmonyPatch(typeof(AbilityGrid), "Awake")] public static class GuadanaInjectionPatch { private static bool hasInjected; public static void Prefix(AbilityGrid __instance) { //IL_0032: 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_0050: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_00b4: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0153: 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) if (hasInjected) { return; } NamedSpriteList abilityIcons = __instance.abilityIcons; if ((Object)(object)abilityIcons == (Object)null || abilityIcons.sprites == null) { Plugin.Log.LogWarning((object)"Guadana: AbilityGrid.abilityIcons was empty this Awake; not injecting yet (will retry on the next grid build)."); return; } NamedSprite val = default(NamedSprite); bool flag = false; foreach (NamedSprite sprite in abilityIcons.sprites) { if (sprite.name != null && sprite.name.ToLower().Contains("invis")) { val = sprite; flag = true; break; } } if (!flag || (Object)(object)val.associatedGameObject == (Object)null) { Plugin.Log.LogError((object)"Guadana: could not find a native instant ability to clone, so the scythe was not added. (Looked for an ability whose name contains 'invis'.)"); return; } GameObject val2 = Object.Instantiate(val.associatedGameObject); Object.DontDestroyOnLoad((Object)(object)val2); ((Object)val2).name = "guadaña"; StripTemplateEffect(val2); InstantAbility component = val2.GetComponent(); if ((Object)(object)component == (Object)null) { Plugin.Log.LogError((object)"Guadana: the cloned ability has no InstantAbility component."); return; } component.SetCoolDown((Fix)8L); component.AudioOnCast = ""; Sprite val3 = GuadanaAbility.LoadIcon(val.sprite) ?? val.sprite; abilityIcons.sprites.Add(new NamedSprite("guadaña", val3, val2, true)); hasInjected = true; Plugin.Log.LogInfo((object)("Guadana: ability injected (cloned '" + val.name + "', " + $"rift {3}s, cooldown {8}s after exit).")); } private static void StripTemplateEffect(GameObject clone) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown InstantAbility component = clone.GetComponent(); if ((Object)(object)component != (Object)null) { component.funcOnEnter = new UnityEvent(); component.isInvisibilty = false; component.EffectOnEnter = null; } Invisibility component2 = clone.GetComponent(); if ((Object)(object)component2 != (Object)null) { Object.Destroy((Object)(object)component2); } SpriteRenderer[] componentsInChildren = clone.GetComponentsInChildren(true); foreach (SpriteRenderer obj in componentsInChildren) { obj.sprite = null; ((Renderer)obj).enabled = false; } } } [HarmonyPatch(typeof(AbilityReadyIndicator), "SetSprite")] public static class GuadanaCirclePatch { public static void Prefix(AbilityReadyIndicator __instance, Sprite sprite) { GuadanaHud.RememberVanilla(__instance); GuadanaHud.RememberIncoming(sprite); } [HarmonyPriority(0)] public static void Postfix(AbilityReadyIndicator __instance, Sprite sprite) { if (GuadanaAbility.IsGuadanaIcon(sprite)) { GuadanaHud.Apply(__instance); } } } [HarmonyPatch(typeof(AbilityReadyIndicator), "SetColor")] public static class GuadanaCircleColorPatch { [HarmonyPriority(0)] public static void Postfix(AbilityReadyIndicator __instance) { GuadanaHud.Apply(__instance); } } [HarmonyPatch(typeof(InstantAbility), "EnterAbility")] public static class GuadanaCastPatch { public static void Postfix(InstantAbility __instance) { if (GuadanaAbility.IsGuadana(((Component)__instance).gameObject)) { SpriteRenderer[] componentsInChildren = ((Component)__instance).GetComponentsInChildren(true); foreach (SpriteRenderer obj in componentsInChildren) { obj.sprite = null; ((Renderer)obj).enabled = false; } RiftState.Cast(__instance.playerInfo.playerId, __instance.playerInfo.AbilityButtonUsedIndex012); } } } [HarmonyPatch(typeof(Updater), "TickSimulation")] public static class GuadanaTickPatch { public static void Postfix() { AbilityApiClonesFix.Ensure(); RiftState.Tick(); } } [HarmonyPatch(typeof(SlimeController), "OldUpdate")] public static class GuadanaCooldownHoldPatch { public static void Postfix(SlimeController __instance) { UniqueGuadanaSlots.FreezeIfActive(__instance); GuadanaHud.Tick(__instance); if (RiftState.IsActive(__instance.GetPlayerId())) { RiftVisuals.SetHudVisible(__instance.GetPlayerId(), visible: false); } } } [HarmonyPatch(typeof(SlimeController), "LateUpdate")] public static class GuadanaInvisPatch { public static void Postfix(SlimeController __instance) { //IL_002c: 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_0051: Unknown result type (might be due to invalid IL or missing references) if (RiftState.IsActive(__instance.GetPlayerId())) { SpriteRenderer playerSprite = __instance.GetPlayerSprite(); if (!((Object)(object)playerSprite == (Object)null)) { Player val = PlayerBodies.PlayerOf(__instance.GetPlayerId()); Color color = playerSprite.color; color.a = ((val != null && val.IsLocalPlayer) ? 0.2f : 0f); playerSprite.color = color; } } } } [HarmonyPatch(typeof(SlimeController), "AddAbility")] public static class GuadanaAddAbilityPatch { public static void Prefix(ref AbilityMonoBehaviour ability) { ability = UniqueGuadanaSlots.CloneIfGuadana(ability); } } [HarmonyPatch(typeof(SlimeController), "AddAdditionalAbility")] public static class GuadanaAddAdditionalAbilityPatch { public static void Prefix(ref AbilityMonoBehaviour ability) { ability = UniqueGuadanaSlots.CloneIfGuadana(ability); } } [HarmonyPatch(typeof(SlimeController), "isAbilityCastable")] public static class GuadanaCastablePatch { public static bool Prefix(SlimeController __instance, ref bool __result) { if (!RiftState.IsActive(__instance.GetPlayerId())) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(PlayerPhysics), "Move")] public static class GuadanaMovePatch { public static bool Prefix(PlayerPhysics __instance) { return !RiftState.IsActive(__instance); } } [HarmonyPatch(typeof(PlayerPhysics), "AddGravityFactor")] public static class GuadanaGravityPatch { public static bool Prefix(PlayerPhysics __instance) { return !RiftState.IsActive(__instance); } } [HarmonyPatch(typeof(PlayerPhysics), "CollisionRaycasts")] public static class GuadanaCollisionPatch { public static bool Prefix(PlayerPhysics __instance, ref bool __result) { if (!RiftState.IsActive(__instance)) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(PlayerPhysics), "VelocityBasedRaycasts")] public static class GuadanaVelocityRayPatch { public static bool Prefix(PlayerPhysics __instance, ref bool __result) { if (!RiftState.IsActive(__instance)) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(PlayerPhysics), "Jump")] public static class GuadanaPhysicsJumpPatch { public static bool Prefix(PlayerPhysics __instance) { return !RiftState.IsActive(__instance); } } [HarmonyPatch(typeof(SlimeController), "Jump")] public static class GuadanaSlimeJumpPatch { public static bool Prefix(SlimeController __instance) { return !RiftState.IsActive(__instance.GetPlayerId()); } } [HarmonyPatch(typeof(PlayerPhysics), "AttachToGround")] public static class GuadanaAttachPatch { public static bool Prefix(PlayerPhysics __instance) { return !RiftState.IsActive(__instance); } } [HarmonyPatch(typeof(PlayerPhysics), "CollideWithGround")] public static class GuadanaCollidePatch { public static bool Prefix(PlayerPhysics __instance) { return !RiftState.IsActive(__instance); } } [HarmonyPatch(typeof(PlayerHandler), "ResetForNextStage")] public static class GuadanaResetPatch { public static void Prefix() { RiftState.ForgetAll(); } } [HarmonyPatch(typeof(Updater), "PreLevelLoad")] public static class GuadanaLevelLoadPatch { public static void Prefix() { RiftState.ForgetAll(); } } internal static class PlayerBodies { public static List PositionsOf(int playerId) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) List list = new List(); PlayerCollision[] array = Object.FindObjectsOfType(); foreach (PlayerCollision val in array) { if (IsLive(val) && val.GetPlayerId() == playerId) { FixTransform component = ((Component)val).GetComponent(); if ((Object)(object)component != (Object)null && !component.IsDestroyed) { list.Add(component.position); } } } return list; } public static bool IsAlive(int playerId) { return PositionsOf(playerId).Count > 0; } public static PlayerPhysics PhysicsOf(int playerId) { PlayerCollision val = CollisionOf(playerId); if (!((Object)(object)val == (Object)null)) { return ((Component)val).GetComponent(); } return null; } public static PlayerCollision CollisionOf(int playerId) { PlayerCollision[] array = Object.FindObjectsOfType(); foreach (PlayerCollision val in array) { if (IsLive(val) && val.GetPlayerId() == playerId) { return val; } } return null; } public static PlayerBody BodyOf(int playerId) { PlayerCollision val = CollisionOf(playerId); if (!((Object)(object)val == (Object)null)) { return ((Component)val).GetComponent(); } return null; } public static Fix RadiusOf(int playerId) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) PlayerPhysics val = PhysicsOf(playerId); if ((Object)(object)val != (Object)null && val.radius > Fix.Zero) { return val.radius; } return GuadanaAbility.BoplRadius; } public static SlimeController SlimeOf(int playerId) { SlimeController[] array = Object.FindObjectsOfType(); foreach (SlimeController val in array) { if ((Object)(object)val != (Object)null && val.GetPlayerId() == playerId) { return val; } } return null; } public static Player PlayerOf(int playerId) { PlayerHandler val = PlayerHandler.Get(); if (val != null) { return val.GetPlayer(playerId); } return null; } public static int PlayerIdOf(PlayerPhysics physics) { if ((Object)(object)physics == (Object)null) { return -1; } IPlayerIdHolder val = ((Component)physics).GetComponent() ?? ((Component)physics).GetComponentInParent(); if (val != null) { return val.GetPlayerId(); } return -1; } public static bool IsLive(PlayerCollision collision) { if ((Object)(object)collision != (Object)null && !((MonoUpdatable)collision).IsDestroyed) { return ((Component)collision).gameObject.activeInHierarchy; } return false; } public static void KillSelf(int playerId) { PlayerCollision val = CollisionOf(playerId); if (!((Object)(object)val == (Object)null)) { val.SetInvulnerable(false, GuadanaAbility.InvulnMask); val.killPlayer(playerId, true, true, (CauseOfDeath)0); } } } [BepInPlugin("com.solsticio.boplbattle.guadana", "Guadaña", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "com.solsticio.boplbattle.guadana"; public const string PluginName = "Guadaña"; public const string PluginVersion = "1.0.0"; internal static ManualLogSource Log; private void Awake() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)"Guadana: loading..."); new Harmony("com.solsticio.boplbattle.guadana").PatchAll(); Log.LogInfo((object)($"Guadana: loaded (rift {3}s, " + $"cooldown {8}s after exit).")); } } internal static class RiftState { internal sealed class Rift { public int playerId; public int abilitySlot = -1; public int ticksLeft; public int holdArmedTicks; } private static readonly List live = new List(); private static readonly Fix Step = (Fix)(31f / 60f); public static bool IsActive(int playerId) { return Find(playerId) != null; } public static bool IsActive(PlayerPhysics physics) { int num = PlayerBodies.PlayerIdOf(physics); if (num >= 0) { return IsActive(num); } return false; } public static int ActiveSlot(int playerId) { return Find(playerId)?.abilitySlot ?? (-1); } public static void Cast(int playerId, int abilitySlot) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_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_0075: 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) if (Find(playerId) == null) { PlayerPhysics val = PlayerBodies.PhysicsOf(playerId); PlayerBody val2 = PlayerBodies.BodyOf(playerId); if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null)) { Vec2 position = val2.position; Vec2 aim = GuadanaAbility.AimOf(playerId); Rift rift = new Rift { playerId = playerId, abilitySlot = abilitySlot, ticksLeft = 180, holdArmedTicks = 2 }; live.Add(rift); Enter(rift, val, val2); RiftVisuals.Slash(playerId, position, aim); RiftVisuals.SetHudVisible(playerId, visible: false); SetInvisible(playerId, hidden: true); } } } public static void Tick() { for (int num = live.Count - 1; num >= 0; num--) { Rift rift = live[num]; if (!PlayerBodies.IsAlive(rift.playerId)) { Cleanup(rift, restorePhysics: false); live.RemoveAt(num); continue; } Steer(rift); RiftVisuals.SetHudVisible(rift.playerId, visible: false); if (rift.holdArmedTicks > 0) { rift.holdArmedTicks--; } else if (!IsHolding(rift)) { Exit(num, timedOut: false); continue; } rift.ticksLeft--; if (rift.ticksLeft <= 0) { Exit(num, timedOut: true); } } RiftVisuals.Tick(); } public static void ForgetAll() { for (int i = 0; i < live.Count; i++) { Cleanup(live[i], restorePhysics: false); } live.Clear(); RiftVisuals.DestroyAll(); } private static void Enter(Rift rift, PlayerPhysics physics, PlayerBody body) { //IL_0009: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) physics.UnGround(true, false); physics.groundedSpeed = Fix.Zero; body.selfImposedVelocity = Vec2.zero; body.externalVelocity = Vec2.zero; PlayerCollision val = PlayerBodies.CollisionOf(rift.playerId); if ((Object)(object)val != (Object)null) { val.SetInvulnerable(true, GuadanaAbility.InvulnMask); } SetCircleEnabled(physics, enabled: false); } private static void Steer(Rift rift) { //IL_003c: 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) //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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) PlayerPhysics val = PlayerBodies.PhysicsOf(rift.playerId); PlayerBody val2 = PlayerBodies.BodyOf(rift.playerId); if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null)) { if (val.IsGrounded()) { val.UnGround(false, false); } val.groundedSpeed = Fix.Zero; val2.selfImposedVelocity = Vec2.zero; val2.externalVelocity = Vec2.zero; val2.position = NextPos(rift.playerId, val2.position); } } private static Vec2 NextPos(int playerId, Vec2 pos) { //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_0007: 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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0049: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_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_0061: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) Vec2 val = Vec2.zero; Vec2 val2 = GuadanaAbility.InputOf(playerId); if (Vec2.Magnitude(val2) > (Fix)0.2f) { val += Vec2.Normalized(val2); } Vec2 val3 = GuadanaAbility.MouseOf(playerId) - pos; if (Vec2.SqrMagnitude(val3) > (Fix)0.04f) { val += Vec2.Normalized(val3); } if (Vec2.SqrMagnitude(val) <= Fix.Zero) { return pos; } return pos + Vec2.Normalized(val) * Step; } private static void Exit(int index, bool timedOut) { //IL_0029: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) Rift rift = live[index]; PlayerBody val = PlayerBodies.BodyOf(rift.playerId); Vec2 val2 = (((Object)(object)val != (Object)null) ? val.position : Vec2.zero); Vec2 aim = GuadanaAbility.AimOf(rift.playerId); RiftVisuals.Slash(rift.playerId, val2, aim); bool flag = (Object)(object)val != (Object)null && OverlapsPlatform(val2, PlayerBodies.RadiusOf(rift.playerId)); Cleanup(rift, restorePhysics: true); live.RemoveAt(index); if (timedOut || flag) { PlayerBodies.KillSelf(rift.playerId); } } private static void Cleanup(Rift rift, bool restorePhysics) { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0059: Unknown result type (might be due to invalid IL or missing references) RiftVisuals.SetHudVisible(rift.playerId, visible: true); SetInvisible(rift.playerId, hidden: false); PlayerCollision val = PlayerBodies.CollisionOf(rift.playerId); if ((Object)(object)val != (Object)null) { val.SetInvulnerable(false, GuadanaAbility.InvulnMask); } PlayerPhysics val2 = PlayerBodies.PhysicsOf(rift.playerId); if ((Object)(object)val2 != (Object)null) { SetCircleEnabled(val2, enabled: true); if (restorePhysics) { val2.groundedSpeed = Fix.Zero; } } PlayerBody val3 = PlayerBodies.BodyOf(rift.playerId); if ((Object)(object)val3 != (Object)null) { val3.selfImposedVelocity = Vec2.zero; val3.externalVelocity = Vec2.zero; } } private static bool OverlapsPlatform(Vec2 pos, Fix radius) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_0051: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_0065: Unknown result type (might be due to invalid IL or missing references) Fix val = radius + GuadanaAbility.PlatformPad; Fix val2 = val * val; StickyRoundedRectangle[] array = Object.FindObjectsOfType(); foreach (StickyRoundedRectangle val3 in array) { if ((Object)(object)val3 == (Object)null) { continue; } GameObject val4 = val3.ThisGameObject(); if (!((Object)(object)val4 == (Object)null) && val4.activeInHierarchy) { if (val3.ContainsPoint(pos)) { return true; } Vec2 closestPoint = val3.GetClosestPoint(pos); if (Vec2.SqrMagnitude(pos - closestPoint) <= val2) { return true; } } } return false; } private static bool IsHolding(Rift rift) { PlayerHandler val = PlayerHandler.Get(); Player val2 = ((val == null) ? null : val.GetPlayer(rift.playerId)); if (val2 != null) { return val2.AbilityButtonIsDown(rift.abilitySlot); } return false; } private static Rift Find(int playerId) { for (int i = 0; i < live.Count; i++) { if (live[i].playerId == playerId) { return live[i]; } } return null; } private static void SetCircleEnabled(PlayerPhysics physics, bool enabled) { DPhysicsCircle component = ((Component)physics).GetComponent(); if ((Object)(object)component != (Object)null) { ((IPhysicsCollider)component).enabled = enabled; } } private static void SetInvisible(int playerId, bool hidden) { //IL_0016: 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) Player val = PlayerBodies.PlayerOf(playerId); if (val != null) { val.isInvisible = hidden; if (hidden) { val.timeSpentInvisible = Fix.Zero; val.timeSinceEnteredAbility = Fix.Zero; } } } } internal static class RiftVisuals { private sealed class Fx { public GameObject go; public int ticksLeft; public bool follow; public int playerId; } private static readonly List live = new List(); private static Sprite heldSprite; private static Sprite crackSprite; public static void Slash(int playerId, Vec2 origin, Vec2 aim) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) SpawnCrack(origin, aim); SpawnScythe(playerId); AudioManager obj = AudioManager.Get(); if (obj != null) { obj.Play("dash"); } } public static void SetHudVisible(int playerId, bool visible) { SlimeController val = PlayerBodies.SlimeOf(playerId); if ((Object)(object)val == (Object)null || val.AbilityReadyIndicators == null) { return; } for (int i = 0; i < val.AbilityReadyIndicators.Length; i++) { AbilityReadyIndicator val2 = val.AbilityReadyIndicators[i]; if (!((Object)(object)val2 == (Object)null)) { ((Component)val2).gameObject.SetActive(visible); if (visible) { val2.InstantlySyncTransform(); } } } } public static void Tick() { //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_0096: Unknown result type (might be due to invalid IL or missing references) for (int num = live.Count - 1; num >= 0; num--) { Fx fx = live[num]; fx.ticksLeft--; if ((Object)(object)fx.go != (Object)null && fx.ticksLeft > 0) { if (fx.follow) { PlaceScythe(fx.go, fx.playerId); } SpriteRenderer component = fx.go.GetComponent(); if ((Object)(object)component != (Object)null && fx.ticksLeft <= 6) { Color color = component.color; color.a = (float)fx.ticksLeft / 6f; component.color = color; } } if (fx.ticksLeft <= 0) { if ((Object)(object)fx.go != (Object)null) { Object.Destroy((Object)(object)fx.go); } live.RemoveAt(num); } } } public static void DestroyAll() { foreach (Fx item in live) { if ((Object)(object)item.go != (Object)null) { Object.Destroy((Object)(object)item.go); } } live.Clear(); } private static void SpawnCrack(Vec2 origin, Vec2 aim) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //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_00cb: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)crackSprite == (Object)null) { crackSprite = GuadanaAbility.LoadCrackSprite(); } if (!((Object)(object)crackSprite == (Object)null)) { GameObject val = new GameObject("GuadanaCrack"); SpriteRenderer obj = val.AddComponent(); obj.sprite = crackSprite; obj.color = Color.white; ((Renderer)obj).sortingOrder = 90; val.transform.position = new Vector3((float)origin.x, (float)origin.y, 0f); val.transform.localScale = Vector3.one; float num = Mathf.Atan2((float)aim.y, (float)aim.x) * 57.29578f - 90f; val.transform.rotation = Quaternion.Euler(0f, 0f, num); live.Add(new Fx { go = val, ticksLeft = 40, follow = false, playerId = -1 }); } } private static void SpawnScythe(int playerId) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)heldSprite == (Object)null) { heldSprite = GuadanaAbility.LoadHeldScythe(); } if (!((Object)(object)heldSprite == (Object)null)) { GameObject val = new GameObject("GuadanaHeld"); SpriteRenderer obj = val.AddComponent(); obj.sprite = heldSprite; obj.color = Color.white; ((Renderer)obj).sortingOrder = 80; PlaceScythe(val, playerId); live.Add(new Fx { go = val, ticksLeft = 24, follow = true, playerId = playerId }); } } private static void PlaceScythe(GameObject go, int playerId) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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_00b7: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_0132: Unknown result type (might be due to invalid IL or missing references) SpriteRenderer val = FindPlayerSprite(playerId); Vec2 val2 = GuadanaAbility.AimOf(playerId); float num = GuadanaAbility.PlayerScale(playerId); int sortingLayerID = 0; int sortingOrder = 80; Vector3 position = default(Vector3); if ((Object)(object)val != (Object)null) { position = ((Component)val).transform.position; sortingLayerID = ((Renderer)val).sortingLayerID; sortingOrder = ((Renderer)val).sortingOrder + 2; } else { List list = PlayerBodies.PositionsOf(playerId); if (list.Count == 0) { return; } ((Vector3)(ref position))..ctor((float)list[0].x, (float)list[0].y, 0f); } Vector3 val3 = new Vector3((float)val2.x, (float)val2.y, 0f) * (1.2f * num); val3.y += -0.05f * num; go.transform.position = position + val3; float num2 = Mathf.Atan2((float)val2.y, (float)val2.x) * 57.29578f + -35f; go.transform.rotation = Quaternion.Euler(0f, 0f, num2); go.transform.localScale = new Vector3(num, num, 1f); SpriteRenderer component = go.GetComponent(); if ((Object)(object)component != (Object)null) { ((Renderer)component).sortingLayerID = sortingLayerID; ((Renderer)component).sortingOrder = sortingOrder; } } private static SpriteRenderer FindPlayerSprite(int playerId) { SlimeController[] array = Object.FindObjectsOfType(); foreach (SlimeController val in array) { if (val.GetPlayerId() == playerId) { SpriteRenderer playerSprite = val.GetPlayerSprite(); if ((Object)(object)playerSprite != (Object)null && ((Component)playerSprite).gameObject.activeInHierarchy) { return playerSprite; } } } return null; } } internal static class UniqueGuadanaSlots { private static readonly FieldInfo TimersField = AccessTools.Field(typeof(SlimeController), "abilityCooldownTimers"); public static void Ensure(SlimeController slime) { if ((Object)(object)slime == (Object)null || slime.abilities == null) { return; } HashSet hashSet = new HashSet(); for (int i = 0; i < slime.abilities.Count; i++) { AbilityMonoBehaviour val = slime.abilities[i]; if ((Object)(object)val == (Object)null || !GuadanaAbility.IsGuadana(((Component)val).gameObject)) { continue; } int instanceID = ((Object)val).GetInstanceID(); if (!hashSet.Add(instanceID)) { InstantAbility val2 = Clone(val); if ((Object)(object)val2 != (Object)null) { slime.abilities[i] = (AbilityMonoBehaviour)(object)val2; } } } } public static AbilityMonoBehaviour CloneIfGuadana(AbilityMonoBehaviour ability) { if ((Object)(object)ability == (Object)null || !GuadanaAbility.IsGuadana(((Component)ability).gameObject)) { return ability; } return (AbilityMonoBehaviour)(((object)Clone(ability)) ?? ((object)ability)); } public static void FreezeIfActive(SlimeController slime) { //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) if ((Object)(object)slime == (Object)null) { return; } Ensure(slime); int num = RiftState.ActiveSlot(slime.GetPlayerId()); if (num < 0 || slime.abilities == null || TimersField == null || num >= slime.abilities.Count) { return; } AbilityMonoBehaviour val = slime.abilities[num]; if ((Object)(object)val == (Object)null || !GuadanaAbility.IsGuadana(((Component)val).gameObject) || !(TimersField.GetValue(slime) is Fix[] array) || num >= array.Length) { return; } array[num] = Fix.Zero; if (slime.AbilityReadyIndicators != null && num < slime.AbilityReadyIndicators.Length) { AbilityReadyIndicator val2 = slime.AbilityReadyIndicators[num]; if ((Object)(object)val2 != (Object)null) { val2.SetCooldownProgress(0f); } } } private static InstantAbility Clone(AbilityMonoBehaviour ability) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) GameObject obj = Object.Instantiate(((Component)ability).gameObject); Object.DontDestroyOnLoad((Object)(object)obj); ((Object)obj).name = "guadaña"; InstantAbility component = obj.GetComponent(); if ((Object)(object)component != (Object)null) { component.SetCoolDown((Fix)8L); component.AudioOnCast = ""; } return component; } } }