Decompiled source of GunGameArena v1.0.2
plugins/GunGameArena/GunGameArena.Core.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.CompilerServices; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyCompany("GunGameArena.Core")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+9485d5f4df5522592f81514e7da3ef3cdc450e7c")] [assembly: AssemblyProduct("GunGameArena.Core")] [assembly: AssemblyTitle("GunGameArena.Core")] [assembly: AssemblyVersion("1.0.0.0")] namespace GunGameArena.Core; public class Contestant { public int Id; public string Name; public int TeamIndex; public int Iff; public int Kills; public float LastKillTime; public bool IsPlayer; public bool IsAlive; public Vec3 Position; public SkillTier Tier = SkillTier.Regular; public void AddKill(float time) { Kills++; LastKillTime = time; } public override string ToString() { return Name + "#" + Id + " t" + TeamIndex + " iff" + Iff + " k" + Kills; } } public struct Rgba { public float R; public float G; public float B; public float A; public Rgba(float r, float g, float b, float a) { R = r; G = g; B = b; A = a; } public static Rgba Hex(string rrggbb, float a = 1f) { int num = int.Parse(rrggbb.TrimStart(new char[1] { '#' }), NumberStyles.HexNumber); return new Rgba((float)((num >> 16) & 0xFF) / 255f, (float)((num >> 8) & 0xFF) / 255f, (float)(num & 0xFF) / 255f, a); } public Rgba Darken(float factor) { return new Rgba(R * factor, G * factor, B * factor, A); } public override bool Equals(object obj) { if (!(obj is Rgba rgba)) { return false; } if (R == rgba.R && G == rgba.G && B == rgba.B) { return A == rgba.A; } return false; } public override int GetHashCode() { return R.GetHashCode() ^ G.GetHashCode() ^ B.GetHashCode() ^ A.GetHashCode(); } public static bool operator ==(Rgba a, Rgba b) { return a.Equals(b); } public static bool operator !=(Rgba a, Rgba b) { return !a.Equals(b); } } public static class HudPalette { public static readonly Rgba FfaCard = Rgba.Hex("2B2B2B"); public static readonly Rgba FfaBorder = Rgba.Hex("555555"); public static readonly Rgba Gold = Rgba.Hex("F5C542"); public static readonly Rgba White = new Rgba(1f, 1f, 1f, 1f); public static readonly Rgba Black = new Rgba(0f, 0f, 0f, 1f); public static readonly Rgba HeaderBg = Rgba.Hex("1A1A1A", 0.85f); public static readonly Rgba TeamBlue = Rgba.Hex("1E3FA8"); public static readonly Rgba TeamRed = Rgba.Hex("A81E1E"); public static readonly Rgba TeamGreen = Rgba.Hex("1E8A3A"); public static readonly Rgba TeamYellow = Rgba.Hex("C9A400"); public static Rgba TeamColor(int teamIndex) { return teamIndex switch { 0 => TeamBlue, 1 => TeamRed, 2 => TeamGreen, _ => TeamYellow, }; } public static string TeamName(int teamIndex) { return teamIndex switch { 0 => "BLUE", 1 => "RED", 2 => "GREEN", _ => "YELLOW", }; } public static Rgba CardBorder(TeamMode mode, int teamIndex, bool isRankOne) { if (mode == TeamMode.Teams) { return TeamColor(teamIndex); } if (!isRankOne) { return FfaBorder; } return Gold; } public static Rgba CardBackground(TeamMode mode, int teamIndex) { if (mode != TeamMode.Teams) { return FfaCard; } return TeamColor(teamIndex).Darken(0.55f); } } public static class HunterPicker { public static int Count(int hostileCount, float share) { if (hostileCount <= 0 || share <= 0f) { return 0; } return Math.Min(hostileCount, (int)Math.Ceiling(share * (float)hostileCount)); } public static List<Contestant> Pick(Random rng, IList<Contestant> hostileToPlayer, float share) { List<Contestant> list = new List<Contestant>(); int num = Count(hostileToPlayer.Count, share); List<Contestant> list2 = new List<Contestant>(hostileToPlayer); for (int i = 0; i < num; i++) { if (list2.Count <= 0) { break; } int index = rng.Next(list2.Count); list.Add(list2[index]); list2.RemoveAt(index); } return list; } } public static class KillAttribution { public static Contestant Nearest(IEnumerable<Contestant> candidates, int killerIff, int victimId, Vec3 point) { if (killerIff < 0) { return null; } Contestant result = null; float num = float.MaxValue; foreach (Contestant candidate in candidates) { if (candidate != null && candidate.IsAlive && candidate.Iff == killerIff && candidate.Id != victimId) { float num2 = Vec3.Distance(candidate.Position, point); if (num2 < num) { num = num2; result = candidate; } } } return result; } } public class NameGenerator { public const int MaxLength = 16; private static readonly string[] Adjectives = new string[40] { "Spicy", "Crispy", "Smoky", "Salty", "Angry", "Sneaky", "Turbo", "Mega", "Tiny", "Chunky", "Greasy", "Soggy", "Frozen", "Rusty", "Shiny", "Lucky", "Silent", "Loud", "Toxic", "Cursed", "Epic", "Dank", "Sus", "Cool", "Evil", "Happy", "Fried", "Grilled", "Juicy", "Pickled", "Rapid", "Sleepy", "Ghost", "Iron", "Neon", "Pixel", "Retro", "Wild", "Zesty", "Ultra" }; private static readonly string[] Nouns = new string[40] { "Glizzy", "Wiener", "Sosig", "Mustard", "Brat", "Hotdog", "Ketchup", "Relish", "Bun", "Kebab", "Sniper", "Ninja", "Gamer", "Toaster", "Goblin", "Wizard", "Pirate", "Knight", "Robot", "Duck", "Potato", "Pickle", "Noodle", "Waffle", "Nugget", "Bacon", "Salami", "Chorizo", "Frank", "Dog", "Slayer", "Hunter", "Camper", "Rusher", "Boomer", "Zoomer", "Gremlin", "Meatman", "Tank", "Yeet" }; private readonly Random _rng; private readonly HashSet<string> _used = new HashSet<string>(); public NameGenerator(int seed) { _rng = ((seed == 0) ? new Random() : new Random(seed)); } public string Next() { for (int i = 0; i < 50; i++) { string text = Compose(); if (text.Length <= 16 && _used.Add(text)) { return text; } } string text3; do { string text2 = Pick(Nouns); if (text2.Length > 12) { text2 = text2.Substring(0, 12); } text3 = text2 + _rng.Next(1000, 9999); } while (!_used.Add(text3)); return text3; } private string Compose() { string text = Pick(Adjectives); string text2 = Pick(Nouns); return _rng.Next(7) switch { 0 => text + text2, 1 => text.ToLowerInvariant() + "_" + text2.ToLowerInvariant(), 2 => "xX_" + text2 + "_Xx", 3 => text2 + _rng.Next(10, 9999), 4 => text + text2 + _rng.Next(10, 99), 5 => "iL" + text2, _ => text2 + "YT", }; } private string Pick(string[] words) { return words[_rng.Next(words.Length)]; } } public class PanelState { public TeamMode Mode; public int TeamCount; public int AllySosigs; public bool Leaderboard; public bool SpreadSpawns; public bool Grudges; public bool Hunters; public bool SkillTiers; public float HunterShare; } public static class PanelModel { public const int MaxAllies = 9; public const float HunterStep = 0.05f; public const int PointsStep = 5; public const int MinPoints = 5; public const int MaxPoints = 200; public static string ModeLabel(TeamMode m) { return m switch { TeamMode.FreeForAll => "Free For All", TeamMode.Teams => "Teams", _ => "Off", }; } public static TeamMode CycleMode(TeamMode m, int dir) { return (TeamMode)((int)(m + ((dir >= 0) ? 1 : (-1)) + 3) % 3); } public static int StepTeamCount(int current, int dir) { return Math.Max(2, Math.Min(4, current + ((dir >= 0) ? 1 : (-1)))); } public static int StepAllies(int current, int dir) { return Math.Max(-1, Math.Min(9, current + ((dir >= 0) ? 1 : (-1)))); } public static string AlliesLabel(int allies) { if (allies >= 0) { return allies.ToString(); } return "Auto"; } public static float StepHunterShare(float current, int dir) { float val = current + ((dir >= 0) ? 0.05f : (-0.05f)); val = Math.Max(0f, Math.Min(1f, val)); return (float)Math.Round(val, 2); } public static string PercentLabel(float share) { return (int)Math.Round(share * 100f) + "%"; } public static string ToggleLabel(string name, bool on) { return name + ": " + (on ? "ON" : "OFF"); } public static int StepPointsToWin(int current, int dir) { return Math.Max(5, Math.Min(200, current + ((dir >= 0) ? 5 : (-5)))); } public static bool TeamRowsEnabled(TeamMode m) { return m == TeamMode.Teams; } } public static class Ranking { public static List<Contestant> Sort(IEnumerable<Contestant> all) { List<Contestant> list = new List<Contestant>(all); list.Sort(Compare); return list; } private static int Compare(Contestant a, Contestant b) { int num = b.Kills.CompareTo(a.Kills); if (num != 0) { return num; } num = a.LastKillTime.CompareTo(b.LastKillTime); if (num != 0) { return num; } return a.Id.CompareTo(b.Id); } public static List<Contestant> Visible(IList<Contestant> sorted, int topCount) { List<Contestant> list = new List<Contestant>(); for (int i = 0; i < sorted.Count && i < topCount; i++) { list.Add(sorted[i]); } for (int j = 0; j < sorted.Count; j++) { if (sorted[j].IsPlayer && !list.Contains(sorted[j])) { list.Add(sorted[j]); break; } } return list; } public static bool IsPinnedPlayer(IList<Contestant> visible, int topCount, Contestant c) { if (c.IsPlayer) { return visible.IndexOf(c) >= topCount; } return false; } public static HashSet<int> CrownedIds(IList<Contestant> sorted, TeamMode mode) { HashSet<int> hashSet = new HashSet<int>(); if (mode == TeamMode.Teams) { HashSet<int> hashSet2 = new HashSet<int>(); for (int i = 0; i < sorted.Count; i++) { Contestant contestant = sorted[i]; if (hashSet2.Add(contestant.TeamIndex) && contestant.Kills > 0) { hashSet.Add(contestant.Id); } } } else if (sorted.Count > 0 && sorted[0].Kills > 0) { hashSet.Add(sorted[0].Id); } return hashSet; } } public static class RivalSelector { public static List<Contestant> Pick(Random rng, Contestant self, IEnumerable<Contestant> all, int count, float radius, float playerWeight) { List<Contestant> list = new List<Contestant>(); List<Contestant> list2 = new List<Contestant>(); foreach (Contestant item in all) { if (item != null && item != self && item.Id != self.Id && item.IsAlive) { if (item.IsPlayer || Vec3.Distance(item.Position, self.Position) <= radius) { list.Add(item); } else { list2.Add(item); } } } if (list.Count < count && list2.Count > 0) { list2.Sort((Contestant a, Contestant b) => Vec3.Distance(a.Position, self.Position).CompareTo(Vec3.Distance(b.Position, self.Position))); for (int num = 0; num < list2.Count; num++) { if (list.Count >= count) { break; } list.Add(list2[num]); } } List<Contestant> list3 = new List<Contestant>(); while (list3.Count < count && list.Count > 0) { float num2 = 0f; for (int num3 = 0; num3 < list.Count; num3++) { num2 += (list[num3].IsPlayer ? playerWeight : 1f); } double num4 = rng.NextDouble() * (double)num2; float num5 = 0f; int index = list.Count - 1; for (int num6 = 0; num6 < list.Count; num6++) { num5 += (list[num6].IsPlayer ? playerWeight : 1f); if (num4 < (double)num5) { index = num6; break; } } list3.Add(list[index]); list.RemoveAt(index); } return list3; } } public enum SkillTier { Rookie, Regular, Veteran, Elite } public struct TierMultipliers { public float Spread; public float FireAngle; public float Refire; public float Reaction; public TierMultipliers(float spread, float fireAngle, float refire, float reaction) { Spread = spread; FireAngle = fireAngle; Refire = refire; Reaction = reaction; } } public static class TierTable { public static readonly int[] DefaultWeights = new int[4] { 30, 40, 20, 10 }; public static TierMultipliers Default(SkillTier tier) { return tier switch { SkillTier.Rookie => new TierMultipliers(2.5f, 2f, 1.3f, 0.6f), SkillTier.Veteran => new TierMultipliers(0.7f, 0.8f, 0.9f, 1.3f), SkillTier.Elite => new TierMultipliers(0.45f, 0.6f, 0.8f, 1.6f), _ => new TierMultipliers(1f, 1f, 1f, 1f), }; } public static int Chevrons(SkillTier tier) { return (int)(tier + 1); } } public static class TierRoller { public static SkillTier Roll(Random rng, int[] weights) { if (weights == null || weights.Length != 4) { return SkillTier.Regular; } int num = 0; for (int i = 0; i < 4; i++) { num += Math.Max(0, weights[i]); } if (num <= 0) { return SkillTier.Regular; } int num2 = rng.Next(num); int num3 = 0; for (int j = 0; j < 4; j++) { num3 += Math.Max(0, weights[j]); if (num2 < num3) { return (SkillTier)j; } } return SkillTier.Regular; } public static int[] ParseWeights(string csv) { if (string.IsNullOrEmpty(csv)) { return TierTable.DefaultWeights; } string[] array = csv.Split(new char[1] { ',' }); if (array.Length != 4) { return TierTable.DefaultWeights; } int[] array2 = new int[4]; for (int i = 0; i < 4; i++) { if (!int.TryParse(array[i].Trim(), out var result)) { return TierTable.DefaultWeights; } array2[i] = result; } return array2; } } public static class SpawnerChooser { public static int Choose(Random rng, IList<Vec3> spawners, int ignoreNear, int ignoreFar, Vec3 player, IList<Vec3> occupied) { int count = spawners.Count; if (count == 0) { return -1; } List<int> list = new List<int>(count); for (int i = 0; i < count; i++) { list.Add(i); } list.Sort((int a, int b) => Vec3.Distance(spawners[a], player).CompareTo(Vec3.Distance(spawners[b], player))); int num = Math.Max(0, ignoreNear); int num2 = count - Math.Max(0, ignoreFar); if (num2 - num <= 0) { num = 0; num2 = count; } float num3 = -1f; List<int> list2 = new List<int>(); for (int num4 = num; num4 < num2; num4++) { int num5 = list[num4]; float num6 = Vec3.Distance(spawners[num5], player); for (int num7 = 0; num7 < occupied.Count; num7++) { num6 = Math.Min(num6, Vec3.Distance(spawners[num5], occupied[num7])); } if (num6 > num3 + 0.0001f) { num3 = num6; list2.Clear(); list2.Add(num5); } else if (Math.Abs(num6 - num3) <= 0.0001f) { list2.Add(num5); } } return list2[rng.Next(list2.Count)]; } } public static class TeamAssigner { public const int MaxIff = 31; public const int OriginalGunGameIff = 1; public static int ResolveAllyCount(int allySetting, int sosigCount) { if (sosigCount <= 0) { return 0; } int val = ((allySetting < 0) ? (sosigCount / 2) : allySetting); return Math.Max(0, Math.Min(val, sosigCount - 1)); } public static int ClampTeamCount(int teamCount) { return Math.Max(2, Math.Min(4, teamCount)); } public static int TeamIndexFor(TeamMode mode, int slot, int sosigCount, int teamCount, int allySetting) { switch (mode) { case TeamMode.FreeForAll: return slot + 1; case TeamMode.Teams: { int num = ResolveAllyCount(allySetting, sosigCount); if (slot < num) { return 0; } int num2 = ClampTeamCount(teamCount) - 1; return 1 + (slot - num) % num2; } default: return 1; } } public static int IffFor(TeamMode mode, int teamIndex, int playerIff) { switch (mode) { case TeamMode.FreeForAll: { int num2 = Math.Max(1, teamIndex); if (playerIff >= 1 && num2 >= playerIff) { num2++; } return Math.Min(num2, 31); } case TeamMode.Teams: { if (teamIndex == 0) { return playerIff; } int num = teamIndex; if (num == playerIff) { num = 31; } return num; } default: return 1; } } } public enum TeamMode { Off, FreeForAll, Teams } public static class TeamScore { public static int Total(IEnumerable<Contestant> contestants, int teamIndex) { int num = 0; foreach (Contestant contestant in contestants) { if (contestant != null && contestant.TeamIndex == teamIndex) { num += contestant.Kills; } } return num; } public static int Winner(IEnumerable<Contestant> contestants, int teamCount, int pointsToWin) { List<Contestant> contestants2 = new List<Contestant>(contestants); for (int i = 0; i < teamCount; i++) { if (Total(contestants2, i) >= pointsToWin) { return i; } } return -1; } } public struct Vec3 { public float X; public float Y; public float Z; public static readonly Vec3 Zero = new Vec3(0f, 0f, 0f); public bool IsZero { get { if (X == 0f && Y == 0f) { return Z == 0f; } return false; } } public Vec3(float x, float y, float z) { X = x; Y = y; Z = z; } public static float Distance(Vec3 a, Vec3 b) { float num = a.X - b.X; float num2 = a.Y - b.Y; float num3 = a.Z - b.Z; return (float)Math.Sqrt(num * num + num2 * num2 + num3 * num3); } public override string ToString() { return "(" + X + ", " + Y + ", " + Z + ")"; } }
plugins/GunGameArena/GunGameArena.dll
Decompiled a day 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.Reflection; using System.Runtime.CompilerServices; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using FistVR; using GunGame.Scripts; using GunGame.Scripts.Options; using GunGameArena.Behaviour; using GunGameArena.Core; using GunGameArena.Hud; using GunGameArena.Panel; using GunGameArena.Patches; using GunGameArena.Portraits; using HarmonyLib; using Steamworks; using UnityEngine; using UnityEngine.AI; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyCompany("GunGameArena")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+9485d5f4df5522592f81514e7da3ef3cdc450e7c")] [assembly: AssemblyProduct("GunGameArena")] [assembly: AssemblyTitle("GunGameArena")] [assembly: AssemblyVersion("1.0.0.0")] namespace GunGameArena { public static class ArenaConfig { public static ConfigEntry<TeamMode> Mode; public static ConfigEntry<int> TeamCount; public static ConfigEntry<int> AllySosigs; public static ConfigEntry<int> PointsToWin; public static ConfigEntry<bool> FriendlyFire; public static ConfigEntry<float> TagRange; public static ConfigEntry<bool> TeamTint; public static ConfigEntry<float> PanelScale; public static ConfigEntry<bool> DebugLogging; public static ConfigEntry<bool> LeaderboardEnabled; public static ConfigEntry<int> TopCount; public static ConfigEntry<float> Scale; public static ConfigEntry<float> Distance; public static ConfigEntry<float> Height; public static ConfigEntry<bool> ShowNames; public static ConfigEntry<bool> ShowTierBadge; public static ConfigEntry<int> NameSeed; public static ConfigEntry<bool> SpreadSpawns; public static ConfigEntry<bool> Grudges; public static ConfigEntry<int> RivalCount; public static ConfigEntry<float> RivalRadius; public static ConfigEntry<float> PlayerRivalWeight; public static ConfigEntry<float> RivalRerollMin; public static ConfigEntry<float> RivalRerollMax; public static ConfigEntry<bool> Hunters; public static ConfigEntry<float> HunterShare; public static ConfigEntry<float> HunterIntervalMin; public static ConfigEntry<float> HunterIntervalMax; public static ConfigEntry<bool> SkillTiers; public static ConfigEntry<string> TierWeights; private static readonly Dictionary<SkillTier, ConfigEntry<float>[]> TierEntries = new Dictionary<SkillTier, ConfigEntry<float>[]>(); public unsafe static void Bind(ConfigFile cfg) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Expected O, but got Unknown //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Expected O, but got Unknown //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Expected O, but got Unknown //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Expected O, but got Unknown //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_040e: Unknown result type (might be due to invalid IL or missing references) //IL_042d: Unknown result type (might be due to invalid IL or missing references) //IL_043e: Unknown result type (might be due to invalid IL or missing references) //IL_0459: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) Mode = cfg.Bind<TeamMode>("Arena", "Mode", (TeamMode)1, "Off = original GunGame. FreeForAll = every sosig for itself. Teams = blue (you + allies) vs red (+ green/yellow)."); TeamCount = cfg.Bind<int>("Arena", "TeamCount", 2, new ConfigDescription("Teams mode only.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(2, 4), new object[0])); AllySosigs = cfg.Bind<int>("Arena", "AllySosigs", -1, "Sosigs on your team in Teams mode. -1 = half of the sosig count."); PointsToWin = cfg.Bind<int>("Teams", "PointsToWin", 30, new ConfigDescription("Team Deathmatch: team score that ends the round.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(5, 200), new object[0])); FriendlyFire = cfg.Bind<bool>("Teams", "FriendlyFire", false, "Team Deathmatch: when false your shots never damage your own team."); TagRange = cfg.Bind<float>("Teams", "TagRange", 0f, "Team Deathmatch: hide teammate name tags beyond this distance in metres. 0 = always visible."); TeamTint = cfg.Bind<bool>("Teams", "TeamTint", true, "Tint your teammates' bodies blue so you can tell them apart."); PanelScale = cfg.Bind<float>("Panel", "Scale", 1f, new ConfigDescription("Size multiplier for the in-map Arena panel.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2f), new object[0])); DebugLogging = cfg.Bind<bool>("Debug", "Verbose", false, "Log diagnostic dumps (panel hierarchy, teammate tag status, per-sosig tint) at Info level."); LeaderboardEnabled = cfg.Bind<bool>("Leaderboard", "Enabled", true, "Show the floating leaderboard HUD."); TopCount = cfg.Bind<int>("Leaderboard", "TopCount", 5, new ConfigDescription("Cards shown before your own card is pinned at the end.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 12), new object[0])); Scale = cfg.Bind<float>("Leaderboard", "Scale", 1f, "Overall HUD size multiplier."); Distance = cfg.Bind<float>("Leaderboard", "Distance", 1f, "Metres in front of your head."); Height = cfg.Bind<float>("Leaderboard", "Height", 0.35f, "Metres above eye line."); ShowNames = cfg.Bind<bool>("Leaderboard", "ShowNames", true, "Name label under each card."); ShowTierBadge = cfg.Bind<bool>("Leaderboard", "ShowTierBadge", true, "Skill tier chevrons under each sosig's name."); NameSeed = cfg.Bind<int>("Names", "Seed", 0, "0 = random names every round; any other value = reproducible roster."); SpreadSpawns = cfg.Bind<bool>("Behaviour", "SpreadSpawns", true, "Spawn each sosig at the spawner farthest from everyone."); Grudges = cfg.Bind<bool>("Behaviour", "Grudges", true, "FFA only: each sosig hunts a few rivals at a time instead of everyone."); RivalCount = cfg.Bind<int>("Behaviour", "RivalCount", 3, new ConfigDescription("Rivals per sosig.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 8), new object[0])); RivalRadius = cfg.Bind<float>("Behaviour", "RivalRadius", 40f, "Metres; rivals are picked from contestants within this radius."); PlayerRivalWeight = cfg.Bind<float>("Behaviour", "PlayerRivalWeight", 2f, "How much more likely you are to be picked as a rival than a sosig (1 = equal)."); RivalRerollMin = cfg.Bind<float>("Behaviour", "RivalRerollSecondsMin", 20f, "Seconds between rival re-rolls (min)."); RivalRerollMax = cfg.Bind<float>("Behaviour", "RivalRerollSecondsMax", 40f, "Seconds between rival re-rolls (max)."); Hunters = cfg.Bind<bool>("Behaviour", "Hunters", true, "Periodically send a share of hostile sosigs toward you."); HunterShare = cfg.Bind<float>("Behaviour", "HunterShare", 0.25f, new ConfigDescription("Fraction of hostile sosigs sent toward you each interval.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0])); HunterIntervalMin = cfg.Bind<float>("Behaviour", "HunterIntervalSecondsMin", 10f, "Seconds between hunter orders (min)."); HunterIntervalMax = cfg.Bind<float>("Behaviour", "HunterIntervalSecondsMax", 20f, "Seconds between hunter orders (max)."); SkillTiers = cfg.Bind<bool>("Behaviour", "SkillTiers", true, "Roll Rookie/Regular/Veteran/Elite per contestant; affects aim, not fire volume."); TierWeights = cfg.Bind<string>("Behaviour", "TierWeights", "30,40,20,10", "Relative weights Rookie,Regular,Veteran,Elite."); TierEntries.Clear(); SkillTier[] array = (SkillTier[])(object)new SkillTier[4] { default(SkillTier), (SkillTier)1, (SkillTier)2, (SkillTier)3 }; for (int i = 0; i < array.Length; i++) { SkillTier val = array[i]; TierMultipliers val2 = TierTable.Default(val); string text = "Tier." + ((object)(*(SkillTier*)(&val))/*cast due to .constrained prefix*/).ToString(); TierEntries[val] = new ConfigEntry<float>[4] { cfg.Bind<float>(text, "Spread", val2.Spread, "Multiplier on weapon projectile spread (bigger = misses more)."), cfg.Bind<float>(text, "FireAngle", val2.FireAngle, "Multiplier on how far off-target the sosig will still fire."), cfg.Bind<float>(text, "Refire", val2.Refire, "Multiplier on delay between shots (bigger = slower)."), cfg.Bind<float>(text, "Reaction", val2.Reaction, "Multiplier on target recognition speed (bigger = faster).") }; } } public static TierMultipliers MultipliersFor(SkillTier tier) { //IL_0005: 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_000f: 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) if (!TierEntries.TryGetValue(tier, out var value)) { return TierTable.Default(tier); } return new TierMultipliers(value[0].Value, value[1].Value, value[2].Value, value[3].Value); } } public static class ConfigMigration { public static void MigrateLegacyConfig(string newPath) { try { if (string.IsNullOrEmpty(newPath)) { return; } string directoryName = Path.GetDirectoryName(newPath); if (string.IsNullOrEmpty(directoryName)) { return; } string text = Path.Combine(directoryName, "shaha.GunGameArena.cfg"); bool flag = !File.Exists(newPath) || new FileInfo(newPath).Length == 0; if (File.Exists(text) && flag) { File.Copy(text, newPath, overwrite: true); if (Plugin.Log != null) { Plugin.Log.LogInfo((object)"Migrated settings from shaha.GunGameArena.cfg to zgames.GunGameArena.cfg."); } } } catch (Exception ex) { if (Plugin.Log != null) { Plugin.Log.LogError((object)("Config migration failed: " + ex)); } } } } public static class GunGameHooks { public static bool RoundActive { get; private set; } public static event Action RoundStarting; public static event Action RoundStarted; public static event Action RoundEnded; public static void Install() { GameManager.BeforeGameStartedEvent = (Action)Delegate.Combine(GameManager.BeforeGameStartedEvent, new Action(OnBefore)); GameManager.GameStartedEvent = (Action)Delegate.Combine(GameManager.GameStartedEvent, new Action(OnStarted)); SceneManager.sceneLoaded += OnSceneLoaded; } public static void Uninstall() { GameManager.BeforeGameStartedEvent = (Action)Delegate.Remove(GameManager.BeforeGameStartedEvent, new Action(OnBefore)); GameManager.GameStartedEvent = (Action)Delegate.Remove(GameManager.GameStartedEvent, new Action(OnStarted)); SceneManager.sceneLoaded -= OnSceneLoaded; } private static void OnBefore() { try { RoundActive = true; Plugin.Log.LogInfo((object)"Round starting."); if (GunGameHooks.RoundStarting != null) { GunGameHooks.RoundStarting(); } } catch (Exception ex) { Plugin.Log.LogError((object)("RoundStarting handler failed: " + ex)); } } private static void OnStarted() { try { Plugin.Log.LogInfo((object)"Round started."); if (GunGameHooks.RoundStarted != null) { GunGameHooks.RoundStarted(); } } catch (Exception ex) { Plugin.Log.LogError((object)("RoundStarted handler failed: " + ex)); } } private static void OnSceneLoaded(Scene scene, LoadSceneMode mode) { try { if (RoundActive) { RoundActive = false; Plugin.Log.LogInfo((object)"Scene changed, round ended."); if (GunGameHooks.RoundEnded != null) { GunGameHooks.RoundEnded(); } } } catch (Exception ex) { Plugin.Log.LogError((object)("RoundEnded handler failed: " + ex)); } } } public static class KillTracker { private struct LastHit { public int Iff; public Vector3 Point; public float Time; } private static readonly Dictionary<int, LastHit> _hits = new Dictionary<int, LastHit>(); private static readonly HashSet<int> _processed = new HashSet<int>(); private static readonly Dictionary<int, bool> _killedByPlayer = new Dictionary<int, bool>(); private static FVRSceneSettings _subscribedScene; public static event Action<Contestant, Contestant> KillRegistered; public static event Action<Slot, int> RetaliationTriggered; public static void Install() { GunGameHooks.RoundStarting += OnRoundStarting; GunGameHooks.RoundEnded += OnRoundEnded; SpawnerPatches.SosigBound += delegate(Slot slot) { if ((Object)(object)slot.Sosig != (Object)null) { ForgetSosig(slot.Sosig); } }; } private static void OnRoundStarting() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown _hits.Clear(); _processed.Clear(); _killedByPlayer.Clear(); if ((Object)(object)_subscribedScene != (Object)null) { _subscribedScene.PlayerDeathFromIFFEvent -= new PlayerDeathFromIFF(OnPlayerDeath); } _subscribedScene = GM.CurrentSceneSettings; if ((Object)(object)_subscribedScene != (Object)null) { _subscribedScene.PlayerDeathFromIFFEvent += new PlayerDeathFromIFF(OnPlayerDeath); } } private static void OnRoundEnded() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown if ((Object)(object)_subscribedScene != (Object)null) { _subscribedScene.PlayerDeathFromIFFEvent -= new PlayerDeathFromIFF(OnPlayerDeath); } _subscribedScene = null; } public static void ForgetSosig(Sosig s) { if (!((Object)(object)s == (Object)null)) { int instanceID = ((Object)s).GetInstanceID(); _hits.Remove(instanceID); _processed.Remove(instanceID); _killedByPlayer.Remove(instanceID); } } public static void RecordHit(Sosig victim, Damage d) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 if ((Object)(object)victim == (Object)null || d == null || !Roster.Active || TeamMatch.ShouldBlockFriendlyFire(victim, d)) { return; } Slot slot = Roster.FindBySosig(victim); if (slot == null) { return; } Vector3 point = ((d.Source_Point == Vector3.zero) ? d.point : d.Source_Point); _hits[((Object)victim).GetInstanceID()] = new LastHit { Iff = d.Source_IFF, Point = point, Time = Time.time }; if (ArenaConfig.Grudges.Value && (int)Roster.Mode == 1 && d.Source_IFF >= 0 && d.Source_IFF != victim.GetIFF() && victim.Priority != null) { victim.Priority.MakeEnemy(d.Source_IFF); if (KillTracker.RetaliationTriggered != null) { KillTracker.RetaliationTriggered(slot, d.Source_IFF); } } } private static Contestant AttributeVictim(Sosig victim, Slot slot, out int killerIff) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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) int instanceID = ((Object)victim).GetInstanceID(); LastHit value; bool flag = _hits.TryGetValue(instanceID, out value); killerIff = (flag ? value.Iff : victim.GetDiedFromIFF()); Vector3 v = (flag ? value.Point : ((Component)victim).transform.position); Roster.UpdatePositions(); return KillAttribution.Nearest(Roster.AllContestants, killerIff, slot.Contestant.Id, Roster.ToVec(v)); } public static void OnSosigDying(Sosig victim) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 if ((Object)(object)victim == (Object)null || !Roster.Active || (int)victim.BodyState == 3) { return; } int instanceID = ((Object)victim).GetInstanceID(); if (!_processed.Add(instanceID)) { return; } Slot slot = Roster.FindBySosig(victim); if (slot != null) { int killerIff; Contestant val = AttributeVictim(victim, slot, out killerIff); Roster.MarkDead(slot); _killedByPlayer[instanceID] = val?.IsPlayer ?? false; if (val != null) { val.AddKill(Time.time); Plugin.Log.LogInfo((object)("KILL " + val.Name + " -> " + slot.Contestant.Name + " (iff " + killerIff + ")")); } else { Plugin.Log.LogInfo((object)("DEATH " + slot.Contestant.Name + " with no credited killer (iff " + killerIff + ")")); } if (KillTracker.KillRegistered != null) { KillTracker.KillRegistered(slot.Contestant, val); } Roster.RaiseChanged(); } } public static bool LastKillWasByPlayer(Sosig victim) { if ((Object)(object)victim == (Object)null) { return true; } if (_killedByPlayer.TryGetValue(((Object)victim).GetInstanceID(), out var value)) { return value; } Slot slot = Roster.FindBySosig(victim); int killerIff; if (slot != null) { return AttributeVictim(victim, slot, out killerIff)?.IsPlayer ?? false; } return victim.GetDiedFromIFF() == Roster.PlayerIff; } public static void OnPlayerDeath(bool killedSelf, int iff) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) try { if (!Roster.Active || killedSelf || Roster.Player == null) { return; } Roster.UpdatePositions(); List<Contestant> list = new List<Contestant>(); foreach (Slot item in Roster.LivingSosigSlots()) { list.Add(item.Contestant); } Contestant val = KillAttribution.Nearest((IEnumerable<Contestant>)list, iff, Roster.Player.Contestant.Id, Roster.Player.Contestant.Position); if (val != null) { val.AddKill(Time.time); Plugin.Log.LogInfo((object)("KILL " + val.Name + " -> " + Roster.Player.Contestant.Name + " (player, iff " + iff + ")")); if (KillTracker.KillRegistered != null) { KillTracker.KillRegistered(null, val); } Roster.RaiseChanged(); } } catch (Exception ex) { Plugin.Log.LogError((object)("KillTracker.OnPlayerDeath: " + ex)); } } } [BepInPlugin("zgames.GunGameArena", "GunGame Arena", "1.0.2")] [BepInDependency("Kodeman.GunGame", "1.0.4")] public class Plugin : BaseUnityPlugin { public const string Guid = "zgames.GunGameArena"; public const string Name = "GunGame Arena"; public const string Version = "1.0.2"; public static ManualLogSource Log; public static Plugin Instance; private Harmony _harmony; private void Awake() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) Instance = this; Log = ((BaseUnityPlugin)this).Logger; try { ConfigMigration.MigrateLegacyConfig(((BaseUnityPlugin)this).Config.ConfigFilePath); ArenaConfig.Bind(((BaseUnityPlugin)this).Config); _harmony = new Harmony("zgames.GunGameArena"); _harmony.PatchAll(typeof(Plugin).Assembly); GunGameHooks.Install(); Roster.Install(); KillTracker.Install(); PortraitRenderer.Install(); LeaderboardHud.Install(); GrudgeDirector.Install(); HunterDirector.Install(); SkillApplier.Install(); PanelInstaller.Install(); TeamMatch.Install(); TeamTags.Install(); TeamTint.Install(); Log.LogInfo((object)("GunGame Arena 1.0.2 loaded. Mode=" + ((object)ArenaConfig.Mode.Value/*cast due to .constrained prefix*/).ToString() + " Leaderboard=" + ArenaConfig.LeaderboardEnabled.Value)); } catch (Exception ex) { Log.LogError((object)("GunGame Arena failed during initialisation: " + ex?.ToString() + " — features may be partially active.")); } } private void OnDestroy() { GunGameHooks.Uninstall(); if (_harmony != null) { _harmony.UnpatchSelf(); } } } public class Slot { public Contestant Contestant; public Sosig Sosig; public Sprite Portrait; public bool IsVacant { get { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 if (!((Object)(object)Sosig == (Object)null)) { return (int)Sosig.BodyState == 3; } return true; } } } public static class Roster { public static bool Active; public static TeamMode Mode = (TeamMode)0; public static int PlayerIff; public static Slot Player; public static readonly List<Slot> SosigSlots = new List<Slot>(); private static int _nextId; private static NameGenerator _names; private static Random _rng; public static IEnumerable<Contestant> AllContestants { get { if (Player != null) { yield return Player.Contestant; } for (int i = 0; i < SosigSlots.Count; i++) { yield return SosigSlots[i].Contestant; } } } public static event Action Changed; public static void Install() { GunGameHooks.RoundStarting += OnRoundStarting; GunGameHooks.RoundEnded += OnRoundEnded; } private static void OnRoundStarting() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) int playerIff; if ((Object)(object)GM.CurrentPlayerBody != (Object)null) { playerIff = GM.CurrentPlayerBody.GetPlayerIFF(); } else { Plugin.Log.LogWarning((object)"Player body missing at round start; assuming player IFF 0."); playerIff = 0; } Reset(GameSettings.MaxSosigCount, ArenaConfig.Mode.Value, playerIff); } private static void OnRoundEnded() { Active = false; SosigSlots.Clear(); Player = null; RaiseChanged(); } public unsafe static void Reset(int sosigCount, TeamMode mode, int playerIff) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: 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_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Expected O, but got Unknown if (sosigCount > 31) { Plugin.Log.LogWarning((object)("Sosig count " + sosigCount + " exceeds " + 31 + " IFFs; some sosigs will share an IFF (spec §4).")); } Mode = mode; PlayerIff = playerIff; _nextId = 1; int value = ArenaConfig.NameSeed.Value; _names = new NameGenerator(value); _rng = ((value == 0) ? new Random() : new Random(value)); int[] weights = TierRoller.ParseWeights(ArenaConfig.TierWeights.Value); SosigSlots.Clear(); for (int i = 0; i < sosigCount; i++) { SosigSlots.Add(NewSlot(i, sosigCount, weights)); } string name = "You"; try { if (!string.IsNullOrEmpty(GM.PlayerName)) { name = GM.PlayerName; } } catch { } Player = new Slot { Contestant = new Contestant { Id = 0, Name = name, TeamIndex = 0, Iff = playerIff, IsPlayer = true, IsAlive = true } }; Active = true; Plugin.Log.LogInfo((object)("Roster reset: " + sosigCount + " sosigs, mode " + ((object)(*(TeamMode*)(&mode))/*cast due to .constrained prefix*/).ToString() + ", player IFF " + playerIff)); if (ArenaConfig.DebugLogging.Value) { for (int j = 0; j < SosigSlots.Count; j++) { Plugin.Log.LogInfo((object)(" slot " + j + ": " + ((object)SosigSlots[j].Contestant)?.ToString() + " tier " + ((object)Unsafe.As<SkillTier, SkillTier>(ref SosigSlots[j].Contestant.Tier)/*cast due to .constrained prefix*/).ToString())); } } RaiseChanged(); } private static Slot NewSlot(int slotIndex, int sosigCount, int[] weights) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_006d: 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_008e: Expected O, but got Unknown int num = TeamAssigner.TeamIndexFor(Mode, slotIndex, sosigCount, ArenaConfig.TeamCount.Value, ArenaConfig.AllySosigs.Value); Contestant contestant = new Contestant { Id = _nextId++, Name = _names.Next(), TeamIndex = num, Iff = TeamAssigner.IffFor(Mode, num, PlayerIff), IsAlive = false, Tier = (SkillTier)((!ArenaConfig.SkillTiers.Value) ? 1 : ((int)TierRoller.Roll(_rng, weights))) }; return new Slot { Contestant = contestant }; } public static Slot ClaimVacantSlot() { for (int i = 0; i < SosigSlots.Count; i++) { if (SosigSlots[i].IsVacant) { return SosigSlots[i]; } } Slot slot = NewSlot(SosigSlots.Count, SosigSlots.Count + 1, TierRoller.ParseWeights(ArenaConfig.TierWeights.Value)); SosigSlots.Add(slot); Plugin.Log.LogWarning((object)("More sosigs than roster slots; added " + (object)slot.Contestant)); return slot; } public static void Bind(Slot slot, Sosig sosig) { slot.Sosig = sosig; slot.Contestant.IsAlive = (Object)(object)sosig != (Object)null; } public static Slot FindBySosig(Sosig sosig) { if ((Object)(object)sosig == (Object)null) { return null; } for (int i = 0; i < SosigSlots.Count; i++) { if ((Object)(object)SosigSlots[i].Sosig == (Object)(object)sosig) { return SosigSlots[i]; } } return null; } public static void MarkDead(Slot slot) { slot.Contestant.IsAlive = false; } public static IEnumerable<Slot> LivingSosigSlots() { for (int i = 0; i < SosigSlots.Count; i++) { Slot slot = SosigSlots[i]; if (!slot.IsVacant && slot.Contestant.IsAlive) { yield return slot; } } } public static Vector3 PlayerHeadPosition() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) FVRPlayerBody currentPlayerBody = GM.CurrentPlayerBody; if ((Object)(object)currentPlayerBody == (Object)null || (Object)(object)currentPlayerBody.Head == (Object)null) { return Vector3.zero; } return currentPlayerBody.Head.position; } public static void UpdatePositions() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) if (Player != null) { Player.Contestant.Position = ToVec(PlayerHeadPosition()); } for (int i = 0; i < SosigSlots.Count; i++) { Slot slot = SosigSlots[i]; if (!((Object)(object)slot.Sosig == (Object)null)) { Transform val = ((slot.Sosig.Links != null && slot.Sosig.Links.Count > 0 && (Object)(object)slot.Sosig.Links[0] != (Object)null) ? ((Component)slot.Sosig.Links[0]).transform : ((Component)slot.Sosig).transform); slot.Contestant.Position = ToVec(val.position); } } } public static Vec3 ToVec(Vector3 v) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vec3(v.x, v.y, v.z); } public static void RaiseChanged() { if (Roster.Changed == null) { return; } Delegate[] invocationList = Roster.Changed.GetInvocationList(); foreach (Delegate obj in invocationList) { try { ((Action)obj)(); } catch (Exception ex) { Plugin.Log.LogError((object)("Roster.Changed handler failed: " + ex)); } } } } } namespace GunGameArena.Portraits { public class PortraitRenderer : MonoBehaviour { private const int Size = 128; private static PortraitRenderer _instance; private Camera _cam; private RenderTexture _rt; public static void Install() { SpawnerPatches.SosigBound += Capture; GunGameHooks.RoundStarted += OnRoundStarted; } private static void OnRoundStarted() { try { if (Roster.Player == null) { return; } ((MonoBehaviour)Ensure()).StartCoroutine(SteamAvatar.Load(delegate(Sprite sprite) { if (Roster.Player != null) { if ((Object)(object)Roster.Player.Portrait != (Object)null && (Object)(object)Roster.Player.Portrait != (Object)(object)Sprites.FallbackAvatar && (Object)(object)Roster.Player.Portrait.texture != (Object)null) { Object.Destroy((Object)(object)Roster.Player.Portrait.texture); } Roster.Player.Portrait = sprite; Roster.RaiseChanged(); } })); } catch (Exception ex) { Plugin.Log.LogError((object)("PortraitRenderer.OnRoundStarted: " + ex)); } } public static void Capture(Slot slot) { try { PortraitRenderer portraitRenderer = Ensure(); ((MonoBehaviour)portraitRenderer).StartCoroutine(portraitRenderer.CaptureRoutine(slot)); } catch (Exception ex) { Plugin.Log.LogError((object)("PortraitRenderer.Capture: " + ex)); } } private static PortraitRenderer Ensure() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown if ((Object)(object)_instance != (Object)null) { return _instance; } GameObject val = new GameObject("GunGameArena_PortraitCam"); _instance = val.AddComponent<PortraitRenderer>(); _instance._cam = val.AddComponent<Camera>(); ((Behaviour)_instance._cam).enabled = false; _instance._cam.clearFlags = (CameraClearFlags)2; _instance._cam.backgroundColor = Color.clear; _instance._cam.fieldOfView = 30f; _instance._cam.nearClipPlane = 0.05f; _instance._cam.farClipPlane = 1.2f; _instance._cam.cullingMask = -1; _instance._rt = new RenderTexture(128, 128, 16, (RenderTextureFormat)0); _instance._cam.targetTexture = _instance._rt; return _instance; } private IEnumerator CaptureRoutine(Slot slot) { yield return null; yield return (object)new WaitForEndOfFrame(); Sosig sosig = slot.Sosig; Sprite val = TryRender(sosig); if ((Object)(object)val == (Object)null) { val = Sprites.FallbackAvatar; } if ((Object)(object)slot.Portrait != (Object)null && (Object)(object)slot.Portrait != (Object)(object)Sprites.FallbackAvatar && (Object)(object)slot.Portrait.texture != (Object)null) { Object.Destroy((Object)(object)slot.Portrait.texture); } slot.Portrait = val; Roster.RaiseChanged(); } private Sprite TryRender(Sosig sosig) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown try { if ((Object)(object)sosig == (Object)null || sosig.Links == null || sosig.Links.Count == 0 || (Object)(object)sosig.Links[0] == (Object)null) { return null; } Transform transform = ((Component)sosig.Links[0]).transform; Vector3 forward = ((Component)sosig).transform.forward; ((Component)_cam).transform.position = transform.position + forward * 0.45f + Vector3.up * 0.03f; ((Component)_cam).transform.LookAt(transform.position); _cam.Render(); RenderTexture active = RenderTexture.active; RenderTexture.active = _rt; Texture2D val = new Texture2D(128, 128, (TextureFormat)5, false); val.ReadPixels(new Rect(0f, 0f, 128f, 128f), 0, 0); val.Apply(); RenderTexture.active = active; return Sprites.FromTexture(val); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Portrait render failed: " + ex.Message)); return null; } } private void OnDestroy() { if ((Object)(object)_rt != (Object)null) { _rt.Release(); } if ((Object)(object)_instance == (Object)(object)this) { _instance = null; } } } public static class Sprites { private static Sprite _crown; private static Sprite _fallback; private static Sprite _solid; public static Sprite Solid { get { if ((Object)(object)_solid == (Object)null) { _solid = MakeSolid(); } return _solid; } } public static Sprite Crown { get { if ((Object)(object)_crown == (Object)null) { _crown = MakeCrown(); } return _crown; } } public static Sprite FallbackAvatar { get { if ((Object)(object)_fallback == (Object)null) { _fallback = MakeFallbackAvatar(); } return _fallback; } } public static Sprite FromTexture(Texture2D tex) { //IL_0019: 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) return Sprite.Create(tex, new Rect(0f, 0f, (float)((Texture)tex).width, (float)((Texture)tex).height), new Vector2(0.5f, 0.5f)); } private static Sprite MakeSolid() { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(4, 4, (TextureFormat)4, false); Color32[] array = (Color32[])(object)new Color32[16]; for (int i = 0; i < array.Length; i++) { array[i] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue); } val.SetPixels32(array); val.Apply(); return FromTexture(val); } private static Sprite MakeCrown() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(32, 32, (TextureFormat)4, false); Color32 val2 = default(Color32); ((Color32)(ref val2))..ctor((byte)0, (byte)0, (byte)0, (byte)0); Color32 val3 = default(Color32); ((Color32)(ref val3))..ctor((byte)245, (byte)197, (byte)66, byte.MaxValue); Color32[] array = (Color32[])(object)new Color32[1024]; for (int i = 0; i < 32; i++) { for (int j = 0; j < 32; j++) { bool flag = false; if (i >= 4 && i < 12) { flag = j >= 3 && j < 29; } else if (i >= 12 && i < 28) { int num = i - 12; int num2 = 5 - num / 4; if (num2 < 1) { num2 = 1; } flag = Mathf.Abs(j - 6) <= num2 || Mathf.Abs(j - 16) <= num2 + 1 || Mathf.Abs(j - 25) <= num2; if (Mathf.Abs(j - 16) <= num2 + 1 && i < 30) { flag = true; } } array[i * 32 + j] = (flag ? val3 : val2); } } val.SetPixels32(array); val.Apply(); return FromTexture(val); } private static Sprite MakeFallbackAvatar() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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) Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false); Color32[] array = (Color32[])(object)new Color32[16384]; Color32 val2 = default(Color32); ((Color32)(ref val2))..ctor((byte)60, (byte)60, (byte)60, byte.MaxValue); Color32 val3 = default(Color32); ((Color32)(ref val3))..ctor((byte)170, (byte)170, (byte)170, byte.MaxValue); for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { float num = (float)j - 64f; float num2 = (float)i - 64f; bool flag = num * num + num2 * num2 <= 3844f; float num3 = (float)j - 64f; float num4 = (float)i - 78f; bool flag2 = num3 * num3 + num4 * num4 <= 484f; float num5 = (float)j - 64f; float num6 = (float)i - 30f; bool flag3 = num5 * num5 / 1444f + num6 * num6 / 576f <= 1f && i < 50; array[i * 128 + j] = (Color32)((!flag) ? new Color32((byte)0, (byte)0, (byte)0, (byte)0) : ((flag2 || flag3) ? val3 : val2)); } } val.SetPixels32(array); val.Apply(); return FromTexture(val); } } public static class SteamAvatar { private const float TimeoutSeconds = 10f; public static IEnumerator Load(Action<Sprite> onDone) { Sprite result = null; if (SafeIsSteamReady()) { float deadline = Time.time + 10f; int num = SafeGetHandle(); while (num == -1 && Time.time < deadline) { yield return (object)new WaitForSeconds(1f); num = SafeGetHandle(); } if (num > 0) { result = SafeToSprite(num); } } if ((Object)(object)result == (Object)null) { Plugin.Log.LogInfo((object)"Steam avatar unavailable, using fallback portrait."); result = Sprites.FallbackAvatar; } onDone(result); } private static bool SafeIsSteamReady() { try { return SteamManager.Initialized; } catch (Exception ex) { Plugin.Log.LogWarning((object)("SteamManager check failed: " + ex.Message)); return false; } } private static int SafeGetHandle() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) try { return SteamFriends.GetLargeFriendAvatar(SteamUser.GetSteamID()); } catch (Exception ex) { Plugin.Log.LogWarning((object)("GetLargeFriendAvatar failed: " + ex.Message)); return 0; } } private static Sprite SafeToSprite(int handle) { //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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown try { uint num = default(uint); uint num2 = default(uint); if (!SteamUtils.GetImageSize(handle, ref num, ref num2) || num == 0 || num2 == 0) { return null; } byte[] array = new byte[num * num2 * 4]; if (!SteamUtils.GetImageRGBA(handle, array, array.Length)) { return null; } byte[] array2 = new byte[array.Length]; int num3 = (int)(num * 4); for (int i = 0; i < num2; i++) { Buffer.BlockCopy(array, i * num3, array2, ((int)(num2 - 1) - i) * num3, num3); } Texture2D val = new Texture2D((int)num, (int)num2, (TextureFormat)4, false); val.LoadRawTextureData(array2); val.Apply(); return Sprites.FromTexture(val); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Steam avatar decode failed: " + ex.Message)); return null; } } } } namespace GunGameArena.Patches { [HarmonyPatch(typeof(Sosig), "ProcessDamage", new Type[] { typeof(Damage), typeof(SosigLink) })] public static class ProcessDamagePatch { [HarmonyPostfix] private static void Postfix(Sosig __instance, Damage d) { try { KillTracker.RecordHit(__instance, d); } catch (Exception ex) { Plugin.Log.LogError((object)("ProcessDamagePatch: " + ex)); } } } [HarmonyPatch(typeof(Sosig), "SosigDies")] public static class SosigDiesPatch { [HarmonyPrefix] private static void Prefix(Sosig __instance) { try { KillTracker.OnSosigDying(__instance); } catch (Exception ex) { Plugin.Log.LogError((object)("SosigDiesPatch: " + ex)); } } } [HarmonyPatch(typeof(Progression), "OnSosigKilledByPlayer")] public static class ProgressionPatches { [HarmonyPrefix] private static bool Prefix(Sosig killedSosig) { try { if (!Roster.Active) { return true; } bool num = KillTracker.LastKillWasByPlayer(killedSosig); if (!num) { Plugin.Log.LogInfo((object)"Blocked progression credit: kill was by an ally, not the player."); } return num; } catch (Exception ex) { Plugin.Log.LogError((object)("ProgressionPatches: " + ex)); return true; } } } [HarmonyPatch(typeof(CustomSosigSpawner), "Spawn")] public static class SpawnerPatches { public static event Action<Slot> SosigBound; [HarmonyPrefix] private static void Prefix(CustomSosigSpawner __instance, ref Slot __state) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) __state = null; try { if (Roster.Active) { __state = Roster.ClaimVacantSlot(); if ((int)Roster.Mode != 0) { __instance.IFF = __state.Contestant.Iff; } } } catch (Exception ex) { Plugin.Log.LogError((object)("SpawnerPatches.Prefix: " + ex)); } } [HarmonyPostfix] private unsafe static void Postfix(SpawnedSosigInfo __result, Slot __state) { //IL_0003: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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) try { if (__state == null || (Object)(object)__result.SpawnedSosig == (Object)null) { return; } Roster.Bind(__state, __result.SpawnedSosig); if ((int)Roster.Mode != 0) { int iff = __state.Contestant.Iff; if (__result.SpawnedSosig.GetIFF() != iff) { __result.SpawnedSosig.SetIFF(iff); } } if (ArenaConfig.DebugLogging.Value) { Plugin.Log.LogInfo((object)("Spawned " + ((object)__state.Contestant)?.ToString() + " as " + ((object)(*(SosigEnemyID*)(&__result.SosigType))/*cast due to .constrained prefix*/).ToString() + " (game IFF " + __result.SpawnedSosig.GetIFF() + ")")); } if (SpawnerPatches.SosigBound != null) { SpawnerPatches.SosigBound(__state); } Roster.RaiseChanged(); } catch (Exception ex) { Plugin.Log.LogError((object)("SpawnerPatches.Postfix: " + ex)); } } } [HarmonyPatch(typeof(SosigBehavior), "SpawnSosigRandomPlace")] public static class SpawnPlacementPatches { private static readonly Random Rng = new Random(); [HarmonyPrefix] private static bool Prefix(SosigBehavior __instance, SosigEnemyID sosigtype) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Invalid comparison between Unknown and I4 //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) try { if (!Roster.Active || !ArenaConfig.SpreadSpawns.Value) { return true; } List<CustomSosigSpawner> sosigSpawners = __instance.SosigSpawners; if (sosigSpawners == null || sosigSpawners.Count == 0 || (Object)(object)GM.CurrentPlayerBody == (Object)null) { return true; } List<Vec3> list = new List<Vec3>(sosigSpawners.Count); for (int i = 0; i < sosigSpawners.Count; i++) { list.Add(Roster.ToVec(((Component)sosigSpawners[i]).transform.position)); } List<Vec3> list2 = new List<Vec3>(); foreach (KeyValuePair<Sosig, SosigEnemyID> sosig in __instance.Sosigs) { Sosig key = sosig.Key; if ((Object)(object)key != (Object)null && (int)key.BodyState != 3) { list2.Add(Roster.ToVec(((Component)key).transform.position)); } } int num = SpawnerChooser.Choose(Rng, (IList<Vec3>)list, __instance.IgnoredSpawnersCloseToPlayer, __instance.IgnoredSpawnersFarFromPlayer, Roster.ToVec(((Component)GM.CurrentPlayerBody).transform.position), (IList<Vec3>)list2); if (num < 0) { return true; } SpawnedSosigInfo val = sosigSpawners[num].Spawn(sosigtype); if ((Object)(object)val.SpawnedSosig != (Object)null && !__instance.Sosigs.ContainsKey(val.SpawnedSosig)) { __instance.Sosigs.Add(val.SpawnedSosig, val.SosigType); } return false; } catch (Exception ex) { Plugin.Log.LogError((object)("SpawnPlacementPatches: " + ex)); return true; } } } [HarmonyPatch(typeof(Progression), "Promote")] public static class PromoteLoopPatch { [HarmonyPrefix] private static void Prefix(Progression __instance) { try { TeamMatch.LoopRotationIfNeeded(__instance); } catch (Exception ex) { Plugin.Log.LogError((object)("PromoteLoopPatch: " + ex)); } } } [HarmonyPatch(typeof(SosigLink), "Damage", new Type[] { typeof(Damage) })] public static class FriendlyFirePatch { [HarmonyPrefix] private static bool Prefix(SosigLink __instance, Damage d) { try { return !((Object)(object)__instance != (Object)null) || !TeamMatch.ShouldBlockFriendlyFire(__instance.S, d); } catch (Exception ex) { Plugin.Log.LogError((object)("FriendlyFirePatch: " + ex)); return true; } } } [HarmonyPatch(typeof(SosigWeapon), "BotPickup")] public static class WeaponPatches { [HarmonyPostfix] private static void Postfix(SosigWeapon __instance, Sosig S) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) try { if (Roster.Active && ArenaConfig.SkillTiers.Value) { Slot slot = Roster.FindBySosig(S); if (slot != null) { SkillApplier.ApplyWeapon(__instance, slot.Contestant.Tier); } } } catch (Exception ex) { Plugin.Log.LogError((object)("WeaponPatches: " + ex)); } } } } namespace GunGameArena.Panel { public class ArenaPanel : MonoBehaviour { public const float Width = 620f; public const float Height = 820f; private const float RowH = 52f; private const float FirstRowY = -110f; private const float BtnH = 34f; private Text _modeValue; private Text _teamsValue; private Text _alliesValue; private Text _hunterShareValue; private Text _pointsValue; private Text _teamsLabel; private Text _alliesLabel; private Text _pointsLabel; private Text _leaderboardBtn; private Text _spreadBtn; private Text _grudgesBtn; private Text _huntersBtn; private Text _tiersBtn; private Text _friendlyFireBtn; public static ArenaPanel Build() { //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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("GunGameArena_Panel", new Type[1] { typeof(RectTransform) }) { layer = 0 }; val.AddComponent<Canvas>().renderMode = (RenderMode)2; val.GetComponent<RectTransform>().sizeDelta = new Vector2(620f, 820f); val.transform.localScale = Vector3.one * 0.01f; Image obj = ((Component)UiFactory.MakeRect(val.transform, "Background", new Vector2(0f, -410f), new Vector2(620f, 820f))).gameObject.AddComponent<Image>(); obj.sprite = UiFactory.UiSprite; obj.type = (Type)1; ((Graphic)obj).color = UiFactory.PanelBlue; ((Graphic)obj).raycastTarget = false; ArenaPanel arenaPanel = val.AddComponent<ArenaPanel>(); try { arenaPanel.BuildRows(); } catch (Exception ex) { Plugin.Log.LogError((object)("ArenaPanel.BuildRows: " + ex)); } arenaPanel.Refresh(); return arenaPanel; } private void BuildRows() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown //IL_013a: 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_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Expected O, but got Unknown //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Expected O, but got Unknown //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Expected O, but got Unknown //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Expected O, but got Unknown //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Expected O, but got Unknown //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Expected O, but got Unknown //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_0410: Unknown result type (might be due to invalid IL or missing references) //IL_041c: Unknown result type (might be due to invalid IL or missing references) //IL_042c: Expected O, but got Unknown //IL_0446: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_0461: Unknown result type (might be due to invalid IL or missing references) //IL_0471: Expected O, but got Unknown //IL_048b: Unknown result type (might be due to invalid IL or missing references) //IL_049a: Unknown result type (might be due to invalid IL or missing references) //IL_04a6: Unknown result type (might be due to invalid IL or missing references) //IL_04b6: Expected O, but got Unknown //IL_04d0: Unknown result type (might be due to invalid IL or missing references) //IL_04df: Unknown result type (might be due to invalid IL or missing references) //IL_04eb: Unknown result type (might be due to invalid IL or missing references) //IL_04fb: Expected O, but got Unknown //IL_0525: Unknown result type (might be due to invalid IL or missing references) //IL_0530: Unknown result type (might be due to invalid IL or missing references) //IL_053f: Unknown result type (might be due to invalid IL or missing references) //IL_0565: Unknown result type (might be due to invalid IL or missing references) //IL_0574: Unknown result type (might be due to invalid IL or missing references) //IL_0580: Unknown result type (might be due to invalid IL or missing references) //IL_0590: Expected O, but got Unknown //IL_05ba: Unknown result type (might be due to invalid IL or missing references) //IL_05c5: Unknown result type (might be due to invalid IL or missing references) //IL_05d4: Unknown result type (might be due to invalid IL or missing references) //IL_05f6: Unknown result type (might be due to invalid IL or missing references) //IL_0601: Unknown result type (might be due to invalid IL or missing references) //IL_0610: Unknown result type (might be due to invalid IL or missing references) //IL_062e: Unknown result type (might be due to invalid IL or missing references) //IL_063d: Unknown result type (might be due to invalid IL or missing references) //IL_0649: Unknown result type (might be due to invalid IL or missing references) //IL_0655: Expected O, but got Unknown //IL_0664: Unknown result type (might be due to invalid IL or missing references) //IL_066f: Unknown result type (might be due to invalid IL or missing references) //IL_067e: Unknown result type (might be due to invalid IL or missing references) //IL_06a0: Unknown result type (might be due to invalid IL or missing references) //IL_06af: Unknown result type (might be due to invalid IL or missing references) //IL_06bb: Unknown result type (might be due to invalid IL or missing references) //IL_06c7: Expected O, but got Unknown //IL_06e1: Unknown result type (might be due to invalid IL or missing references) //IL_06f0: Unknown result type (might be due to invalid IL or missing references) //IL_06fc: Unknown result type (might be due to invalid IL or missing references) //IL_070c: Expected O, but got Unknown //IL_0736: Unknown result type (might be due to invalid IL or missing references) //IL_0741: Unknown result type (might be due to invalid IL or missing references) //IL_0750: Unknown result type (might be due to invalid IL or missing references) //IL_0786: Unknown result type (might be due to invalid IL or missing references) //IL_0791: Unknown result type (might be due to invalid IL or missing references) //IL_07a0: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)this).transform; UiFactory.MakeText(transform, "Title", "Arena", 44, Color.white, new Vector2(0f, -50f), new Vector2(580f, 60f), (TextAnchor)4, (FontStyle)1); float num = -110f; UiFactory.MakeText(transform, "ModeLabel", "Mode", 26, Color.white, new Vector2(-200f, num), new Vector2(180f, 52f), (TextAnchor)3, (FontStyle)0); UiFactory.MakeButton(transform, "ModePrev", "<", new Vector2(-60f, num), new Vector2(50f, 34f), (UnityAction)delegate { Click(delegate { //IL_000a: 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) ArenaConfig.Mode.Value = PanelModel.CycleMode(ArenaConfig.Mode.Value, -1); }); }, out var labelText); _modeValue = UiFactory.MakeText(transform, "ModeValue", "", 26, Color.white, new Vector2(95f, num), new Vector2(230f, 52f), (TextAnchor)4, (FontStyle)1); UiFactory.MakeButton(transform, "ModeNext", ">", new Vector2(250f, num), new Vector2(50f, 34f), (UnityAction)delegate { Click(delegate { //IL_000a: 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) ArenaConfig.Mode.Value = PanelModel.CycleMode(ArenaConfig.Mode.Value, 1); }); }, out labelText); num -= 52f; _teamsLabel = UiFactory.MakeText(transform, "TeamsLabel", "Teams", 26, Color.white, new Vector2(-200f, num), new Vector2(180f, 52f), (TextAnchor)3, (FontStyle)0); UiFactory.MakeButton(transform, "TeamsPrev", "<", new Vector2(-60f, num), new Vector2(50f, 34f), (UnityAction)delegate { Click(delegate { ArenaConfig.TeamCount.Value = PanelModel.StepTeamCount(ArenaConfig.TeamCount.Value, -1); }); }, out labelText); _teamsValue = UiFactory.MakeText(transform, "TeamsValue", "", 26, Color.white, new Vector2(95f, num), new Vector2(230f, 52f), (TextAnchor)4, (FontStyle)1); UiFactory.MakeButton(transform, "TeamsNext", ">", new Vector2(250f, num), new Vector2(50f, 34f), (UnityAction)delegate { Click(delegate { ArenaConfig.TeamCount.Value = PanelModel.StepTeamCount(ArenaConfig.TeamCount.Value, 1); }); }, out labelText); num -= 52f; _alliesLabel = UiFactory.MakeText(transform, "AlliesLabel", "Allies", 26, Color.white, new Vector2(-200f, num), new Vector2(180f, 52f), (TextAnchor)3, (FontStyle)0); UiFactory.MakeButton(transform, "AlliesPrev", "<", new Vector2(-60f, num), new Vector2(50f, 34f), (UnityAction)delegate { Click(delegate { ArenaConfig.AllySosigs.Value = PanelModel.StepAllies(ArenaConfig.AllySosigs.Value, -1); }); }, out labelText); _alliesValue = UiFactory.MakeText(transform, "AlliesValue", "", 26, Color.white, new Vector2(95f, num), new Vector2(230f, 52f), (TextAnchor)4, (FontStyle)1); UiFactory.MakeButton(transform, "AlliesNext", ">", new Vector2(250f, num), new Vector2(50f, 34f), (UnityAction)delegate { Click(delegate { ArenaConfig.AllySosigs.Value = PanelModel.StepAllies(ArenaConfig.AllySosigs.Value, 1); }); }, out labelText); num -= 52f; _pointsLabel = UiFactory.MakeText(transform, "PointsLabel", "Points to win", 26, Color.white, new Vector2(-200f, num), new Vector2(180f, 52f), (TextAnchor)3, (FontStyle)0); UiFactory.MakeButton(transform, "PointsPrev", "<", new Vector2(-60f, num), new Vector2(50f, 34f), (UnityAction)delegate { Click(delegate { ArenaConfig.PointsToWin.Value = PanelModel.StepPointsToWin(ArenaConfig.PointsToWin.Value, -1); }); }, out labelText); _pointsValue = UiFactory.MakeText(transform, "PointsValue", "", 26, Color.white, new Vector2(95f, num), new Vector2(230f, 52f), (TextAnchor)4, (FontStyle)1); UiFactory.MakeButton(transform, "PointsNext", ">", new Vector2(250f, num), new Vector2(50f, 34f), (UnityAction)delegate { Click(delegate { ArenaConfig.PointsToWin.Value = PanelModel.StepPointsToWin(ArenaConfig.PointsToWin.Value, 1); }); }, out labelText); num -= 52f; UiFactory.MakeButton(transform, "FriendlyFireToggle", "", new Vector2(0f, num), new Vector2(420f, 34f), (UnityAction)delegate { Click(delegate { ArenaConfig.FriendlyFire.Value = !ArenaConfig.FriendlyFire.Value; }); }, out _friendlyFireBtn); num -= 62f; UiFactory.MakeButton(transform, "LeaderboardToggle", "", new Vector2(0f, num), new Vector2(420f, 34f), (UnityAction)delegate { Click(delegate { ArenaConfig.LeaderboardEnabled.Value = !ArenaConfig.LeaderboardEnabled.Value; LeaderboardHud.SetEnabledLive(ArenaConfig.LeaderboardEnabled.Value); }); }, out _leaderboardBtn); num -= 52f; UiFactory.MakeButton(transform, "SpreadToggle", "", new Vector2(0f, num), new Vector2(420f, 34f), (UnityAction)delegate { Click(delegate { ArenaConfig.SpreadSpawns.Value = !ArenaConfig.SpreadSpawns.Value; }); }, out _spreadBtn); num -= 52f; UiFactory.MakeButton(transform, "GrudgesToggle", "", new Vector2(0f, num), new Vector2(420f, 34f), (UnityAction)delegate { Click(delegate { ArenaConfig.Grudges.Value = !ArenaConfig.Grudges.Value; }); }, out _grudgesBtn); num -= 38f; UiFactory.MakeText(transform, "GrudgesNote", "(each sosig fights 3 rivals at a time, not everyone)", 17, new Color(1f, 1f, 1f, 0.85f), new Vector2(0f, num), new Vector2(560f, 40f), (TextAnchor)1, (FontStyle)2); num -= 40f; UiFactory.MakeButton(transform, "HuntersToggle", "", new Vector2(0f, num), new Vector2(420f, 34f), (UnityAction)delegate { Click(delegate { ArenaConfig.Hunters.Value = !ArenaConfig.Hunters.Value; }); }, out _huntersBtn); num -= 38f; UiFactory.MakeText(transform, "HuntersNote", "(every 10–20 s a few sosigs are sent toward you)", 17, new Color(1f, 1f, 1f, 0.85f), new Vector2(0f, num), new Vector2(560f, 40f), (TextAnchor)1, (FontStyle)2); num -= 44f; UiFactory.MakeText(transform, "HunterShareLabel", "Pressure", 26, Color.white, new Vector2(-200f, num), new Vector2(180f, 52f), (TextAnchor)3, (FontStyle)0); UiFactory.MakeButton(transform, "HunterSharePrev", "<", new Vector2(-60f, num), new Vector2(50f, 34f), (UnityAction)delegate { Click(delegate { ArenaConfig.HunterShare.Value = PanelModel.StepHunterShare(ArenaConfig.HunterShare.Value, -1); }); }, out labelText); _hunterShareValue = UiFactory.MakeText(transform, "HunterShareValue", "", 26, Color.white, new Vector2(95f, num), new Vector2(230f, 52f), (TextAnchor)4, (FontStyle)1); UiFactory.MakeButton(transform, "HunterShareNext", ">", new Vector2(250f, num), new Vector2(50f, 34f), (UnityAction)delegate { Click(delegate { ArenaConfig.HunterShare.Value = PanelModel.StepHunterShare(ArenaConfig.HunterShare.Value, 1); }); }, out labelText); num -= 52f; UiFactory.MakeButton(transform, "TiersToggle", "", new Vector2(0f, num), new Vector2(420f, 34f), (UnityAction)delegate { Click(delegate { ArenaConfig.SkillTiers.Value = !ArenaConfig.SkillTiers.Value; }); }, out _tiersBtn); num -= 38f; UiFactory.MakeText(transform, "TiersNote", "(each sosig gets an aim level: Rookie ^ … Elite ^^^^)", 17, new Color(1f, 1f, 1f, 0.85f), new Vector2(0f, num), new Vector2(560f, 40f), (TextAnchor)1, (FontStyle)2); num -= 40f; UiFactory.MakeText(transform, "Footer", "Mode, Teams and Allies apply at the next Start Game. Everything saves to the config file.", 17, new Color(1f, 1f, 1f, 0.85f), new Vector2(0f, num), new Vector2(560f, 50f), (TextAnchor)1, (FontStyle)0); } private void Click(Action change) { try { change(); Refresh(); } catch (Exception ex) { Plugin.Log.LogError((object)("ArenaPanel click: " + ex)); } } public void Refresh() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) try { TeamMode value = ArenaConfig.Mode.Value; _modeValue.text = PanelModel.ModeLabel(value); _teamsValue.text = ArenaConfig.TeamCount.Value.ToString(); _alliesValue.text = PanelModel.AlliesLabel(ArenaConfig.AllySosigs.Value); _pointsValue.text = ArenaConfig.PointsToWin.Value.ToString(); _friendlyFireBtn.text = PanelModel.ToggleLabel("Friendly fire", ArenaConfig.FriendlyFire.Value); float num = (PanelModel.TeamRowsEnabled(value) ? 1f : 0.4f); Text[] array = (Text[])(object)new Text[6] { _teamsLabel, _teamsValue, _alliesLabel, _alliesValue, _pointsLabel, _pointsValue }; for (int i = 0; i < array.Length; i++) { ((Graphic)array[i]).color = new Color(1f, 1f, 1f, num); } ((Graphic)_friendlyFireBtn).color = new Color(UiFactory.ButtonText.r, UiFactory.ButtonText.g, UiFactory.ButtonText.b, num); _leaderboardBtn.text = PanelModel.ToggleLabel("Leaderboard", ArenaConfig.LeaderboardEnabled.Value); _spreadBtn.text = PanelModel.ToggleLabel("Spread spawns", ArenaConfig.SpreadSpawns.Value); _grudgesBtn.text = PanelModel.ToggleLabel("Grudges", ArenaConfig.Grudges.Value); _huntersBtn.text = PanelModel.ToggleLabel("Hunters", ArenaConfig.Hunters.Value); _hunterShareValue.text = PanelModel.PercentLabel(ArenaConfig.HunterShare.Value); _tiersBtn.text = PanelModel.ToggleLabel("Skill tiers", ArenaConfig.SkillTiers.Value); } catch (Exception ex) { Plugin.Log.LogError((object)("ArenaPanel.Refresh: " + ex)); } try { TeamMatch.ApplyWeaponCountLock(); } catch (Exception ex2) { Plugin.Log.LogError((object)("ArenaPanel.Refresh (weapon-count lock): " + ex2)); } } } public class PanelInstaller : MonoBehaviour { private const float GapMetres = 0.12f; private const float FallbackWidthMetres = 0.7f; private const float NearestCanvasMaxDistance = 3f; private const float FallbackNoRendererOffset = 0.7f; private const float FallbackNoRendererHeight = 0.35f; private const float FallbackScale = 0.01f; private const int MaxPolls = 20; private const int MaxCanvasDumpCount = 15; private const int MaxDumpLineLength = 200; private const string MaxSosigCountTextFieldName = "MaxSosigCountText"; private const float MinBoardHeightMetres = 0.3f; private const float MaxBoardHeightMetres = 6f; private const float MoreOptionsHeightBoost = 1.15f; private const float CanvasChildMaxWidthMetres = 2f; private const int MaxBoardDumpChildren = 20; private const string WeaponPoolSelectionPanelName = "WeaponPoolSelectionPanel"; private static readonly FieldInfo MaxSosigCountTextField = AccessTools.Field(typeof(GameSettings), "MaxSosigCountText"); private static PanelInstaller _runner; private static ArenaPanel _panel; public static void Install() { SceneManager.sceneLoaded += OnSceneLoaded; } private static void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown try { if ((int)mode != 1 || !((Object)(object)_panel != (Object)null)) { if ((Object)(object)_panel != (Object)null) { Object.Destroy((Object)(object)((Component)_panel).gameObject); } _panel = null; if ((Object)(object)_runner == (Object)null) { GameObject val = new GameObject("GunGameArena_PanelInstaller"); Object.DontDestroyOnLoad((Object)val); _runner = val.AddComponent<PanelInstaller>(); } ((MonoBehaviour)_runner).StopAllCoroutines(); ((MonoBehaviour)_runner).StartCoroutine(_runner.WaitAndBuild()); } } catch (Exception ex) { Plugin.Log.LogError((object)("PanelInstaller.OnSceneLoaded: " + ex)); } } private IEnumerator WaitAndBuild() { for (int i = 0; i < 20; i++) { yield return (object)new WaitForSeconds(1f); if (TryBuild()) { yield break; } } LogPollTimeout(); } private static void LogPollTimeout() { try { if ((Object)(object)MonoBehaviourSingleton<GameSettings>.Instance == (Object)null) { Plugin.Log.LogInfo((object)"GameSettings.Instance never appeared in 20 s; Arena panel not shown."); } } catch (Exception ex) { Plugin.Log.LogError((object)("PanelInstaller.LogPollTimeout: " + ex)); } } private static bool TryBuild() { try { if ((Object)(object)_panel != (Object)null) { return true; } GameSettings instance = MonoBehaviourSingleton<GameSettings>.Instance; if ((Object)(object)instance == (Object)null) { return false; } try { BuildPanel(instance); } finally { DumpHierarchyIfEnabled(instance); } try { TeamMatch.ApplyWeaponCountLock(); } catch (Exception ex) { Plugin.Log.LogError((object)("PanelInstaller.TryBuild (weapon-count lock): " + ex)); } return true; } catch (Exception ex2) { Plugin.Log.LogError((object)("PanelInstaller.TryBuild: " + ex2)); return true; } } private static void BuildPanel(GameSettings settings) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) try { if (PlaceUsingMoreOptionsBoard(settings)) { return; } Transform transform = ((Component)settings).transform; Canvas val = ((Component)settings).GetComponentInParent<Canvas>(); string text; if ((Object)(object)val != (Object)null) { text = "canvas-parent"; } else { val = ((Component)settings).GetComponentInChildren<Canvas>(true); if ((Object)(object)val != (Object)null) { text = "canvas-child"; } else { val = NearestCanvas(transform.position, 3f); text = (((Object)(object)val != (Object)null) ? "canvas-nearest" : null); } } if ((Object)(object)val != (Object)null) { bool capScale = text == "canvas-child" || text == "canvas-nearest"; PlaceUsingCanvas(val, capScale); } else if (PlaceUsingRendererBounds(transform)) { text = "renderer-bounds"; } else { PlaceUsingFallbackOffset(transform); text = "fallback-offset"; } Plugin.Log.LogInfo((object)("Arena panel placed via " + text + ".")); } catch (Exception ex) { Plugin.Log.LogError((object)("PanelInstaller.BuildPanel: " + ex)); if ((Object)(object)_panel != (Object)null) { Object.Destroy((Object)(object)((Component)_panel).gameObject); _panel = null; } throw; } } private static bool PlaceUsingMoreOptionsBoard(GameSettings settings) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) if (!TryFindMoreOptionsBoard(settings, out var board, out var _, out var minX, out var _, out var _, out var maxY, out var widthMetres, out var heightMetres)) { return false; } if (heightMetres < 0.3f || heightMetres > 6f) { Plugin.Log.LogInfo((object)("[Panel dump] More-options board height " + heightMetres.ToString("0.###") + " m looks degenerate; falling back to older anchor strategies.")); return false; } try { float num = heightMetres / 820f * ArenaConfig.PanelScale.Value * 1.15f; _panel = ArenaPanel.Build(); Transform transform = ((Component)_panel).transform; transform.rotation = board.rotation; transform.localScale = Vector3.one * num; float num2 = 620f * num * 0.5f; Vector3 val = board.TransformPoint(new Vector3(minX, 0f, 0f)); transform.position = val - board.right * (0.12f + num2); Vector3 val2 = Vector3.Project(board.TransformPoint(new Vector3(0f, maxY, 0f)) - transform.position, board.up); transform.position += val2 - board.up * (820f * num * 0.5f); Plugin.Log.LogInfo((object)("Arena panel placed via more-options-board (board '" + ((Object)board).name + "', " + widthMetres.ToString("0.##") + "x" + heightMetres.ToString("0.##") + " m).")); return true; } catch (Exception ex) { Plugin.Log.LogError((object)("PanelInstaller.PlaceUsingMoreOptionsBoard: " + ex)); if ((Object)(object)_panel != (Object)null) { Object.Destroy((Object)(object)((Component)_panel).gameObject); _panel = null; } return false; } } private static bool TryFindMoreOptionsBoard(GameSettings settings, out Transform board, out Text capText, out float minX, out float maxX, out float minY, out float maxY, out float widthMetres, out float heightMetres) { //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: 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_01bb: 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_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: 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_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0237: 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_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0281: 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) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: 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_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: 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_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) board = null; capText = null; minX = (maxX = (minY = (maxY = (widthMetres = (heightMetres = 0f))))); try { if ((object)MaxSosigCountTextField == null) { return false; } object? value = MaxSosigCountTextField.GetValue(settings); capText = (Text)((value is Text) ? value : null); if ((Object)(object)capText == (Object)null) { return false; } Transform val = ((Component)capText).transform; while ((Object)(object)val != (Object)null && (Object)(object)val.parent != (Object)null) { if ((Object)(object)((Component)val.parent).GetComponent<Canvas>() != (Object)null) { board = val; break; } val = val.parent; } if ((Object)(object)board == (Object)null) { board = ((Component)capText).transform.parent; } if ((Object)(object)board == (Object)null) { return false; } float minX2 = float.MaxValue; float maxX2 = float.MinValue; float minY2 = float.MaxValue; float maxY2 = float.MinValue; bool flag = false; RectTransform[] componentsInChildren = ((Component)board).GetComponentsInChildren<RectTransform>(true); Vector3[] array = (Vector3[])(object)new Vector3[4]; for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].GetWorldCorners(array); for (int j = 0; j < 4; j++) { EncapsulateLocal(board, array[j], ref minX2, ref maxX2, ref minY2, ref maxY2); flag = true; } } Renderer[] componentsInChildren2 = ((Component)board).GetComponentsInChildren<Renderer>(true); for (int k = 0; k < componentsInChildren2.Length; k++) { Bounds bounds = componentsInChildren2[k].bounds; Vector3 center = ((Bounds)(ref bounds)).center; Vector3 extents = ((Bounds)(ref bounds)).extents; EncapsulateLocal(board, center + new Vector3(extents.x, extents.y, extents.z), ref minX2, ref maxX2, ref minY2, ref maxY2); EncapsulateLocal(board, center + new Vector3(extents.x, extents.y, 0f - extents.z), ref minX2, ref maxX2, ref minY2, ref maxY2); EncapsulateLocal(board, center + new Vector3(extents.x, 0f - extents.y, extents.z), ref minX2, ref maxX2, ref minY2, ref maxY2); EncapsulateLocal(board, center + new Vector3(extents.x, 0f - extents.y, 0f - extents.z), ref minX2, ref maxX2, ref minY2, ref maxY2); EncapsulateLocal(board, center + new Vector3(0f - extents.x, extents.y, extents.z), ref minX2, ref maxX2, ref minY2, ref maxY2); EncapsulateLocal(board, center + new Vector3(0f - extents.x, extents.y, 0f - extents.z), ref minX2, ref maxX2, ref minY2, ref maxY2); EncapsulateLocal(board, center + new Vector3(0f - extents.x, 0f - extents.y, extents.z), ref minX2, ref maxX2, ref minY2, ref maxY2); EncapsulateLocal(board, center + new Vector3(0f - extents.x, 0f - extents.y, 0f - extents.z), ref minX2, ref maxX2, ref minY2, ref maxY2); flag = true; } if (!flag) { return false; } minX = minX2; maxX = maxX2; minY = minY2; maxY = maxY2; widthMetres = Vector3.Distance(board.TransformPoint(new Vector3(minX, 0f, 0f)), board.TransformPoint(new Vector3(maxX, 0f, 0f))); heightMetres = Vector3.Distance(board.TransformPoint(new Vector3(0f, minY, 0f)), board.TransformPoint(new Vector3(0f, maxY, 0f))); return true; } catch (Exception ex) { Plugin.Log.LogError((object)("PanelInstaller.TryFindMoreOptionsBoard: " + ex)); return false; } } private static void EncapsulateLocal(Transform board, Vector3 worldPoint, ref float minX, ref float maxX, ref float minY, ref float maxY) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_001a: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_004d: Unknown result type (might be due to invalid IL or missing references) try { Vector3 val = board.InverseTransformPoint(worldPoint); if (val.x < minX) { minX = val.x; } if (val.x > maxX) { maxX = val.x; } if (val.y < minY) { minY = val.y; } if (val.y > maxY) { maxY = val.y; } } catch (Exception ex) { Plugin.Log.LogError((object)("PanelInstaller.EncapsulateLocal: " + ex)); } } private static Canvas NearestCanvas(Vector3 position, float maxDistance) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) try { Canvas[] array = Object.FindObjectsOfType<Canvas>(); Canvas result = null; float num = maxDistance; foreach (Canvas val in array) { if (!((Object)(object)val == (Object)null)) { float num2 = Vector3.Distance(((Component)val).transform.position, position); if (num2 <= num) { result = val; num = num2; } } } return result; } catch (Exception ex) { Plugin.Log.LogError((object)("PanelInstaller.NearestCanvas: " + ex)); return null; } } private static void PlaceUsingCanvas(Canvas host, bool capScale) { //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_002c: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0115: 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_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: 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_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: 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_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) try { RectTransform component = ((Component)host).GetComponent<RectTransform>(); float num; Rect rect; if (!((Object)(object)component != (Object)null)) { num = 0f; } else { rect = component.rect; num = ((Rect)(ref rect)).width * ((Component)host).transform.lossyScale.x; } float num2 = num; int num3; if (!((Object)(object)component == (Object)null) && !(num2 <= 0.05f)) { num3 = (float.IsNaN(num2) ? 1 : 0); if (num3 == 0) { goto IL_005b; } } else { num3 = 1; } num2 = 0.7f; goto IL_005b; IL_005b: _panel = ArenaPanel.Build(); Transform transform = ((Component)_panel).transform; transform.rotation = ((Component)host).transform.rotation; transform.localScale = (capScale ? (Vector3.one * Mathf.Min(((Component)host).transform.lossyScale.x, 0.0032258064f)) : ((Component)host).transform.lossyScale); float num4 = 620f * transform.localScale.x * 0.5f; if (num3 == 0) { Transform transform2 = ((Component)host).transform; rect = component.rect; Vector3 val = transform2.TransformPoint(new Vector3(((Rect)(ref rect)).xMin, 0f, 0f)); transform.position = val - ((Component)host).transform.right * (0.12f + num4); } else { transform.position = ((Component)host).transform.position - ((Component)host).transform.right * (num2 * 0.5f + 0.12f + num4); } if ((Object)(object)component != (Object)null) { rect = component.rect; float yMax = ((Rect)(ref rect)).yMax; Vector3 val2 = Vector3.Project(((Component)host).transform.TransformPoint(new Vector3(0f, yMax, 0f)) - transform.position, ((Component)host).transform.up); transform.position += val2 - ((Component)host).transform.up * (820f * transform.localScale.y * 0.5f); } } catch (Exception ex) { Plugin.Log.LogError((object)("PanelInstaller.PlaceUsingCanvas: " + ex)); throw; } } private static bool PlaceUsingRendererBounds(Transform anchor) { //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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing