Due to update 2.4.3, some mods may no longer function. FixedConfig may be necessary.
Decompiled source of BoplBotl v1.1.0
BoplBotl.dll
Decompiled 3 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.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using BoplFixedMath; using HarmonyLib; using Steamworks; using Steamworks.Data; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("BoplBotl")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BoplBotl")] [assembly: AssemblyTitle("BoplBotl")] [assembly: AssemblyVersion("1.0.0.0")] namespace BoplBotl; internal enum AbilityUse { Attack, Escape, Self, Never } internal enum AbilityAim { AtTarget, AwayFromTarget, Up, Down, None } internal class AbilityProfile { public AbilityUse Use; public AbilityAim Aim; public Fix MinRange = Fix.Zero; public Fix MaxRange = (Fix)25L; public int HoldTicks = 20; public Fix Lob = Fix.Zero; public bool NeedsSight = true; } internal static class AbilityProfiles { private static readonly AbilityProfile Default = new AbilityProfile(); private static readonly Dictionary<string, AbilityProfile> Profiles = new Dictionary<string, AbilityProfile> { ["bow"] = new AbilityProfile { MaxRange = (Fix)45L, HoldTicks = 40, Lob = (Fix)0.12f }, ["grenade"] = new AbilityProfile { MaxRange = (Fix)30L, HoldTicks = 25, Lob = (Fix)0.35f, NeedsSight = false }, ["rock"] = new AbilityProfile { MaxRange = (Fix)25L, HoldTicks = 20, Lob = (Fix)0.25f }, ["throw"] = new AbilityProfile { MaxRange = (Fix)25L, HoldTicks = 20, Lob = (Fix)0.2f }, ["missile"] = new AbilityProfile { MaxRange = (Fix)60L, HoldTicks = 90, NeedsSight = false }, ["black hole"] = new AbilityProfile { MaxRange = (Fix)25L, HoldTicks = 30 }, ["beam"] = new AbilityProfile { MaxRange = (Fix)60L, HoldTicks = 40 }, ["blink gun"] = new AbilityProfile { MaxRange = (Fix)40L, HoldTicks = 5 }, ["shrink ray"] = new AbilityProfile { MaxRange = (Fix)40L, HoldTicks = 5 }, ["growth ray"] = new AbilityProfile { MaxRange = (Fix)40L, HoldTicks = 5 }, ["duplicator"] = new AbilityProfile { MaxRange = (Fix)40L, HoldTicks = 5 }, ["magnet gun"] = new AbilityProfile { MaxRange = (Fix)30L, HoldTicks = 30 }, ["gust"] = new AbilityProfile { MaxRange = (Fix)12L, HoldTicks = 5 }, ["push"] = new AbilityProfile { MaxRange = (Fix)10L, HoldTicks = 5 }, ["spike"] = new AbilityProfile { MaxRange = (Fix)8L, HoldTicks = 5, Aim = AbilityAim.None }, ["tesla coil"] = new AbilityProfile { MaxRange = (Fix)15L, HoldTicks = 5, Aim = AbilityAim.None, NeedsSight = false }, ["mine"] = new AbilityProfile { MaxRange = (Fix)25L, HoldTicks = 5, Aim = AbilityAim.None, NeedsSight = false }, ["meteor"] = new AbilityProfile { MaxRange = (Fix)15L, HoldTicks = 10, Aim = AbilityAim.Down, NeedsSight = false }, ["drill"] = new AbilityProfile { MaxRange = (Fix)15L, HoldTicks = 40 }, ["roll"] = new AbilityProfile { MaxRange = (Fix)15L, HoldTicks = 30 }, ["dash"] = new AbilityProfile { Use = AbilityUse.Escape, Aim = AbilityAim.AwayFromTarget, MaxRange = (Fix)6L, HoldTicks = 3 }, ["superdash"] = new AbilityProfile { Use = AbilityUse.Escape, Aim = AbilityAim.AwayFromTarget, MaxRange = (Fix)6L, HoldTicks = 3 }, ["megadash"] = new AbilityProfile { Use = AbilityUse.Escape, Aim = AbilityAim.AwayFromTarget, MaxRange = (Fix)6L, HoldTicks = 3 }, ["updash"] = new AbilityProfile { Use = AbilityUse.Escape, Aim = AbilityAim.Up, MaxRange = (Fix)6L, HoldTicks = 3 }, ["invisibility"] = new AbilityProfile { Use = AbilityUse.Escape, Aim = AbilityAim.None, MaxRange = (Fix)20L, HoldTicks = 3 }, ["smoke"] = new AbilityProfile { Use = AbilityUse.Escape, Aim = AbilityAim.None, MaxRange = (Fix)12L, HoldTicks = 3 }, ["time stop"] = new AbilityProfile { Use = AbilityUse.Self, Aim = AbilityAim.None, MaxRange = (Fix)30L, HoldTicks = 3 }, ["revival"] = new AbilityProfile { Use = AbilityUse.Self, Aim = AbilityAim.None, MaxRange = (Fix)1000L, HoldTicks = 3 }, ["bot-l"] = new AbilityProfile { Use = AbilityUse.Self, Aim = AbilityAim.None, MaxRange = (Fix)1000L, HoldTicks = 3 }, ["teleport"] = new AbilityProfile { Use = AbilityUse.Never }, ["grappling hook"] = new AbilityProfile { Use = AbilityUse.Never }, ["platform"] = new AbilityProfile { Use = AbilityUse.Never }, ["engine"] = new AbilityProfile { Use = AbilityUse.Never } }; public static AbilityProfile For(AbilityMonoBehaviour ability) { if ((Object)(object)ability == (Object)null) { return Default; } string key = ((Object)((Component)ability).gameObject).name.Replace("(Clone)", "").Trim().ToLower(); if (!Profiles.TryGetValue(key, out var value)) { return Default; } return value; } } [HarmonyPatch(typeof(AbilityGrid), "Awake")] internal static class AbilityGrid_Awake_Patch { public const string AbilityName = "Bot-L"; private const string TemplateName = "teleport"; private static readonly Fix Cooldown = (Fix)15L; private static bool _added; public static void Prefix(AbilityGrid __instance) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown //IL_00f3: 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_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) if (_added) { return; } NamedSpriteList abilityIcons = __instance.abilityIcons; if ((Object)(object)abilityIcons == (Object)null || abilityIcons.sprites == null) { return; } if (abilityIcons.sprites.Exists((NamedSprite s) => s.name == "Bot-L")) { _added = true; return; } int num = abilityIcons.sprites.FindIndex((NamedSprite s) => s.name != null && s.name.ToLower() == "teleport"); if (num < 0) { Plugin.Log.LogError((object)"Couldn't find teleport in the ability list"); return; } NamedSprite val = abilityIcons.sprites[num]; GameObject val2 = Object.Instantiate<GameObject>(val.associatedGameObject); Object.DontDestroyOnLoad((Object)(object)val2); ((Object)val2).name = "Bot-L"; InstantAbility component = val2.GetComponent<InstantAbility>(); if ((Object)(object)component == (Object)null) { Plugin.Log.LogError((object)"teleport isn't an instant ability, can't use it as a template"); Object.Destroy((Object)(object)val2); return; } component.funcOnEnter = new UnityEvent(); component.SetCoolDown(Cooldown); Sprite val3 = IconLoader.Load("BoplBotl.BotLIcon.png", val.sprite); abilityIcons.sprites.Add(new NamedSprite("Bot-L", val3, val2, true)); _added = true; Plugin.Log.LogInfo((object)("Added Bot-L (copied from " + val.name + ")")); } } [HarmonyPatch(typeof(Updater), "TickSimulation")] internal static class BotBrain { private static readonly Fix StopDistance = (Fix)14L; private static readonly Fix JumpIfTargetAbove = (Fix)5L; private static readonly Fix WaterMargin = (Fix)6L; private static readonly Fix SafeShotRadius = (Fix)4L; private static readonly Fix EyeHeight = (Fix)1L; private static readonly Fix SightSlack = (Fix)2L; private static readonly Fix LaunchTolerance = (Fix)1.5f; private static readonly Fix CloseEnough = (Fix)4L; private static readonly Fix NewGoalDistance = (Fix)3L; private static readonly Fix StuckMovePerTick = (Fix)0.02f; private const int MaxHoldTicks = 150; private const int AfterUseTicks = 20; private const int JumpCooldownTicks = 45; private const int StuckTicksBeforeJump = 20; private static readonly FieldRef<SlimeController, Fix[]> CooldownTimers = AccessTools.FieldRefAccess<SlimeController, Fix[]>("abilityCooldownTimers"); private static readonly Func<SlimeController, int, bool> IsAbilityReady = AccessTools.MethodDelegate<Func<SlimeController, int, bool>>(AccessTools.Method(typeof(SlimeController), "isAbilityReady", (Type[])null, (Type[])null), (object)null, true); private static readonly Func<SlimeController, int, bool> IsAbilityCastable = AccessTools.MethodDelegate<Func<SlimeController, int, bool>>(AccessTools.Method(typeof(SlimeController), "isAbilityCastable", (Type[])null, (Type[])null), (object)null, true); public static void Prefix() { List<int> botIds = BotManager.BotIds; List<int> ids = LobbyBots.Ids; if ((botIds.Count == 0 && ids.Count == 0) || GameSession.inMenus || (Object)(object)DetPhysics.Get() == (Object)null) { return; } if (GameSessionHandler.HasGameEnded()) { LobbyBots.ReleaseInputs(); return; } Navigator.Refresh(); for (int i = 0; i < ids.Count; i++) { if (LobbyBots.TryGet(ids[i], out var state)) { ThinkIfAlive(ids[i], state); } } for (int j = 0; j < botIds.Count; j++) { if (BotManager.TryGet(botIds[j], out var state2)) { ThinkIfAlive(botIds[j], state2); } } } private static void ThinkIfAlive(int id, BotState state) { Player player = PlayerHandler.Get().GetPlayer(id); if (player != null && player.IsAlive && !((Object)(object)state.Slime == (Object)null) && !((MonoUpdatable)state.Slime).IsDestroyed) { Think(player, state); } } private static void Think(Player bot, BotState state) { //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_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_0077: 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_009f: 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_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) //IL_00fb: 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_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_0221: 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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: 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_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: 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_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0205: 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_0161: 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_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: 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_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) if (state.ShotCooldownTicks > 0) { state.ShotCooldownTicks--; } if (state.JumpCooldownTicks > 0) { state.JumpCooldownTicks--; } Vec2 stick = Vec2.zero; bool jump = false; int num = -1; Vec2 position = bot.Position; bool flag = !((Component)state.Slime).gameObject.activeInHierarchy; bool flag2 = !flag && (Object)(object)state.Physics != (Object)null && state.Physics.IsGrounded(); Player val = FindNearestEnemy(bot, position); if (state.ActiveSlot >= 0) { state.ActiveTicks++; stick = AimFor(state.ActiveProfile, position, val); if (state.ActiveTicks < state.ActiveProfile.HoldTicks && state.ActiveTicks < 150) { num = state.ActiveSlot; } else { state.ActiveSlot = -1; state.ShotCooldownTicks = 20; } } else if (val != null && !flag) { Vec2 val2 = val.Position - position; Fix distance = Vec2.Magnitude(val2); int num2 = ((state.ShotCooldownTicks == 0) ? PickAbility(bot, state, position, val, distance) : (-1)); if (num2 >= 0) { state.ActiveSlot = num2; state.ActiveProfile = AbilityProfiles.For(state.Slime.abilities[num2]); state.ActiveTicks = 1; num = num2; stick = AimFor(state.ActiveProfile, position, val); } else if (flag2) { Navigate(state, position, val, val2, distance, ref stick, ref jump); } else { Vec2 val3 = val.Position; if ((Object)(object)state.AirGoal != (Object)null && Navigator.TryClosestPointOn(state.AirGoal, position, out var closest)) { val3 = closest; } stick = Horizontal(val3.x - position.x); } } if (!flag2 && !flag && (Object)(object)state.AirGoal == (Object)null && position.y < SceneBounds.WaterHeight + WaterMargin) { stick = Horizontal(-position.x); } if (flag2) { state.AirGoal = null; } bot.ForceSetInputProfile(false, false, jump, num == 0, num == 1, num == 2, InputProfile.JoyStickAngleByteFromVector(stick), false, false, false, false); } private static void Navigate(BotState state, Vec2 me, Player target, Vec2 toTarget, Fix distance, ref Vec2 stick, ref bool jump) { //IL_000d: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_00e0: 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_0096: 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_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_0130: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_013c: 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_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: 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_00cd: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) StickyRoundedRectangle attachedGround = state.Physics.getAttachedGround(); StickyRoundedRectangle val = Navigator.PlatformNear(target.Position, mustBeTouching: false); Navigator.Jump jump2 = null; if ((Object)(object)attachedGround != (Object)null && (Object)(object)val != (Object)null && (Object)(object)attachedGround != (Object)(object)val) { jump2 = Navigator.FirstJump(attachedGround, val, state.Physics); } if (jump2 != null) { if (Vec2.Magnitude(jump2.LaunchPos - me) < LaunchTolerance && state.JumpCooldownTicks == 0) { jump = true; state.AirGoal = jump2.To; state.JumpCooldownTicks = 45; state.StuckTicks = 0; } else { stick = WalkAround(state, attachedGround, me, jump2.LaunchPos); } } else if ((Object)(object)attachedGround != (Object)null && (Object)(object)attachedGround == (Object)(object)val) { if (distance > CloseEnough) { stick = WalkAround(state, attachedGround, me, target.Position); } } else if (distance > StopDistance) { stick = Horizontal(toTarget.x); if (toTarget.y > JumpIfTargetAbove && state.JumpCooldownTicks == 0) { jump = true; state.JumpCooldownTicks = 45; } } if (Vec2.Magnitude(stick) > Fix.Zero && Vec2.Magnitude(me - state.LastPos) < StuckMovePerTick) { state.StuckTicks++; } else { state.StuckTicks = 0; } state.LastPos = me; if (state.StuckTicks >= 20 && state.JumpCooldownTicks == 0) { jump = true; state.JumpCooldownTicks = 45; state.StuckTicks = 0; } } private static Vec2 WalkAround(BotState state, StickyRoundedRectangle platform, Vec2 me, Vec2 goal) { //IL_000a: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_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_008a: 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_00da: 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_00a6: 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) if (!Navigator.TryCenter(platform, out var center)) { return Vec2.NormalizedSafe(goal - me); } if (state.CircleDir == 0 || (Object)(object)state.CirclePlatform != (Object)(object)platform || Vec2.Magnitude(goal - state.CircleGoal) > NewGoalDistance) { Vec2 val = me - center; Vec2 val2 = goal - center; Fix val3 = val.x * val2.y - val.y * val2.x; state.CircleDir = ((!(val3 > 0L)) ? 1 : (-1)); state.CirclePlatform = platform; state.CircleGoal = goal; } Vec2 val4 = platform.currentNormal(state.Body); Vec2 val5 = default(Vec2); ((Vec2)(ref val5))..ctor(val4.y, -val4.x); if (state.CircleDir <= 0) { return -val5; } return val5; } private static Vec2 Horizontal(Fix dx) { //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_000b: 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_0017: 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_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_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) if (Fix.Abs(dx) < (Fix)0.3f) { return Vec2.zero; } return new Vec2((dx > 0L) ? Fix.One : (-Fix.One), Fix.Zero); } private static Player FindNearestEnemy(Player bot, Vec2 me) { //IL_000d: 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_003a: 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_0040: 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_004a: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) List<Player> list = PlayerHandler.Get().PlayerList(); Player val = null; Fix val2 = Fix.Zero; for (int i = 0; i < list.Count; i++) { Player val3 = list[i]; if (val3.IsAlive && val3.Team != bot.Team) { Fix val4 = Vec2.SqrMagnitude(val3.Position - me); if (val == null || val4 < val2) { val = val3; val2 = val4; } } } return val; } private static bool HasLineOfSight(Vec2 from, Vec2 to, Fix distance) { //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_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_0017: 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_001e: 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) //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_0039: 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_003b: 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_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_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_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_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) Vec2 val = from + new Vec2(Fix.Zero, EyeHeight); Vec2 val2 = to - val; Fix val3 = Vec2.Magnitude(val2); if (val3 == Fix.Zero) { return true; } RaycastInformation val4 = DetPhysics.Get().RaycastToClosestRoundedRect(val, val2 / val3, val3); if (RaycastInformation.op_Implicit(val4)) { return val4.nearDist > val3 - SightSlack; } return true; } private static bool TeammateInLineOfFire(Player bot, Vec2 from, Vec2 to) { //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_000d: 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_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_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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_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) //IL_0073: 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_007a: 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_008f: 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_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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) List<Player> list = PlayerHandler.Get().PlayerList(); Vec2 val = to - from; Fix val2 = Vec2.SqrMagnitude(val); if (val2 == Fix.Zero) { return false; } for (int i = 0; i < list.Count; i++) { Player val3 = list[i]; if (val3 != bot && val3.IsAlive && val3.Team == bot.Team) { Fix val4 = Vec2.Dot(val3.Position - from, val) / val2; if (val4 < Fix.Zero) { val4 = Fix.Zero; } if (val4 > Fix.One) { val4 = Fix.One; } Vec2 val5 = from + val * val4; if (Vec2.SqrMagnitude(val3.Position - val5) < SafeShotRadius * SafeShotRadius) { return true; } } } return false; } private static int PickAbility(Player bot, BotState state, Vec2 me, Player target, Fix distance) { //IL_00b0: 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) SlimeController slime = state.Slime; if (slime.abilities == null || CooldownTimers.Invoke(slime) == null) { return -1; } int num = ((slime.abilities.Count < 3) ? slime.abilities.Count : 3); AbilityUse[] array = new AbilityUse[3] { AbilityUse.Escape, AbilityUse.Attack, AbilityUse.Self }; foreach (AbilityUse abilityUse in array) { for (int j = 0; j < num; j++) { AbilityMonoBehaviour val = slime.abilities[j]; if (!((Object)(object)val == (Object)null) && !((MonoUpdatable)val).IsDestroyed) { AbilityProfile abilityProfile = AbilityProfiles.For(val); if (abilityProfile.Use == abilityUse && IsAbilityReady(slime, j) && IsAbilityCastable(slime, j) && WantsToUse(bot, abilityProfile, me, target, distance)) { return j; } } } } return -1; } private static bool WantsToUse(Player bot, AbilityProfile profile, Vec2 me, Player target, Fix distance) { //IL_001e: 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_002d: 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_0010: 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_0046: 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_0061: 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) switch (profile.Use) { case AbilityUse.Escape: case AbilityUse.Self: return distance <= profile.MaxRange; case AbilityUse.Attack: if (distance < profile.MinRange || distance > profile.MaxRange) { return false; } if (profile.NeedsSight && !HasLineOfSight(me, target.Position, distance)) { return false; } if (profile.Aim == AbilityAim.AtTarget && TeammateInLineOfFire(bot, me, target.Position)) { return false; } return true; default: return false; } } private static Vec2 AimFor(AbilityProfile profile, Vec2 me, Player target) { //IL_0003: 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_002c: 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) //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_003b: 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_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_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) //IL_0094: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b0: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0072: 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_0081: Unknown result type (might be due to invalid IL or missing references) if (profile == null) { return Vec2.zero; } switch (profile.Aim) { case AbilityAim.Up: return Vec2.up; case AbilityAim.Down: return Vec2.down; case AbilityAim.None: return Vec2.zero; default: { if (target == null) { return Vec2.zero; } Vec2 val = target.Position - me; if (profile.Aim == AbilityAim.AwayFromTarget) { return Vec2.NormalizedSafe(new Vec2(-val.x, Fix.Abs(val.x) * (Fix)0.3f)); } Fix val2 = Vec2.Magnitude(val); return Vec2.NormalizedSafe(new Vec2(val.x, val.y + val2 * profile.Lob)); } } } } internal class BotButton : MonoBehaviour, IPointerClickHandler, IEventSystemHandler, IPointerEnterHandler, IPointerExitHandler { private const float HeightOfJoin = 0.4f; private const float WidthOfJoin = 0.8f; private const float GapOfJoin = 0.04f; private const float ScreenMargin = 8f; private const float CornerOfHeight = 0.5f; private const float FadeSpeed = 10f; private CharacterSelectBox _box; private CharSelectClickToJoin _join; private Color _onColor; private int _slot; private Image _fill; private Image _border; private TextMeshProUGUI _label; private RectTransform _rect; private bool _hovering; private float _hoverTime; public static void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_00a3: Unknown result type (might be due to invalid IL or missing references) if (((Scene)(ref scene)).name != "CharacterSelect") { return; } CharacterSelectHandler val = Object.FindObjectOfType<CharacterSelectHandler>(); if ((Object)(object)val == (Object)null) { return; } for (int i = 0; i < val.characterSelectBoxes.Length && i < LobbyBots.Slots.Length; i++) { CharacterSelectBox val2 = val.characterSelectBoxes[i]; CharSelectClickToJoin val3 = (((Object)(object)val2.joinColor != (Object)null) ? ((Component)val2.joinColor).GetComponent<CharSelectClickToJoin>() : null); if ((Object)(object)val3 == (Object)null || (Object)(object)val3.fillImage == (Object)null || (Object)(object)val3.borderImage == (Object)null || (Object)(object)val3.textComponent == (Object)null) { Plugin.Log.LogWarning((object)$"Couldn't find box {i}'s JOIN button, no bot button for it"); } else { Create(val2, val3, val.orange, i); } } } private static void Create(CharacterSelectBox box, CharSelectClickToJoin join, Color onColor, int slot) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_007c: 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_0187: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("BoplBotl Bot Button", new Type[4] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image), typeof(BotButton) }); val.transform.SetParent(((Component)box).transform.parent, false); val.transform.SetAsLastSibling(); BotButton component = val.GetComponent<BotButton>(); component._box = box; component._join = join; component._onColor = onColor; component._slot = slot; component._rect = val.GetComponent<RectTransform>(); component._fill = val.GetComponent<Image>(); UseRounded(component._fill, RoundedSprites.Fill); component._border = MakeChild<Image>(val.transform, "Border"); UseRounded(component._border, RoundedSprites.Ring); ((Graphic)component._border).raycastTarget = false; component._label = MakeChild<TextMeshProUGUI>(val.transform, "Label"); ((TMP_Text)component._label).font = ((TMP_Text)join.textComponent).font; ((TMP_Text)component._label).fontSharedMaterial = ((TMP_Text)join.textComponent).fontSharedMaterial; ((TMP_Text)component._label).alignment = (TextAlignmentOptions)514; ((TMP_Text)component._label).fontStyle = (FontStyles)1; ((TMP_Text)component._label).enableAutoSizing = true; ((TMP_Text)component._label).fontSizeMin = 8f; ((TMP_Text)component._label).fontSizeMax = 200f; ((TMP_Text)component._label).margin = new Vector4(12f, 4f, 12f, 4f); ((Graphic)component._label).raycastTarget = false; component.Layout(); component.Refresh(); } private static T MakeChild<T>(Transform parent, string name) where T : Component { //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_0040: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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) GameObject val = new GameObject(name, new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(T) }); val.transform.SetParent(parent, false); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; return val.GetComponent<T>(); } private static void UseRounded(Image image, Sprite sprite) { image.sprite = sprite; image.type = (Type)1; image.fillCenter = true; } private void SetCornerRadius(float localHeight) { Canvas componentInParent = ((Component)this).GetComponentInParent<Canvas>(); float num = (((Object)(object)componentInParent != (Object)null) ? componentInParent.referencePixelsPerUnit : 100f); float num2 = localHeight * 0.5f; if (!(num2 <= 0f)) { float pixelsPerUnitMultiplier = 24f * (num / 100f) / num2; _fill.pixelsPerUnitMultiplier = pixelsPerUnitMultiplier; _border.pixelsPerUnitMultiplier = pixelsPerUnitMultiplier; } } private void Layout() { //IL_0075: 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_0081: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: 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_00f3: 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_010a: 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) Vector3[] array = (Vector3[])(object)new Vector3[4]; ((Graphic)_join.fillImage).rectTransform.GetWorldCorners(array); float num = array[3].x - array[0].x; float num2 = array[1].y - array[0].y; if (!(num <= 0f) && !(num2 <= 0f)) { float num3 = num * 0.8f; float num4 = num2 * 0.4f; Vector3 val = (array[0] + array[3]) * 0.5f; Vector3 lossyScale = ((Component)this).transform.parent.lossyScale; ((Transform)_rect).localScale = Vector3.one; _rect.sizeDelta = new Vector2(num3 / lossyScale.x, num4 / lossyScale.y); SetCornerRadius(_rect.sizeDelta.y); ((Transform)_rect).position = val + Vector3.down * (num2 * 0.04f + num4 * 0.5f); KeepOnScreen(num4); } } private void KeepOnScreen(float worldHeight) { //IL_0012: 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_002d: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0067: 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_0073: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) Canvas componentInParent = ((Component)this).GetComponentInParent<Canvas>(); if (!((Object)(object)componentInParent == (Object)null)) { Camera obj = (((int)componentInParent.renderMode == 0) ? null : componentInParent.worldCamera); Vector3 val = ((Transform)_rect).position + Vector3.down * (worldHeight * 0.5f); Vector3 val2 = ((Transform)_rect).position + Vector3.up * (worldHeight * 0.5f); float y = RectTransformUtility.WorldToScreenPoint(obj, val).y; float y2 = RectTransformUtility.WorldToScreenPoint(obj, val2).y; if (!(y >= 8f) && !(y2 <= y)) { float num = worldHeight / (y2 - y); RectTransform rect = _rect; ((Transform)rect).position = ((Transform)rect).position + Vector3.up * ((8f - y) * num); } } } private void LateUpdate() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) bool flag = (Object)(object)_box != (Object)null && (int)_box.menuState == 0 && ((Component)_join).gameObject.activeInHierarchy; if (!flag) { LobbyBots.Slots[_slot] = false; } ((Behaviour)_fill).enabled = flag; ((Behaviour)_border).enabled = flag; ((Behaviour)_label).enabled = flag; if (flag) { _hoverTime = Mathf.Clamp01(_hoverTime + (_hovering ? Time.deltaTime : (0f - Time.deltaTime)) * 10f); Layout(); Refresh(); } } private void Refresh() { //IL_0072: 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_0088: 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_00a9: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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_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_002b: 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_004b: Unknown result type (might be due to invalid IL or missing references) if (LobbyBots.Slots[_slot]) { ((Graphic)_fill).color = Color.Lerp(_onColor, Color.white, _hoverTime * 0.25f); ((Graphic)_border).color = Color.white; ((Graphic)_label).color = Color.white; ((TMP_Text)_label).text = "BOT: ON"; } else { ((Graphic)_fill).color = Color.Lerp(_join.baseColor, _join.hoverColor, _hoverTime); ((Graphic)_border).color = Color.Lerp(_join.borderBaseColor, _join.borderHoverColor, _hoverTime); ((Graphic)_label).color = Color.Lerp(_join.textBaseColor, _join.textHoverColor, _hoverTime); ((TMP_Text)_label).text = "+ ADD BOT"; } } public void OnPointerClick(PointerEventData eventData) { if (((Behaviour)_fill).enabled) { LobbyBots.Slots[_slot] = !LobbyBots.Slots[_slot]; AudioManager obj = AudioManager.Get(); if (obj != null) { obj.Play(LobbyBots.Slots[_slot] ? "accept" : "decline"); } Refresh(); } } public void OnPointerEnter(PointerEventData eventData) { _hovering = true; } public void OnPointerExit(PointerEventData eventData) { _hovering = false; } } internal class BotState { public int OwnerId; public SlimeController Slime; public PlayerBody Body; public PlayerPhysics Physics; public int ActiveSlot = -1; public int ActiveTicks; public AbilityProfile ActiveProfile; public int ShotCooldownTicks; public int JumpCooldownTicks; public int StuckTicks; public StickyRoundedRectangle AirGoal; public int CircleDir; public StickyRoundedRectangle CirclePlatform; public Vec2 CircleGoal; public Vec2 LastPos; } internal static class BotManager { private const int FirstBotId = 100; private static readonly Vec2 SpawnOffset = new Vec2(Fix.Zero, (Fix)3L); private static readonly Dictionary<int, BotState> Bots = new Dictionary<int, BotState>(); private static int _nextId = 100; public static readonly List<int> BotIds = new List<int>(); public static bool IsBot(int playerId) { return Bots.ContainsKey(playerId); } public static bool TryGet(int playerId, out BotState state) { return Bots.TryGetValue(playerId, out state); } public static int CountBotsIn(List<Player> players) { int num = 0; for (int i = 0; i < players.Count; i++) { if (IsBot(players[i].Id)) { num++; } } return num; } public static void Summon(PlayerInfo info) { //IL_0005: 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_00ff: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_012a: 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_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Expected O, but got Unknown //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: 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_016e: Unknown result type (might be due to invalid IL or missing references) //IL_01af: 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_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020d: 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_0287: Unknown result type (might be due to invalid IL or missing references) Player player = PlayerHandler.Get().GetPlayer(info.playerId); SlimeController slimeController = info.slimeController; if (player == null || (Object)(object)slimeController == (Object)null || IsBot(player.Id) || GameSessionHandler.HasGameEnded()) { return; } foreach (KeyValuePair<int, BotState> bot in Bots) { Player player2 = PlayerHandler.Get().GetPlayer(bot.Key); if (bot.Value.OwnerId == player.Id && player2 != null && player2.IsAlive) { return; } } List<NamedSprite> list = CopyOwnerAbilities(slimeController); if (list.Count == 0) { Plugin.Log.LogError((object)"Couldn't find any abilities for the blob"); return; } PlayerCollision playerCollision = slimeController.GetPlayerCollision(); if ((Object)(object)playerCollision == (Object)null || (Object)(object)playerCollision.reviveEffectPrefab == (Object)null) { Plugin.Log.LogError((object)"Couldn't find the slime prefab to spawn a blob"); return; } int num = _nextId++; Vec2 val = info.position + SpawnOffset; Player val2 = new Player(num, player.Team) { Color = player.Color, UsesKeyboardAndMouse = false, IsLocalPlayer = false, playersAndClonesStillAlive = 1 }; foreach (NamedSprite item in list) { val2.Abilities.Add(item.associatedGameObject); val2.AbilityIcons.Add(item.sprite); } PlayerHandler.Get().PlayerList().Add(val2); SlimeController val3 = FixTransform.InstantiateFixed<SlimeController>(playerCollision.reviveEffectPrefab.emptyPlayerPrefab, val); val3.playerNumber = num; val3.GetPlayerSprite().sprite = null; ((Renderer)val3.GetPlayerSprite()).material = player.Color; val3.abilities = new List<AbilityMonoBehaviour>(); List<Sprite> list2 = new List<Sprite>(); foreach (NamedSprite item2 in list) { GameObject val4 = FixTransform.InstantiateFixed(item2.associatedGameObject, Vec2.zero); val4.SetActive(false); val2.CurrentAbilities.Add(val4); val3.abilities.Add(val4.GetComponent<AbilityMonoBehaviour>()); list2.Add(item2.sprite); } val3.AbilityReadyIndicators = MakeIndicators(playerCollision.reviveEffectPrefab, val3, player.Team, list2); val3.ReSpawn(val); BotIds.Add(num); Bots[num] = new BotState { OwnerId = player.Id, Slime = val3, Body = ((Component)val3).GetComponent<PlayerBody>(), Physics = ((Component)val3).GetComponent<PlayerPhysics>(), ShotCooldownTicks = 60 }; Plugin.Log.LogInfo((object)$"Player {player.Id} summoned blob {num}"); } public static void RemoveAll() { if (Bots.Count == 0) { return; } foreach (KeyValuePair<int, BotState> bot in Bots) { SlimeController slime = bot.Value.Slime; if ((Object)(object)slime == (Object)null || ((MonoUpdatable)slime).IsDestroyed) { continue; } if (slime.AbilityReadyIndicators != null) { AbilityReadyIndicator[] abilityReadyIndicators = slime.AbilityReadyIndicators; foreach (AbilityReadyIndicator val in abilityReadyIndicators) { if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)((Component)val).gameObject); } } } for (int j = 0; j < slime.abilities.Count; j++) { AbilityMonoBehaviour val2 = slime.abilities[j]; if ((Object)(object)val2 != (Object)null && !((MonoUpdatable)val2).IsDestroyed) { Updater.DestroyFix(((Component)val2).gameObject); } } slime.abilities.Clear(); Updater.DestroyFix(((Component)slime).gameObject); } PlayerHandler.Get().PlayerList()?.RemoveAll((Player p) => IsBot(p.Id)); Plugin.Log.LogInfo((object)$"Removed {Bots.Count} blob(s)"); Bots.Clear(); BotIds.Clear(); _nextId = 100; Navigator.Reset(); } private static AbilityReadyIndicator[] MakeIndicators(ReviveEffect prefabs, SlimeController slime, int team, List<Sprite> icons) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) AbilityReadyIndicator[] array = (AbilityReadyIndicator[])(object)new AbilityReadyIndicator[3]; for (int i = 0; i < array.Length; i++) { AbilityReadyIndicator component = Object.Instantiate<GameObject>(prefabs.AbilityReadyIndicators[i]).GetComponent<AbilityReadyIndicator>(); component.Init(); component.SetColor(prefabs.teamColors.teamColors[team].fill); ((Component)component).GetComponent<FollowTransform>().Leader = ((Component)slime).transform; ((Component)component).gameObject.SetActive(false); if (i < icons.Count) { component.SetSprite(icons[i], true); } array[i] = component; } return array; } private static List<NamedSprite> CopyOwnerAbilities(SlimeController ownerSlime) { //IL_00bc: 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) List<NamedSprite> list = new List<NamedSprite>(); NamedSpriteList abilityIconsFull = ownerSlime.abilityIconsFull; if (ownerSlime.abilities != null) { foreach (AbilityMonoBehaviour ability3 in ownerSlime.abilities) { if (!((Object)(object)ability3 == (Object)null) && !((MonoUpdatable)ability3).IsDestroyed) { string text = ((Object)((Component)ability3).gameObject).name.Replace("(Clone)", "").Trim(); if (!(text == "Bot-L") && TryFindAbility(abilityIconsFull, text.ToLower(), out var ability)) { list.Add(ability); } } } } if (list.Count == 0 && TryFindAbility(abilityIconsFull, "bow", out var ability2)) { list.Add(ability2); } return list; } private static bool TryFindAbility(NamedSpriteList list, string name, out NamedSprite ability) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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) ability = default(NamedSprite); if ((Object)(object)list == (Object)null || list.sprites == null) { return false; } int num = list.sprites.FindIndex((NamedSprite s) => s.name != null && s.name.ToLower() == name); if (num < 0 || (Object)(object)list.sprites[num].associatedGameObject == (Object)null) { return false; } ability = list.sprites[num]; return true; } } internal static class Constants { public const string ModVersion = "1.1.0"; public const string ModAuthor = "Shayos"; public const string ModName = "BoplBotl"; public const string ModId = "com.Shayos.BoplBotl"; public const string Banner = "+-----------------------------------------------------------------------------------------------------------+\n| |\n| ______________ _______________ __ __ _____________ __ ______ _________________________________ |\n| ___ ____/_ / / /_ ____/__ //_/ _ \\/ /_ __ \\_ / / / ___ |/ /__ |__ __ \\__ /___ ____/ |\n| __ /_ _ / / /_ / __ ,< __ /_ / / / / / / __ /|_/ /__ /| |_ /_/ /_ / __ __/ |\n| _ __/ / /_/ / / /___ _ /| | _ / / /_/ // /_/ / _ / / / _ ___ | ____/_ /___ /___ |\n| /_/ \\____/ \\____/ /_/ |_| /_/ \\____/ \\____/ /_/ /_/ /_/ |_/_/ /_____/_____/ |\n| |\n+-----------------------------------------------------------------------------------------------------------+"; } [HarmonyPatch(typeof(InstantAbility), "EnterAbility")] internal static class InstantAbility_EnterAbility_Patch { public static void Postfix(InstantAbility __instance, PlayerInfo playerInfo) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (((Object)((Component)__instance).gameObject).name.Contains("Bot-L")) { BotManager.Summon(playerInfo); } } } [HarmonyPatch(typeof(PlayerHandler), "NumberOfPlayers")] internal static class PlayerHandler_NumberOfPlayers_Patch { public static void Postfix(ref int __result) { List<Player> list = PlayerHandler.Get().PlayerList(); if (list != null) { __result -= BotManager.CountBotsIn(list); } } } [HarmonyPatch(typeof(GameSessionHandler), "ActivateWinnerTriangle")] internal static class GameSessionHandler_ActivateWinnerTriangle_Patch { public static void Prefix() { BotManager.RemoveAll(); LobbyBots.ReleaseInputs(); } } [HarmonyPatch(typeof(GameSessionHandler), "LoadNextLevelScene")] internal static class GameSessionHandler_LoadNextLevelScene_Patch { public static void Prefix() { BotManager.RemoveAll(); } } [HarmonyPatch(typeof(GameSessionHandler), "LoadAbilitySelectScene")] internal static class GameSessionHandler_LoadAbilitySelectScene_Patch { public static void Prefix() { BotManager.RemoveAll(); } } [HarmonyPatch(typeof(GameSessionHandler), "InstantlyLoadAbilitySelectScene")] internal static class GameSessionHandler_InstantlyLoadAbilitySelectScene_Patch { public static void Prefix() { BotManager.RemoveAll(); } } [HarmonyPatch(typeof(GameSessionHandler), "LeaveGame")] internal static class GameSessionHandler_LeaveGame_Patch { public static void Prefix() { BotManager.RemoveAll(); } } internal static class IconLoader { public static Sprite Load(string resourceName, Sprite fallback) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_007f: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName); if (stream == null) { Plugin.Log.LogError((object)("No embedded resource called " + resourceName)); return fallback; } byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); Texture2D val = new Texture2D(2, 2); if (!ImageConversion.LoadImage(val, array)) { Plugin.Log.LogError((object)(resourceName + " isn't a valid PNG")); return fallback; } float num = fallback.pixelsPerUnit * (float)((Texture)val).width; Rect rect = fallback.rect; float num2 = num / ((Rect)(ref rect)).width; return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), num2); } } internal static class LobbyBots { public static readonly bool[] Slots = new bool[4]; public static readonly List<int> Ids = new List<int>(); private static readonly Dictionary<int, BotState> States = new Dictionary<int, BotState>(); private static readonly List<Player> Stashed = new List<Player>(); public static bool IsLobbyBot(int playerId) { return Ids.Contains(playerId); } public static bool TryGet(int playerId, out BotState state) { return States.TryGetValue(playerId, out state); } public static void AddToMatch(CharacterSelectHandler handler, List<Player> players) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) int num = 0; for (int i = 0; i < handler.characterSelectBoxes.Length && i < Slots.Length; i++) { if (Slots[i] && (int)handler.characterSelectBoxes[i].menuState == 0) { num++; } } PlayerColors value = Traverse.Create((object)handler).Field("playerColors").GetValue<PlayerColors>(); AddBots(players, num, value); } public static void AddBots(List<Player> players, int count, PlayerColors colors) { //IL_0073: 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_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_00d0: 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) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Expected O, but got Unknown //IL_0109: 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) Ids.Clear(); States.Clear(); if (count <= 0 || (Object)(object)colors == (Object)null) { return; } NamedSpriteList abilityIcons = SteamManager.instance.abilityIcons; int num = abilityIcons.sprites.FindIndex((NamedSprite s) => s.name != null && s.name.ToLower() == "random"); if (num < 0) { Plugin.Log.LogError((object)"Couldn't find the Random ability, no bots added"); return; } NamedSprite val = abilityIcons.sprites[num]; int num2 = ((!((Object)(object)Settings.Get() != (Object)null)) ? 1 : Settings.Get().NumberOfAbilities); for (int num3 = 0; num3 < count; num3++) { if (players.Count >= 4) { break; } int num4 = players.Count + 1; Player val2 = new Player(num4, FreeTeam(players)) { Color = colors.playerColors[FreeColor(players, colors)].playerMaterial, UsesKeyboardAndMouse = false, IsLocalPlayer = false, CanUseAbilities = true, Abilities = new List<GameObject>(), AbilityIcons = new List<Sprite>() }; for (int num5 = 0; num5 < Mathf.Max(1, num2); num5++) { val2.Abilities.Add(val.associatedGameObject); val2.AbilityIcons.Add(val.sprite); } players.Add(val2); Ids.Add(num4); Plugin.Log.LogInfo((object)$"Added bot player {num4} (team {val2.Team})"); } } public static void OnPlayersSpawned(SlimeController[] slimes) { States.Clear(); if (Ids.Count == 0 || slimes == null) { return; } foreach (SlimeController val in slimes) { if (!((Object)(object)val == (Object)null) && IsLobbyBot(val.playerNumber)) { States[val.playerNumber] = new BotState { OwnerId = val.playerNumber, Slime = val, Body = ((Component)val).GetComponent<PlayerBody>(), Physics = ((Component)val).GetComponent<PlayerPhysics>(), ShotCooldownTicks = 60 }; } } } public static void ReleaseInputs() { for (int i = 0; i < Ids.Count; i++) { Player player = PlayerHandler.Get().GetPlayer(Ids[i]); if (player != null) { player.ForceSetInputProfile(false, false, false, false, false, false, (byte)0, false, false, false, false); } } } public static void RemoveFromPlayerList() { if (Ids.Count != 0) { PlayerHandler.Get().PlayerList()?.RemoveAll((Player p) => IsLobbyBot(p.Id)); Ids.Clear(); States.Clear(); } } private static int FreeTeam(List<Player> players) { int team; for (team = 0; team < 4; team++) { if (!players.Exists((Player p) => p.Team == team)) { return team; } } return 3; } public static void StashForNextLevel() { Stashed.Clear(); List<Player> list = PlayerHandler.Get().PlayerList(); if (list == null || Ids.Count == 0) { return; } for (int num = list.Count - 1; num >= 0; num--) { if (IsLobbyBot(list[num].Id)) { Stashed.Insert(0, list[num]); list.RemoveAt(num); } } } public static void RestoreAfterNextLevel() { List<Player> list = PlayerHandler.Get().PlayerList(); if (list != null && Stashed.Count != 0) { list.AddRange(Stashed); Stashed.Clear(); } } private static int FreeColor(List<Player> players, PlayerColors colors) { for (int i = 0; i < colors.playerColors.Length; i++) { Material material = colors.playerColors[i].playerMaterial; if (!players.Exists((Player p) => (Object)(object)p.Color == (Object)(object)material)) { return i; } } return 0; } } [HarmonyPatch(typeof(CharacterSelectHandler), "TryStartGame_inner")] internal static class CharacterSelectHandler_TryStartGame_Patch { private static readonly FieldRef<bool> AllReady = AccessTools.StaticFieldRefAccess<bool>(AccessTools.Field(typeof(CharacterSelectHandler), "allReadyForMoreThanOneFrame")); public static void Prefix(out bool __state) { __state = CharacterSelectHandler.startButtonAvailable && AllReady.Invoke(); } public static void Postfix(CharacterSelectHandler __instance, bool __state) { if (__state) { LobbyBots.AddToMatch(__instance, PlayerHandler.Get().PlayerList()); } } } [HarmonyPatch(typeof(CharacterSelectHandler), "LoadPreviousChoices")] internal static class CharacterSelectHandler_LoadPreviousChoices_Patch { public static void Prefix() { LobbyBots.RemoveFromPlayerList(); } } [HarmonyPatch(typeof(GameSessionHandler), "SpawnPlayers")] internal static class GameSessionHandler_SpawnPlayers_Patch { private static readonly FieldRef<GameSessionHandler, SlimeController[]> Slimes = AccessTools.FieldRefAccess<GameSessionHandler, SlimeController[]>("slimeControllers"); public static void Postfix(GameSessionHandler __instance) { LobbyBots.OnPlayersSpawned(Slimes.Invoke(__instance)); } } internal static class Navigator { internal class Jump { public StickyRoundedRectangle To; public Vec2 LaunchPos; } private class Platform { public StickyRoundedRectangle Sticky; public RoundedRect Shape; public Fix HalfWidth; public Fix HalfHeight; } private class CachedJumps { public int Tick; public List<Jump> Jumps; } private const int CacheTicks = 120; private const int MaxSimTicks = 150; private const int MaxSearchNodes = 40; private static readonly Fix MaxHorizontalGap = (Fix)50L; private static readonly Fix MaxRise = (Fix)20L; private static readonly Fix LandSlack = (Fix)0.3f; private static readonly Fix ProbeDistance = (Fix)100L; private static readonly Fix TopEdgeFraction = (Fix)0.8f; private static readonly Fix NearPlatformDistance = (Fix)4L; private static readonly List<Platform> Platforms = new List<Platform>(); private static readonly Dictionary<int, StickyRoundedRectangle> StickyById = new Dictionary<int, StickyRoundedRectangle>(); private static readonly Dictionary<StickyRoundedRectangle, CachedJumps> JumpCache = new Dictionary<StickyRoundedRectangle, CachedJumps>(); private static int _refreshedTick = -1; public static void Refresh() { //IL_003a: 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_0040: 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_0070: 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_0089: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00a2: 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_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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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_00d4: 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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) if (_refreshedTick == Updater.SimulationTicks) { return; } _refreshedTick = Updater.SimulationTicks; Platforms.Clear(); PhysicsBodyList<RoundedRect> roundedRects = DetPhysics.Get().roundedRects; for (int i = 0; i < roundedRects.Length; i++) { PhysicsParent val = roundedRects.physicsParents[i]; if (DetPhysics.IsActive(val)) { StickyRoundedRectangle sticky = GetSticky(val); if (!((Object)(object)sticky == (Object)null) && !((MonoUpdatable)sticky).IsDestroyed) { RoundedRect val2 = roundedRects.colliders[i]; Platforms.Add(new Platform { Sticky = sticky, Shape = val2, HalfWidth = Fix.Abs(val2.box.right.x) + Fix.Abs(val2.box.up.x) + val2.radius, HalfHeight = Fix.Abs(val2.box.right.y) + Fix.Abs(val2.box.up.y) + val2.radius }); } } } } public static void Reset() { Platforms.Clear(); StickyById.Clear(); JumpCache.Clear(); _refreshedTick = -1; } public static StickyRoundedRectangle PlatformNear(Vec2 pos, bool mustBeTouching) { //IL_0002: 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_001c: 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_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_002d: 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) //IL_0047: 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_0032: 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_0060: Unknown result type (might be due to invalid IL or missing references) Platform platform = null; Fix val = Fix.Zero; for (int i = 0; i < Platforms.Count; i++) { Fix val2 = Vec2.Magnitude(((RoundedRect)(ref Platforms[i].Shape)).GetClosestPoint(pos) - pos); if (platform == null || val2 < val) { platform = Platforms[i]; val = val2; } } if (platform == null || (mustBeTouching && val > NearPlatformDistance)) { return null; } return platform.Sticky; } public static bool TryCenter(StickyRoundedRectangle sticky, out Vec2 center) { //IL_0018: 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_001d: Unknown result type (might be due to invalid IL or missing references) Platform platform = Find(sticky); center = ((platform != null) ? ((RoundedRect)(ref platform.Shape)).Pos() : Vec2.zero); return platform != null; } public static bool TryClosestPointOn(StickyRoundedRectangle sticky, Vec2 pos, out Vec2 closest) { //IL_0018: 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_000b: 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) Platform platform = Find(sticky); closest = ((platform != null) ? ((RoundedRect)(ref platform.Shape)).GetClosestPoint(pos) : Vec2.zero); return platform != null; } public static Jump FirstJump(StickyRoundedRectangle from, StickyRoundedRectangle to, PlayerPhysics physics) { if ((Object)(object)from == (Object)null || (Object)(object)to == (Object)null || (Object)(object)from == (Object)(object)to) { return null; } if (Find(from) == null || Find(to) == null) { return null; } Dictionary<StickyRoundedRectangle, Jump> dictionary = new Dictionary<StickyRoundedRectangle, Jump>(); Queue<StickyRoundedRectangle> queue = new Queue<StickyRoundedRectangle>(); HashSet<StickyRoundedRectangle> hashSet = new HashSet<StickyRoundedRectangle> { from }; queue.Enqueue(from); int num = 0; while (queue.Count > 0 && num < 40) { StickyRoundedRectangle val = queue.Dequeue(); num++; List<Jump> list = JumpsFrom(val, physics); for (int i = 0; i < list.Count; i++) { StickyRoundedRectangle to2 = list[i].To; if (!hashSet.Contains(to2)) { hashSet.Add(to2); dictionary[to2] = (((Object)(object)val == (Object)(object)from) ? list[i] : dictionary[val]); if ((Object)(object)to2 == (Object)(object)to) { return dictionary[to2]; } queue.Enqueue(to2); } } } return null; } private static List<Jump> JumpsFrom(StickyRoundedRectangle sticky, PlayerPhysics physics) { //IL_0077: 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) if (JumpCache.TryGetValue(sticky, out var value) && Updater.SimulationTicks - value.Tick < 120) { return value.Jumps; } List<Jump> list = new List<Jump>(); Platform platform = Find(sticky); if (platform != null) { for (int i = 0; i < Platforms.Count; i++) { Platform platform2 = Platforms[i]; if (platform2 != platform && WorthTrying(platform, platform2) && TryFindLaunch(platform, platform2, physics, out var launch)) { list.Add(new Jump { To = platform2.Sticky, LaunchPos = launch }); } } } JumpCache[sticky] = new CachedJumps { Tick = Updater.SimulationTicks, Jumps = list }; return list; } private static bool WorthTrying(Platform from, Platform to) { //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_0012: 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_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_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_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_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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_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) //IL_006a: 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_0078: 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) Vec2 val = ((RoundedRect)(ref from.Shape)).Pos(); Vec2 val2 = ((RoundedRect)(ref to.Shape)).Pos(); Fix val3 = Fix.Abs(val2.x - val.x) - from.HalfWidth - to.HalfWidth; Fix val4 = val2.y - to.HalfHeight - (val.y + from.HalfHeight); if (val3 < MaxHorizontalGap) { return val4 < MaxRise; } return false; } private static bool TryFindLaunch(Platform from, Platform to, PlayerPhysics physics, out Vec2 launch) { //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_0012: 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_001d: 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_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_003a: 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_0041: 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) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_005a: 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_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_0066: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_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) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: 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_00d3: 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_00d9: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: 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_00f3: 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_00fb: 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_0101: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: 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_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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: 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_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_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_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_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: 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_01a4: Unknown result type (might be due to invalid IL or missing references) Vec2 val = ((RoundedRect)(ref from.Shape)).Pos(); Fix val2 = ((((RoundedRect)(ref to.Shape)).Pos().x >= val.x) ? Fix.One : (-Fix.One)); Fix val3 = from.HalfWidth * TopEdgeFraction; Vec2[] array = (Vec2[])(object)new Vec2[6] { new Vec2(val.x + val2 * val3, val.y + ProbeDistance), new Vec2(val.x, val.y + ProbeDistance), new Vec2(val.x + val2 * ProbeDistance, val.y), new Vec2(val.x - val2 * val3, val.y + ProbeDistance), new Vec2(val.x, val.y - ProbeDistance), new Vec2(val.x - val2 * ProbeDistance, val.y) }; for (int i = 0; i < array.Length; i++) { Vec2 closestPoint = ((RoundedRect)(ref from.Shape)).GetClosestPoint(array[i]); Vec2 val4 = Vec2.NormalizedSafe(array[i] - closestPoint); Vec2 val5 = closestPoint + val4 * (physics.radius + LandSlack); if (SimulateJump(val5, val4, from, to, physics)) { launch = val5; return true; } } launch = Vec2.zero; return false; } private static bool SimulateJump(Vec2 start, Vec2 normal, Platform from, Platform to, PlayerPhysics physics) { //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_0012: 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_001d: 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_0030: 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_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_0043: 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_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_005a: 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) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_0088: 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_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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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_00c9: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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_00e5: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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_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_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_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: 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_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0145: 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_013e: Unknown result type (might be due to invalid IL or missing references) //IL_014a: 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_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_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_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: 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_018a: Unknown result type (might be due to invalid IL or missing references) /