Decompiled source of SuperBattleBros v0.7.40
SbgShields.dll
Decompiled 2 weeks 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.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using FMOD; using FMOD.Studio; using FMODUnity; using HarmonyLib; using Microsoft.CodeAnalysis; using Mirror; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Rendering; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("SbgShields")] [assembly: AssemblyConfiguration("DevDebug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+97ba1a3cf21c4702dff36855daecb5f66fa8c805")] [assembly: AssemblyProduct("SbgShields")] [assembly: AssemblyTitle("SbgShields")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace SbgShields { internal static class AimedAt { private static bool _loggedRanges; internal static bool Anyone(PlayerInfo me, Vector3 centre, float tolerance, out string who) { //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_02af: 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_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Invalid comparison between Unknown and I4 //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: 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_0188: 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_018b: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) who = null; if (!Plugin.AimedAtParry.Value) { return false; } if (!_loggedRanges) { _loggedRanges = true; try { ItemSettings itemSettings = GameManager.ItemSettings; Plugin.Log.LogInfo((object)$"Game gun ranges: pistol {itemSettings.DuelingPistolMaxShotDistance:0} m, elephant gun {itemSettings.ElephantGunMaxShotDistance:0} m. Parry.AimedAtRange is {Plugin.AimedAtRange.Value:0} m."); } catch { } } float num = Mathf.Max(1f, Plugin.AimedAtRange.Value); float num2 = float.MaxValue; IReadOnlyList<PlayerInfo> remotePlayers; try { remotePlayers = GameManager.RemotePlayers; } catch { return false; } if (remotePlayers == null) { return false; } foreach (PlayerInfo item in remotePlayers) { if ((Object)(object)item == (Object)null || item == me) { continue; } bool flag = false; try { flag = me.IsTeammateOf(item, true); } catch { } if (flag && !ShieldState.BypassesTeamProtection(KnockoutTypeOf(item.NetworkedEquippedItem))) { continue; } try { if (!item.NetworkedIsAimingItem || (int)item.NetworkedEquippedItem == 0) { continue; } Vector3 val = (((Object)(object)item.ChestBone != (Object)null) ? item.ChestBone.position : (((Component)item).transform.position + Vector3.up)); Vector3 val2 = centre - val; float magnitude = ((Vector3)(ref val2)).magnitude; if (magnitude > num) { continue; } float num3 = 0f; try { num3 = item.AnimatorIo.AimingYawOffset; } catch { } Vector3 val3 = Quaternion.AngleAxis(num3, Vector3.up) * ((Component)item).transform.forward; val3.y = 0f; if (((Vector3)(ref val3)).sqrMagnitude < 0.0001f) { continue; } ((Vector3)(ref val3)).Normalize(); Vector3 val4 = val2; val4.y = 0f; float num4 = Vector3.Dot(val4, val3); if (num4 <= 0f) { continue; } Vector3 val5 = Vector3.Cross(val3, val4); float magnitude2 = ((Vector3)(ref val5)).magnitude; if (!(magnitude2 > tolerance) && magnitude2 < num2) { num2 = magnitude2; string text; try { text = item.PlayerId.PlayerNameNoRichText; } catch { text = "a player"; } who = $"{text} aiming {item.NetworkedEquippedItem} from {magnitude:0.0}m (off by {magnitude2:0.0}m)"; } } catch (Exception ex) { if (Plugin.VerboseLogging.Value) { Plugin.Log.LogWarning((object)("AimedAt check: " + ex.Message)); } } } return who != null; } private static KnockoutType KnockoutTypeOf(ItemType item) { //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_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_002b: 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_0037: 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_001e: Invalid comparison between Unknown and I4 //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) if ((int)item <= 3) { if ((int)item == 2) { return (KnockoutType)4; } if ((int)item == 3) { return (KnockoutType)5; } } else { if ((int)item == 7) { return (KnockoutType)7; } if ((int)item == 16) { return (KnockoutType)26; } } return (KnockoutType)0; } } internal static class BubbleHalo { private class Halo { public GameObject Go; public MeshRenderer Renderer; public MaterialPropertyBlock Block; public Color Last; } private static readonly Dictionary<PlayerInfo, Halo> _halos = new Dictionary<PlayerInfo, Halo>(); private static readonly List<PlayerInfo> _dead = new List<PlayerInfo>(); private static Material _mat; private static Texture2D _tex; private static string _colorProp = "_BaseColor"; private static bool _matFailed; private static bool _bloomLogged; private static double _firstTick = -1.0; internal static void Tick() { if (!Plugin.BubbleHalo.Value || !ShieldTint.Enabled) { if (_halos.Count > 0) { RemoveAll(); } return; } try { Touch(GameManager.LocalPlayerInfo); List<PlayerInfo> remotePlayers = GameManager.RemotePlayers; if (remotePlayers != null) { foreach (PlayerInfo item in remotePlayers) { Touch(item); } } } catch { } _dead.Clear(); foreach (KeyValuePair<PlayerInfo, Halo> halo in _halos) { bool flag = false; try { flag = (Object)(object)halo.Key != (Object)null && halo.Key.IsElectromagnetShieldActive; } catch { } if (!flag || (Object)(object)halo.Value.Go == (Object)null) { _dead.Add(halo.Key); } } foreach (PlayerInfo item2 in _dead) { Remove(item2); } LogBloomOnce(); } private static void Touch(PlayerInfo p) { //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: 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_0182: 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_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: 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_022d: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)p == (Object)null) { return; } bool isElectromagnetShieldActive; try { isElectromagnetShieldActive = p.IsElectromagnetShieldActive; } catch { return; } if (!isElectromagnetShieldActive) { return; } if (ShieldTint.IsItemShield(p)) { Remove(p); return; } SphereCollider electromagnetShieldCollider = p.ElectromagnetShieldCollider; if ((Object)(object)electromagnetShieldCollider == (Object)null) { return; } if (!_halos.TryGetValue(p, out var value)) { value = Create(); if (value == null) { return; } _halos[p] = value; } if ((Object)(object)value.Go == (Object)null) { _halos.Remove(p); return; } float num = electromagnetShieldCollider.radius * Mathf.Max(new float[3] { ((Component)electromagnetShieldCollider).transform.lossyScale.x, ((Component)electromagnetShieldCollider).transform.lossyScale.y, ((Component)electromagnetShieldCollider).transform.lossyScale.z }); Transform transform = value.Go.transform; transform.position = ((Component)electromagnetShieldCollider).transform.position; Camera val = GameManager.Camera; if ((Object)(object)val == (Object)null) { val = Camera.main; } if ((Object)(object)val != (Object)null) { transform.rotation = Quaternion.LookRotation(transform.position - ((Component)val).transform.position); } transform.localScale = Vector3.one * (num * 2f * Mathf.Max(1f, Plugin.BubbleHaloSize.Value)); Color val2 = ShieldTint.CurrentColour(p); float num2 = Mathf.Max(0f, Plugin.BubbleHaloStrength.Value) * Mathf.Max(0.1f, Plugin.BitsGlow.Value) * Mathf.Clamp01(val2.a); Color val3 = default(Color); ((Color)(ref val3))..ctor(val2.r * num2, val2.g * num2, val2.b * num2, 1f); if (val3 != value.Last) { value.Last = val3; value.Block.SetColor(_colorProp, val3); ((Renderer)value.Renderer).SetPropertyBlock(value.Block); } } private static Halo Create() { //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Expected O, but got Unknown //IL_0137: 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) if (_matFailed) { return null; } try { if ((Object)(object)_tex == (Object)null) { _tex = MakeHaloTexture(128); } if ((Object)(object)_mat == (Object)null) { _mat = LaunchVfx.MakeUnlitMaterial(_tex, additive: true); if ((Object)(object)_mat == (Object)null) { _matFailed = true; return null; } _colorProp = (_mat.HasProperty("_BaseColor") ? "_BaseColor" : "_Color"); } GameObject val = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)val).name = "SbgBubbleHalo"; Collider component = val.GetComponent<Collider>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } MeshRenderer component2 = val.GetComponent<MeshRenderer>(); ((Renderer)component2).sharedMaterial = _mat; ((Renderer)component2).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component2).receiveShadows = false; ((Renderer)component2).lightProbeUsage = (LightProbeUsage)0; ((Renderer)component2).reflectionProbeUsage = (ReflectionProbeUsage)0; return new Halo { Go = val, Renderer = component2, Block = new MaterialPropertyBlock(), Last = new Color(-1f, 0f, 0f, 0f) }; } catch (Exception ex) { _matFailed = true; Plugin.Log.LogWarning((object)("Bubble halo failed: " + ex.Message)); return null; } } private static Texture2D MakeHaloTexture(int size) { //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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_006b: 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_00fc: 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) Texture2D val = new Texture2D(size, size, (TextureFormat)4, true) { wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1 }; Color[] array = (Color[])(object)new Color[size * size]; float num = (float)size * 0.5f; float num2 = 1f / Mathf.Max(1f, Plugin.BubbleHaloSize.Value); for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num3 = Vector2.Distance(new Vector2((float)j + 0.5f, (float)i + 0.5f), new Vector2(num, num)) / num; float num4 = ((!(num3 <= num2)) ? (0.5f * Mathf.Exp(0f - Mathf.Pow((num3 - num2) / ((1f - num2) * 0.45f), 2f))) : (0.12f + 0.38f * Mathf.Pow(num3 / num2, 3f))); if (num3 > 1f) { num4 = 0f; } array[i * size + j] = new Color(num4, num4, num4, num4); } } val.SetPixels(array); val.Apply(true); return val; } private static void Remove(PlayerInfo p) { if (_halos.TryGetValue(p, out var value) && (Object)(object)value.Go != (Object)null) { Object.Destroy((Object)(object)value.Go); } _halos.Remove(p); } private static void RemoveAll() { foreach (KeyValuePair<PlayerInfo, Halo> halo in _halos) { if ((Object)(object)halo.Value.Go != (Object)null) { Object.Destroy((Object)(object)halo.Value.Go); } } _halos.Clear(); } internal static void DestroyAll() { RemoveAll(); if ((Object)(object)_mat != (Object)null) { Object.Destroy((Object)(object)_mat); } if ((Object)(object)_tex != (Object)null) { Object.Destroy((Object)(object)_tex); } _mat = null; _tex = null; _matFailed = false; } private static void LogBloomOnce() { if (_bloomLogged) { return; } if (_firstTick < 0.0) { _firstTick = Time.timeAsDouble; } else { if (Time.timeAsDouble - _firstTick < 3.0) { return; } _bloomLogged = true; try { Type type = Type.GetType("UnityEngine.Rendering.VolumeManager, Unity.RenderPipelines.Core.Runtime"); Type type2 = Type.GetType("UnityEngine.Rendering.Universal.Bloom, Unity.RenderPipelines.Universal.Runtime"); if (type == null || type2 == null) { Plugin.Log.LogInfo((object)"Post-processing: URP volume types not found; cannot tell if bloom is on."); return; } object obj = type.GetProperty("instance", BindingFlags.Static | BindingFlags.Public)?.GetValue(null); object obj2 = type.GetProperty("stack", BindingFlags.Instance | BindingFlags.Public)?.GetValue(obj); if (obj2 == null) { Plugin.Log.LogInfo((object)"Post-processing: no volume stack yet; cannot tell if bloom is on."); return; } MethodInfo methodInfo = null; MethodInfo[] methods = obj2.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public); foreach (MethodInfo methodInfo2 in methods) { if (methodInfo2.Name == "GetComponent" && methodInfo2.IsGenericMethodDefinition && methodInfo2.GetParameters().Length == 0) { methodInfo = methodInfo2; break; } } object obj3 = methodInfo?.MakeGenericMethod(type2).Invoke(obj2, null); if (obj3 == null) { Plugin.Log.LogInfo((object)"Post-processing: no bloom component in the volume stack; the glow is brightness only."); return; } bool flag = false; try { flag = (bool)type2.GetMethod("IsActive", BindingFlags.Instance | BindingFlags.Public).Invoke(obj3, null); } catch { } string text = "?"; try { object obj5 = type2.GetField("intensity", BindingFlags.Instance | BindingFlags.Public)?.GetValue(obj3); object obj6 = obj5?.GetType().GetProperty("value")?.GetValue(obj5); if (obj6 != null) { text = Convert.ToSingle(obj6).ToString("0.00"); } } catch { } Plugin.Log.LogInfo((object)(flag ? ("Post-processing: bloom is on (intensity " + text + "); BubbleGlow and BitsGlow read as a glow.") : "Post-processing: bloom is off; BubbleGlow and BitsGlow only brighten. The halo carries the glow.")); } catch (Exception ex) { Plugin.Log.LogInfo((object)("Post-processing: could not read the volume stack (" + ex.GetType().Name + ").")); } } } } internal static class ChatCommands { internal static bool TryHandle(string raw) { if (string.IsNullOrWhiteSpace(raw)) { return false; } string text = raw.Trim(); if (text.Length < 2 || text[0] != '/') { return false; } if (!Plugin.EnableChatCommands.Value) { Say("chat commands are off. Turn on Debug > ChatCommands in ModConfig."); return true; } string[] array = text.Substring(1).Split(new char[1] { ' ' }, 2, StringSplitOptions.RemoveEmptyEntries); string text2 = array[0].ToLowerInvariant(); string text3 = ((array.Length > 1) ? array[1].Trim() : ""); try { switch (text2) { case "give": return Give(text3); case "pct": case "percent": return SetPercent(text3); case "pips": return SetPips(text3); case "sbg": case "shields": return Status(); default: return false; } } catch (Exception ex) { Say("command failed: " + ex.Message); return true; } } private static bool Give(string arg) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Invalid comparison between Unknown and I4 //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0174: 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) if (arg.Length == 0) { Say("usage: /give rocketlauncher (" + string.Join(", ", Enum.GetNames(typeof(ItemType))) + ")"); return true; } if (!Enum.TryParse<ItemType>(arg.Replace(" ", ""), ignoreCase: true, out ItemType result) || (int)result == 0) { Say("'" + arg + "' is not an item."); return true; } PlayerInfo localPlayerInfo = GameManager.LocalPlayerInfo; if ((Object)(object)localPlayerInfo == (Object)null || (Object)(object)localPlayerInfo.Inventory == (Object)null) { Say("no local player yet."); return true; } if (!NetworkServer.active) { Say("only the host can spawn items -- inventories are server-side."); return true; } int num = default(int); if (!localPlayerInfo.Inventory.HasSpaceForItem(ref num)) { Say("inventory is full."); return true; } int num2 = 1; ItemData val = default(ItemData); if ((Object)(object)GameManager.AllItems != (Object)null && GameManager.AllItems.TryGetItemData(result, ref val) && val.MaxUses > 0) { num2 = val.MaxUses; } Say(localPlayerInfo.Inventory.ServerTryAddItem(result, num2) ? $"gave {result} x{num2} (slot {num})." : $"the game refused {result}."); return true; } private static bool SetPercent(string arg) { if (!float.TryParse(arg, out var result)) { Say("usage: /pct 150"); return true; } if (!ShieldState.InPlayableHole) { Say("percent only exists during a hole."); return true; } ShieldState.SetPercent(result); Say($"percent = {ShieldState.Percent:0}."); return true; } private static bool SetPips(string arg) { if (!int.TryParse(arg, out var result)) { Say("usage: /pips 3"); return true; } ShieldState.Pips = Mathf.Clamp(result, 0, Plugin.MaxPips.Value); Say($"pips = {ShieldState.Pips}/{Plugin.MaxPips.Value}."); return true; } private static bool Status() { string text = (ModHandshake.GameplayEnabled ? "active" : ("STANDING DOWN (" + ModHandshake.BlockReason + ")")); Say(string.Format("v{0} | {1} | pips {2}/{3} | percent {4:0} | ", "0.7.40", text, ShieldState.Pips, Plugin.MaxPips.Value, ShieldState.Percent) + (NetworkServer.active ? "hosting" : "client")); return true; } private static void Say(string text) { try { TextChatUi.ShowMessage("<b>[shields]</b> " + text); } catch { Plugin.Log.LogInfo((object)("[shields] " + text)); } } } [HarmonyPatch(typeof(TextChatManager), "SendChatMessage")] internal static class ChatCommandPatch { [HarmonyPriority(200)] private static bool Prefix(string message) { try { return !ChatCommands.TryHandle(message); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Chat command error: " + ex.Message)); return true; } } } internal static class Credits { internal unsafe static void PostStarKo(PlayerInfo victim, PlayerInfo by, KnockoutType type) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)victim == (Object)null || !Plugin.KillFeedStarKo.Value) { return; } try { EliminationData val = default(EliminationData); if (!Enum.TryParse<EliminationReason>(((object)(*(KnockoutType*)(&type))/*cast due to .constrained prefix*/).ToString(), out EliminationReason result) || !GameManager.EliminationSettings.TryGetEliminationData(result, ref val)) { result = (EliminationReason)1; } if ((Object)(object)by != (Object)null && by != victim) { InfoFeed.ShowEliminationMessage(by, victim, result); } else { InfoFeed.ShowSelfEliminationMessage(victim, result); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Kill feed post failed: " + ex.Message)); } } } internal static class Hud { private struct ShakeStep { public float pct; public float secs; } private static Font _font; private static bool _fontSearched; private static Texture2D _bubbleTex; private static Texture2D _dotTex; private static Texture2D _glowTex; private static GUIStyle _percentStyle; private static GUIStyle _timerStyle; private static double _shakeStart = double.MinValue; private static float _shakeSeed; private static int _cachedPct = int.MinValue; private static int _cachedFontSize = -1; private static readonly GUIContent _pctContent = new GUIContent(); private static Vector2 _pctSize; private static Vector2 _pctMax; private static bool _pipsWereShown; private static double _pipsShownAt = double.MinValue; private static string _lastHideReason = "(never drawn)"; private static Vector2 _lastOffset; private static ShakeStep[] _shakeTable; private static string _shakeTableSource; private static GUIStyle _noticeBig; private static GUIStyle _noticeSmall; private static Texture2D _panelTex; internal static void Init() { ShieldState.PercentIncreased -= OnPercentIncreased; ShieldState.PercentIncreased += OnPercentIncreased; } internal static void Shutdown() { ShieldState.PercentIncreased -= OnPercentIncreased; if ((Object)(object)_panelTex != (Object)null) { Object.Destroy((Object)(object)_panelTex); _panelTex = null; } if ((Object)(object)_bubbleTex != (Object)null) { Object.Destroy((Object)(object)_bubbleTex); _bubbleTex = null; } if ((Object)(object)_dotTex != (Object)null) { Object.Destroy((Object)(object)_dotTex); _dotTex = null; } if ((Object)(object)_glowTex != (Object)null) { Object.Destroy((Object)(object)_glowTex); _glowTex = null; } _percentStyle = null; DestroyFont(); _cachedPct = int.MinValue; } internal static void InvalidateFont() { DestroyFont(); _percentStyle = null; _cachedPct = int.MinValue; } private static void DestroyFont() { if ((Object)(object)_font != (Object)null) { Object.Destroy((Object)(object)_font); _font = null; } _fontSearched = false; } private static void OnPercentIncreased(float _) { _shakeStart = Time.timeAsDouble; _shakeSeed = Random.value * 100f; } private static void EnsureAssets() { //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Expected O, but got Unknown //IL_0144: 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_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Expected O, but got Unknown if (!_fontSearched) { _fontSearched = true; _font = FindFont(Plugin.PercentFontName.Value); if ((Object)(object)_font == (Object)null) { Plugin.Log.LogWarning((object)("Font '" + Plugin.PercentFontName.Value + "' not installed on this machine; using the default. Install DF Gothic as a system font and restart to use it.")); } else { Plugin.Log.LogInfo((object)("Percent font: " + ((Object)_font).name)); } } if ((Object)(object)_bubbleTex == (Object)null) { _bubbleTex = MakeBubbleTexture(128); } if ((Object)(object)_dotTex == (Object)null) { _dotTex = MakeDotTexture(24); } if ((Object)(object)_glowTex == (Object)null) { _glowTex = MakeGlowTexture(96); } if (_percentStyle == null) { _percentStyle = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)6, fontStyle = (FontStyle)1, wordWrap = false, clipping = (TextClipping)0 }; if ((Object)(object)_font != (Object)null) { _percentStyle.font = _font; } _percentStyle.normal.textColor = Color.white; _timerStyle = new GUIStyle(_percentStyle) { alignment = (TextAnchor)4 }; } } private static Font FindFont(string wanted) { if (string.IsNullOrEmpty(wanted)) { return null; } try { string[] oSInstalledFontNames = Font.GetOSInstalledFontNames(); string text = Normalize(wanted); string text2 = null; string[] array = oSInstalledFontNames; foreach (string text3 in array) { string text4 = Normalize(text3); if (text4 == text) { text2 = text3; break; } if (text2 == null && text4.Contains(text)) { text2 = text3; } } if (text2 == null) { return null; } return Font.CreateDynamicFontFromOSFont(text2, 64); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Font lookup failed: " + ex.Message)); return null; } } private static string Normalize(string s) { return s.Replace(" ", "").Replace("-", "").Replace("_", "") .ToLowerInvariant(); } private static Texture2D MakeBubbleTexture(int size) { //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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //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) Texture2D val = new Texture2D(size, size, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1 }; float num = (float)size * 0.5f; Color[] array = (Color[])(object)new Color[size * size]; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num2 = ((float)j + 0.5f - num) / num; float num3 = ((float)i + 0.5f - num) / num; float num4 = Mathf.Sqrt(num2 * num2 + num3 * num3); float num5 = 0f; if (num4 < 1f) { float num6 = Mathf.Lerp(0.22f, 0.55f, Mathf.Pow(num4, 2.5f)); float num7 = Mathf.Exp(0f - Mathf.Pow((num4 - 0.93f) / 0.05f, 2f)) * 0.9f; float num8 = num2 + 0.42f; float num9 = num3 - 0.42f; float num10 = Mathf.Exp((0f - (num8 * num8 + num9 * num9)) / 0.05f) * 0.85f; num5 = Mathf.Clamp01(num6 + num7 + num10); num5 *= Mathf.Clamp01((1f - num4) / 0.03f); } array[i * size + j] = new Color(1f, 1f, 1f, num5); } } val.SetPixels(array); val.Apply(); return val; } private static Texture2D MakeDotTexture(int size) { //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_0013: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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) Texture2D val = new Texture2D(size, size, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1 }; float num = (float)size * 0.5f; Color[] array = (Color[])(object)new Color[size * size]; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num2 = Vector2.Distance(new Vector2((float)j + 0.5f, (float)i + 0.5f), new Vector2(num, num)) / num; array[i * size + j] = new Color(1f, 1f, 1f, Mathf.Clamp01((1f - num2) / 0.12f)); } } val.SetPixels(array); val.Apply(); return val; } private static Texture2D MakeGlowTexture(int size) { //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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(size, size, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1 }; float num = (float)size * 0.5f; Color[] array = (Color[])(object)new Color[size * size]; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num2 = Vector2.Distance(new Vector2((float)j + 0.5f, (float)i + 0.5f), new Vector2(num, num)) / num; float num3 = ((num2 >= 1f) ? 0f : (Mathf.Exp((0f - num2) * num2 * 3.5f) * Mathf.Clamp01((1f - num2) / 0.15f))); array[i * size + j] = new Color(1f, 1f, 1f, num3); } } val.SetPixels(array); val.Apply(); return val; } private static void DrawGlow(Rect around, Color colour, float strength, float spread) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) if (!(strength <= 0.005f) && !((Object)(object)_glowTex == (Object)null)) { Color color = GUI.color; float x = ((Rect)(ref around)).center.x; float y = ((Rect)(ref around)).center.y; float num = Mathf.Max(((Rect)(ref around)).width, ((Rect)(ref around)).height) * spread; float num2 = num * 0.62f; GUI.color = new Color(colour.r, colour.g, colour.b, Mathf.Clamp01(strength * 0.45f)); GUI.DrawTexture(new Rect(x - num * 0.5f, y - num * 0.5f, num, num), (Texture)(object)_glowTex, (ScaleMode)0, true); GUI.color = new Color(colour.r, colour.g, colour.b, Mathf.Clamp01(strength * 0.7f)); GUI.DrawTexture(new Rect(x - num2 * 0.5f, y - num2 * 0.5f, num2, num2), (Texture)(object)_glowTex, (ScaleMode)0, true); GUI.color = color; } } internal static void Draw() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_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_023c: 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_0405: Unknown result type (might be due to invalid IL or missing references) if (Event.current == null || (int)Event.current.type != 7 || !Plugin.ShowHud.Value) { return; } if (!ModHandshake.GameplayEnabled) { DrawStandDownNotice(); return; } PlayerInfo localPlayerInfo = GameManager.LocalPlayerInfo; if ((Object)(object)localPlayerInfo == (Object)null || !ShouldShow()) { return; } try { if ((Object)(object)localPlayerInfo.Movement != (Object)null && localPlayerInfo.Movement.IsRespawningOrDrowning) { return; } } catch { } if (!KillZone.IsLingering) { EnsureAssets(); float value = Plugin.HudScale.Value; float num = (float)Screen.height - Plugin.HudBottomMargin.Value * value; bool flag = ShieldState.InPlayableHole && Plugin.PercentEnabled.Value; int num2 = Mathf.RoundToInt((float)Plugin.PercentFontSize.Value * value); int num3 = Mathf.RoundToInt(ShieldState.Percent); if (num3 != _cachedPct || num2 != _cachedFontSize) { _cachedPct = num3; _cachedFontSize = num2; _pctContent.text = num3 + "%"; _percentStyle.fontSize = Mathf.RoundToInt((float)num2 * (1f + Plugin.PercentShakePunch.Value)); _pctMax = _percentStyle.CalcSize(_pctContent); _percentStyle.fontSize = num2; _pctSize = _percentStyle.CalcSize(_pctContent); } float num4 = (flag ? (((float)Screen.width - _pctSize.x) * 0.5f + Plugin.HudHorizontalOffset.Value * value) : ((float)Screen.width * 0.5f + Plugin.HudHorizontalOffset.Value * value)); float num5 = num + Plugin.PercentVerticalOffset.Value * value; if (flag) { DrawPercent(new Rect(num4, num5 - _pctSize.y, _pctSize.x, _pctSize.y), _pctContent.text, num2); } if (flag && Stocks.On && Stocks.Remaining >= 0) { DrawStocks(localPlayerInfo, new Vector2(num4 + _pctSize.x * 0.5f, num5 - _pctSize.y - 6f * value), Stocks.Mode, Stocks.Remaining, value); } bool isElectromagnetShieldActive = localPlayerInfo.IsElectromagnetShieldActive; bool flag2 = ShieldState.IsOnBreakCooldown || (ShieldState.Pips <= 0 && !Plugin.RestoreAfterBreakCooldown.Value); string why; bool flag3 = Plugin.ActivationBlockedByState(localPlayerInfo, forHud: true, out why) && !isElectromagnetShieldActive; bool flag4 = isElectromagnetShieldActive || !flag3 || flag2; string text = (flag4 ? null : why); if (text != _lastHideReason) { _lastHideReason = text; Plugin.Log.LogInfo((object)((text == null) ? "HUD: bubble icon shown." : ("HUD: bubble icon hidden (" + text + ")."))); } bool flag5 = Plugin.ShowPipDots.Value && flag4 && !flag2 && ShieldState.Pips > 0; if (flag5 && !_pipsWereShown) { _pipsShownAt = Time.timeAsDouble; } _pipsWereShown = flag5; if (flag4) { float num6 = Plugin.BubbleHudSize.Value * value; float num7 = Plugin.BubbleHudGap.Value * value; float num8 = ((!flag) ? (num4 - num6 * 0.5f) : (Plugin.BubbleHudOnLeft.Value ? (num4 - num7 - num6) : (num4 + _pctMax.x + num7))); float num9 = num - num6; DrawBubble(localPlayerInfo, new Rect(num8, num9, num6, num6), value, isElectromagnetShieldActive, flag2, flag5); } } } private static float PopEase(float t) { if (t <= 0f) { return 0f; } if (t >= 1f) { return 1f; } float num = t - 1f; return 1f + 2.70158f * num * num * num + 1.70158f * num * num; } private static bool ShouldShow() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Invalid comparison between Unknown and I4 try { if (PauseMenu.IsPaused) { return false; } if (Scoreboard.IsVisible) { return false; } if (ShieldState.InDrivingRange) { return true; } MatchState matchState = CourseManager.MatchState; MatchState val = matchState; if (val - 2 <= 3) { return true; } return false; } catch { return true; } } private static void DrawPercent(Rect rect, string text, int fontSize) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0292: 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_02a8: Unknown result type (might be due to invalid IL or missing references) float num = ShakeDuration(ShieldState.Percent); float num2 = ((num <= 0.01f) ? 1f : ((float)((Time.timeAsDouble - _shakeStart) / (double)num))); float num3 = 0f; float num4 = 1f; if (num2 >= 0f && num2 < 1f) { float num5 = (1f - num2) * (1f - num2); num3 = Plugin.PercentShakePixels.Value * num5; num4 = 1f + Plugin.PercentShakePunch.Value * num5 * num5; } Vector2 zero = Vector2.zero; if (num3 > 0.01f) { float num6 = Time.time * Plugin.PercentShakeSpeed.Value + _shakeSeed; ((Vector2)(ref zero))..ctor((Mathf.PerlinNoise(num6, 0.3f) - 0.5f) * 2f * num3, (Mathf.PerlinNoise(0.7f, num6) - 0.5f) * 2f * num3); } Rect r = default(Rect); ((Rect)(ref r))..ctor(((Rect)(ref rect)).x + zero.x, ((Rect)(ref rect)).yMax - _pctSize.y + zero.y, _pctSize.x, _pctSize.y); Color val = PercentColor(ShieldState.Percent); float thickness = Mathf.Max(1f, 3f * Plugin.HudScale.Value); Matrix4x4 matrix = GUI.matrix; if (num4 != 1f) { GUIUtility.ScaleAroundPivot(new Vector2(num4, num4), ((Rect)(ref r)).center); } _percentStyle.fontSize = fontSize; int num7 = Mathf.RoundToInt(Plugin.PercentBlurSamples.Value); if (num7 > 0 && num3 > 0.5f) { Vector2 val2 = zero - _lastOffset; if (((Vector2)(ref val2)).sqrMagnitude > 0.01f) { float num8 = Mathf.Clamp01(num3 / Mathf.Max(1f, Plugin.PercentShakePixels.Value)); Rect val3 = default(Rect); for (int i = 1; i <= num7; i++) { float num9 = (float)i / (float)(num7 + 1); ((Rect)(ref val3))..ctor(((Rect)(ref r)).x - val2.x * num9 * Plugin.PercentBlurLength.Value, ((Rect)(ref r)).y - val2.y * num9 * Plugin.PercentBlurLength.Value, ((Rect)(ref r)).width, ((Rect)(ref r)).height); Color color = val; color.a = val.a * (1f - num9) * 0.5f * num8; Color color2 = GUI.color; GUI.color = color; GUI.Label(val3, text, _percentStyle); GUI.color = color2; } } } _lastOffset = zero; DrawOutlined(r, text, _percentStyle, val, Color.black, thickness); GUI.matrix = matrix; } private static float ShakeDuration(float pct) { ShakeStep[] array = ShakeTable(); if (array == null || array.Length == 0) { return Plugin.PercentShakeDuration.Value; } if (pct <= array[0].pct) { return array[0].secs; } for (int i = 1; i < array.Length; i++) { if (!(pct > array[i].pct)) { ShakeStep shakeStep = array[i - 1]; ShakeStep shakeStep2 = array[i]; float num = Mathf.Max(0.001f, shakeStep2.pct - shakeStep.pct); return Mathf.Lerp(shakeStep.secs, shakeStep2.secs, (pct - shakeStep.pct) / num); } } return array[^1].secs; } internal static void InvalidateShakeTable() { _shakeTable = null; } private static ShakeStep[] ShakeTable() { string value = Plugin.PercentShakeDurationTable.Value; if (_shakeTable != null && value == _shakeTableSource) { return _shakeTable; } _shakeTableSource = value; List<ShakeStep> list = new List<ShakeStep>(); string[] array = value.Split(','); foreach (string text in array) { string[] array2 = text.Split(':'); if (array2.Length == 2 && float.TryParse(array2[0].Trim(), out var result) && float.TryParse(array2[1].Trim(), out var result2)) { list.Add(new ShakeStep { pct = result, secs = Mathf.Max(0f, result2) }); } } list.Sort((ShakeStep x, ShakeStep y) => x.pct.CompareTo(y.pct)); if (list.Count == 0) { Plugin.Log.LogWarning((object)("Could not read PercentShakeDurationTable '" + value + "'; using PercentShakeDuration instead.")); } _shakeTable = list.ToArray(); return _shakeTable; } private static void DrawStandDownNotice() { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_022f: 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_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Expected O, but got Unknown //IL_014f: 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_015e: 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_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_019e: 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_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) string blockReason = ModHandshake.BlockReason; if (string.IsNullOrEmpty(blockReason)) { return; } double num = Time.timeAsDouble - ModHandshake.BlockedSince; if (!(num < 1.5)) { if (_noticeBig == null) { _noticeBig = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)4, wordWrap = true, fontStyle = (FontStyle)1 }; _noticeSmall = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)4, wordWrap = true }; } if ((Object)(object)_panelTex == (Object)null) { _panelTex = new Texture2D(1, 1, (TextureFormat)4, false); _panelTex.SetPixel(0, 0, new Color(0f, 0f, 0f, 0.78f)); _panelTex.Apply(); } float value = Plugin.HudScale.Value; if (!(num < 1.5 + (double)Plugin.MismatchPopupDuration.Value)) { _noticeSmall.fontSize = Mathf.RoundToInt(16f * value); string text = "SBG Shields inactive - " + blockReason; Vector2 val = _noticeSmall.CalcSize(new GUIContent(text)); Rect r = default(Rect); ((Rect)(ref r))..ctor(((float)Screen.width - val.x) * 0.5f, 8f * value, val.x, val.y); DrawOutlined(r, text, _noticeSmall, new Color(1f, 0.78f, 0.25f), Color.black, 2f); return; } _noticeBig.fontSize = Mathf.RoundToInt(26f * value); _noticeSmall.fontSize = Mathf.RoundToInt(17f * value); float num2 = Mathf.Min((float)Screen.width * 0.7f, 720f * value); float num3 = 150f * value; Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(((float)Screen.width - num2) * 0.5f, (float)Screen.height * 0.22f, num2, num3); GUI.DrawTexture(val2, (Texture)(object)_panelTex, (ScaleMode)0); Rect r2 = default(Rect); ((Rect)(ref r2))..ctor(((Rect)(ref val2)).x, ((Rect)(ref val2)).y + 14f * value, ((Rect)(ref val2)).width, 34f * value); DrawOutlined(r2, "SBG Shields is standing down", _noticeBig, new Color(1f, 0.78f, 0.25f), Color.black, 2f); Rect r3 = default(Rect); ((Rect)(ref r3))..ctor(((Rect)(ref val2)).x + 20f * value, ((Rect)(ref val2)).y + 54f * value, ((Rect)(ref val2)).width - 40f * value, 80f * value); string text2 = (blockReason.Contains("public lobby") ? "The shield is disabled in public lobbies on purpose.\n\nHost a Friends or Invite Only lobby to use it." : (blockReason + ".\n\nThe match is running vanilla rules so nothing desyncs. Everyone needs SBG Shields 0.7.40 for the shield to work.")); DrawOutlined(r3, text2, _noticeSmall, Color.white, Color.black, 1.5f); } } private static Color PercentColor(float pct) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp01(pct / Mathf.Max(1f, Plugin.PercentForMaxScaling.Value)); if (num < 0.33f) { return Color.Lerp(Color.white, new Color(1f, 0.92f, 0.25f), num / 0.33f); } if (num < 0.66f) { return Color.Lerp(new Color(1f, 0.92f, 0.25f), new Color(1f, 0.55f, 0.1f), (num - 0.33f) / 0.33f); } return Color.Lerp(new Color(1f, 0.55f, 0.1f), new Color(0.9f, 0.08f, 0.08f), (num - 0.66f) / 0.34f); } private static void DrawBubble(PlayerInfo player, Rect rect, float scale, bool up, bool onBreakCd, bool showPips) { //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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0170: 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_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_04ed: Unknown result type (might be due to invalid IL or missing references) //IL_0420: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_0451: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Unknown result type (might be due to invalid IL or missing references) //IL_049b: Unknown result type (might be due to invalid IL or missing references) //IL_04be: Unknown result type (might be due to invalid IL or missing references) //IL_0467: Unknown result type (might be due to invalid IL or missing references) Color val = Skin.Of(player); string reason; bool flag = ShieldState.CanActivate(out reason); float secondsUntilReady = ShieldState.SecondsUntilReady; Color color = val; if (up) { color = Color.Lerp(val, Color.white, 0.25f); rect = Grow(rect, 6f * scale); } else if (!flag) { color = val * 0.3f; color.a = 1f; } float num = Mathf.Max(0f, Plugin.HudGlow.Value); double timeAsDouble = Time.timeAsDouble; float num2 = (float)((timeAsDouble - ShieldState.LastParryAt) / (double)Plugin.ParryFlashSeconds); bool flag2 = num2 >= 0f && num2 < 1f; Color colour = val; float spread = 1.9f; float strength; if (flag2) { colour = Color.Lerp(Color.white, val, num2); strength = num * Mathf.Lerp(1.4f, 0.9f, num2); spread = Mathf.Lerp(2.6f, 1.9f, num2); } else if (up) { float num3 = 0.5f + 0.5f * Mathf.Sin((float)(timeAsDouble * 4.5)); strength = num * Mathf.Lerp(0.75f, 1f, num3); spread = Mathf.Lerp(1.9f, 2.15f, num3); } else { strength = num * (flag ? 0.55f : 0.12f); } DrawGlow(rect, colour, strength, spread); Color color2 = GUI.color; GUI.color = color; GUI.DrawTexture(rect, (Texture)(object)_bubbleTex, (ScaleMode)2, true); GUI.color = color2; if (!flag) { _timerStyle.fontSize = Mathf.RoundToInt((float)Plugin.PercentFontSize.Value * 0.42f * scale); string text = (float.IsInfinity(secondsUntilReady) ? "X" : ((secondsUntilReady >= 10f) ? $"{secondsUntilReady:0}" : $"{secondsUntilReady:0.0}")); DrawOutlined(rect, text, _timerStyle, Color.white, Color.black, Mathf.Max(1f, 2f * scale)); } if (!showPips) { GUI.color = color2; return; } int num4 = Mathf.Max(1, Plugin.MaxPips.Value); int num5 = (num4 + 1) / 2; float num6 = 12f * scale; float num7 = 5f * scale; float num8 = (float)num5 * num6 + (float)(num5 - 1) * num7; float num9 = ((Rect)(ref rect)).center.x - num8 * 0.5f; float num10 = ((Rect)(ref rect)).yMax + 4f * scale; double timeAsDouble2 = Time.timeAsDouble; double num11 = timeAsDouble2 - _pipsShownAt; Rect val2 = default(Rect); for (int i = 0; i < num5; i++) { int num12 = Mathf.Clamp(ShieldState.Pips - i * 2, 0, 2); float num13 = PopEase((float)((num11 - (double)i * 0.06) / 0.16)); if (num13 <= 0f) { continue; } float num14 = num6 * num13; bool flag3 = i == ShieldState.LastPipLossDot && timeAsDouble2 - ShieldState.LastPipLossAt < 0.25 && ShieldState.LastPipLossAt > _pipsShownAt; if (flag3) { num14 *= 1f + 0.5f * (1f - (float)((timeAsDouble2 - ShieldState.LastPipLossAt) / 0.25)); } float num15 = num9 + (float)i * (num6 + num7) + num6 * 0.5f; float num16 = num10 + num6 * 0.5f; ((Rect)(ref val2))..ctor(num15 - num14 * 0.5f, num16 - num14 * 0.5f, num14, num14); if (num12 > 0) { DrawGlow(val2, flag3 ? Color.white : val, num * (flag3 ? 1.2f : ((num12 == 2) ? 0.6f : 0.3f)) * (up ? 1.15f : 1f), 2.6f); } GUI.color = new Color(0f, 0f, 0f, 0.55f); GUI.DrawTexture(val2, (Texture)(object)_dotTex, (ScaleMode)2, true); if (num12 != 0) { GUI.color = (flag3 ? Color.white : val); if (num12 == 2) { GUI.DrawTexture(val2, (Texture)(object)_dotTex, (ScaleMode)2, true); continue; } GUI.BeginGroup(new Rect(((Rect)(ref val2)).x, ((Rect)(ref val2)).y, ((Rect)(ref val2)).width * 0.5f, ((Rect)(ref val2)).height)); GUI.DrawTexture(new Rect(0f, 0f, ((Rect)(ref val2)).width, ((Rect)(ref val2)).height), (Texture)(object)_dotTex, (ScaleMode)2, true); GUI.EndGroup(); } } GUI.color = color2; } private static void DrawStocks(PlayerInfo player, Vector2 bottomCentre, int total, int left, float scale) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: 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_009e: 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) if (!((Object)(object)_bubbleTex == (Object)null) && total > 0) { Color color = GUI.color; Color val = Skin.Of(player); float num = 18f * scale; float num2 = 5f * scale; float num3 = (float)total * num + (float)(total - 1) * num2; float num4 = bottomCentre.x - num3 * 0.5f; float num5 = bottomCentre.y - num; Rect val2 = default(Rect); for (int i = 0; i < total; i++) { ((Rect)(ref val2))..ctor(num4 + (float)i * (num + num2), num5, num, num); GUI.color = (Color)((i < left) ? val : new Color(1f, 1f, 1f, 0.22f)); GUI.DrawTexture(val2, (Texture)(object)_bubbleTex, (ScaleMode)2, true); } GUI.color = color; } } private static Rect Grow(Rect r, float by) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) return new Rect(((Rect)(ref r)).x - by, ((Rect)(ref r)).y - by, ((Rect)(ref r)).width + 2f * by, ((Rect)(ref r)).height + 2f * by); } private static void DrawOutlined(Rect r, string text, GUIStyle style, Color fill, Color outline, float thickness) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_0116: Unknown result type (might be due to invalid IL or missing references) Color textColor = style.normal.textColor; style.normal.textColor = outline; GUI.Label(new Rect(((Rect)(ref r)).x - thickness, ((Rect)(ref r)).y, ((Rect)(ref r)).width, ((Rect)(ref r)).height), text, style); GUI.Label(new Rect(((Rect)(ref r)).x + thickness, ((Rect)(ref r)).y, ((Rect)(ref r)).width, ((Rect)(ref r)).height), text, style); GUI.Label(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y - thickness, ((Rect)(ref r)).width, ((Rect)(ref r)).height), text, style); GUI.Label(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + thickness, ((Rect)(ref r)).width, ((Rect)(ref r)).height), text, style); GUI.Label(new Rect(((Rect)(ref r)).x + thickness, ((Rect)(ref r)).y + thickness, ((Rect)(ref r)).width, ((Rect)(ref r)).height), text, style); style.normal.textColor = fill; GUI.Label(r, text, style); style.normal.textColor = textColor; } } internal static class ImmunityFlicker { private class Entry { public readonly List<Renderer> Renderers = new List<Renderer>(); public bool Active; public bool Washed; } private static readonly Dictionary<PlayerInfo, Entry> _entries = new Dictionary<PlayerInfo, Entry>(); private static readonly List<PlayerInfo> _scratch = new List<PlayerInfo>(); private static readonly List<PlayerInfo> _dead = new List<PlayerInfo>(); private static readonly List<SkinnedMeshRenderer> _skinned = new List<SkinnedMeshRenderer>(); private static readonly List<MeshRenderer> _meshes = new List<MeshRenderer>(); private static readonly MaterialPropertyBlock _block = new MaterialPropertyBlock(); private static readonly int ColorId = Shader.PropertyToID("_Color"); private static readonly int BaseColorId = Shader.PropertyToID("_BaseColor"); internal static void Tick() { //IL_01d8: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.ImmunityFlickerEnabled.Value) { if (_entries.Count > 0) { ClearAll(); } return; } _scratch.Clear(); PlayerInfo localPlayerInfo = GameManager.LocalPlayerInfo; if ((Object)(object)localPlayerInfo != (Object)null) { _scratch.Add(localPlayerInfo); } try { List<PlayerInfo> remotePlayers = GameManager.RemotePlayers; if (remotePlayers != null) { _scratch.AddRange(remotePlayers); } } catch { } _dead.Clear(); foreach (KeyValuePair<PlayerInfo, Entry> entry in _entries) { if ((Object)(object)entry.Key == (Object)null || !_scratch.Contains(entry.Key)) { _dead.Add(entry.Key); } } foreach (PlayerInfo item in _dead) { if (_entries.TryGetValue(item, out var value)) { Clear(value); } _entries.Remove(item); } float num = Mathf.Max(1f, Plugin.ImmunityFlickerRate.Value); bool flag = Time.timeAsDouble * (double)num % 1.0 < 0.5; foreach (PlayerInfo item2 in _scratch) { if ((Object)(object)item2 == (Object)null) { continue; } bool flag2 = false; try { flag2 = (Object)(object)item2.Movement != (Object)null && item2.Movement.KnockoutImmunityStatus.hasImmunity && item2.Movement.IsVisible; } catch { } _entries.TryGetValue(item2, out var value2); if (!flag2) { if (value2 != null && value2.Active) { Clear(value2); } continue; } if (value2 == null) { value2 = new Entry(); _entries[item2] = value2; } if (!value2.Active) { value2.Active = true; value2.Washed = false; Gather(item2, value2); } if (flag != value2.Washed) { value2.Washed = flag; if (flag) { Wash(value2); } else { Unwash(value2); } } } } private static void Gather(PlayerInfo p, Entry e) { e.Renderers.Clear(); try { _skinned.Clear(); ((Component)p).GetComponentsInChildren<SkinnedMeshRenderer>(true, _skinned); foreach (SkinnedMeshRenderer item in _skinned) { e.Renderers.Add((Renderer)(object)item); } _meshes.Clear(); ((Component)p).GetComponentsInChildren<MeshRenderer>(true, _meshes); foreach (MeshRenderer mesh in _meshes) { e.Renderers.Add((Renderer)(object)mesh); } } catch (Exception ex) { if (Plugin.VerboseLogging.Value) { Plugin.Log.LogWarning((object)("Flicker gather: " + ex.Message)); } } } private static void Wash(Entry e) { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp01(Plugin.ImmunityFlickerWash.Value); foreach (Renderer renderer in e.Renderers) { if ((Object)(object)renderer == (Object)null) { continue; } try { Material[] sharedMaterials = renderer.sharedMaterials; for (int i = 0; i < sharedMaterials.Length; i++) { Material val = sharedMaterials[i]; if ((Object)(object)val == (Object)null) { continue; } bool flag = val.HasProperty(ColorId); bool flag2 = val.HasProperty(BaseColorId); if (flag || flag2) { _block.Clear(); renderer.GetPropertyBlock(_block, i); if (flag) { _block.SetColor(ColorId, Color.Lerp(val.GetColor(ColorId), Color.white, num)); } if (flag2) { _block.SetColor(BaseColorId, Color.Lerp(val.GetColor(BaseColorId), Color.white, num)); } renderer.SetPropertyBlock(_block, i); } } } catch { } } } private static void Unwash(Entry e) { foreach (Renderer renderer in e.Renderers) { if ((Object)(object)renderer == (Object)null) { continue; } try { int num = renderer.sharedMaterials.Length; for (int i = 0; i < num; i++) { renderer.SetPropertyBlock((MaterialPropertyBlock)null, i); } } catch { } } } private static void Clear(Entry e) { if (e.Washed) { Unwash(e); } e.Washed = false; e.Active = false; } internal static void ClearAll() { foreach (KeyValuePair<PlayerInfo, Entry> entry in _entries) { Clear(entry.Value); } _entries.Clear(); } } [HarmonyPatch(typeof(PlayerMovement), "UpdateKnockoutImmunityVfx")] internal static class HideGameBubblePatch { private static FieldRef<PlayerMovement, PoolableParticleSystem> _vfx; private static bool Prepare() { try { _vfx = AccessTools.FieldRefAccess<PlayerMovement, PoolableParticleSystem>("knockoutImmunityVfx"); return true; } catch (Exception ex) { Plugin.Log.LogWarning((object)("knockoutImmunityVfx not found; HideGameBubble does nothing. " + ex.Message)); return false; } } private static void Postfix(PlayerMovement __instance) { if (!Plugin.ImmunityFlickerEnabled.Value || !Plugin.HideGameBubble.Value) { return; } try { PoolableParticleSystem val = _vfx.Invoke(__instance); if ((Object)(object)val != (Object)null) { val.Stop((ParticleSystemStopBehavior)0); } } catch { } } } internal static class KillZone { private static bool _armed; private static double _armedAt; private static bool _wentUp; private static bool _lingering; private static double _respawnAt; private static GameObject _flashGo; private static ParticleSystem _flashPs; private static ParticleSystem _sparkPs; private static Material _flashMat; private static Material _sparkMat; private static Texture2D _starTex; private static Texture2D _dotTex; internal static bool IsArmed => _armed; internal static bool IsLingering => _lingering; internal static void Arm() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) _armed = true; _armedAt = Time.timeAsDouble; _wentUp = false; float value = Plugin.KillZoneUpwardBoost.Value; if (value > 0f) { ShieldState.PendingVelocityCorrection += Vector3.up * value; ShieldState.HasPendingVelocityCorrection = true; ShieldState.LaunchDragUntil = double.MinValue; } if (Plugin.VerboseLogging.Value) { Plugin.Log.LogInfo((object)$"Kill zone armed at {ShieldState.Percent:0}%: +{value:0} m/s up, waiting for the apex."); } } internal static void Disarm() { _armed = false; } internal static void StandDown() { if (_armed) { _armed = false; Plugin.Log.LogInfo((object)"Standing down: the death launch is cancelled; vanilla rules from here."); } if (_lingering) { _lingering = false; PlayerMovement val = (((Object)(object)GameManager.LocalPlayerInfo != (Object)null) ? GameManager.LocalPlayerInfo.Movement : null); if ((Object)(object)val != (Object)null) { BeginRespawn(val); } } } internal static void Tick() { //IL_00c9: Unknown result type (might be due to invalid IL or missing references) if (_lingering) { TickLinger(); } else { if (!_armed) { return; } if (!ModHandshake.GameplayEnabled) { StandDown(); return; } PlayerInfo localPlayerInfo = GameManager.LocalPlayerInfo; PlayerMovement val = (((Object)(object)localPlayerInfo != (Object)null) ? localPlayerInfo.Movement : null); if ((Object)(object)val == (Object)null) { _armed = false; return; } double timeAsDouble = Time.timeAsDouble; if (val.IsRespawningOrDrowning) { _armed = false; return; } if (!val.IsKnockedOut) { if (timeAsDouble - _armedAt > 1.0) { _armed = false; } return; } float y = val.Velocity.y; if (y > 0.5f) { _wentUp = true; } bool flag = _wentUp && y <= 0f; bool flag2 = !_wentUp && timeAsDouble - _armedAt > 0.35; bool flag3 = timeAsDouble - _armedAt > (double)Plugin.KillZoneMaxRiseTime.Value; if (flag || flag2 || flag3) { Fire(localPlayerInfo, val); } } } private static void Fire(PlayerInfo p, PlayerMovement mv) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) _armed = false; ShieldState.Stats.StarKos++; Vector3 val = (((Object)(object)p.ChestBone != (Object)null) ? p.ChestBone.position : (((Component)p).transform.position + Vector3.up)); if (Plugin.VerboseLogging.Value) { Plugin.Log.LogInfo((object)$"STAR KO at {ShieldState.Percent:0}% (height {val.y:0.0})."); } PlayStar(p, val); PlayerInfo lastHitBy = ShieldState.LastHitBy; bool flag = (Object)(object)lastHitBy != (Object)null && lastHitBy != p && Time.timeAsDouble - ShieldState.LastHitAt < 15.0; SbgNet.SendStarKo(flag ? lastHitBy : null, ShieldState.LastHitType); string arg = null; if (flag) { try { arg = lastHitBy.PlayerId.PlayerNameNoRichText; } catch { arg = "someone"; } } Plugin.Log.LogInfo((object)(flag ? $"STAR KO by {arg} ({ShieldState.LastHitType})." : "STAR KO (self).")); ShieldState.LastHitBy = null; ShieldState.Percent = Mathf.Max(0f, Plugin.PercentAfterKillZoneDeath.Value); try { Stocks.OnLocalStarKo(); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Stocks: " + ex.Message)); } float num = Mathf.Max(0f, Plugin.KillZoneDeathLinger.Value); if (num > 0.01f && Hide(mv)) { _lingering = true; _respawnAt = Time.timeAsDouble + (double)num; } else { BeginRespawn(mv); } } private static void PlayStar(PlayerInfo p, Vector3 pos) { //IL_00e5: 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) if (Plugin.KillZoneFlash.Value) { try { PlayFlash(pos, Skin.Of(p)); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Kill flash failed: " + ex.Message)); } } if (!Plugin.KillZoneBoom.Value) { return; } try { RuntimeManager.PlayOneShot(GameManager.AudioSettings.ElectromagnetShieldExplosionEvent, pos); } catch (Exception ex2) { if (Plugin.VerboseLogging.Value) { Plugin.Log.LogWarning((object)("Kill boom failed: " + ex2.Message)); } } BreakSoundCarryPatch.CarryToListener(GameManager.AudioSettings.ElectromagnetShieldExplosionEvent, pos, Plugin.KillZoneBoomCarry.Value, "Kill boom carry"); try { CameraModuleController.Shake(GameManager.CameraGameplaySettings.RocketExplosionScreenshakeSettings, pos, 1.6f, 1.4f); } catch { try { CameraModuleController.Shake(GameManager.CameraGameplaySettings.ElectromagnetExplosionScreenshakeSettings, pos, 1f, 1f); } catch { } } } internal static void PlayRemoteStar(PlayerInfo p) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_0040: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)p == (Object)null)) { Vector3 pos = (((Object)(object)p.ChestBone != (Object)null) ? p.ChestBone.position : (((Component)p).transform.position + Vector3.up)); PlayStar(p, pos); } } private static bool Hide(PlayerMovement mv) { try { mv.NetworkisVisible = false; return true; } catch (Exception ex) { Plugin.Log.LogWarning((object)("Kill zone could not hide the player: " + ex.Message)); return false; } } private static void TickLinger() { PlayerInfo localPlayerInfo = GameManager.LocalPlayerInfo; PlayerMovement val = (((Object)(object)localPlayerInfo != (Object)null) ? localPlayerInfo.Movement : null); if ((Object)(object)val == (Object)null) { _lingering = false; } else if (val.IsRespawningOrDrowning) { _lingering = false; } else if (!(Time.timeAsDouble < _respawnAt) && !Stocks.OutLocal) { _lingering = false; BeginRespawn(val); } } private static void BeginRespawn(PlayerMovement mv) { ShieldState.KillZoneDeathPending = true; bool flag = false; try { flag = mv.TryBeginRespawn(false, (RespawnTarget)0, true); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Kill respawn failed: " + ex.Message)); } if (flag) { return; } ShieldState.KillZoneDeathPending = false; bool flag2 = false; try { flag2 = mv.PlayerInfo.AsGolfer.IsMatchResolved; } catch { } if (flag2 || Stocks.OutLocal) { _lingering = true; _respawnAt = double.MaxValue; Plugin.Log.LogInfo((object)"Kill zone: out of this hole; staying hidden until the next one."); return; } Plugin.Log.LogWarning((object)"Kill zone: the game refused the respawn (already respawning)."); try { mv.NetworkisVisible = true; } catch { } } internal static void CancelLinger() { if (!_lingering) { return; } _lingering = false; PlayerMovement val = (((Object)(object)GameManager.LocalPlayerInfo != (Object)null) ? GameManager.LocalPlayerInfo.Movement : null); if (!((Object)(object)val != (Object)null)) { return; } try { val.NetworkisVisible = true; } catch { } } private static void EnsureFlash() { //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_018a: 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_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Expected O, but got Unknown //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_026c: 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_0283: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Expected O, but got Unknown //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_0399: 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_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_0435: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Unknown result type (might be due to invalid IL or missing references) //IL_044b: Unknown result type (might be due to invalid IL or missing references) //IL_0450: 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_045f: Expected O, but got Unknown //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_flashGo != (Object)null)) { if ((Object)(object)_starTex == (Object)null) { _starTex = MakeStarTexture(128); } if ((Object)(object)_dotTex == (Object)null) { _dotTex = MakeDotTexture(32); } if ((Object)(object)_flashMat == (Object)null) { _flashMat = LaunchVfx.MakeUnlitMaterial(_starTex, additive: true, Plugin.BitsGlow.Value); } if ((Object)(object)_sparkMat == (Object)null) { _sparkMat = LaunchVfx.MakeUnlitMaterial(_dotTex, additive: true, Plugin.BitsGlow.Value); } if (!((Object)(object)_flashMat == (Object)null)) { _flashGo = new GameObject("SbgKillFlash"); _flashPs = _flashGo.AddComponent<ParticleSystem>(); _flashPs.Stop(true, (ParticleSystemStopBehavior)0); MainModule main = _flashPs.main; ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; ((MainModule)(ref main)).loop = false; ((MainModule)(ref main)).playOnAwake = false; ((MainModule)(ref main)).duration = 0.1f; ((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(0.55f); ((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0f); ((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(1f); ((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0f); ((MainModule)(ref main)).maxParticles = 4; EmissionModule emission = _flashPs.emission; ((EmissionModule)(ref emission)).enabled = true; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f); ((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[1] { new Burst(0f, (short)1) }); ShapeModule shape = _flashPs.shape; ((ShapeModule)(ref shape)).enabled = false; SizeOverLifetimeModule sizeOverLifetime = _flashPs.sizeOverLifetime; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, new AnimationCurve((Keyframe[])(object)new Keyframe[4] { new Keyframe(0f, 0.05f), new Keyframe(0.12f, 1f), new Keyframe(0.5f, 1.15f), new Keyframe(1f, 1.4f) })); ColorOverLifetimeModule colorOverLifetime = _flashPs.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true; RotationOverLifetimeModule rotationOverLifetime = _flashPs.rotationOverLifetime; ((RotationOverLifetimeModule)(ref rotationOverLifetime)).enabled = true; ((RotationOverLifetimeModule)(ref rotationOverLifetime)).z = MinMaxCurve.op_Implicit(0.9f); ParticleSystemRenderer component = _flashGo.GetComponent<ParticleSystemRenderer>(); ((Renderer)component).sharedMaterial = _flashMat; component.renderMode = (ParticleSystemRenderMode)0; ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component).receiveShadows = false; GameObject val = new GameObject("Sparks"); val.transform.SetParent(_flashGo.transform, false); _sparkPs = val.AddComponent<ParticleSystem>(); _sparkPs.Stop(true, (ParticleSystemStopBehavior)0); MainModule main2 = _sparkPs.main; ((MainModule)(ref main2)).simulationSpace = (ParticleSystemSimulationSpace)1; ((MainModule)(ref main2)).loop = false; ((MainModule)(ref main2)).playOnAwake = false; ((MainModule)(ref main2)).duration = 0.1f; ((MainModule)(ref main2)).startLifetime = new MinMaxCurve(0.4f, 0.8f); ((MainModule)(ref main2)).startSpeed = new MinMaxCurve(6f, 14f); ((MainModule)(ref main2)).startSize = new MinMaxCurve(0.25f, 0.6f); ((MainModule)(ref main2)).gravityModifier = MinMaxCurve.op_Implicit(0.3f); ((MainModule)(ref main2)).maxParticles = 64; EmissionModule emission2 = _sparkPs.emission; ((EmissionModule)(ref emission2)).enabled = true; ((EmissionModule)(ref emission2)).rateOverTime = MinMaxCurve.op_Implicit(0f); ((EmissionModule)(ref emission2)).SetBursts((Burst[])(object)new Burst[1] { new Burst(0f, (short)28) }); ShapeModule shape2 = _sparkPs.shape; ((ShapeModule)(ref shape2)).enabled = true; ((ShapeModule)(ref shape2)).shapeType = (ParticleSystemShapeType)0; ((ShapeModule)(ref shape2)).radius = 0.3f; SizeOverLifetimeModule sizeOverLifetime2 = _sparkPs.sizeOverLifetime; ((SizeOverLifetimeModule)(ref sizeOverLifetime2)).enabled = true; ((SizeOverLifetimeModule)(ref sizeOverLifetime2)).size = new MinMaxCurve(1f, new AnimationCurve((Keyframe[])(object)new Keyframe[2] { new Keyframe(0f, 1f), new Keyframe(1f, 0f) })); ColorOverLifetimeModule colorOverLifetime2 = _sparkPs.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime2)).enabled = true; ParticleSystemRenderer component2 = val.GetComponent<ParticleSystemRenderer>(); ((Renderer)component2).sharedMaterial = _sparkMat; component2.renderMode = (ParticleSystemRenderMode)1; component2.lengthScale = 3f; component2.velocityScale = 0.05f; ((Renderer)component2).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component2).receiveShadows = false; } } } private static void PlayFlash(Vector3 pos, Color skin) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) EnsureFlash(); if (!((Object)(object)_flashGo == (Object)null)) { float value = Plugin.KillZoneFlashSize.Value; MainModule main = _flashPs.main; ((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(value); Color val = Color.Lerp(Color.white, skin, 0.6f); Gradient val2 = new Gradient(); val2.SetKeys((GradientColorKey[])(object)new GradientColorKey[3] { new GradientColorKey(Color.white, 0f), new GradientColorKey(Color.white, 0.35f), new GradientColorKey(val, 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[3] { new GradientAlphaKey(1f, 0f), new GradientAlphaKey(1f, 0.4f), new GradientAlphaKey(0f, 1f) }); ColorOverLifetimeModule colorOverLifetime = _flashPs.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val2); Gradient val3 = new Gradient(); val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[2] { new GradientColorKey(Color.white, 0f), new GradientColorKey(val, 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[2] { new GradientAlphaKey(1f, 0f), new GradientAlphaKey(0f, 1f) }); ColorOverLifetimeModule colorOverLifetime2 = _sparkPs.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime2)).color = new MinMaxGradient(val3); _flashGo.transform.position = pos; _flashPs.Play(true); } } private static Texture2D MakeStarTexture(int size) { //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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(size, size, (TextureFormat)4, true) { wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1 }; Color[] array = (Color[])(object)new Color[size * size]; float num = (float)size * 0.5f; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num2 = ((float)j + 0.5f - num) / num; float num3 = ((float)i + 0.5f - num) / num; float num4 = Mathf.Sqrt(num2 * num2 + num3 * num3); float num5 = Mathf.Atan2(num3, num2); float num6 = Mathf.Pow(Mathf.Abs(Mathf.Cos(2f * num5)), 12f); float num7 = Mathf.Pow(Mathf.Abs(Mathf.Cos(4f * num5)), 20f) * 0.45f; float num8 = 0.18f + 0.82f * Mathf.Max(num6, num7); float num9 = Mathf.Clamp01((num8 - num4) / 0.06f); float num10 = Mathf.Exp((0f - num4) * num4 * 9f) * 0.8f; float num11 = Mathf.Clamp01(num9 + num10); array[i * size + j] = new Color(num11, num11, num11, num11); } } val.SetPixels(array); val.Apply(true); return val; } private static Texture2D MakeDotTexture(int size) { //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_0013: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(size, size, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1 }; Color[] array = (Color[])(object)new Color[size * size]; float num = (float)size * 0.5f; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num2 = Vector2.Distance(new Vector2((float)j + 0.5f, (float)i + 0.5f), new Vector2(num, num)) / num; float num3 = Mathf.Clamp01(1f - num2 * num2); array[i * size + j] = new Color(num3, num3, num3, num3); } } val.SetPixels(array); val.Apply(); return val; } internal static void DestroyAll() { CancelLinger(); if ((Object)(object)_flashGo != (Object)null) { Object.Destroy((Object)(object)_flashGo); } if ((Object)(object)_flashMat != (Object)null) { Object.Dest