Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of GlowStick v1.1.1
plugins/GlowStick.dll
Decompiled 13 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using ExitGames.Client.Photon; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("GlowStick")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.1.0")] [assembly: AssemblyInformationalVersion("1.1.1")] [assembly: AssemblyProduct("GlowStick")] [assembly: AssemblyTitle("GlowStick")] [assembly: AssemblyVersion("1.1.1.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace GlowSticks { internal static class Glow { private static ConfigEntry<KeyCode> KThrow; private static ConfigEntry<float> CCooldown; private static ConfigEntry<int> CMax; private static ConfigEntry<float> CRegen; private static ConfigEntry<float> CSpeed; private static ConfigEntry<bool> CLight; private static ConfigEntry<bool> CHud; public static ConfigEntry<bool> Enabled; private static ConfigEntry<float> CLightRange; private static ConfigEntry<float> CLightPower; private static ConfigEntry<int> CLightMax; private static ConfigEntry<KeyCode> KGrab; private static ConfigEntry<float> CGrabRange; private static ConfigEntry<float> CGrabDist; private static ConfigEntry<float> CGrabSpring; private static ConfigEntry<float> CGrabDamp; private static ConfigEntry<float> CGrabThrow; private static int _stock = -1; private static float _cdUntil; private static float _regAt; private static int _colIdx; private static bool _init; private static ConfigEntry<string>[] CC; private static ConfigEntry<int> CFix; private static string _colSig; private static float _colAt; public static readonly string[] DEFA_HEX = new string[8] { "#FFDE1A", "#FF2E29", "#40FF47", "#338CFF", "#FFFFFF", "#FF850D", "#B847FF", "#FF5CC2" }; private static readonly Color[] DEF_COLORS = (Color[])(object)new Color[8] { new Color(1f, 0.87f, 0.1f), new Color(1f, 0.18f, 0.16f), new Color(0.25f, 1f, 0.28f), new Color(0.2f, 0.55f, 1f), new Color(1f, 1f, 1f), new Color(1f, 0.52f, 0.05f), new Color(0.72f, 0.28f, 1f), new Color(1f, 0.36f, 0.76f) }; public static Color[] Colors = (Color[])DEF_COLORS.Clone(); public static string[] ColorNames = new string[8] { "YELLOW", "RED", "GREEN", "BLUE", "WHITE", "ORANGE", "PURPLE", "PINK" }; public static float LightRange { get { if (CLightRange == null) { return 14f; } return CLightRange.Value; } } public static float LightPower { get { if (CLightPower == null) { return 6.5f; } return CLightPower.Value; } } public static bool LightOn { get { if (CLight != null) { return CLight.Value; } return true; } } public static int LightBudget { get { if (CLightMax == null) { return 16; } return CLightMax.Value; } } public static bool Enabled2 { get { if (Enabled != null) { return Enabled.Value; } return true; } } public static KeyCode GrabKeyRaw { get { //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (KGrab == null) { return (KeyCode)101; } return KGrab.Value; } } public static float GrabRange { get { if (CGrabRange == null) { return 3.5f; } return CGrabRange.Value; } } public static float GrabDist { get { if (CGrabDist == null) { return 1.35f; } return CGrabDist.Value; } } public static float GrabSpring { get { if (CGrabSpring == null) { return 55f; } return CGrabSpring.Value; } } public static float GrabDamp { get { if (CGrabDamp == null) { return 9f; } return CGrabDamp.Value; } } public static float GrabThrowSpeed { get { if (CGrabThrow == null) { return 11f; } return CGrabThrow.Value; } } public static int Stock { get { if (_stock >= 0) { return _stock; } return 0; } } public static int MaxStock { get { if (CMax == null) { return 10; } return CMax.Value; } } public static bool HudOn { get { if (CHud != null) { return CHud.Value; } return true; } } public static int ColFix { get { if (CFix == null) { return 0; } return CFix.Value; } } public static Color NextColor => Colors[NextIdx()]; public static string NextColorName => ColorNames[NextIdx() % ColorNames.Length]; public static void Init(ConfigFile c) { Enabled = LangHost.B(c, "enable", def: true, null); KThrow = LangHost.B<KeyCode>(c, "tk", (KeyCode)120, null); CCooldown = LangHost.B(c, "cd", 5f, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f)); CMax = LangHost.B(c, "mx", 10, (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 30)); CRegen = LangHost.B(c, "rg", 30f, (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 300f)); CSpeed = LangHost.B(c, "sp", 6f, (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 20f)); CLight = LangHost.B(c, "lt", def: true, null); CLightRange = LangHost.B(c, "lr", 14f, (AcceptableValueBase)(object)new AcceptableValueRange<float>(3f, 40f)); CLightPower = LangHost.B(c, "lp", 6.5f, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 25f)); CLightMax = LangHost.B(c, "lb", 16, (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 60)); CHud = LangHost.B(c, "hud", def: true, null); KGrab = LangHost.B<KeyCode>(c, "gk", (KeyCode)101, null); CGrabRange = LangHost.B(c, "gr", 3.5f, (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 12f)); CGrabDist = LangHost.B(c, "gd", 1.35f, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 4f)); CGrabSpring = LangHost.B(c, "gs", 55f, (AcceptableValueBase)(object)new AcceptableValueRange<float>(8f, 200f)); CGrabDamp = LangHost.B(c, "gp", 9f, (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 40f)); CGrabThrow = LangHost.B(c, "gt", 11f, (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 30f)); CC = new ConfigEntry<string>[8]; for (int i = 0; i < 8; i++) { CC[i] = LangHost.B(c, "c" + (i + 1), DEFA_HEX[i], null); if (CC[i] != null) { CC[i].SettingChanged += OnColorChanged; } } CFix = LangHost.B(c, "cfix", 0, (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 8)); LoadColors(); _stock = CMax.Value; _regAt = Time.time + CRegen.Value; _init = true; GlowPlugin.LogInfo("glow init, stock=" + _stock + " max=" + CMax.Value + " colors=" + ColorNames[0] + "," + ColorNames[1] + " mode=" + ColFix); } public static void Tick() { //IL_00d7: Unknown result type (might be due to invalid IL or missing references) ColorGuard(); GlowStick.TickAll(); try { GlowItem.TickAll(); } catch { } try { GlowItem.Scan(); } catch { } try { GlowStick.GrabTick(); } catch { } if (!_init || !Enabled.Value || !GlowPlugin.InLevel()) { return; } if (_stock < CMax.Value) { if (Time.time >= _regAt) { _stock++; _regAt = Time.time + CRegen.Value; GlowPlugin.LogInfo("glow regen -> " + _stock + "/" + CMax.Value); } } else { _regAt = Time.time + CRegen.Value; } if (CanThrow() && GlowPlugin.KeyDown(KThrow.Value)) { Throw(); } } private static bool CanThrow() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 if (_stock <= 0) { return false; } if (Time.time < _cdUntil) { return false; } if ((int)Cursor.lockState != 1) { return false; } return true; } public static float CooldownLeft() { float num = _cdUntil - Time.time; if (!(num < 0f)) { return num; } return 0f; } private static void Throw() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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) if (PlayerPos(out var v)) { Camera val = GlowPlugin.Cam(); Vector3 val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.forward : Vector3.forward); int num; if (ColFix > 0) { num = Mathf.Clamp(ColFix - 1, 0, Colors.Length - 1); } else { num = _colIdx % Colors.Length; _colIdx++; } Color col = Colors[num]; string text = ColorNames[num % ColorNames.Length]; Vector3 pos = GlowItem.FrontPoint(v, val2); Vector3 vel = val2 * CSpeed.Value + Vector3.up * 1.6f; GlowStick.Spawn(pos, vel, col, 0.55f, num); _stock--; _cdUntil = Time.time + CCooldown.Value; GlowPlugin.LogInfo("glow throw " + text + " left=" + _stock + "/" + CMax.Value + " alive=" + (GlowItem.All.Count + GlowStick.All.Count)); if (!CLight.Value) { KillLights(); } } } private static void KillLights() { for (int i = 0; i < GlowStick.All.Count; i++) { GlowStick glowStick = GlowStick.All[i]; if (!((Object)(object)glowStick == (Object)null)) { Light componentInChildren = ((Component)glowStick).GetComponentInChildren<Light>(); if ((Object)(object)componentInChildren != (Object)null) { ((Behaviour)componentInChildren).enabled = false; } } } } private static bool PlayerPos(out Vector3 v) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) v = Vector3.zero; try { PlayerAvatar instance = PlayerAvatar.instance; if ((Object)(object)instance != (Object)null) { v = ((Component)instance).transform.position; return true; } } catch { } try { Component val = GlowPlugin.LocalCtrl(); if ((Object)(object)val != (Object)null) { v = val.transform.position; return true; } } catch { } return false; } public static float RegenFrac() { if (_stock >= MaxStock) { return 1f; } float num = ((CRegen != null) ? CRegen.Value : 30f); if (num <= 0.01f) { return 1f; } return Mathf.Clamp01(1f - (_regAt - Time.time) / num); } private static int NextIdx() { if (ColFix > 0) { return Mathf.Clamp(ColFix - 1, 0, Colors.Length - 1); } return _colIdx % Colors.Length; } private static void OnColorChanged(object sender, EventArgs e) { LoadColors(); } private static Color ParseHex(string raw, Color fb) { //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) try { if (string.IsNullOrEmpty(raw)) { return fb; } string text = raw.Trim(); if (text.StartsWith("#")) { text = text.Substring(1); } if (text.Length == 3) { text = text[0].ToString() + text[0] + text[1] + text[1] + text[2] + text[2]; } if (text.Length != 6) { return fb; } int num = Convert.ToInt32(text.Substring(0, 2), 16); int num2 = Convert.ToInt32(text.Substring(2, 2), 16); int num3 = Convert.ToInt32(text.Substring(4, 2), 16); return new Color((float)num / 255f, (float)num2 / 255f, (float)num3 / 255f, 1f); } catch { return fb; } } public static void LoadColors() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) if (Colors == null) { Colors = (Color[])DEF_COLORS.Clone(); } for (int i = 0; i < 8 && i < Colors.Length; i++) { ConfigEntry<string> val = ((CC != null && i < CC.Length) ? CC[i] : null); string text = ((val != null) ? val.Value : DEFA_HEX[i]); Colors[i] = ParseHex(text, DEF_COLORS[i]); ColorNames[i] = (string.IsNullOrEmpty(text) ? DEFA_HEX[i] : text.Trim().ToUpperInvariant()); } } private static void ColorGuard() { if (CC != null && !(Time.time - _colAt < 1f)) { _colAt = Time.time; StringBuilder stringBuilder = new StringBuilder(64); for (int i = 0; i < CC.Length; i++) { stringBuilder.Append((CC[i] != null) ? CC[i].Value : "").Append('|'); } string text = stringBuilder.ToString(); if (!(text == _colSig)) { _colSig = text; LoadColors(); GlowPlugin.LogInfo("glow colors -> " + string.Join(",", ColorNames) + " mode=" + ColFix); } } } } internal class GlowItem : MonoBehaviour { public const string MARK = "yangs"; public static readonly List<GlowItem> All = new List<GlowItem>(); public static string PathLog = "-"; private static Type _tItem; private static Type _tAttr; private static bool _typesTried; private static float _scanAt; private static readonly string[] Prefer = new string[13] { "grenadestun", "stungrenade", "stung", "stun", "itemgrenade", "grenade", "itemlight", "flashlight", "battery", "rubberduck", "duck", "candy", "cone" }; private static readonly string[] Banish = new string[6] { "explosive", "ducttape", "human", "mine", "molotov", "shockwave" }; public Color color = Color.white; public PhotonView pv; public Rigidbody rb; private Transform _halo; private Material _bodyMat; private Material _haloMat; private Light _light; private Vector3 _vel; private bool _velDone; private float _haloPulse; private bool _built; private bool _hasShell; private static Type _tPool; private static readonly List<string> _cands = new List<string>(); private static int _candIdx; public static int MaxAlive = 26; private static bool Banned(string path) { if (string.IsNullOrEmpty(path)) { return true; } string text = path.ToLower().Replace(" ", "").Replace("_", ""); for (int i = 0; i < Banish.Length; i++) { if (text.IndexOf(Banish[i], StringComparison.Ordinal) >= 0) { return true; } } return false; } private static void TryTypes() { if (_typesTried) { return; } _typesTried = true; try { _tAttr = FindTypeByName("ItemAttributes", mustBeSO: false); _tItem = FindTypeByName("Item", mustBeSO: true); } catch { } } private static Type FindTypeByName(string name, bool mustBeSO) { try { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { Type[] types; try { types = assemblies[i].GetTypes(); } catch { continue; } foreach (Type type in types) { if (!(type == null) && !(type.Name != name) && (!mustBeSO || typeof(ScriptableObject).IsAssignableFrom(type))) { return type; } } } } catch { } return null; } private static string PathOf(object item) { try { object obj = R.Get(item, "prefab"); if (obj == null) { return null; } return R.Get(obj, "ResourcePath") as string; } catch { } return null; } private static string NameOf(object item) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown try { string text = R.Get(item, "itemName") as string; if (!string.IsNullOrEmpty(text)) { return text; } } catch { } try { Object val = (Object)item; if (val != (Object)null) { return val.name; } } catch { } return "?"; } private static void AddCand(List<string> list, string p) { if (!string.IsNullOrEmpty(p) && p.Length >= 4 && !Banned(p) && !list.Contains(p)) { list.Add(p); } } private static int RankOf(string path) { if (string.IsNullOrEmpty(path)) { return 0; } string text = path.ToLower().Replace(" ", "").Replace("_", ""); if (Banned(path)) { return -1000; } for (int i = 0; i < Prefer.Length; i++) { if (text.IndexOf(Prefer[i], StringComparison.Ordinal) >= 0) { return 100 - i * 6; } } if (text.IndexOf("item") >= 0) { return 20; } if (text.IndexOf("prop") >= 0) { return 10; } return 0; } private static string BundleNameOf(object item) { try { object obj = R.Get(item, "prefab"); if (obj == null) { return null; } object obj2 = R.Get(obj, "bundle"); if (obj2 == null) { return null; } object obj3 = R.Get(obj2, "name"); if (obj3 is string && !string.IsNullOrEmpty((string)obj3)) { return (string)obj3; } } catch { } return null; } private static void CollectPoolKeys(List<string> outList) { try { if (_tPool == null) { _tPool = R.FindType("MultiplayerPool"); } if (_tPool == null) { LogWarn("glow item: no MultiplayerPool type"); return; } object obj = R.Static(_tPool, "ResourceCache"); if (obj == null) { object obj2 = R.Static(_tPool, "instance"); if (obj2 == null) { obj2 = R.Static(_tPool, "Instance"); } if (obj2 != null) { obj = R.Get(obj2, "ResourceCache"); } } if (obj == null) { try { Object val = Object.FindObjectOfType(_tPool); if (val != (Object)null) { obj = R.Get(val, "ResourceCache"); } } catch { } } if (!(obj is IDictionary dictionary)) { LogWarn("glow item: ResourceCache unavailable"); return; } int num = 0; foreach (object key in dictionary.Keys) { string text = key as string; if (!string.IsNullOrEmpty(text)) { AddCand(outList, text); num++; } } LogInfo("glow item: pool keys = " + num); } catch (Exception ex) { LogWarn("glow item: pool cache fail " + ex.Message); } } private static void CollectBundleIds(List<string> outList) { try { Type type = R.FindType("AssetBundle"); if (type == null) { LogWarn("glow item: no AssetBundle type"); return; } MethodInfo method = type.GetMethod("GetAllLoadedAssetBundles", BindingFlags.Static | BindingFlags.Public); if (method == null) { LogWarn("glow item: no GetAllLoadedAssetBundles"); } else { if (!(method.Invoke(null, null) is IEnumerable enumerable)) { return; } int num = 0; int num2 = 0; foreach (object item in enumerable) { if (item == null || !(R.Call(item, "GetAllAssetNames") is string[] array) || array.Length == 0) { continue; } num++; string text = R.Get(item, "name") as string; if (string.IsNullOrEmpty(text)) { continue; } foreach (string text2 in array) { if (string.IsNullOrEmpty(text2) || !text2.EndsWith(".prefab", StringComparison.OrdinalIgnoreCase)) { continue; } string text3 = text2.ToLower(); if (text3.IndexOf("item") >= 0 || text3.IndexOf("prop") >= 0 || text3.IndexOf("duck") >= 0 || text3.IndexOf("candy") >= 0 || text3.IndexOf("cone") >= 0 || text3.IndexOf("light") >= 0) { int count = outList.Count; AddCand(outList, "AssetBundles/" + text + "/" + text2); if (outList.Count > count) { num2++; } } } } LogInfo("glow item: bundles = " + num + " ids = " + num2); } } catch (Exception ex) { LogWarn("glow item: bundle scan fail " + ex.Message); } } private static void CollectSceneIds(List<string> outList) { try { Type type = R.FindType("PhysGrabObject"); if (type == null) { return; } Object[] array = Object.FindObjectsOfType(type); int num = 0; foreach (Object obj in array) { Component val = (Component)(object)((obj is Component) ? obj : null); if ((Object)(object)val == (Object)null) { continue; } PhotonView componentInParent = val.GetComponentInParent<PhotonView>(); if ((Object)(object)componentInParent == (Object)null) { continue; } object obj2 = R.Get(componentInParent, "PrefabData"); if (obj2 == null) { continue; } string text = null; try { FieldInfo[] fields = obj2.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (!(fieldInfo.FieldType != typeof(string))) { string text2 = fieldInfo.GetValue(obj2) as string; if (!string.IsNullOrEmpty(text2) && (text2.StartsWith("AssetBundles/") || text2.StartsWith("Items/"))) { text = text2; break; } } } } catch { } if (text != null) { AddCand(outList, text); num++; } } if (num > 0) { LogInfo("glow item: scene ids = " + num); } } catch { } } public static List<string> PickPath() { if (_cands.Count > 0) { return _cands; } List<string> list = new List<string>(); CollectPoolKeys(list); CollectSceneIds(list); try { TryTypes(); if (_tItem != null) { Object[] array = Resources.FindObjectsOfTypeAll(_tItem); foreach (Object val in array) { if (val == (Object)null) { continue; } string text = PathOf(val); if (!string.IsNullOrEmpty(text)) { string text2 = BundleNameOf(val); if (!string.IsNullOrEmpty(text2)) { AddCand(list, "AssetBundles/" + text2 + "/" + text); } } } } } catch { } if (list.Count == 0) { CollectBundleIds(list); } if (list.Count == 0) { PathLog = "(no candidate)"; LogWarn("glow item: no candidate"); return _cands; } List<KeyValuePair<int, string>> list2 = new List<KeyValuePair<int, string>>(); for (int j = 0; j < list.Count; j++) { list2.Add(new KeyValuePair<int, string>(-RankOf(list[j]), list[j])); } list2.Sort((KeyValuePair<int, string> x, KeyValuePair<int, string> y) => (x.Key != y.Key) ? x.Key.CompareTo(y.Key) : string.CompareOrdinal(x.Value, y.Value)); int num = 24; for (int num2 = 0; num2 < list2.Count && num2 < num && list2[num2].Key < 0; num2++) { _cands.Add(list2[num2].Value); } if (_cands.Count == 0) { _cands.Add(list[0]); } PathLog = _cands[0] + " (+" + (_cands.Count - 1) + " more)"; LogInfo("glow item: shell candidates = " + _cands.Count); for (int num3 = 0; num3 < _cands.Count && num3 < 10; num3++) { LogInfo(" shell[" + num3 + "] " + _cands[num3]); } return _cands; } private static string NextPath() { _candIdx++; LogWarn("glow item: shell failed, retry #" + _candIdx); if (_cands.Count == 0) { return null; } if (_candIdx >= _cands.Count) { return null; } return _cands[_candIdx]; } public static Vector3 FrontPoint(Vector3 basePos, Vector3 fwd) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_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) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) Vector3 up = Vector3.up; float num = 0.45f; try { PlayerAvatar instance = PlayerAvatar.instance; if ((Object)(object)instance != (Object)null) { CapsuleCollider componentInChildren = ((Component)instance).GetComponentInChildren<CapsuleCollider>(); if ((Object)(object)componentInChildren != (Object)null) { float num2 = Mathf.Abs(((Component)instance).transform.lossyScale.x); float num3 = Mathf.Abs(((Component)instance).transform.lossyScale.z); float num4 = Mathf.Max(num2, num3); if (num4 < 0.2f || num4 > 1.6f) { num4 = 1f; } num = Mathf.Clamp(componentInChildren.radius * num4, 0.3f, 0.9f); } } } catch { } try { Camera val = GlowPlugin.Cam(); if ((Object)(object)val != (Object)null) { fwd = ((Component)val).transform.forward; } } catch { } fwd.y = 0f; if (((Vector3)(ref fwd)).sqrMagnitude < 0.01f) { fwd = Vector3.forward; } ((Vector3)(ref fwd)).Normalize(); Vector3 val2 = basePos + up * 0.95f; float num5 = num + 0.55f; for (int i = 0; i < 3; i++) { Vector3 val3 = val2 + up * (0.3f * (float)i); for (int j = 0; j < 6; j++) { Vector3 val4 = val3 + fwd * (num5 + 0.22f * (float)j); if (Free(val4, 0.34f)) { return val4; } } } return basePos + up * (1.3f + num5); } private static bool Free(Vector3 p, float r) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) try { Collider[] array = Physics.OverlapSphere(p, r, -1, (QueryTriggerInteraction)1); for (int i = 0; i < array.Length; i++) { if (!((Object)(object)array[i] == (Object)null) && !IsPlayer((Component)(object)array[i])) { return false; } } return true; } catch { return true; } } private static bool IsPlayer(Component c) { if ((Object)(object)c == (Object)null) { return false; } try { return (Object)(object)c.GetComponentInParent<PlayerAvatar>() != (Object)null; } catch { } return false; } public static GameObject Spawn(Vector3 pos, Vector3 vel, int colIdx) { //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) List<string> list = PickPath(); if (list == null || list.Count == 0) { LogWarn("glow item: no shell path at all"); return null; } GameObject val = null; int num = _candIdx; if (num < 0 || num >= list.Count) { num = 0; } for (int i = 0; i < list.Count; i++) { int num2 = num + i; if (num2 >= list.Count) { break; } string text = list[num2]; object[] array = new object[2] { "yangs", colIdx }; try { if (PhotonNetwork.InRoom) { Quaternion val2 = Quaternion.LookRotation((((Vector3)(ref vel)).sqrMagnitude > 0.01f) ? ((Vector3)(ref vel)).normalized : Vector3.up); val = PhotonNetwork.InstantiateRoomObject(text, pos, val2, (byte)0, array); } else { GameObject val3 = Resources.Load<GameObject>(text); if ((Object)(object)val3 != (Object)null) { val = Object.Instantiate<GameObject>(val3, pos, Quaternion.identity); } } } catch (Exception ex) { LogWarn("glow item: spawn ex " + ex.GetType().Name + " " + text + " : " + ex.Message); val = null; } if ((Object)(object)val != (Object)null) { if (num2 != _candIdx) { _candIdx = num2; LogInfo("glow item: shell locked -> " + text); } break; } LogWarn("glow item: spawn returned null for " + text); } if ((Object)(object)val == (Object)null) { return null; } GlowItem glowItem = Dress(val, colIdx); if ((Object)(object)glowItem != (Object)null) { glowItem._vel = vel; } LogInfo("glow item: spawned " + ((Object)val).name + " at " + ((Vector3)(ref pos)).ToString("F2")); return val; } private static GlowItem Dress(GameObject go, int colIdx) { //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) if ((Object)(object)go == (Object)null) { return null; } GlowItem glowItem = null; try { glowItem = go.GetComponent<GlowItem>(); } catch { } if ((Object)(object)glowItem == (Object)null) { glowItem = go.AddComponent<GlowItem>(); } int num = colIdx % Glow.Colors.Length; glowItem.color = Glow.Colors[num]; glowItem.Build(); if (!All.Contains(glowItem)) { All.Add(glowItem); } Trim(); return glowItem; } private void Build() { //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Expected O, but got Unknown //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Unknown result type (might be due to invalid IL or missing references) //IL_043b: 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_0479: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) if (_built) { return; } _built = true; int num = 0; try { Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if ((Object)(object)val == (Object)null) { continue; } try { if (!val.enabled) { val.enabled = true; } } catch { } num++; Material[] array = null; try { array = val.materials; } catch { } if (array == null) { continue; } foreach (Material val2 in array) { if ((Object)(object)val2 == (Object)null) { continue; } try { if (val2.HasProperty("_EmissionColor")) { val2.EnableKeyword("_EMISSION"); val2.SetColor("_EmissionColor", new Color(color.r, color.g, color.b, 1f) * 1.6f); } if (val2.HasProperty("_EmissionMap") && (Object)(object)val2.GetTexture("_EmissionMap") == (Object)null) { Texture texture = val2.GetTexture("_MainTex"); if ((Object)(object)texture != (Object)null) { val2.SetTexture("_EmissionMap", texture); } } } catch { } } } } catch { } _hasShell = num > 0; try { Type type = R.FindType("ItemGrenade"); if (type != null) { Component[] componentsInChildren2 = ((Component)this).GetComponentsInChildren(type, true); for (int k = 0; k < componentsInChildren2.Length; k++) { Component obj5 = componentsInChildren2[k]; MonoBehaviour val3 = (MonoBehaviour)(object)((obj5 is MonoBehaviour) ? obj5 : null); if ((Object)(object)val3 != (Object)null) { try { ((Behaviour)val3).enabled = false; } catch { } } try { R.Set(componentsInChildren2[k], "isActive", false); } catch { } try { R.Set(componentsInChildren2[k], "isSpawnedGrenade", false); } catch { } } } Type type2 = R.FindType("ItemEquippable"); if (type2 != null) { Component[] componentsInChildren3 = ((Component)this).GetComponentsInChildren(type2, true); foreach (Component obj9 in componentsInChildren3) { MonoBehaviour val4 = (MonoBehaviour)(object)((obj9 is MonoBehaviour) ? obj9 : null); if ((Object)(object)val4 != (Object)null) { try { ((Behaviour)val4).enabled = false; } catch { } } } } } catch (Exception ex) { LogWarn("glow item: defuse fail " + ex.Message); } try { pv = ((Component)this).GetComponent<PhotonView>(); if ((Object)(object)pv == (Object)null) { pv = ((Component)this).GetComponentInParent<PhotonView>(); } } catch { } try { rb = ((Component)this).GetComponent<Rigidbody>(); if ((Object)(object)rb == (Object)null) { rb = ((Component)this).GetComponentInChildren<Rigidbody>(); } } catch { } if (!_hasShell) { try { GameObject val5 = new GameObject("yanvis"); val5.transform.SetParent(((Component)this).transform, false); val5.AddComponent<MeshFilter>().sharedMesh = GlowMesh.Cylinder(0.033f, 0.32f, 12); MeshRenderer obj13 = val5.AddComponent<MeshRenderer>(); _bodyMat = GlowMesh.Mat("YanItemBody", null, Color.white, 3100); if (_bodyMat.HasProperty("_Color")) { _bodyMat.SetColor("_Color", color); } ((Renderer)obj13).sharedMaterial = _bodyMat; ((Renderer)obj13).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)obj13).receiveShadows = false; } catch (Exception ex2) { LogWarn("glow item: body fail " + ex2.Message); } } try { float lightRange = Glow.LightRange; GameObject val6 = new GameObject("halo"); val6.transform.SetParent(((Component)this).transform, false); val6.AddComponent<MeshFilter>().sharedMesh = GlowMesh.Quad(); MeshRenderer obj14 = val6.AddComponent<MeshRenderer>(); Color col = default(Color); ((Color)(ref col))..ctor(color.r, color.g, color.b, 0.55f); _haloMat = GlowMesh.Mat("YanItemHalo", GlowMesh.Halo(), col, 3200); ((Renderer)obj14).sharedMaterial = _haloMat; ((Renderer)obj14).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)obj14).receiveShadows = false; _halo = val6.transform; _halo.localScale = Vector3.one * Mathf.Clamp(lightRange * 0.2f, 1.2f, 6f); } catch { } try { GameObject val7 = new GameObject("light"); val7.transform.SetParent(((Component)this).transform, false); Light val8 = val7.AddComponent<Light>(); val8.type = (LightType)2; val8.color = color; val8.range = Glow.LightRange; val8.intensity = Glow.LightPower; val8.shadows = (LightShadows)0; val8.renderMode = (LightRenderMode)1; _light = val8; ((Behaviour)_light).enabled = Glow.LightOn; } catch (Exception ex3) { LogWarn("glow item: light fail " + ex3.Message); } if (!(((Vector3)(ref _vel)).sqrMagnitude > 0.01f)) { return; } try { if (PhotonNetwork.InRoom && (Object)(object)pv != (Object)null && !pv.IsMine) { pv.TransferOwnership(PhotonNetwork.LocalPlayer); } } catch { } } public static void Scan() { if (Time.time < _scanAt) { return; } _scanAt = Time.time + 0.6f; try { PhotonView[] array = Resources.FindObjectsOfTypeAll<PhotonView>(); foreach (PhotonView val in array) { if ((Object)(object)val == (Object)null) { continue; } object[] array2 = null; try { array2 = val.InstantiationData; } catch { } if (array2 == null || array2.Length == 0 || !(array2[0] is string) || (string)array2[0] != "yangs") { continue; } GameObject gameObject = ((Component)val).gameObject; if ((Object)(object)gameObject == (Object)null || (Object)(object)gameObject.GetComponent<GlowItem>() != (Object)null) { continue; } int colIdx = 0; try { if (array2.Length > 1 && array2[1] != null) { colIdx = Convert.ToInt32(array2[1]); } } catch { } Dress(gameObject, colIdx); LogInfo("glow item: dressed remote " + ((Object)gameObject).name); } } catch { } } public static void TickAll() { for (int num = All.Count - 1; num >= 0; num--) { GlowItem glowItem = All[num]; if ((Object)(object)glowItem == (Object)null) { All.RemoveAt(num); } else { glowItem.Tick(); } } } private void Tick() { //IL_00bf: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) if (!_velDone && ((Vector3)(ref _vel)).sqrMagnitude > 0.01f) { bool flag = true; try { if (PhotonNetwork.InRoom && (Object)(object)pv != (Object)null && !pv.IsMine) { flag = false; } } catch { } if (flag && (Object)(object)rb != (Object)null) { try { rb.velocity = _vel; rb.angularVelocity = Random.insideUnitSphere * 9f; } catch { } _velDone = true; } } if ((Object)(object)_halo != (Object)null) { try { Camera val = GlowPlugin.Cam(); if ((Object)(object)val != (Object)null) { _halo.rotation = ((Component)val).transform.rotation; _haloPulse += Time.deltaTime * 3.1f; float num = 0.55f + 0.06f * Mathf.Sin(_haloPulse); if ((Object)(object)_haloMat != (Object)null && _haloMat.HasProperty("_Color")) { _haloMat.SetColor("_Color", new Color(color.r, color.g, color.b, num)); } } } catch { } } if (!((Object)(object)_light != (Object)null)) { return; } try { Camera val2 = GlowPlugin.Cam(); bool flag2 = Glow.LightOn; if (flag2 && (Object)(object)val2 != (Object)null) { Vector3 val3 = ((Component)this).transform.position - ((Component)val2).transform.position; if (((Vector3)(ref val3)).sqrMagnitude > 676f) { flag2 = false; } } if (((Behaviour)_light).enabled != flag2) { ((Behaviour)_light).enabled = flag2; } } catch { } } private static void Trim() { while (All.Count > MaxAlive) { GlowItem glowItem = All[0]; All.RemoveAt(0); if ((Object)(object)glowItem == (Object)null) { continue; } try { if (PhotonNetwork.InRoom) { PhotonNetwork.Destroy(((Component)glowItem).gameObject); } else { Object.Destroy((Object)(object)((Component)glowItem).gameObject); } } catch { try { Object.Destroy((Object)(object)((Component)glowItem).gameObject); } catch { } } } } private static void LogInfo(string s) { GlowPlugin.LogInfo(s); } private static void LogWarn(string s) { GlowPlugin.LogWarn(s); } } internal static class GlowMesh { private static readonly Dictionary<string, Mesh> _cache = new Dictionary<string, Mesh>(); private static Mesh _quad; private static Texture2D _halo; private static Texture2D _disc; private static Shader _sh; public static Shader Glow => _sh ?? (_sh = PickShader()); private static Shader PickShader() { string[] array = new string[6] { "Sprites/Default", "Unlit/Transparent", "Unlit/Color", "Legacy Shaders/Particles/Additive", "Particles/Standard Unlit", "Standard" }; for (int i = 0; i < array.Length; i++) { Shader val = Shader.Find(array[i]); if ((Object)(object)val != (Object)null && val.isSupported) { GlowPlugin.LogInfo("glow shader -> " + array[i]); return val; } } GlowPlugin.LogWarn("glow shader: nothing found, fallback Standard"); return Shader.Find("Standard"); } public static Mesh Cylinder(float radius, float height, int seg) { //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0136: 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_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: 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_0373: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Expected O, but got Unknown //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_026f: 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_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) string key = "c" + radius.ToString("F3") + "_" + height.ToString("F3") + "_" + seg; if (_cache.TryGetValue(key, out var value) && (Object)(object)value != (Object)null) { return value; } List<Vector3> list = new List<Vector3>(); List<Vector3> list2 = new List<Vector3>(); List<Vector2> list3 = new List<Vector2>(); List<int> list4 = new List<int>(); float num = height * 0.5f; for (int i = 0; i < seg; i++) { float num2 = MathF.PI * 2f * (float)i / (float)seg; float num3 = MathF.PI * 2f * (float)(i + 1) / (float)seg; float num4 = Mathf.Cos(num2); float num5 = Mathf.Sin(num2); float num6 = Mathf.Cos(num3); float num7 = Mathf.Sin(num3); int count = list.Count; list.Add(new Vector3(num4 * radius, 0f - num, num5 * radius)); list.Add(new Vector3(num6 * radius, 0f - num, num7 * radius)); list.Add(new Vector3(num6 * radius, num, num7 * radius)); list.Add(new Vector3(num4 * radius, num, num5 * radius)); list2.Add(new Vector3(num4, 0f, num5)); list2.Add(new Vector3(num6, 0f, num7)); list2.Add(new Vector3(num6, 0f, num7)); list2.Add(new Vector3(num4, 0f, num5)); list3.Add(new Vector2((float)i / (float)seg, 0f)); list3.Add(new Vector2((float)(i + 1) / (float)seg, 0f)); list3.Add(new Vector2((float)(i + 1) / (float)seg, 1f)); list3.Add(new Vector2((float)i / (float)seg, 1f)); list4.Add(count); list4.Add(count + 3); list4.Add(count + 2); list4.Add(count); list4.Add(count + 2); list4.Add(count + 1); } for (int j = 0; j < 2; j++) { float num8 = ((j == 0) ? num : (0f - num)); Vector3 item = ((j == 0) ? Vector3.up : Vector3.down); int count2 = list.Count; list.Add(new Vector3(0f, num8, 0f)); list2.Add(item); list3.Add(new Vector2(0.5f, 0.5f)); for (int k = 0; k < seg; k++) { float num9 = MathF.PI * 2f * (float)k / (float)seg; list.Add(new Vector3(Mathf.Cos(num9) * radius, num8, Mathf.Sin(num9) * radius)); list2.Add(item); list3.Add(new Vector2(Mathf.Cos(num9) * 0.5f + 0.5f, Mathf.Sin(num9) * 0.5f + 0.5f)); } for (int l = 0; l < seg; l++) { int item2 = count2 + 1 + l; int item3 = count2 + 1 + (l + 1) % seg; if (j == 0) { list4.Add(count2); list4.Add(item3); list4.Add(item2); } else { list4.Add(count2); list4.Add(item2); list4.Add(item3); } } } value = new Mesh(); ((Object)value).name = "YanStick"; value.SetVertices(list); value.SetNormals(list2); value.SetUVs(0, list3); value.SetTriangles(list4, 0); value.RecalculateBounds(); _cache[key] = value; return value; } public static Mesh Quad() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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_0102: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Expected O, but got Unknown if ((Object)(object)_quad != (Object)null) { return _quad; } List<Vector3> vertices = new List<Vector3> { new Vector3(-0.5f, -0.5f, 0f), new Vector3(0.5f, -0.5f, 0f), new Vector3(0.5f, 0.5f, 0f), new Vector3(-0.5f, 0.5f, 0f) }; List<Vector3> normals = new List<Vector3> { Vector3.back, Vector3.back, Vector3.back, Vector3.back }; List<Vector2> list = new List<Vector2> { new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(1f, 1f), new Vector2(0f, 1f) }; List<int> list2 = new List<int> { 0, 2, 1, 0, 3, 2 }; _quad = new Mesh(); ((Object)_quad).name = "YanQuad"; _quad.SetVertices(vertices); _quad.SetNormals(normals); _quad.SetUVs(0, list); _quad.SetTriangles(list2, 0); _quad.RecalculateBounds(); return _quad; } public static Texture2D Halo() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_00eb: 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) if ((Object)(object)_halo != (Object)null) { return _halo; } _halo = new Texture2D(64, 64, (TextureFormat)4, false); ((Object)_halo).name = "YanHalo"; ((Texture)_halo).wrapMode = (TextureWrapMode)1; Color32[] array = (Color32[])(object)new Color32[4096]; float num = 32f; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; 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); if (num4 > 1f) { num4 = 1f; } float num5 = 1f - num4; num5 = num5 * num5 * (3f - 2f * num5); num5 = Mathf.Pow(num5, 1.35f); byte b = (byte)(Mathf.Clamp01(num5) * 255f); array[i * 64 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, b); } } _halo.SetPixels32(array); _halo.Apply(false, false); return _halo; } public static Texture2D Disc() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //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) if ((Object)(object)_disc != (Object)null) { return _disc; } _disc = new Texture2D(64, 64, (TextureFormat)4, false); ((Object)_disc).name = "YanDisc"; ((Texture)_disc).wrapMode = (TextureWrapMode)1; Color32[] array = (Color32[])(object)new Color32[4096]; float num = 32f; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; 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.Clamp01(1f - Mathf.Max(0f, num4 - 0.55f) / 0.45f); byte b = (byte)(num5 * num5 * 255f); array[i * 64 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, b); } } _disc.SetPixels32(array); _disc.Apply(false, false); return _disc; } public static Material Mat(string name, Texture2D tex, Color col, int queue) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0035: 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) Material val = new Material(Glow); ((Object)val).name = name; if ((Object)(object)tex != (Object)null) { val.mainTexture = (Texture)(object)tex; } if (val.HasProperty("_Color")) { val.SetColor("_Color", col); } if (val.HasProperty("_TintColor")) { val.SetColor("_TintColor", col); } val.renderQueue = queue; return val; } } internal class GlowStick : MonoBehaviour { public static readonly List<GlowStick> All = new List<GlowStick>(); public static int MaxAlive = 120; public Rigidbody rb; public Color color; public float bornAt; private Transform _halo; private Material _haloMat; private Material _bodyMat; private Light _light; private float _haloPulse; private Vector3 _prev; internal bool grabbed; internal float sortKey; internal int stuckFrames; private static GlowStick _held; public int netId; public bool remote; internal bool _settled; internal Vector3 _netPos; internal Quaternion _netRot; internal bool _netHas; private float _netStill; private float _lastSend; private static bool _remoteBuild; private static int _remoteId; public static readonly List<GlowStick> Outbox = new List<GlowStick>(); public static readonly Dictionary<int, GlowStick> Remotes = new Dictionary<int, GlowStick>(); private static float _lbAt; private static readonly List<GlowStick> _tmp = new List<GlowStick>(); private float lostT; public static GlowStick Held => _held; public static GlowStick Spawn(Vector3 pos, Vector3 vel, Color col, float camDist, int colIdx = -1) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_002a: 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_0064: 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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: 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_0300: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown //IL_00ef: 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_00fb: 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) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_0412: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_043e: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Expected O, but got Unknown //IL_034e: 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_0360: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_04ff: Unknown result type (might be due to invalid IL or missing references) //IL_0500: Unknown result type (might be due to invalid IL or missing references) if (!_remoteBuild) { pos = SafeSpawn(pos, camDist); } GameObject val = new GameObject("GlowStick"); val.layer = 0; GlowStick glowStick = val.AddComponent<GlowStick>(); glowStick.color = col; glowStick.bornAt = Time.time; val.AddComponent<MeshFilter>().sharedMesh = GlowMesh.Cylinder(0.033f, 0.32f, 12); MeshRenderer obj = val.AddComponent<MeshRenderer>(); glowStick._bodyMat = GlowMesh.Mat("YanStickBody", null, Color.white, 3100); if (glowStick._bodyMat.HasProperty("_Color")) { glowStick._bodyMat.SetColor("_Color", col); } ((Renderer)obj).sharedMaterial = glowStick._bodyMat; ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)obj).receiveShadows = false; float lightRange = Glow.LightRange; GameObject val2 = new GameObject("halo"); val2.transform.SetParent(val.transform, false); val2.AddComponent<MeshFilter>().sharedMesh = GlowMesh.Quad(); MeshRenderer obj2 = val2.AddComponent<MeshRenderer>(); Color col2 = default(Color); ((Color)(ref col2))..ctor(col.r, col.g, col.b, 0.55f); glowStick._haloMat = GlowMesh.Mat("YanStickHalo", GlowMesh.Halo(), col2, 3200); ((Renderer)obj2).sharedMaterial = glowStick._haloMat; ((Renderer)obj2).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)obj2).receiveShadows = false; glowStick._halo = val2.transform; float num = Mathf.Clamp(lightRange * 0.2f, 1.2f, 6f); glowStick._halo.localScale = Vector3.one * num; try { GameObject val3 = new GameObject("light"); val3.transform.SetParent(val.transform, false); Light val4 = val3.AddComponent<Light>(); val4.type = (LightType)2; val4.color = col; val4.range = lightRange; val4.intensity = Glow.LightPower; val4.shadows = (LightShadows)0; val4.renderMode = (LightRenderMode)1; glowStick._light = val4; ((Behaviour)glowStick._light).enabled = Glow.LightOn; } catch (Exception ex) { GlowPlugin.LogWarn("glow light fail: " + ex.Message); } if (!_remoteBuild) { Rigidbody val5 = val.AddComponent<Rigidbody>(); val5.mass = 0.55f; val5.drag = 0.12f; val5.angularDrag = 0.55f; val5.useGravity = true; val5.interpolation = (RigidbodyInterpolation)1; val5.collisionDetectionMode = (CollisionDetectionMode)3; val5.maxAngularVelocity = 26f; try { val5.maxDepenetrationVelocity = 2f; } catch { } glowStick.rb = val5; CapsuleCollider val6 = val.AddComponent<CapsuleCollider>(); val6.radius = 0.052f; val6.height = 0.36f; val6.direction = 1; try { PhysicMaterial val7 = new PhysicMaterial("YanStickMat"); val7.dynamicFriction = 0.52f; val7.staticFriction = 0.58f; val7.bounciness = 0.26f; val7.frictionCombine = (PhysicMaterialCombine)0; val7.bounceCombine = (PhysicMaterialCombine)3; ((Collider)val6).material = val7; } catch { } Quaternion rotationUniform = Random.rotationUniform; val5.position = pos; val5.rotation = rotationUniform; val.transform.position = pos; val.transform.rotation = rotationUniform; try { Physics.SyncTransforms(); } catch { } float magnitude = ((Vector3)(ref vel)).magnitude; if (magnitude > 16f) { vel *= 16f / magnitude; } val5.velocity = vel; val5.angularVelocity = Random.insideUnitSphere * 9f; glowStick._prev = pos; try { string[] obj6 = new string[8] { "glow spawn at=", ((Vector3)(ref pos)).ToString("F1"), " rb=", null, null, null, null, null }; Vector3 position = val5.position; obj6[3] = ((Vector3)(ref position)).ToString("F1"); obj6[4] = " tf="; position = val.transform.position; obj6[5] = ((Vector3)(ref position)).ToString("F1"); obj6[6] = " vel="; obj6[7] = ((Vector3)(ref vel)).ToString("F1"); GlowPlugin.LogInfo(string.Concat(obj6)); } catch { } } else { glowStick.remote = true; glowStick.netId = _remoteId; glowStick._netPos = pos; glowStick._settled = false; glowStick._netHas = false; glowStick._prev = pos; val.transform.position = pos; val.transform.rotation = Random.rotationUniform; try { CapsuleCollider obj8 = val.AddComponent<CapsuleCollider>(); obj8.radius = 0.052f; obj8.height = 0.36f; obj8.direction = 1; ((Collider)obj8).isTrigger = true; } catch (Exception ex2) { GlowPlugin.LogWarn("glow remote cap: " + ex2.Message); } } All.Add(glowStick); Trim(); if (_remoteBuild) { if (glowStick.netId != 0 && !Remotes.ContainsKey(glowStick.netId)) { Remotes[glowStick.netId] = glowStick; } } else { glowStick.netId = Net.NewId(); if (Net.Ready) { glowStick._lastSend = Time.time; Outbox.Add(glowStick); Net.SendSpawn(glowStick.netId, pos, vel, colIdx); } } return glowStick; } private static Vector3 SafeSpawn(Vector3 want, float camDist) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0113: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_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_0035: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_0115: Unknown result type (might be due to invalid IL or missing references) try { Camera val = GlowPlugin.Cam(); Vector3 val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.forward : Vector3.forward); RaycastHit[] array = Physics.RaycastAll(want - val2 * (camDist + 0.05f), val2, camDist + 0.05f, -1, (QueryTriggerInteraction)1); float num = 999f; for (int i = 0; i < array.Length; i++) { if (!(((RaycastHit)(ref array[i])).distance < 0.001f) && !IsPlayer((Component)(object)((RaycastHit)(ref array[i])).collider) && ((RaycastHit)(ref array[i])).distance < num) { num = ((RaycastHit)(ref array[i])).distance; } } if (num < camDist - 0.02f) { want -= val2 * (camDist - num + 0.12f); } for (int j = 0; j < 10; j++) { if (!Blocked(want, 0.085f)) { return want; } want += val2 * 0.07f + Vector3.up * 0.05f; } } catch { } return want; } private static bool Blocked(Vector3 p, float r) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) try { Collider[] array = Physics.OverlapSphere(p, r, -1, (QueryTriggerInteraction)1); for (int i = 0; i < array.Length; i++) { if (!((Object)(object)array[i] == (Object)null) && !(array[i] is CharacterController) && !IsPlayer((Component)(object)array[i])) { Rigidbody attachedRigidbody = array[i].attachedRigidbody; if (!((Object)(object)attachedRigidbody != (Object)null) || !attachedRigidbody.isKinematic) { return true; } } } } catch { } return false; } private static bool IsPlayer(Component c) { if ((Object)(object)c == (Object)null) { return false; } try { return (Object)(object)c.GetComponentInParent<PlayerAvatar>() != (Object)null; } catch { } return false; } private static void Trim() { while (All.Count > MaxAlive) { GlowStick glowStick = All[0]; All.RemoveAt(0); if ((Object)(object)glowStick != (Object)null) { if ((Object)(object)_held == (Object)(object)glowStick) { _held = null; } Object.Destroy((Object)(object)((Component)glowStick).gameObject); } } } public static void ClearAll() { for (int num = All.Count - 1; num >= 0; num--) { if ((Object)(object)All[num] != (Object)null) { Object.Destroy((Object)(object)((Component)All[num]).gameObject); } } All.Clear(); _held = null; Outbox.Clear(); Remotes.Clear(); } private static Color ColAt(int i) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) try { Color[] colors = Glow.Colors; if (colors != null && colors.Length != 0) { int num = (i % colors.Length + colors.Length) % colors.Length; return colors[num]; } } catch { } return Color.white; } public static void NetTick(float dt) { //IL_006a: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: 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_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) if (!Net.Ready) { if (Outbox.Count > 0) { Outbox.Clear(); } return; } for (int num = Outbox.Count - 1; num >= 0; num--) { GlowStick glowStick = Outbox[num]; if ((Object)(object)glowStick == (Object)null || (Object)(object)glowStick.rb == (Object)null) { Outbox.RemoveAt(num); } else { Vector3 velocity = glowStick.rb.velocity; if (((Vector3)(ref velocity)).magnitude < 0.02f) { glowStick._netStill += dt; } else { glowStick._netStill = 0f; } if (glowStick._netStill > 0.35f || Time.time - glowStick.bornAt > 8f) { Outbox.RemoveAt(num); glowStick._settled = true; Net.SendSettle(glowStick.netId, glowStick.rb.position, glowStick.rb.rotation); } else if (Time.time - glowStick._lastSend >= 0.09f) { glowStick._lastSend = Time.time; Net.SendMove(glowStick.netId, glowStick.rb.position, glowStick.rb.rotation); } } } if (Remotes.Count == 0) { return; } float num2 = Mathf.Clamp01(dt * 16f); foreach (KeyValuePair<int, GlowStick> remote in Remotes) { GlowStick value = remote.Value; if (!((Object)(object)value == (Object)null) && value._netHas) { if (value._settled) { ((Component)value).transform.position = value._netPos; ((Component)value).transform.rotation = value._netRot; } else { ((Component)value).transform.position = Vector3.Lerp(((Component)value).transform.position, value._netPos, num2); ((Component)value).transform.rotation = Quaternion.Slerp(((Component)value).transform.rotation, value._netRot, num2); } } } } public static void Claim(GlowStick s) { //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown if ((Object)(object)s == (Object)null || !s.remote) { return; } int num = s.netId; if (num != 0 && Remotes.TryGetValue(num, out var value) && (Object)(object)value == (Object)(object)s) { Remotes.Remove(num); } s.remote = false; s._settled = false; s._netHas = false; s._netStill = 0f; try { CapsuleCollider component = ((Component)s).GetComponent<CapsuleCollider>(); if ((Object)(object)component != (Object)null) { ((Collider)component).isTrigger = false; try { PhysicMaterial val = new PhysicMaterial("YanStickMatMp"); val.dynamicFriction = 0.52f; val.staticFriction = 0.58f; val.bounciness = 0.26f; val.frictionCombine = (PhysicMaterialCombine)0; val.bounceCombine = (PhysicMaterialCombine)3; ((Collider)component).material = val; } catch { } } Rigidbody val2 = ((Component)s).gameObject.AddComponent<Rigidbody>(); val2.mass = 0.55f; val2.drag = 0.12f; val2.angularDrag = 0.55f; val2.useGravity = true; val2.interpolation = (RigidbodyInterpolation)1; val2.collisionDetectionMode = (CollisionDetectionMode)3; val2.maxAngularVelocity = 26f; try { val2.maxDepenetrationVelocity = 2f; } catch { } Vector3 position = ((Component)s).transform.position; Quaternion rotation = ((Component)s).transform.rotation; val2.position = position; val2.rotation = rotation; try { Physics.SyncTransforms(); } catch { } val2.velocity = Vector3.zero; val2.angularVelocity = Vector3.zero; s.rb = val2; s._prev = position; } catch (Exception ex) { GlowPlugin.LogWarn("glow claim rb: " + ex.Message); } s.netId = Net.NewId(); s._lastSend = Time.time; if (!Outbox.Contains(s)) { Outbox.Add(s); } if (Net.Ready) { Net.SendClaim(num, s.netId, ((Component)s).transform.position, Vector3.zero, s.color); } GlowPlugin.LogInfo("glow claim old=" + num + " new=" + s.netId); } public static void RemoteClaim(int oldId, int newId, Vector3 pos, Vector3 vel, Color col) { //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) if (newId == 0) { return; } bool flag = false; if (Remotes.TryGetValue(oldId, out var value)) { flag = true; Remotes.Remove(oldId); if ((Object)(object)value != (Object)null) { All.Remove(value); if ((Object)(object)_held == (Object)(object)value) { _held = null; } Object.Destroy((Object)(object)((Component)value).gameObject); } } for (int num = All.Count - 1; num >= 0; num--) { GlowStick glowStick = All[num]; if (!((Object)(object)glowStick == (Object)null) && !glowStick.remote && glowStick.netId == oldId) { flag = true; if ((Object)(object)_held == (Object)(object)glowStick) { _held = null; } Outbox.Remove(glowStick); All.RemoveAt(num); Object.Destroy((Object)(object)((Component)glowStick).gameObject); } } if (!flag || (Remotes.TryGetValue(newId, out var value2) && (Object)(object)value2 != (Object)null)) { return; } GlowStick glowStick2 = null; _remoteBuild = true; _remoteId = newId; try { glowStick2 = Spawn(pos, Vector3.zero, col, 0f); } catch (Exception ex) { GlowPlugin.LogWarn("glow claim sp: " + ex.Message); } finally { _remoteBuild = false; _remoteId = 0; } if (!((Object)(object)glowStick2 == (Object)null)) { glowStick2.netId = newId; glowStick2.remote = true; glowStick2._settled = false; glowStick2._netPos = pos; glowStick2._netHas = true; Remotes[newId] = glowStick2; } } public static void RemoteSpawn(int id, Vector3 pos, Vector3 vel, int colIdx) { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (id == 0) { return; } if (Remotes.TryGetValue(id, out var value)) { Remotes.Remove(id); if ((Object)(object)value != (Object)null) { Object.Destroy((Object)(object)((Component)value).gameObject); } } GlowStick glowStick = null; _remoteBuild = true; _remoteId = id; try { glowStick = Spawn(pos, Vector3.zero, ColAt(colIdx), 0f, colIdx); } catch (Exception ex) { GlowPlugin.LogWarn("glow remote spawn: " + ex.Message); } finally { _remoteBuild = false; _remoteId = 0; } if (!((Object)(object)glowStick == (Object)null)) { glowStick.netId = id; glowStick.remote = true; glowStick._settled = false; glowStick._netPos = pos; glowStick._netHas = true; Remotes[id] = glowStick; } } public static void RemoteMove(int id, Vector3 pos, Quaternion rot) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) if (!Remotes.TryGetValue(id, out var value) || (Object)(object)value == (Object)null) { return; } value._netPos = pos; value._netRot = rot; value._netHas = true; if (!value._settled) { Vector3 val = ((Component)value).transform.position - pos; if (((Vector3)(ref val)).sqrMagnitude > 9f) { ((Component)value).transform.position = pos; } } } public static void RemoteSettle(int id, Vector3 pos, Quaternion rot) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_003b: 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) if (!Remotes.TryGetValue(id, out var value) || (Object)(object)value == (Object)null) { return; } value._netPos = pos; value._netRot = rot; value._netHas = true; value._settled = true; try { ((Component)value).transform.position = pos; ((Component)value).transform.rotation = rot; } catch { } } public static void RemoteKill(int id) { if (Remotes.TryGetValue(id, out var value)) { Remotes.Remove(id); if ((Object)(object)value != (Object)null) { Object.Destroy((Object)(object)((Component)value).gameObject); } } } public static void ClearRemote() { if (Remotes.Count == 0) { return; } List<GlowStick> list = new List<GlowStick>(Remotes.Values); Remotes.Clear(); for (int i = 0; i < list.Count; i++) { if ((Object)(object)list[i] != (Object)null) { Object.Destroy((Object)(object)((Component)list[i]).gameObject); } } } public static GlowStick Aimed(float maxDist) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) Camera val = GlowPlugin.Cam(); if ((Object)(object)val == (Object)null) { return null; } Ray val2 = val.ScreenPointToRay(new Vector3((float)Screen.width * 0.5f, (float)Screen.height * 0.5f, 0f)); RaycastHit[] array; try { array = Physics.RaycastAll(val2, maxDist, -1, (QueryTriggerInteraction)2); } catch { return null; } Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance)); for (int num = 0; num < array.Length; num++) { if (!((Object)(object)((RaycastHit)(ref array[num])).collider == (Object)null) && !IsPlayer((Component)(object)((RaycastHit)(ref array[num])).collider) && !((Component)((RaycastHit)(ref array[num])).collider).transform.IsChildOf(transformOfCam(val))) { GlowStick componentInParent = ((Component)((RaycastHit)(ref array[num])).collider).GetComponentInParent<GlowStick>(); if ((Object)(object)componentInParent != (Object)null) { return componentInParent; } if (!((RaycastHit)(ref array[num])).collider.isTrigger) { break; } } } return Assist(val, maxDist); } private static GlowStick Assist(Camera cam, float maxDist) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cam == (Object)null || All.Count == 0) { return null; } Vector3 position = ((Component)cam).transform.position; Vector3 forward = ((Component)cam).transform.forward; GlowStick result = null; float num = 999f; for (int i = 0; i < All.Count; i++) { GlowStick glowStick = All[i]; if ((Object)(object)glowStick == (Object)null) { continue; } Vector3 val = ((Component)glowStick).transform.position - position; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude > maxDist || magnitude < 0.05f) { continue; } float num2 = Vector3.Angle(forward, val / magnitude); if (!(num2 > 11f) && Clear(position, ((Component)glowStick).transform.position)) { float num3 = num2 * 0.35f + magnitude * 0.1f; if (num3 < num) { num = num3; result = glowStick; } } } return result; } private static bool Clear(Vector3 a, Vector3 b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) try { Vector3 val = b - a; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude < 0.001f) { return true; } RaycastHit[] array = Physics.RaycastAll(a, val / magnitude, magnitude - 0.05f, -1, (QueryTriggerInteraction)1); for (int i = 0; i < array.Length; i++) { if (!((Object)(object)((RaycastHit)(ref array[i])).collider == (Object)null) && !IsPlayer((Component)(object)((RaycastHit)(ref array[i])).collider) && !((Object)(object)((Component)((RaycastHit)(ref array[i])).collider).GetComponentInParent<GlowStick>() != (Object)null)) { return false; } } return true; } catch { return true; } } private static Transform transformOfCam(Camera c) { try { return ((Object)(object)c != (Object)null) ? ((Component)c).transform : null; } catch { } return null; } public static void Release() { if ((Object)(object)_held != (Object)null && (Object)(object)_held.rb != (Object)null) { _held.grabbed = false; _held.rb.angularDrag = 0.55f; } _held = null; } public static void GrabTick() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Invalid comparison between Unknown and I4 //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_017a: 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_0184: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: 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_01be: 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_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: 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_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_0231: 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_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) if (!GlowPlugin.InLevel()) { try { Release(); return; } catch { return; } } Camera val = GlowPlugin.Cam(); if ((Object)(object)val == (Object)null) { Release(); return; } if (!Glow.Enabled2 || (int)Cursor.lockState != 1) { Release(); return; } bool flag = GlowPlugin.KeyDown(Glow.GrabKeyRaw); if ((Object)(object)_held == (Object)null) { if (flag) { GlowStick glowStick = Aimed(Glow.GrabRange); if ((Object)(object)glowStick != (Object)null && glowStick.remote) { Claim(glowStick); } if ((Object)(object)glowStick != (Object)null && (Object)(object)glowStick.rb != (Object)null) { _held = glowStick; glowStick.grabbed = true; glowStick.rb.angularDrag = 5f; glowStick.stuckFrames = 0; Vector3 val2 = glowStick.rb.position - ((Component)val).transform.position; GlowPlugin.LogInfo("glow grab dist=" + ((Vector3)(ref val2)).magnitude.ToString("0.00")); } else { GlowPlugin.LogInfo("glow grab miss"); } } return; } if ((Object)(object)_held == (Object)null || (Object)(object)_held.rb == (Object)null) { _held = null; return; } if (flag) { GlowPlugin.LogInfo("glow drop"); Release(); return; } Vector3 val3 = ((Component)val).transform.position + ((Component)val).transform.forward * Glow.GrabDist - _held.rb.position; if (((Vector3)(ref val3)).magnitude > Glow.GrabRange * 2.5f) { Release(); return; } Vector3 val4 = val3 * Glow.GrabSpring - _held.rb.velocity * Glow.GrabDamp; _held.rb.AddForce(val4, (ForceMode)5); Rigidbody obj2 = _held.rb; obj2.angularVelocity *= 0.86f; if (Input.GetMouseButtonDown(0)) { Vector3 forward = ((Component)val).transform.forward; _held.rb.velocity = forward * Glow.GrabThrowSpeed + Vector3.up * 1.2f; _held.rb.angularVelocity = Random.insideUnitSphere * 12f; GlowPlugin.LogInfo("glow hurl speed=" + Glow.GrabThrowSpeed.ToString("0.0")); Release(); } } public static void TickAll() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) if (All.Count == 0) { return; } Camera val = GlowPlugin.Cam(); Quaternion rotation = (((Object)(object)val != (Object)null) ? ((Component)val).transform.rotation : Quaternion.identity); for (int num = All.Count - 1; num >= 0; num--) { GlowStick glowStick = All[num]; if ((Object)(object)glowStick == (Object)null) { All.RemoveAt(num); if ((Object)(object)_held == (Object)(object)glowStick) { _held = null; } } else if (((Component)glowStick).transform.position.y < -200f) { if ((Object)(object)_held == (Object)(object)glowStick) { _held = null; } All.RemoveAt(num); Object.Destroy((Object)(object)((Component)glowStick).gameObject); } else { if ((Object)(object)glowStick._halo != (Object)null && (Object)(object)val != (Object)null) { glowStick._halo.rotation = rotation; } glowStick._haloPulse += Time.deltaTime; float num2 = 0.86f + 0.14f * Mathf.Sin(glowStick._haloPulse * 2.3f); if ((Object)(object)glowStick._haloMat != (Object)null) { Color val2 = glowStick.color; val2.a = 0.5f * num2; if (glowStick._haloMat.HasProperty("_Color")) { glowStick._haloMat.SetColor("_Color", val2); } } if ((Object)(object)glowStick._light != (Object)null && ((Behaviour)glowStick._light).enabled) { glowStick._light.intensity = Glow.LightPower * num2; } } } LightBudget(); } private static void LightBudget() { //IL_003d: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) float time = Time.time; if (time - _lbAt < 0.25f) { return; } _lbAt = time; int lightBudget = Glow.LightBudget; Camera val = GlowPlugin.Cam(); Vector3 val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.position : Vector3.zero); _tmp.Clear(); for (int i = 0; i < All.Count; i++) { GlowStick glowStick = All[i]; if (!((Object)(object)glowStick == (Object)null)) { Vector3 val3 = ((Component)glowStick).transform.position - val2; glowStick.sortKey = ((Vector3)(ref val3)).sqrMagnitude; _tmp.Add(glowStick); } } _tmp.Sort((GlowStick a, GlowStick b) => a.sortKey.CompareTo(b.sortKey)); bool lightOn = Glow.LightOn; for (int num = 0; num < _tmp.Count; num++) { GlowStick glowStick2 = _tmp[num]; if (!((Object)(object)glowStick2 == (Object)null) && !((Object)(object)glowStick2._light == (Object)null)) { ((Behaviour)glowStick2._light).enabled = lightOn && num < lightBudget; } } _tmp.Clear(); } private void FixedUpdate() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)rb == (Object)null) { return; } if (grabbed) { _prev = rb.position; lostT = 0f; return; } Vector3 position = rb.position; Vector3 val = position - _prev; _ = ((Vector3)(ref val)).magnitude; if (rb.velocity.y < -14f) { lostT += Time.fixedDeltaTime; } else { lostT = 0f; } if (position.y < -30f || lostT > 1.6f) { lostT = 0f; if (Rescue()) { return; } } Vector3 velocity = rb.velocity; if (((Vector3)(ref velocity)).sqrMagnitude < 0.02f && position.y > -5f) { stuckFrames++; if (stuckFrames > 45) { stuckFrames = 0; rb.AddForce(Vector3.down * 1.6f, (ForceMode)5); } } else { stuckFrames = 0; } _prev = position; } private bool Rescue() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: