Decompiled source of RoundEvents v1.1.3
RoundEvents.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; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using ModdingUtils.Utils; using Photon.Pun; using RoundEvents.Events; using TMPro; using UnboundLib; using UnboundLib.GameModes; using UnboundLib.Networking; using UnboundLib.Utils; using UnboundLib.Utils.UI; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("RoundEvents")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.2.0")] [assembly: AssemblyInformationalVersion("1.0.2+ddf9180d6a77d25cf198abec79e83d7c2e8ae5b7")] [assembly: AssemblyProduct("RoundEvents")] [assembly: AssemblyTitle("RoundEvents")] [assembly: AssemblyVersion("1.0.2.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace RoundEvents { internal abstract class RoundEvent { protected Random Rng; protected float Elapsed; private readonly Dictionary<string, int> notes = new Dictionary<string, int>(); public abstract string Id { get; } public abstract string Title { get; } public abstract string Rule { get; } public abstract Color Color { get; } public virtual string Phase => null; public virtual float PhaseLeft => 0f; public virtual string Detail => null; public virtual int Holder => -1; public virtual Vector2 Center => Vector2.zero; public virtual float Radius => 0f; public bool Running { get; private set; } protected void Note(string kind, string msg) { notes.TryGetValue(kind, out var value); notes[kind] = value + 1; if (value < 3) { Plugin.Log.LogInfo((object)("[events] " + Title + ": " + msg)); } } public void Begin(int seed) { notes.Clear(); Rng = new Random(seed); Elapsed = 0f; Running = true; OnStart(); } public void End() { if (Running) { Running = false; OnStop(); } } public void Tick(float dt) { if (Running) { Elapsed += dt; OnUpdate(dt); } } protected abstract void OnStart(); protected abstract void OnStop(); protected virtual void OnUpdate(float dt) { } } internal class Director : MonoBehaviour { public static Director Instance; public static readonly List<RoundEvent> All = new List<RoundEvent>(); public static RoundEvent Current; private static int quiet = 3; private static string forced; private static bool battle; private static RoundEvent pending; private static int pendingSeed; private static readonly float[] chanceAfterQuiet = new float[6] { 0.08f, 0.12f, 0.22f, 0.4f, 0.6f, 0.85f }; private static RoundEvent lastHosted; private float nextOutCheck; public static float ChanceNow(int quietFights, float scale) { return Mathf.Clamp01(chanceAfterQuiet[Mathf.Clamp(quietFights, 0, chanceAfterQuiet.Length - 1)] * scale); } public static void Install() { GameModeManager.AddHook("GameStart", (Func<IGameModeHandler, IEnumerator>)((IGameModeHandler _) => Reset())); GameModeManager.AddHook("PointStart", (Func<IGameModeHandler, IEnumerator>)((IGameModeHandler _) => OnPointStart())); GameModeManager.AddHook("BattleStart", (Func<IGameModeHandler, IEnumerator>)((IGameModeHandler _) => OnBattleStart())); GameModeManager.AddHook("PointEnd", (Func<IGameModeHandler, IEnumerator>)((IGameModeHandler _) => OnPointEnd())); GameModeManager.AddHook("GameEnd", (Func<IGameModeHandler, IEnumerator>)((IGameModeHandler _) => Reset())); } private static bool OutOfGame() { if ((Object)(object)PlayerManager.instance == (Object)null || PlayerManager.instance.players == null || PlayerManager.instance.players.Count == 0) { return true; } if (!PhotonNetwork.OfflineMode) { return !PhotonNetwork.InRoom; } return false; } public static void Force(string id) { forced = id; Plugin.Log.LogInfo((object)("[events] next fight forced: " + id)); } private static IEnumerator Reset() { StopCurrent(); quiet = 3; yield break; } private static IEnumerator OnPointStart() { StopCurrent(keepPending: true); battle = false; if (!Util.IsHost) { yield break; } int num = -1; List<RoundEvent> on = All.Where(Plugin.Enabled).ToList(); if (forced != null) { num = All.FindIndex((RoundEvent e) => e.Id.Equals(forced, StringComparison.OrdinalIgnoreCase)); forced = null; } else if (on.Count > 0 && Random.value < ChanceNow(quiet, Plugin.Frequency)) { List<RoundEvent> list = on.Where((RoundEvent e) => e != lastHosted || on.Count == 1).ToList(); num = All.IndexOf(list[Random.Range(0, list.Count)]); } if (num >= 0) { quiet = 0; lastHosted = All[num]; } else { quiet++; } Plugin.Log.LogInfo((object)((num >= 0) ? ("[events] this fight: " + All[num].Title) : $"[events] no event this fight (quiet streak {quiet})")); NetworkingManager.RPC(typeof(Director), "RPCA_Event", new object[2] { num, Random.Range(1, int.MaxValue) }); } [UnboundRPC] public static void RPCA_Event(int id, int seed) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) StopCurrent(); if (id < 0 || id >= All.Count) { pending = null; return; } pending = All[id]; pendingSeed = seed; try { Banner.Show(pending.Title, pending.Rule, pending.Color); } catch (Exception ex) { Plugin.Log.LogWarning((object)("[events] banner: " + ex.Message)); } if (battle) { StartPending(); } } private static IEnumerator OnBattleStart() { battle = true; StartPending(); yield break; } public static void ForceBattle() { battle = true; StartPending(); } private static void StartPending() { if (pending == null) { return; } Current = pending; pending = null; try { Current.Begin(pendingSeed); Plugin.Log.LogInfo((object)("[events] started " + Current.Title)); } catch (Exception arg) { Plugin.Log.LogWarning((object)$"[events] {Current.Title} failed to start, fight goes on without it: {arg}"); StopCurrent(); } } private static IEnumerator OnPointEnd() { battle = false; StopCurrent(); yield break; } public static void StopCurrent(bool keepPending = false) { if (!keepPending) { pending = null; Banner.Hide(); } RoundEvent current = Current; Current = null; if (current == null) { return; } try { current.End(); Plugin.Log.LogInfo((object)("[events] stopped " + current.Title)); } catch (Exception arg) { Plugin.Log.LogWarning((object)$"[events] {current.Title} cleanup: {arg}"); } } private void Update() { if ((Current != null || Banner.Showing) && Time.unscaledTime >= nextOutCheck) { nextOutCheck = Time.unscaledTime + 0.5f; if (OutOfGame()) { Plugin.Log.LogInfo((object)"[events] left the game: event stopped"); StopCurrent(); return; } } RoundEvent current = Current; if (current == null) { return; } try { current.Tick(Time.deltaTime); } catch (Exception arg) { Plugin.Log.LogWarning((object)$"[events] {current.Title} stopped after an error: {arg}"); StopCurrent(); } } } internal static class Hooks { public static Func<Player, Player, Vector2, Vector2> BeforeDamage; public static Action<Player, Player, Vector2> AfterDamage; public static Action<ProjectileHit, Vector2, Vector2> BulletHit; public static float HealthBefore; public static void Install(Harmony h) { //IL_0027: 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_0049: Expected O, but got Unknown //IL_0049: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown h.Patch((MethodBase)AccessTools.Method(typeof(HealthHandler), "DoDamage", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Hooks), "DoDamagePrefix", (Type[])null), new HarmonyMethod(typeof(Hooks), "DoDamagePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(ProjectileHit), "RPCA_DoHit", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Hooks), "DoHitPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } public static void Clear() { BeforeDamage = null; AfterDamage = null; BulletHit = null; } private static void DoDamagePrefix(HealthHandler __instance, ref Vector2 damage, Player damagingPlayer, out float __state) { //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_0048: Unknown result type (might be due to invalid IL or missing references) __state = float.NaN; try { Player component = ((Component)__instance).GetComponent<Player>(); if (!((Object)(object)component == (Object)null) && Util.Alive(component)) { __state = component.data.health; if (BeforeDamage != null) { damage = BeforeDamage(component, damagingPlayer, damage); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[events] damage hook: " + ex.Message)); } } private static void DoDamagePostfix(HealthHandler __instance, Vector2 damage, Player damagingPlayer, float __state) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) try { if (!float.IsNaN(__state) && AfterDamage != null) { Player component = ((Component)__instance).GetComponent<Player>(); if ((Object)(object)component != (Object)null && (component.data.health < __state - 0.001f || component.data.dead)) { HealthBefore = __state; AfterDamage(component, damagingPlayer, damage); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[events] damage hook: " + ex.Message)); } } private static void DoHitPostfix(ProjectileHit __instance, Vector2 hitPoint, Vector2 hitNormal) { //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) try { BulletHit?.Invoke(__instance, hitPoint, hitNormal); } catch (Exception ex) { Plugin.Log.LogWarning((object)("[events] hit hook: " + ex.Message)); } } } [BepInPlugin("dannythealien.rounds.roundevents", "Round Events", "1.1.3")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private static class Dev { private static readonly bool active = Environment.GetEnvironmentVariable("RE_DEV") == "1"; private static readonly string file; private static float next; private static void Give(string[] a) { string name = string.Join(" ", a.Skip(2)); CardInfo val = CardManager.cards.Values.Select((Card c) => c.cardInfo).FirstOrDefault((Func<CardInfo, bool>)((CardInfo c) => (Object)(object)c != (Object)null && string.Equals(c.cardName, name, StringComparison.OrdinalIgnoreCase))); Player val2 = Util.Players.ElementAtOrDefault(int.Parse(a[1])); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { Log.LogInfo((object)("[events] give: no card '" + name + "' or no player " + a[1])); return; } Cards.instance.AddCardToPlayer(val2, val, false, "", 0f, 0f, true); Log.LogInfo((object)$"[events] gave {val.cardName} to p{val2.playerID}"); } public static void Poll() { if (!active || Time.unscaledTime < next) { return; } next = Time.unscaledTime + 0.5f; try { if (!File.Exists(file)) { File.WriteAllText(file, ""); return; } string[] array = File.ReadAllLines(file); if (array.Length == 0) { return; } File.WriteAllText(file, ""); foreach (string item in from l in array select l.Trim() into l where l.Length > 0 select l) { Log.LogInfo((object)("[events] command: " + item)); string[] a = item.Split(new char[1] { ' ' }); switch (a[0]) { case "force": Director.Force(a[1]); break; case "now": { int num2 = Director.All.FindIndex((RoundEvent e) => e.Id == a[1]); NetworkingManager.RPC(typeof(Director), "RPCA_Event", new object[2] { num2, Random.Range(1, int.MaxValue) }); Director.ForceBattle(); break; } case "stop": Director.StopCurrent(); break; case "give": Give(a); break; case "check": { FieldInfo fieldInfo = AccessTools.Field(typeof(Gun), "forceShootDir"); foreach (Player player in Util.Players) { Gun val = player.data.weaponHandler?.gun; GunAmmo val2 = ((val != null) ? ((Component)val).GetComponentInChildren<GunAmmo>() : null); Log.LogInfo((object)string.Format("[events] check p{0}: aim={1} bounces={2} knock={3} atkspd={4} move={5} ghost={6} spawns={7} maxAmmo={8} reloadAdd={9} gravity={10} event={11}", player.playerID, Object.op_Implicit((Object)(object)val) ? fieldInfo.GetValue(val) : null, val?.reflects, val?.knockback, val?.attackSpeed, player.data.stats?.movementSpeed, val?.ignoreWalls, val?.objectsToSpawn?.Length, val2?.maxAmmo, val2?.reloadTimeAdd, ((Component)player).GetComponent<Gravity>()?.gravityForce, Director.Current?.Id ?? "none")); } break; } case "layers": Log.LogInfo((object)("[events] layers: " + string.Join(", ", SortingLayer.layers.Select((SortingLayer l) => $"{((SortingLayer)(ref l)).name}({((SortingLayer)(ref l)).value})")))); foreach (IGrouping<(string, int, string, string), Renderer> item2 in (from r in Object.FindObjectsOfType<Renderer>() where r.enabled && ((Component)r).gameObject.activeInHierarchy group r by (SortingLayer.IDToName(r.sortingLayerID), sortingOrder: r.sortingOrder, Name: ((object)r).GetType().Name, name: ((Object)((Component)r).transform.root).name) into g orderby g.Key.sortingOrder select g).Take(60)) { ManualLogSource log = Log; object[] obj = new object[7] { item2.Key.Item1, item2.Key.Item2, item2.Key.Item3, item2.Key.Item4, item2.Count(), item2.Average((Renderer r) => ((Component)r).transform.position.z), null }; Material sharedMaterial = item2.First().sharedMaterial; object obj2; if (sharedMaterial == null) { obj2 = null; } else { Shader shader = sharedMaterial.shader; obj2 = ((shader != null) ? ((Object)shader).name : null); } obj[6] = obj2; log.LogInfo((object)string.Format("[events] {0}/{1} {2} root={3} x{4} z={5:0.##} mat={6}", obj)); } break; case "list": Log.LogInfo((object)("[events] " + string.Join(", ", Director.All.Select((RoundEvent e) => e.Id)))); break; case "odds": { for (int num = 0; num <= 6; num++) { Log.LogInfo((object)$"[events] after {num} quiet: {Director.ChanceNow(num, Frequency):P0}"); } break; } default: Log.LogInfo((object)"[events] unknown command"); break; } } } catch (Exception ex) { Log.LogWarning((object)("[events] command: " + ex.Message)); } } static Dev() { string configPath = Paths.ConfigPath; string environmentVariable = Environment.GetEnvironmentVariable("FFT_ID"); file = Path.Combine(configPath, "roundevents-dev" + ((environmentVariable != null && environmentVariable.Length > 0) ? ("-" + environmentVariable) : "") + ".txt"); } } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__8_0; public static UnityAction<float> <>9__12_0; internal void <Awake>b__8_0() { } internal void <BuildMenu>b__12_0(float v) { frequency.Value = v; } } public const string Guid = "dannythealien.rounds.roundevents"; public const string Version = "1.1.3"; internal static ManualLogSource Log; private static ConfigEntry<float> frequency; private static readonly Dictionary<string, ConfigEntry<bool>> eventOn = new Dictionary<string, ConfigEntry<bool>>(); internal static float Frequency => Mathf.Clamp(frequency.Value, 0f, 2.5f); internal static bool Enabled(RoundEvent e) { if (eventOn.TryGetValue(e.Id, out var value)) { return value.Value; } return true; } private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Expected O, but got Unknown //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Harmony val = new Harmony("dannythealien.rounds.roundevents"); Director.All.AddRange(new RoundEvent[16] { new HotPotato(), new MusicalChairs(), new OneShot(), new Payback(), new Vampire(), new GravityFlip(), new ClosingRing(), new GhostBullets(), new LightsOut(), new Telefrag(), new RedLight(), new ExplodingBullets(), new Trampoline(), new BouncyBullets(), new SpeedRush(), new Knockback() }); frequency = ((BaseUnityPlugin)this).Config.Bind<float>("Round Events", "How often", 1f, "1 = about one fight in four. 0 = never, higher = more often (2 = about one in three). The host's setting counts."); foreach (RoundEvent item in Director.All) { eventOn[item.Id] = ((BaseUnityPlugin)this).Config.Bind<bool>("Events", item.Title, true, item.Rule + " (The host's setting counts.)"); } Hooks.Install(val); GravityFlip.Install(val); val.Patch((MethodBase)AccessTools.Method(typeof(MoveTransform), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "BulletStart", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); object obj = <>c.<>9__8_0; if (obj == null) { UnityAction val2 = delegate { }; <>c.<>9__8_0 = val2; obj = (object)val2; } Unbound.RegisterMenu("Round Events", (UnityAction)obj, (Action<GameObject>)BuildMenu, (GameObject)null, false); Log.LogInfo((object)string.Format("Round Events {0} loaded ({1} events)", "1.1.3", Director.All.Count)); } private static void BulletStart(MoveTransform __instance) { GravityFlip.BulletSpawned(__instance); } private void Start() { Director.Instance = ((Component)this).gameObject.AddComponent<Director>(); Director.Install(); } private void Update() { Dev.Poll(); } private static void BuildMenu(GameObject menu) { TextMeshProUGUI val = default(TextMeshProUGUI); MenuHandler.CreateText("Events every few fights (host's settings count)", menu, ref val, 30, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null); Slider val2 = default(Slider); MenuHandler.CreateSlider("How often", menu, 40, 0f, 2.5f, frequency.Value, (UnityAction<float>)delegate(float v) { frequency.Value = v; }, ref val2, false, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null); foreach (RoundEvent item in Director.All) { ConfigEntry<bool> entry = eventOn[item.Id]; MenuHandler.CreateToggle(entry.Value, item.Title, menu, (UnityAction<bool>)delegate(bool v) { entry.Value = v; }, 35, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null); } } } internal static class Util { private static readonly FieldInfo velField = AccessTools.Field(typeof(PlayerVelocity), "velocity"); public static bool IsHost { get { if (!PhotonNetwork.OfflineMode && !PhotonNetwork.IsMasterClient) { return !PhotonNetwork.InRoom; } return true; } } public static IEnumerable<Player> Players { get { if (!((Object)(object)PlayerManager.instance == (Object)null)) { return from p in PlayerManager.instance.players where (Object)(object)p != (Object)null orderby p.playerID select p; } return Enumerable.Empty<Player>(); } } public static bool Mine(Player p) { if ((Object)(object)p != (Object)null && (Object)(object)p.data != (Object)null && (Object)(object)p.data.view != (Object)null) { return p.data.view.IsMine; } return false; } public static bool Alive(Player p) { if ((Object)(object)p != (Object)null && (Object)(object)p.data != (Object)null && !p.data.dead) { return p.data.isPlaying; } return false; } public static List<Player> AlivePlayers() { return Players.Where(Alive).ToList(); } public static Player ById(int id) { return Players.FirstOrDefault((Func<Player, bool>)((Player p) => p.playerID == id)); } public static Vector2 GetVel(Player p) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) return (Vector2)velField.GetValue(p.data.playerVel); } public static void SetVel(Player p, Vector2 v) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) velField.SetValue(p.data.playerVel, v); } public static void SelfDamage(Player p, float amount, bool lethal = true) { //IL_0032: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) if (Mine(p) && Alive(p) && !(amount <= 0f)) { p.data.view.RPC("RPCA_SendTakeDamage", (RpcTarget)0, new object[4] { Vector2.down * amount, Vector2.op_Implicit(((Component)p).transform.position), lethal, -1 }); } } public static void Teleport(Player p, Vector3 pos) { //IL_0019: 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_004c: Unknown result type (might be due to invalid IL or missing references) if (Mine(p) && Alive(p)) { pos.z = ((Component)p).transform.position.z; PlayerCollision componentInParent = ((Component)p).GetComponentInParent<PlayerCollision>(); if (componentInParent != null) { componentInParent.IgnoreWallForFrames(2); } ((Component)p).transform.root.position = pos; SetVel(p, Vector2.zero); } } public static Rect View() { //IL_005e: 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_0064: 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_0082: 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) Camera val = (((Object)(object)MainCam.instance != (Object)null) ? MainCam.instance.cam : Camera.main); if ((Object)(object)val == (Object)null) { return new Rect(-35f, -20f, 70f, 40f); } float num = val.orthographicSize * 2f; float num2 = num * val.aspect; Vector3 position = ((Component)val).transform.position; return new Rect(position.x - num2 / 2f, position.y - num / 2f, num2, num); } public static bool Free(Vector2 pos) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return (Object)(object)Physics2D.OverlapCircle(pos, 0.6f, LayerMask.GetMask(new string[1] { "Default" })) == (Object)null; } } internal static class Visuals { private static TMP_FontAsset font; private static Sprite circle; private static Sprite square; private static Material spriteMat; private static Canvas canvas; private static Sprite soft; public static TMP_FontAsset Font { get { if ((Object)(object)font == (Object)null) { font = (from t in Resources.FindObjectsOfTypeAll<TextMeshProUGUI>() select ((TMP_Text)t).font).FirstOrDefault((Func<TMP_FontAsset, bool>)((TMP_FontAsset f) => (Object)(object)f != (Object)null)) ?? Resources.FindObjectsOfTypeAll<TMP_FontAsset>().FirstOrDefault(); } return font; } } public static int TopLayer { get { SortingLayer[] layers = SortingLayer.layers; if (layers.Length == 0) { return 0; } return ((SortingLayer)(ref layers[^1])).id; } } public static Material SpriteMat { get { //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_0022: Expected O, but got Unknown //IL_0023: Expected O, but got Unknown if (!((Object)(object)spriteMat != (Object)null)) { Material val = new Material(Shader.Find("Sprites/Default")); spriteMat = val; return val; } return spriteMat; } } public static Sprite Circle { get { //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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_00ea: 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_0056: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)circle != (Object)null) { return circle; } Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1 }; Color[] array = (Color[])(object)new Color[16384]; for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { float num = Vector2.Distance(new Vector2((float)j + 0.5f, (float)i + 0.5f), new Vector2(64f, 64f)) / 64f; array[i * 128 + j] = new Color(1f, 1f, 1f, Mathf.Clamp01((1f - num) * 20f)); } } val.SetPixels(array); val.Apply(); return circle = Sprite.Create(val, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f), 128f); } } public static Sprite Soft { get { //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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_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) if ((Object)(object)soft != (Object)null) { return soft; } Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1 }; Color[] array = (Color[])(object)new Color[16384]; for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { float num = Mathf.Clamp01(Vector2.Distance(new Vector2((float)j + 0.5f, (float)i + 0.5f), new Vector2(64f, 64f)) / 64f); float num2 = (1f - num) * (1f - num); array[i * 128 + j] = new Color(1f, 1f, 1f, num2); } } val.SetPixels(array); val.Apply(); return soft = Sprite.Create(val, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f), 128f); } } public static Sprite Square { get { //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_0033: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown if ((Object)(object)square != (Object)null) { return square; } Texture2D val = new Texture2D(4, 4, (TextureFormat)4, false); val.SetPixels(Enumerable.Repeat<Color>(Color.white, 16).ToArray()); val.Apply(); return square = Sprite.Create(val, new Rect(0f, 0f, 4f, 4f), new Vector2(0.5f, 0.5f), 4f); } } public static Canvas Canvas { get { //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_0068: Expected O, but got Unknown //IL_0068: 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) Camera val = (((Object)(object)MainCam.instance != (Object)null) ? MainCam.instance.cam : Camera.main); if ((Object)(object)canvas != (Object)null) { if ((Object)(object)canvas.worldCamera != (Object)(object)val && (Object)(object)val != (Object)null) { canvas.worldCamera = val; } return canvas; } GameObject val2 = new GameObject("RoundEventsCanvas"); Object.DontDestroyOnLoad((Object)val2); canvas = val2.AddComponent<Canvas>(); canvas.renderMode = (RenderMode)(((Object)(object)val != (Object)null) ? 1 : 0); canvas.worldCamera = val; canvas.planeDistance = 5f; canvas.sortingLayerID = TopLayer; canvas.sortingOrder = 30000; CanvasScaler obj = val2.AddComponent<CanvasScaler>(); obj.uiScaleMode = (ScaleMode)1; obj.referenceResolution = new Vector2(1920f, 1080f); obj.matchWidthOrHeight = 1f; return canvas; } } public static TextMeshProUGUI Text(Transform parent, string s, float size, Color c, Vector2 anchor, Vector2 pos) { //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_002a: 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_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_008a: 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_008d: 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_0099: 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_00ae: 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) GameObject val = new GameObject("text", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parent, false); TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>(); if ((Object)(object)Font != (Object)null) { ((TMP_Text)val2).font = Font; } ((TMP_Text)val2).text = s; ((TMP_Text)val2).fontSize = size; ((Graphic)val2).color = c; ((TMP_Text)val2).alignment = (TextAlignmentOptions)514; ((TMP_Text)val2).enableWordWrapping = false; ((Graphic)val2).raycastTarget = false; ((TMP_Text)val2).fontStyle = (FontStyles)1; RectTransform val3 = (RectTransform)val.transform; Vector2 anchorMin = (val3.anchorMax = anchor); val3.anchorMin = anchorMin; val3.pivot = new Vector2(0.5f, 0.5f); val3.sizeDelta = new Vector2(1600f, size * 1.4f); val3.anchoredPosition = pos; return val2; } public static Image Dot(Transform parent, float size, Color c, Vector2 anchor, Vector2 pos) { //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_002a: 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_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_0058: 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_0064: 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_0071: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("dot", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parent, false); Image val2 = val.AddComponent<Image>(); val2.sprite = Circle; ((Graphic)val2).color = c; ((Graphic)val2).raycastTarget = false; RectTransform val3 = (RectTransform)val.transform; Vector2 anchorMin = (val3.anchorMax = anchor); val3.anchorMin = anchorMin; val3.sizeDelta = new Vector2(size, size); val3.anchoredPosition = pos; return val2; } public static TextMeshPro WorldText(string s, float size, Color c) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) TextMeshPro val = new GameObject("RoundEventsLabel").AddComponent<TextMeshPro>(); if ((Object)(object)Font != (Object)null) { ((TMP_Text)val).font = Font; } ((TMP_Text)val).text = s; ((TMP_Text)val).fontSize = size; ((Graphic)val).color = c; ((TMP_Text)val).alignment = (TextAlignmentOptions)514; ((TMP_Text)val).enableWordWrapping = false; ((TMP_Text)val).fontStyle = (FontStyles)1; val.sortingLayerID = TopLayer; val.sortingOrder = 30000; return val; } public static SpriteRenderer WorldSprite(Sprite s, Color c, int order = 30000) { //IL_0005: 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) SpriteRenderer obj = new GameObject("RoundEventsSprite").AddComponent<SpriteRenderer>(); obj.sprite = s; obj.color = c; ((Renderer)obj).sortingLayerID = TopLayer; ((Renderer)obj).sortingOrder = order; ((Renderer)obj).material = SpriteMat; return obj; } public static void Burst(Vector3 pos, Color c, float size = 6f, float time = 0.35f) { //IL_0005: 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_001d: 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) SpriteRenderer val = WorldSprite(Circle, c); ((Component)val).transform.position = new Vector3(pos.x, pos.y, 0f); ((MonoBehaviour)Director.Instance).StartCoroutine(BurstRoutine(val, size, time)); } private static IEnumerator BurstRoutine(SpriteRenderer r, float size, float time) { Color c = r.color; for (float t = 0f; t < time; t += Time.deltaTime) { if (!((Object)(object)r != (Object)null)) { break; } float num = t / time; ((Component)r).transform.localScale = Vector3.one * Mathf.Lerp(size * 0.3f, size, Mathf.Sqrt(num)); r.color = new Color(c.r, c.g, c.b, c.a * (1f - num)); yield return null; } if ((Object)(object)r != (Object)null) { Object.Destroy((Object)(object)((Component)r).gameObject); } } } internal class Banner : MonoBehaviour { private static Banner current; private TextMeshProUGUI head; private TextMeshProUGUI sub; private TextMeshProUGUI tagLine; private CanvasGroup group; private float t; public static bool Showing => (Object)(object)current != (Object)null; public static void Show(string title, string rule, Color c) { //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_004f: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_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_0077: 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_0094: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)current != (Object)null) { Object.Destroy((Object)(object)((Component)current).gameObject); } GameObject val = new GameObject("RoundEventsBanner", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(((Component)Visuals.Canvas).transform, false); RectTransform val2 = (RectTransform)val.transform; val2.anchorMin = Vector2.zero; val2.anchorMax = Vector2.one; Vector2 offsetMin = (val2.offsetMax = Vector2.zero); val2.offsetMin = offsetMin; current = val.AddComponent<Banner>(); current.Build(title, rule, c); } public static void Hide() { if ((Object)(object)current != (Object)null) { Object.Destroy((Object)(object)((Component)current).gameObject); } } private void Build(string title, string rule, Color c) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_010d: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) group = ((Component)this).gameObject.AddComponent<CanvasGroup>(); group.blocksRaycasts = false; tagLine = Visuals.Text(((Component)this).transform, "ROUND EVENT", 34f, new Color(1f, 1f, 1f, 0.85f), new Vector2(0.5f, 0.5f), new Vector2(0f, 110f)); ((TMP_Text)tagLine).characterSpacing = 18f; head = Visuals.Text(((Component)this).transform, title.ToUpperInvariant(), 130f, c, new Vector2(0.5f, 0.5f), new Vector2(0f, 20f)); ((TMP_Text)head).outlineWidth = 0.12f; ((TMP_Text)head).outlineColor = new Color32((byte)0, (byte)0, (byte)0, (byte)200); sub = Visuals.Text(((Component)this).transform, rule, 46f, Color.white, new Vector2(0.5f, 0.5f), new Vector2(0f, -70f)); ((TMP_Text)sub).outlineWidth = 0.15f; ((TMP_Text)sub).outlineColor = new Color32((byte)0, (byte)0, (byte)0, (byte)220); } private void Update() { //IL_00bc: 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_00e1: 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_0037: 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_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) t += Time.unscaledDeltaTime; float num = Mathf.Clamp01(t / 0.25f); if (t < 3.2f) { ((Component)this).transform.localScale = Vector3.one * (1f + 0.25f * (1f - num) * (1f - num) * 3f * ((num < 1f) ? 1f : 0f)); group.alpha = num; ((RectTransform)((Component)this).transform).anchoredPosition = Vector2.zero; } else { float num2 = Mathf.Clamp01((t - 3.2f) / 0.4f); ((Component)this).transform.localScale = Vector3.one * Mathf.Lerp(1f, 0.38f, num2); ((RectTransform)((Component)this).transform).anchoredPosition = new Vector2(0f, Mathf.Lerp(0f, -470f, num2)); group.alpha = Mathf.Lerp(1f, 0.9f, num2); ((TMP_Text)tagLine).alpha = 1f - num2; } } } } namespace RoundEvents.Events { internal class BouncyBullets : RoundEvent { private const int Extra = 5; private readonly Dictionary<Gun, int> saved = new Dictionary<Gun, int>(); public override string Id => "bouncy"; public override string Title => "Bouncy Bullets"; public override string Rule => "Every bullet bounces 5 extra times. Watch your angles!"; public override Color Color => new Color(1f, 0.85f, 0.2f); protected override void OnStart() { saved.Clear(); foreach (Player player in Util.Players) { Gun val = player.data.weaponHandler?.gun; if (!((Object)(object)val == (Object)null)) { int num = ((val.reflects <= 2147483642) ? 5 : 0); saved[val] = num; val.reflects += num; } } Note("guns", $"{saved.Count} guns bounce {5} more times"); } protected override void OnStop() { foreach (KeyValuePair<Gun, int> item in saved) { if ((Object)(object)item.Key != (Object)null) { Gun key = item.Key; key.reflects -= item.Value; } } saved.Clear(); } } internal class ClosingRing : RoundEvent { private const float CloseTime = 20f; private const float StartDelay = 3f; private const float MinFraction = 0.22f; private const float BurnPerSecond = 0.15f; private const float TickEvery = 0.25f; private const int Segments = 96; private Vector2 center; private float startRadius; private float radius; private float nextTick; private LineRenderer line; private LineRenderer haze; public override string Id => "closingring"; public override string Title => "Closing Ring"; public override string Rule => "The ring is closing in. Stay inside or burn!"; public override Color Color => new Color(1f, 0.3f, 0.85f); public override Vector2 Center => center; public override float Radius => radius; public override string Phase { get { if (!(Elapsed < 3f)) { if (!(Elapsed < 23f)) { return "closed"; } return "closing"; } return "about to close"; } } public override float PhaseLeft => Mathf.Max(0f, ((Elapsed < 3f) ? 3f : 23f) - Elapsed); public override string Detail => $"safe circle center [{center.x:0.0}, {center.y:0.0}] radius {radius:0.0}; outside it you burn {0.15f:P0} of max hp per second"; protected override void OnStart() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0061: 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_008b: Unknown result type (might be due to invalid IL or missing references) Rect val = Util.View(); center = ((Rect)(ref val)).center; startRadius = ((Rect)(ref val)).height * 16f / 9f * 0.5f; radius = startRadius; nextTick = 0.25f; haze = MakeLine(new Color(Color.r, Color.g, Color.b, 0.25f), 3.5f, 29998); line = MakeLine(Color, 0.55f, 29999); Draw(); } private static LineRenderer MakeLine(Color c, float width, int order) { //IL_0005: 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_0033: 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_003a: Unknown result type (might be due to invalid IL or missing references) LineRenderer obj = new GameObject("RoundEventsRing").AddComponent<LineRenderer>(); ((Renderer)obj).material = Visuals.SpriteMat; obj.loop = true; obj.positionCount = 96; obj.useWorldSpace = true; Color startColor = (obj.endColor = c); obj.startColor = startColor; float startWidth = (obj.endWidth = width); obj.startWidth = startWidth; ((Renderer)obj).sortingLayerID = Visuals.TopLayer; ((Renderer)obj).sortingOrder = order; return obj; } protected override void OnStop() { if ((Object)(object)line != (Object)null) { Object.Destroy((Object)(object)((Component)line).gameObject); } if ((Object)(object)haze != (Object)null) { Object.Destroy((Object)(object)((Component)haze).gameObject); } } protected override void OnUpdate(float dt) { //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_010a: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp01((Elapsed - 3f) / 20f); radius = Mathf.Lerp(startRadius, startRadius * 0.22f, num * num * (3f - 2f * num)); Draw(); nextTick -= dt; if (nextTick > 0f) { return; } nextTick += 0.25f; foreach (Player item in Util.AlivePlayers()) { if (Util.Mine(item) && !(Vector2.Distance(Vector2.op_Implicit(((Component)item).transform.position), center) <= radius)) { Util.SelfDamage(item, item.data.maxHealth * 0.15f * 0.25f); Note("burn", $"p{item.playerID} burning outside the ring"); Visuals.Burst(((Component)item).transform.position, Color, 2.5f, 0.2f); } } } private void Draw() { //IL_007b: 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) float num = 1f + 0.08f * Mathf.Sin(Time.time * 6f); Vector3 val = default(Vector3); for (int i = 0; i < 96; i++) { float num2 = (float)i * (float)Math.PI * 2f / 96f; ((Vector3)(ref val))..ctor(center.x + Mathf.Cos(num2) * radius, center.y + Mathf.Sin(num2) * radius, 0f); line.SetPosition(i, val); haze.SetPosition(i, val); } LineRenderer obj = haze; float startWidth = (haze.endWidth = 3.5f * num); obj.startWidth = startWidth; } } internal class ExplodingBullets : RoundEvent { private readonly Dictionary<Gun, ObjectsToSpawn[]> saved = new Dictionary<Gun, ObjectsToSpawn[]>(); public override string Id => "explodingbullets"; public override string Title => "Exploding Bullets"; public override string Rule => "Every bullet explodes where it lands!"; public override Color Color => new Color(1f, 0.55f, 0.15f); public static ObjectsToSpawn FindExplosion() { CardInfo[] source = (CardInfo[])(((object)CardChoice.instance?.cards) ?? ((object)new CardInfo[0])); CardInfo? obj = ((IEnumerable<CardInfo>)source).FirstOrDefault((Func<CardInfo, bool>)((CardInfo c) => (Object)(object)c != (Object)null && c.cardName != null && c.cardName.Trim().ToUpperInvariant() == "EXPLOSIVE BULLET")) ?? ((IEnumerable<CardInfo>)source).FirstOrDefault((Func<CardInfo, bool>)((CardInfo c) => (Object)(object)c != (Object)null && ((Component)c).GetComponent<Gun>()?.objectsToSpawn?.Any((ObjectsToSpawn o) => (Object)(object)o?.effect != (Object)null && (Object)(object)o.effect.GetComponentInChildren<Explosion>() != (Object)null) == true)); if (obj == null) { return null; } return ((Component)obj).GetComponent<Gun>()?.objectsToSpawn?.FirstOrDefault((Func<ObjectsToSpawn, bool>)((ObjectsToSpawn o) => (Object)(object)o?.effect != (Object)null && (Object)(object)o.effect.GetComponentInChildren<Explosion>() != (Object)null)); } protected override void OnStart() { saved.Clear(); ObjectsToSpawn val = FindExplosion(); if (val == null) { Plugin.Log.LogWarning((object)"[events] Exploding Bullets: no explosion effect found"); return; } foreach (Player player in Util.Players) { Gun val2 = player.data.weaponHandler?.gun; if (!((Object)(object)val2 == (Object)null)) { saved[val2] = val2.objectsToSpawn; val2.objectsToSpawn = ((IEnumerable<ObjectsToSpawn>)(((object)val2.objectsToSpawn) ?? ((object)new ObjectsToSpawn[0]))).Concat((IEnumerable<ObjectsToSpawn>)(object)new ObjectsToSpawn[1] { val }).ToArray(); } } Note("guns", $"{saved.Count} guns got the explosion ({((Object)val.effect).name})"); } protected override void OnStop() { foreach (KeyValuePair<Gun, ObjectsToSpawn[]> item in saved) { if ((Object)(object)item.Key != (Object)null) { item.Key.objectsToSpawn = item.Value; } } saved.Clear(); } } internal class GhostBullets : RoundEvent { private readonly Dictionary<Gun, bool> saved = new Dictionary<Gun, bool>(); public override string Id => "ghostbullets"; public override string Title => "Ghost Bullets"; public override string Rule => "Bullets fly through walls. Cover won't save you."; public override Color Color => new Color(0.55f, 0.95f, 1f); protected override void OnStart() { saved.Clear(); foreach (Player player in Util.Players) { Gun val = player.data.weaponHandler?.gun; if (!((Object)(object)val == (Object)null)) { saved[val] = val.ignoreWalls; val.ignoreWalls = true; } } Note("guns", $"{saved.Count} guns shoot through walls"); } protected override void OnStop() { foreach (KeyValuePair<Gun, bool> item in saved) { if ((Object)(object)item.Key != (Object)null) { item.Key.ignoreWalls = item.Value; } } saved.Clear(); } } internal class GravityFlip : RoundEvent { private const float Every = 6f; private static GravityFlip self; private readonly Dictionary<Gravity, float> saved = new Dictionary<Gravity, float>(); private readonly Dictionary<int, float> air = new Dictionary<int, float>(); private bool flipped; private TextMeshProUGUI warn; private TextMeshProUGUI sign; private static bool patched; public override string Id => "gravityflip"; public override string Title => "Gravity Flip"; public override string Rule => "Every 6 seconds, gravity flips upside down!"; public override Color Color => new Color(0.4f, 0.8f, 1f); public override string Phase { get { if (!flipped) { return "gravity down"; } return "gravity up"; } } public override float PhaseLeft => 6f - Elapsed % 6f; public static void Install(Harmony h) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown if (!patched) { patched = true; h.Patch((MethodBase)AccessTools.Method(typeof(PlayerJump), "Jump", (Type[])null, (Type[])null), new HarmonyMethod(typeof(GravityFlip), "JumpPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } protected override void OnStart() { //IL_0039: 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_007a: 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_00a9: 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_00e5: Unknown result type (might be due to invalid IL or missing references) self = this; flipped = false; saved.Clear(); air.Clear(); warn = Visuals.Text(((Component)Visuals.Canvas).transform, "", 90f, Color, new Vector2(0.5f, 0.5f), Vector2.zero); ((TMP_Text)warn).outlineWidth = 0.15f; ((TMP_Text)warn).outlineColor = new Color32((byte)0, (byte)0, (byte)0, (byte)200); sign = Visuals.Text(((Component)Visuals.Canvas).transform, "", 44f, Color, new Vector2(0.5f, 1f), new Vector2(0f, -60f)); ((TMP_Text)sign).outlineWidth = 0.15f; ((TMP_Text)sign).outlineColor = new Color32((byte)0, (byte)0, (byte)0, (byte)200); } protected override void OnStop() { SetFlipped(on: false); if ((Object)(object)warn != (Object)null) { Object.Destroy((Object)(object)((Component)warn).gameObject); } if ((Object)(object)sign != (Object)null) { Object.Destroy((Object)(object)((Component)sign).gameObject); } if (self == this) { self = null; } } protected override void OnUpdate(float dt) { //IL_00bf: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0125: 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_01aa: 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_01b1: 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_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) bool flag = Mathf.FloorToInt(Elapsed / 6f) % 2 == 1; if (flag != flipped) { SetFlipped(flag); } float num = 6f - Elapsed % 6f; ((TMP_Text)warn).text = ((num <= 2f) ? ((flipped ? "DOWN IN " : "UP IN ") + Mathf.CeilToInt(num)) : ""); ((TMP_Text)sign).text = (flipped ? "GRAVITY: UP" : "GRAVITY: DOWN"); ((Graphic)sign).color = (Color)(flipped ? new Color(1f, 0.45f, 0.9f) : Color); if (!flipped) { return; } foreach (Player item in Util.AlivePlayers()) { if (Util.Mine(item)) { RaycastHit2D val = Physics2D.Raycast(Vector2.op_Implicit(((Component)item).transform.position), Vector2.up, 1.3f, LayerMask.GetMask(new string[1] { "Default" })); bool num2 = (Object)(object)((RaycastHit2D)(ref val)).collider != (Object)null; air.TryGetValue(item.playerID, out var value); value = (num2 ? 0f : (value + dt)); air[item.playerID] = value; Gravity component = ((Component)item).GetComponent<Gravity>(); float value2; float num3 = (saved.TryGetValue(component, out value2) ? value2 : 30f) * Mathf.Clamp(value, 0.3f, 1.2f); Vector2 vel = Util.GetVel(item); vel += Vector2.up * num3 * dt * TimeHandler.timeScale; Util.SetVel(item, vel); } } } private void SetFlipped(bool on) { //IL_008e: 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) if (on == flipped) { return; } flipped = on; Note("flip", on ? "gravity now UP" : "gravity back DOWN"); foreach (Player player in Util.Players) { Gravity component = ((Component)player).GetComponent<Gravity>(); if (!((Object)(object)component == (Object)null)) { float value; if (on) { saved[component] = component.gravityForce; component.gravityForce = 0f; } else if (saved.TryGetValue(component, out value)) { component.gravityForce = value; } Visuals.Burst(((Component)player).transform.position, Color, 4f); } } if (!on) { saved.Clear(); } MoveTransform[] array = Object.FindObjectsOfType<MoveTransform>(); foreach (MoveTransform obj in array) { obj.gravity = 0f - obj.gravity; } } private static bool JumpPrefix(PlayerJump __instance, bool forceJump) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_005f: 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_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_0082: 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) GravityFlip gravityFlip = self; if (gravityFlip == null || !gravityFlip.flipped) { return true; } Player component = ((Component)__instance).GetComponent<Player>(); if ((Object)(object)component == (Object)null || !Util.Mine(component)) { return true; } RaycastHit2D val = Physics2D.Raycast(Vector2.op_Implicit(((Component)component).transform.position), Vector2.up, 1.3f, LayerMask.GetMask(new string[1] { "Default" })); if (!((Object)(object)((RaycastHit2D)(ref val)).collider != (Object)null) && !forceJump) { return false; } Vector2 vel = Util.GetVel(component); Util.SetVel(component, new Vector2(vel.x, Mathf.Min(vel.y, 0f) - 25f * component.data.stats.jump)); gravityFlip.Note("jump", $"p{component.playerID} jumped off the ceiling"); gravityFlip.air[component.playerID] = 0f; return false; } public static void BulletSpawned(MoveTransform m) { if (self != null && self.flipped && (Object)(object)m != (Object)null) { m.gravity = 0f - Mathf.Abs(m.gravity); } } } internal class HotPotato : RoundEvent { private const float Fuse = 15f; private static HotPotato self; private int holder = -1; private float fuseLeft; private float newHolderIn; private float sincePass; private float resendIn; private TextMeshPro label; private SpriteRenderer glow; public override string Id => "hotpotato"; public override string Title => "Hot Potato"; public override string Rule => "One player has the bomb. Shoot someone to pass it. Don't hold it at zero!"; public override Color Color => new Color(1f, 0.45f, 0.1f); public override int Holder => holder; public override string Phase { get { if (holder < 0) { return "no bomb yet"; } return "bomb held"; } } public override float PhaseLeft { get { if (holder < 0) { return Mathf.Max(0f, newHolderIn); } return Mathf.Max(0f, fuseLeft); } } public override string Detail { get { if (holder < 0) { return null; } return $"holder {holder}; the holder passes it by shooting someone; it explodes on the holder at 0"; } } protected override void OnStart() { //IL_002f: 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) self = this; holder = -1; newHolderIn = 1.5f; sincePass = 10f; label = Visuals.WorldText("", 14f, Color); glow = Visuals.WorldSprite(Visuals.Soft, new Color(1f, 0.35f, 0.05f, 0.9f)); ((Component)label).gameObject.SetActive(false); ((Component)glow).gameObject.SetActive(false); Hooks.AfterDamage = OnHit; } protected override void OnStop() { Hooks.Clear(); if ((Object)(object)label != (Object)null) { Object.Destroy((Object)(object)((Component)label).gameObject); } if ((Object)(object)glow != (Object)null) { Object.Destroy((Object)(object)((Component)glow).gameObject); } if (self == this) { self = null; } } protected override void OnUpdate(float dt) { //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: 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) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) sincePass += dt; Player val = Util.ById(holder); if (!((Object)(object)val != (Object)null) || !Util.Alive(val)) { ((Component)label).gameObject.SetActive(false); ((Component)glow).gameObject.SetActive(false); if (Util.IsHost) { newHolderIn -= dt; List<Player> list = Util.AlivePlayers(); if (newHolderIn <= 0f && list.Count >= 2) { newHolderIn = 1.5f; Player val2 = list[Random.Range(0, list.Count)]; NetworkingManager.RPC(typeof(HotPotato), "RPCA_Holder", new object[3] { val2.playerID, 15f, true }); } } return; } fuseLeft -= dt; if (Util.IsHost && (resendIn -= dt) <= 0f) { resendIn = 2f; NetworkingManager.RPC(typeof(HotPotato), "RPCA_Sync", new object[2] { holder, fuseLeft }); } float num = 1f + 0.25f * Mathf.Sin(Time.time * Mathf.Lerp(6f, 30f, 1f - fuseLeft / 15f)); Vector3 val3 = ((Component)val).transform.position + Vector3.up * 2.4f; ((Component)label).gameObject.SetActive(true); ((Component)glow).gameObject.SetActive(true); label.transform.position = val3 + Vector3.up * 0.1f; ((TMP_Text)label).text = Mathf.CeilToInt(Mathf.Max(0f, fuseLeft)).ToString(); ((Graphic)label).color = Color.Lerp(Color.white, new Color(1f, 0.15f, 0.1f), 1f - fuseLeft / 15f); ((Component)glow).transform.position = val3; ((Component)glow).transform.localScale = Vector3.one * 4.5f * num; if (fuseLeft <= 0f && Util.IsHost) { NetworkingManager.RPC(typeof(HotPotato), "RPCA_Boom", new object[1] { holder }); holder = -1; } } private void OnHit(Player victim, Player attacker, Vector2 dmg) { if (Util.IsHost && !((Object)(object)attacker == (Object)null) && attacker.playerID == holder && !((Object)(object)victim == (Object)(object)attacker) && !(sincePass < 0.3f)) { sincePass = 0f; NetworkingManager.RPC(typeof(HotPotato), "RPCA_Holder", new object[3] { victim.playerID, fuseLeft, false }); } } [UnboundRPC] public static void RPCA_Holder(int playerId, float fuse, bool fresh) { //IL_0083: 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) if (self != null && self.Running) { self.holder = playerId; self.fuseLeft = fuse; self.sincePass = 0f; self.Note("holder", string.Format("bomb {0} p{1}, {2:0.0} s left", fresh ? "given to" : "passed to", playerId, fuse)); Player val = Util.ById(playerId); if ((Object)(object)val != (Object)null) { Visuals.Burst(((Component)val).transform.position, self.Color, 5f); } } } [UnboundRPC] public static void RPCA_Sync(int playerId, float fuse) { if (self != null && self.Running && !Util.IsHost) { self.holder = playerId; self.fuseLeft = fuse; } } [UnboundRPC] public static void RPCA_Boom(int playerId) { //IL_0079: 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_00ac: 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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: 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_0167: 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_0189: Unknown result type (might be due to invalid IL or missing references) if (self == null || !self.Running) { return; } self.holder = -1; self.newHolderIn = 1.5f; Player p = Util.ById(playerId); if ((Object)(object)p == (Object)null) { return; } self.Note("boom", $"bomb exploded on p{playerId}"); Visuals.Burst(((Component)p).transform.position, new Color(1f, 0.5f, 0.1f), 16f, 0.6f); Visuals.Burst(((Component)p).transform.position, Color.white, 7f, 0.25f); Util.SelfDamage(p, p.data.maxHealth * 10f + 1000f); foreach (Player item in from o in Util.AlivePlayers() where (Object)(object)o != (Object)(object)p && Util.Mine(o) select o) { Vector2 val = Vector2.op_Implicit(((Component)item).transform.position - ((Component)p).transform.position); if (((Vector2)(ref val)).magnitude < 7f) { item.data.healthHandler.TakeForce(((Vector2)(ref val)).normalized * 25000f * (1f - ((Vector2)(ref val)).magnitude / 7f), (ForceMode2D)1, true, true, 0f); } } } } internal class Knockback : RoundEvent { private readonly Dictionary<Gun, float> saved = new Dictionary<Gun, float>(); public override string Id => "knockback"; public override string Title => "Knockback Party"; public override string Rule => "Bullets knock players flying. Stay away from the edges!"; public override Color Color => new Color(1f, 0.4f, 0.75f); protected override void OnStart() { saved.Clear(); foreach (Player player in Util.Players) { Gun val = player.data.weaponHandler?.gun; if (!((Object)(object)val == (Object)null)) { saved[val] = val.knockback; val.knockback *= 4f; } } Note("guns", $"{saved.Count} guns hit 4x harder"); } protected override void OnStop() { foreach (KeyValuePair<Gun, float> item in saved) { if ((Object)(object)item.Key != (Object)null) { Gun key = item.Key; key.knockback /= 4f; } } saved.Clear(); } } internal class LightsOut : RoundEvent { private const float Dim = 0.07f; private SpriteRenderer veil; private readonly Dictionary<int, SpriteRenderer> halos = new Dictionary<int, SpriteRenderer>(); private readonly Dictionary<SpriteRenderer, Color> mapSprites = new Dictionary<SpriteRenderer, Color>(); private readonly HashSet<Renderer> glow = new HashSet<Renderer>(); private readonly Dictionary<LineRenderer, (Color a, Color b)> mapLines = new Dictionary<LineRenderer, (Color, Color)>(); private float fade; private float nextScan; public override string Id => "lightsout"; public override string Title => "Lights Out"; public override string Rule => "The map goes dark. Only players and bullets glow."; public override Color Color => new Color(0.65f, 0.55f, 1f); protected override void OnStart() { //IL_006e: 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_00a1: 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_00bc: 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_0113: Unknown result type (might be due to invalid IL or missing references) fade = 0f; mapSprites.Clear(); mapLines.Clear(); halos.Clear(); glow.Clear(); nextScan = 0f; Scan(); int sortingLayerID = SortingLayer.NameToID("Background"); veil = Visuals.WorldSprite(Visuals.Square, new Color(0.01f, 0.01f, 0.025f, 0f), 32000); ((Renderer)veil).sortingLayerID = sortingLayerID; Rect val = Util.View(); ((Component)veil).transform.position = new Vector3(((Rect)(ref val)).center.x, ((Rect)(ref val)).center.y, 5f); ((Component)veil).transform.localScale = new Vector3(((Rect)(ref val)).width * 2f, ((Rect)(ref val)).height * 2f, 1f); foreach (Player player in Util.Players) { SpriteRenderer val2 = Visuals.WorldSprite(Visuals.Soft, Color.clear, 32001); ((Renderer)val2).sortingLayerID = sortingLayerID; halos[player.playerID] = val2; } Note("dark", string.Format("dimmed {0} map pieces, hid {1} glow effects ({2})", mapSprites.Count, glow.Count, string.Join(", ", glow.Select((Renderer r) => ((Object)r).name + ":" + ((object)r).GetType().Name).Distinct().Take(6)))); } protected override void OnStop() { //IL_002e: 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_009c: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<SpriteRenderer, Color> mapSprite in mapSprites) { if ((Object)(object)mapSprite.Key != (Object)null) { mapSprite.Key.color = mapSprite.Value; } } foreach (KeyValuePair<LineRenderer, (Color, Color)> mapLine in mapLines) { if ((Object)(object)mapLine.Key != (Object)null) { mapLine.Key.startColor = mapLine.Value.Item1; mapLine.Key.endColor = mapLine.Value.Item2; } } mapSprites.Clear(); mapLines.Clear(); foreach (Renderer item in glow) { if ((Object)(object)item != (Object)null) { item.enabled = true; } } glow.Clear(); if ((Object)(object)veil != (Object)null) { Object.Destroy((Object)(object)((Component)veil).gameObject); } foreach (SpriteRenderer value in halos.Values) { if ((Object)(object)value != (Object)null) { Object.Destroy((Object)(object)((Component)value).gameObject); } } halos.Clear(); } private int Scan() { //IL_0061: 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_00bb: Unknown result type (might be due to invalid IL or missing references) MapManager instance = MapManager.instance; object obj; if (instance == null) { obj = null; } else { MapWrapper currentMap = instance.currentMap; obj = ((currentMap != null) ? currentMap.Map : null); } Map val = (Map)obj; if ((Object)(object)val == (Object)null) { return 0; } int num = 0; SpriteRenderer[] componentsInChildren = ((Component)val).GetComponentsInChildren<SpriteRenderer>(true); foreach (SpriteRenderer val2 in componentsInChildren) { if ((Object)(object)val2 != (Object)null && !mapSprites.ContainsKey(val2)) { mapSprites[val2] = val2.color; num++; } } LineRenderer[] componentsInChildren2 = ((Component)val).GetComponentsInChildren<LineRenderer>(true); foreach (LineRenderer val3 in componentsInChildren2) { if ((Object)(object)val3 != (Object)null && !mapLines.ContainsKey(val3)) { mapLines[val3] = (val3.startColor, val3.endColor); num++; } } int num2 = SortingLayer.NameToID("MapParticle"); Renderer[] array = Object.FindObjectsOfType<Renderer>(); foreach (Renderer val4 in array) { if ((Object)(object)val4 != (Object)null && val4.enabled && val4.sortingLayerID == num2 && (Object)(object)((Component)val4).GetComponentInParent<Player>() == (Object)null && glow.Add(val4)) { num++; } } return num; } protected override void OnUpdate(float dt) { //IL_0059: 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_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_0087: 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_0138: 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_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) bool flag = false; if (Time.unscaledTime >= nextScan) { nextScan = Time.unscaledTime + 0.5f; int num = Scan(); if (num > 0) { flag = true; Note("dark+", $"dimmed {num} more map pieces (map built after the event started)"); } if ((Object)(object)veil != (Object)null) { Rect val = Util.View(); ((Component)veil).transform.position = new Vector3(((Rect)(ref val)).center.x, ((Rect)(ref val)).center.y, 5f); ((Component)veil).transform.localScale = new Vector3(((Rect)(ref val)).width * 2f, ((Rect)(ref val)).height * 2f, 1f); } } if (fade < 1f || flag) { fade = Mathf.Clamp01(fade + dt / 1.2f); float k = Mathf.Lerp(1f, 0.07f, fade); foreach (KeyValuePair<SpriteRenderer, Color> mapSprite in mapSprites) { if ((Object)(object)mapSprite.Key != (Object)null) { mapSprite.Key.color = Darker(mapSprite.Value, k); } } foreach (KeyValuePair<LineRenderer, (Color, Color)> mapLine in mapLines) { if ((Object)(object)mapLine.Key != (Object)null) { mapLine.Key.startColor = Darker(mapLine.Value.Item1, k); mapLine.Key.endColor = Darker(mapLine.Value.Item2, k); } } if ((Object)(object)veil != (Object)null) { veil.color = new Color(0.01f, 0.01f, 0.025f, 0.97f * fade); } foreach (Renderer item in glow) { if ((Object)(object)item != (Object)null) { item.enabled = fade < 0.5f; } } } foreach (Player player in Util.Players) { if (halos.TryGetValue(player.playerID, out var value) && !((Object)(object)value == (Object)null)) { Color val2 = PlayerColor(player); value.color = (Color)(Util.Alive(player) ? new Color(val2.r, val2.g, val2.b, 0.7f * fade) : Color.clear); ((Component)value).transform.position = new Vector3(((Component)player).transform.position.x, ((Component)player).transform.position.y, 4f); ((Component)value).transform.localScale = Vector3.one * (11f + 0.6f * Mathf.Sin(Time.time * 3f + (float)player.playerID)); } } } private static Color Darker(Color c, float k) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_0018: 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) return new Color(c.r * k, c.g * k, c.b * k, c.a); } private static Color PlayerColor(Player p) { //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_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_001c: Unknown result type (might be due to invalid IL or missing references) try { return PlayerSkinBank.GetPlayerSkinColors(p.teamID).color; } catch { return Color.white; } } } internal class MusicalChairs : RoundEvent { private const float Every = 8f; private static MusicalChairs self; private float next; private TextMeshProUGUI warn; public override string Id => "musicalchairs"; public override string Title => "Musical Chairs"; public override string Rule => "Every 8 seconds, everyone swaps places!"; public override Color Color => new Color(0.75f, 0.35f, 1f); public override string Phase => "waiting"; public override float PhaseLeft => Mathf.Max(0f, next); public override string Detail => "when it reaches 0 everyone is moved to another player's spot"; protected override void OnStart() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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) self = this; next = 8f; warn = Visuals.Text(((Component)Visuals.Canvas).transform, "", 90f, Color, new Vector2(0.5f, 0.5f), new Vector2(0f, 0f)); ((TMP_Text)warn).outlineWidth = 0.15f; ((TMP_Text)warn).outlineColor = new Color32((byte)0, (byte)0, (byte)0, (byte)200); } protected override void OnStop() { if ((Object)(object)warn != (Object)null) { Object.Destroy((Object)(object)((Component)warn).gameObject); } if (self == this) { self = null; } } protected override void OnUpdate(float dt) { //IL_0063: 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_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_0154: 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) next -= dt; ((TMP_Text)warn).text = ((next <= 3f && next > 0f) ? ("SWAP IN " + Mathf.CeilToInt(next)) : ""); ((TMP_Text)warn).transform.localScale = Vector3.one * (1f + 0.3f * (1f - (next - Mathf.Floor(next)))); if (next > 0f) { return; } next += 8f; if (!Util.IsHost) { return; } List<Player> list = Util.AlivePlayers(); if (list.Count >= 2) { List<Player> list2 = list.OrderBy((Player _) => Random.value).ToList(); int[] array = new int[list2.Count]; float[] array2 = new float[list2.Count]; float[] array3 = new float[list2.Count]; for (int num = 0; num < list2.Count; num++) { Vector3 position = ((Component)list2[(num + 1) % list2.Count]).transform.position; array[num] = list2[num].playerID; array2[num] = position.x; array3[num] = position.y; } NetworkingManager.RPC(typeof(MusicalChairs), "RPCA_Swap", new object[3] { array, array2, array3 }); } } [UnboundRPC] public static void RPCA_Swap(int[] ids, float[] xs, float[] ys) { //IL_0059: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) if (self == null || !self.Running) { return; } self.Note("swap", $"swapped {ids.Length} players"); Vector3 pos = default(Vector3); for (int i = 0; i < ids.Length; i++) { Player val = Util.ById(ids[i]); if (!((Object)(object)val == (Object)null) && Util.Alive(val)) { Visuals.Burst(((Component)val).transform.position, self.Color, 4f); ((Vector3)(ref pos))..ctor(xs[i], ys[i], 0f); Visuals.Burst(pos, Color.white, 4f); Util.Teleport(val, pos); } } } } internal class OneShot : RoundEvent { private static readonly FieldInfo current = AccessTools.Field(typeof(GunAmmo), "currentAmmo"); private readonly Dictionary<GunAmmo, (int max, float add)> saved = new Dictionary<GunAmmo, (int, float)>(); public override string Id => "oneshot"; public override string Title => "One Shot"; public override string Rule => "One bullet. One hit kills. Slow reload. Make it count."; public override Color Color => new Color(1f, 0.85f, 0.2f); private static void Refill(GunAmmo a) { current.SetValue(a, a.maxAmmo); a.ReDrawTotalBullets(); } protected override void OnStart() { saved.Clear(); foreach (Player player in Util.Players) { WeaponHandler weaponHandler = player.data.weaponHandler; object obj; if (weaponHandler == null) { obj = null; } else { Gun gun = weaponHandler.gun; obj = ((gun != null) ? ((Component)gun).GetComponentInChildren<GunAmmo>() : null); } GunAmmo val = (GunAmmo)obj; if (!((Object)(object)val == (Object)null)) { saved[val] = (val.maxAmmo, val.reloadTimeAdd); val.maxAmmo = 1; val.reloadTimeAdd += 1.5f; Refill(val); } } Hooks.BeforeDamage = delegate(Player victim, Player attacker, Vector2 dmg) { //IL_001f: 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_004e: 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) if ((Object)(object)attacker == (Object)null || (Object)(object)attacker == (Object)(object)victim || dmg == Vector2.zero) { return dmg; } Note("hit", $"p{attacker.playerID} one-shot p{victim.playerID}"); return ((Vector2)(ref dmg)).normalized * (victim.data.maxHealth * 2f + 100f); }; Note("ammo", $"{saved.Count} guns set to 1 bullet"); } protected override void OnStop() { Hooks.Clear(); foreach (KeyValuePair<GunAmmo, (int, float)> item in saved) { if (!((Object)(object)item.Key == (Object)null)) { item.Key.maxAmmo = item.Value.Item1; item.Key.reloadTimeAdd = item.Value.Item2; Refill(item.Key); } } saved.Clear(); } } internal class Payback : RoundEvent { private static readonly FieldInfo shootDir = AccessTools.Field(typeof(Gun), "forceShootDir"); private readonly Dictionary<int, float> lastFired = new Dictionary<int, float>(); private readonly Dictionary<(int, int), float> paybackDue = new Dictionary<(int, int), float>(); private readonly Dictionary<Gun, int> aiming = new Dictionary<Gun, int>(); public override string Id => "payback"; public override string Title => "Payback"; public override string Rule => "Get hit and your gun fires straight back at whoever shot you."; public override Color Color => new Color(0.2f, 1f, 0.55f); protected override void OnStart() { lastFired.Clear(); paybackDue.Clear(); aiming.Clear(); Hooks.AfterDamage = OnHit; } protected override void OnStop() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) Hooks.Clear(); foreach (Gun key in aiming.Keys) { if ((Object)(object)key != (Object)null) { shootDir.SetValue(key, Vector3.zero); } } aiming.Clear(); } private void OnHit(Player victim, Player attacker, Vector2 dmg) { //IL_00ef: 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_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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_011b: 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) if ((Object)(object)attacker == (Object)null || (Object)(object)attacker == (Object)(object)victim) { return; } (int, int) key = (attacker.playerID, victim.playerID); if (paybackDue.TryGetValue(key, out var value) && Time.time <= value) { paybackDue.Remove(key); } else { if (!Util.Alive(victim) || !Util.Alive(attacker)) { return; } paybackDue[(victim.playerID, attacker.playerID)] = Time.time + 1.5f; if (Util.Mine(victim) && (!lastFired.TryGetValue(victim.playerID, out var value2) || !(Time.time - value2 < 0.35f))) { lastFired[victim.playerID] = Time.time; Gun val = victim.data.weaponHandler?.gun; if (!((Object)(object)val == (Object)null)) { Vector3 val2 = ((Component)attacker).transform.position - ((Component)victim).transform.position; Vector3 normalized = ((Vector3)(ref val2)).normalized; Visuals.Burst(((Component)victim).transform.position, Color, 3.5f, 0.25f); Note("fire", $"p{victim.playerID} fired back at p{attacker.playerID}"); ((MonoBehaviour)Director.Instance).StartCoroutine(Fire(val, normalized)); } } } } private IEnumerator Fire(Gun gun, Vector3 dir) { //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) aiming.TryGetValue(gun, out var value); aiming[gun] = value + 1; shootDir.SetValue(gun, dir); try { ((Weapon)gun).Attack(0f, true, 1f, 1f, false); } catch { } yield return (object)new WaitForSeconds(0.5f); if (!((Object)(object)gun == (Object)null) && aiming.TryGetValue(gun, out value)) { if (value <= 1) { aiming.Remove(gun); shootDir.SetValue(gun, Vector3.zero); } else { aiming[gun] = value - 1; } } } } internal class RedLight : RoundEvent { private enum Light { Green, Yellow, Red } private static readonly Color G = new Color(0.2f, 1f, 0.3f); private static readonly Color Y = new Color(1f, 0.85f, 0.1f); private static readonly Color R = new Color(1f, 0.12f, 0.12f); private const float FirstZap = 0.1f; private const float ZapPerSecond = 0.4f; private const float ZapTick = 0.1f; private const float Grace = 0.15f; private readonly List<(float end, Light light)> plan = new List<(float, Light)>(); private readonly Dictionary<int, (bool zappedThisRed, float next)> zap = new Dictionary<int, (bool, float)>(); private GameObject ui; private Image[] lamps; private TextMeshProUGUI word; private int lastPhase = -1; private float redStart; public override string Id => "redlight"; public override string Title => "Red Light, Green Light"; public override string Rule => "On RED, don't move, jump or shoot... or get zapped!"; public override Color Color => new Color(0.25f, 1f, 0.3f); public override string Phase { get { int phase; return Now(out phase) switch { Light.Yellow => "yellow", Light.Red => "red", _ => "green", }; } } public override float PhaseLeft { get { Now(out var phase); return Mathf.Max(0f, (plan.Count > 0) ? (plan[phase].end - Elapsed) : 0f); } } public override string Detail => $"on red (after {0.15f:0.00} s) any move, jump or shot zaps you: {0.1f:P0} of max hp, then {0.4f:P0} per second"; protected override void OnStart() { plan.Clear(); zap.Clear(); lastPhase = -1; float num = 2f + (float)Rng.NextDouble() * 2f; plan.Add((num, Light.Green)); while (num < 600f) { num += 0.5f; plan.Add((num, Light.Yellow)); num += 2f + (float)Rng.NextDouble(); plan.Add((num, Light.Red)); num += 3f + (float)Rng.NextDouble() * 3f; plan.Add((num, Light.Green)); } BuildUi(); } protected override void OnStop() { if ((Object)(object)ui != (Object)null) { Object.Destroy((Object)(object)ui); } } private Light Now(out int phase) { for (phase = 0; phase < plan.Count; phase++) { if (Elapsed < plan[phase].end) { return plan[phase].light; } } phase = plan.Count - 1; return Light.Green; } protected override void OnUpdate(float dt) { int phase; Light light = Now(out phase); if (phase != lastPhase) { lastPhase = phase; if (light == Light.Red) { redStart = Elapsed; zap.Clear(); } } UpdateUi(light); if (light != Light.Red || Elapsed - redStart < 0.15f) { return; } foreach (Player item in Util.AlivePlayers()) { if (Util.Mine(item) && Moving(item)) { zap.TryGetValue(item.playerID, out (bool, float) value); if (!value.Item1) { Util.SelfDamage(item, item.data.maxHealth * 0.1f); zap[item.playerID] = (true, Time.time + 0.1f); Zapped(item); Plugin.Log.LogInfo((object)$"[events] red light: p{item.playerID} moved on red (hp {item.data.health:0}/{item.data.maxHealth:0})"); } else if (Time.time >= value.Item2) { Util.SelfDamage(item, item.data.maxHealth * 0.4f * 0.1f); zap[item.playerID] = (true, Time.time + 0.1f); Zapped(item); } } } } private static bool Moving(Player p) { GeneralInput input = p.data.input; if ((Object)(object)input != (Object)null) { if (!(Mathf.Abs(input.direction.x) > 0.2f) && !input.jumpWasPressed && !input.jumpIsPressed && !input.shootWasPressed) { return input.shootIsPressed; } return true; } return false; } private static void Zapped(Player p) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) Visuals.Burst(((Component)p).transform.position, R, 3.5f, 0.2f); } private void BuildUi() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0049: 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_0061: 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_006d: 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_008c: 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_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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0164: 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_0190: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) ui = new GameObject("RedLightUi", new Type[1] { typeof(RectTransform) }); ui.transform.SetParent(((Component)Visuals.Canvas).transform, false); RectTransform val = (RectTransform)ui.transform; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0.5f, 1f); val.anchorMax = val2; val.anchorMin = val2; val.anchoredPosition = new Vector2(0f, -170f); val.sizeDelta = new Vector2(300f, 100f); Image obj = Visuals.Dot(ui.transform, 1f, new Color(0.05f, 0.05f, 0.07f, 0.85f), new Vector2(0.5f, 0.5f), Vector2.zero); obj.sprite = Visuals.Square; ((RectTransform)((Component)obj).transform).sizeDelta = new Vector2(270f, 90f); lamps = (Image[])(object)new Image[3] { Visuals.Dot(ui.transform, 70f, R, new Vector2(0.5f, 0.5f), new Vector2(-85f, 0f)), Visuals.Dot(ui.transform, 70f, Y, new Vector2(0.5f, 0.5f), new Vector2(0f, 0f)), Visuals.Dot(ui.transform, 70f, G, new Vector2(0.5f, 0.5f), new Vector2(85f, 0f)) }; word = Visuals.Text(ui.transform, "", 60f, G, new Vector2(0.5f, 0.5f), new Vector2(0f, -85f)); ((TMP_Text)word).outlineWidth = 0.15f; ((TMP_Text)word).outlineColor = new Color32((byte)0, (byte)0, (byte)0, (byte)220); } private void UpdateUi(Light light) { //IL_002e: 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_005c: 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_00c6: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) if (lamps != null) { float pulse = 0.85f + 0.15f * Mathf.Sin(Time.time * 10f); Set(lamps[0], R, light == Light.Red, pulse); Set(lamps[1], Y, light == Light.Yellow, pulse); Set(lamps[2], G, light == Light.Green, 1f); ((TMP_Text)word).text = light switch { Light.Yellow => "...", Light.Red => "STOP!", _ => "GO", }; ((Graphic)word).color = (Color)(light switch { Light.Yellow => Y, Light.Red => R, _ => G,