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 BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ChaosCarnival.Features; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using REPOLib.Modules; using TMPro; using UnityEngine; using UnityEngine.Networking; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyCompany("ChaosCarnival")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Chaos-party content mod for R.E.P.O. — cursed farting loot, Fart Goblins, mystery lottery, the Klutz treatment, and more.")] [assembly: AssemblyFileVersion("1.0.27.0")] [assembly: AssemblyInformationalVersion("1.0.27")] [assembly: AssemblyProduct("ChaosCarnival")] [assembly: AssemblyTitle("ChaosCarnival")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyVersion("1.0.27.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 ChaosCarnival { public class CarnivalState { public int CursedViewID = -1; public int CursedHolderViewID = -1; public int[] GoblinViewIDs = Array.Empty(); public string KlutzName = ""; public int LotteryViewID = -1; public float LotteryValue; public int ToiletViewID = -1; public int MeltdownViewID = -1; public float MeltdownValue; public bool MeltdownLocked; public int CurseType; public int[] InfectedViewIDs = Array.Empty(); public string[] TallyNames = Array.Empty(); public float[] TallyDamage = Array.Empty(); public bool BlackoutActive; public int SnitchViewID = -1; public float[] PortalExit = Array.Empty(); public float[] PortalEntry = Array.Empty(); public int PowerUpViewID = -1; public int PowerUpPhase; public int TokenViewID = -1; public float[] ToiletPos = Array.Empty(); public int PossessedPlayerViewID = -1; public int RouletteOutbreak; public float[] PortalData = Array.Empty(); public object[] Pack() { return new object[25] { CursedViewID, CursedHolderViewID, GoblinViewIDs, KlutzName, LotteryViewID, LotteryValue, ToiletViewID, MeltdownViewID, MeltdownValue, MeltdownLocked, CurseType, InfectedViewIDs, TallyNames, TallyDamage, ToiletPos, BlackoutActive, SnitchViewID, PortalExit, PortalEntry, PowerUpViewID, PowerUpPhase, TokenViewID, PossessedPlayerViewID, RouletteOutbreak, PortalData }; } public static CarnivalState Unpack(object[] d) { if (d == null) { return new CarnivalState(); } return new CarnivalState { CursedViewID = ToInt(0), CursedHolderViewID = ToInt(1), GoblinViewIDs = ToIntArray(2), KlutzName = ToString(3), LotteryViewID = ToInt(4), LotteryValue = ToFloat(5), ToiletViewID = ToInt(6), MeltdownViewID = ToInt(7), MeltdownValue = ToFloat(8), MeltdownLocked = ToBool(9), CurseType = ToInt(10, 0), InfectedViewIDs = ToIntArray(11), TallyNames = ToStringArray(12), TallyDamage = ToFloatArray(13), ToiletPos = ToFloatArray(14), BlackoutActive = ToBool(15), SnitchViewID = ToInt(16), PortalExit = ToFloatArray(17), PortalEntry = ToFloatArray(18), PowerUpViewID = ToInt(19), PowerUpPhase = ToInt(20, 0), TokenViewID = ToInt(21), PossessedPlayerViewID = ToInt(22), RouletteOutbreak = ToInt(23, 0), PortalData = ToFloatArray(24) }; bool ToBool(int index, bool fallback = false) { if (index >= d.Length || d[index] == null) { return fallback; } try { return Convert.ToBoolean(d[index]); } catch { return fallback; } } float ToFloat(int index, float fallback = 0f) { if (index >= d.Length || d[index] == null) { return fallback; } try { return Convert.ToSingle(d[index]); } catch { return fallback; } } float[] ToFloatArray(int index) { if (index >= d.Length || d[index] == null) { return Array.Empty(); } try { if (d[index] is float[] result) { return result; } Array array = (Array)d[index]; float[] array2 = new float[array.Length]; for (int i = 0; i < array.Length; i++) { array2[i] = Convert.ToSingle(array.GetValue(i)); } return array2; } catch { return Array.Empty(); } } int ToInt(int index, int fallback = -1) { if (index >= d.Length || d[index] == null) { return fallback; } try { return Convert.ToInt32(d[index]); } catch { return fallback; } } int[] ToIntArray(int index) { if (index >= d.Length || d[index] == null) { return Array.Empty(); } try { if (d[index] is int[] result) { return result; } Array array = (Array)d[index]; int[] array2 = new int[array.Length]; for (int i = 0; i < array.Length; i++) { array2[i] = Convert.ToInt32(array.GetValue(i)); } return array2; } catch { return Array.Empty(); } } string ToString(int index, string fallback = "") { if (index >= d.Length || d[index] == null) { return fallback; } try { return Convert.ToString(d[index]); } catch { return fallback; } } string[] ToStringArray(int index) { if (index >= d.Length || d[index] == null) { return Array.Empty(); } try { if (d[index] is string[] result) { return result; } Array array = (Array)d[index]; string[] array2 = new string[array.Length]; for (int i = 0; i < array.Length; i++) { array2[i] = Convert.ToString(array.GetValue(i)); } return array2; } catch { return Array.Empty(); } } } } public static class Fx { public const string GlowLightName = "ChaosCarnival.GlowLight"; public const string AuraName = "ChaosCarnival.Aura"; public static void Glow(GameObject obj, Color color, float emission = 1.8f, float lightRange = 4.5f, float lightIntensity = 2.2f) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) if ((Object)obj == (Object)null || (Object)obj.transform.Find("ChaosCarnival.GlowLight") != (Object)null) { return; } try { Renderer[] componentsInChildren = obj.GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if ((Object)val == (Object)null || val.materials == null) { continue; } Material[] materials = val.materials; foreach (Material val2 in materials) { if (!((Object)val2 == (Object)null)) { val2.EnableKeyword("_EMISSION"); val2.SetColor("_EmissionColor", color * emission); } } } GameObject val3 = new GameObject("ChaosCarnival.GlowLight"); val3.transform.SetParent(obj.transform, false); val3.transform.localPosition = Vector3.up * 0.1f; Light obj2 = val3.AddComponent(); obj2.type = (LightType)2; obj2.color = color; obj2.range = lightRange; obj2.intensity = lightIntensity; obj2.shadows = (LightShadows)0; } catch (Exception ex) { Plugin.Log.LogWarning((object)("[Fx] Glow failed on " + ((Object)obj).name + ": " + ex.Message)); } } public static void Poof(Vector3 position, Color color, int particles = 30) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0011: 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_001c: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_00e7: 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_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_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Expected O, but got Unknown try { GameObject val = new GameObject("ChaosCarnival.Poof"); val.transform.position = position + Vector3.up * 0.4f; ParticleSystem val2 = val.AddComponent(); MainModule main = val2.main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(color); ((MainModule)(ref main)).startSize = new MinMaxCurve(0.25f, 0.6f); ((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.8f, 2.2f); ((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.5f, 0.9f); ((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(-0.05f); ((MainModule)(ref main)).loop = false; ((MainModule)(ref main)).playOnAwake = false; EmissionModule emission = val2.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f); ((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[1] { new Burst(0f, (short)particles) }); ShapeModule shape = val2.shape; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0; ((ShapeModule)(ref shape)).radius = 0.35f; ((Renderer)val.GetComponent()).material = new Material(Shader.Find("Sprites/Default")) { color = color }; val2.Play(); Object.Destroy((Object)val, 2f); } catch (Exception ex) { Plugin.Log.LogWarning((object)("[Fx] Poof failed: " + ex.Message)); } } public static void Aura(GameObject obj, Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0073: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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_0102: 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_0112: 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_013c: 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_0148: Expected O, but got Unknown if ((Object)obj == (Object)null || (Object)obj.transform.Find("ChaosCarnival.Aura") != (Object)null) { return; } try { GameObject val = new GameObject("ChaosCarnival.Aura"); val.transform.SetParent(obj.transform, false); val.transform.localPosition = Vector3.up * 0.6f; ParticleSystem obj2 = val.AddComponent(); MainModule main = obj2.main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(color.r, color.g, color.b, 0.55f)); ((MainModule)(ref main)).startSize = new MinMaxCurve(0.15f, 0.4f); ((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.2f, 0.7f); ((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.8f, 1.4f); ((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(-0.08f); ((MainModule)(ref main)).loop = true; EmissionModule emission = obj2.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(14f); ShapeModule shape = obj2.shape; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0; ((ShapeModule)(ref shape)).radius = 0.45f; ((Renderer)val.GetComponent()).material = new Material(Shader.Find("Sprites/Default")) { color = color }; obj2.Play(); } catch (Exception ex) { Plugin.Log.LogWarning((object)("[Fx] Aura failed: " + ex.Message)); } } public static void RemoveAura(GameObject obj) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown if (!((Object)obj == (Object)null)) { Transform val = obj.transform.Find("ChaosCarnival.Aura"); if ((Object)val != (Object)null) { Object.Destroy((Object)((Component)val).gameObject); } } } public static T GetField(object obj, string field) { if (obj == null) { return default(T); } FieldInfo fieldInfo = AccessTools.Field(obj.GetType(), field); if (!(fieldInfo == null)) { return (T)fieldInfo.GetValue(obj); } return default(T); } public static void SetField(object obj, string field, object value) { AccessTools.Field(obj?.GetType(), field)?.SetValue(obj, value); } public static void CallMethod(object obj, string method, params object[] args) { AccessTools.Method(obj?.GetType(), method, (Type[])null, (Type[])null)?.Invoke(obj, args); } } public static class Hud { private static Texture2D _bg; private static GUIStyle _title; private static GUIStyle _row; private static GUIStyle _rowKlutz; private static GUIStyle _banner; private static string _bannerText; private static float _bannerUntil; private static float _spinStart; private static float _spinUntil; private static float _nextFlip; private static string _spinLabel; private static readonly string[] SpinLabels; public static void StartSpin(float seconds) { _spinStart = Time.time; _spinUntil = Time.time + seconds; _nextFlip = 0f; } static Hud() { _spinStart = -1f; _spinUntil = -1f; _spinLabel = ""; SpinLabels = new string[14] { "x2 JACKPOT!!", "x1.5 WINNER!", "NOTHING...", "x0.75 TAX", "x0.5 BUST!!", "MONSTER NAP", "HEALING WAVE", "BANKRUPT!!", "SACRIFICE!", "BUBBLE GUTS!", "GOLDEN RAIN!", "LIGHTS OUT!", "GRAVE ROBBER!", "JITTERS!" }; Net.OnBroadcast += delegate(string text, float seconds) { //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) _bannerText = text; _bannerUntil = Time.time + seconds; _spinUntil = -1f; try { SemiFunc.UIBigMessage(text, "\ud83c\udfb0", 1.1f, Color.yellow, Color.white); } catch { } }; } public static void Draw() { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Enabled) { return; } DrawBanner(); if (!Plugin.CfgHud.Value || !ShouldShow()) { return; } EnsureStyles(); CarnivalState state = Net.State; int num = Mathf.Max(1, state.TallyNames.Length); float num2 = 250f; float num3 = 52f + 20f * (float)num + (string.IsNullOrEmpty(state.KlutzName) ? 0f : 22f); Rect val = default(Rect); ((Rect)(ref val))..ctor((float)Screen.width - num2 - 18f, 80f, num2, num3); GUI.DrawTexture(val, (Texture)_bg, (ScaleMode)0); GUILayout.BeginArea(new Rect(((Rect)(ref val)).x + 10f, ((Rect)(ref val)).y + 8f, ((Rect)(ref val)).width - 20f, ((Rect)(ref val)).height - 12f)); GUILayout.Label("ACCIDENT TALLY", _title, Array.Empty()); if (state.TallyNames.Length == 0) { GUILayout.Label("Clean record... so far.", _row, Array.Empty()); } else { for (int i = 0; i < state.TallyNames.Length && i < state.TallyDamage.Length; i++) { bool flag = state.TallyNames[i].Equals(state.KlutzName, StringComparison.OrdinalIgnoreCase); GUILayout.Label($"{state.TallyNames[i]} — ${state.TallyDamage[i]:F0}", flag ? _rowKlutz : _row, Array.Empty()); } } if (!string.IsNullOrEmpty(state.KlutzName)) { GUILayout.Label("CURRENT KLUTZ: " + state.KlutzName, _rowKlutz, Array.Empty()); } GUILayout.EndArea(); } private static void DrawBanner() { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //IL_0109: 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_0151: 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_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Expected O, but got Unknown //IL_017c: Unknown result type (might be due to invalid IL or missing references) if (Time.time < _spinUntil) { EnsureStyles(); if (Time.time >= _nextFlip) { float num = Mathf.Clamp01((Time.time - _spinStart) / (_spinUntil - _spinStart)); _spinLabel = SpinLabels[Random.Range(0, SpinLabels.Length)]; _nextFlip = Time.time + Mathf.Lerp(0.07f, 0.5f, num * num); } Rect val = new Rect((float)Screen.width * 0.5f - 320f, (float)Screen.height * 0.12f, 640f, 46f); GUI.DrawTexture(val, (Texture)_bg, (ScaleMode)0); GUI.Label(val, "THE WHEEL SPINS... [ " + _spinLabel + " ]", _banner); } else if (!string.IsNullOrEmpty(_bannerText) && !(Time.time > _bannerUntil)) { EnsureStyles(); float num2 = Mathf.Clamp01((_bannerUntil - Time.time) / 0.6f); Color color = GUI.color; Rect val2 = new Rect((float)Screen.width * 0.5f - 320f, (float)Screen.height * 0.12f, 640f, 46f); GUI.color = new Color(1f, 1f, 1f, num2 * 0.85f); GUI.DrawTexture(val2, (Texture)_bg, (ScaleMode)0); GUI.color = new Color(1f, 1f, 1f, num2); GUI.Label(val2, _bannerText, _banner); GUI.color = color; } } private static bool ShouldShow() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown try { PlayerAvatar instance = PlayerAvatar.instance; if ((Object)instance != (Object)null && Fx.GetField(instance, "isDisabled")) { return true; } MapToolController instance2 = MapToolController.instance; if ((Object)instance2 != (Object)null && Fx.GetField(instance2, "Active")) { return true; } } catch { } return false; } private static void EnsureStyles() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_003e: 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_0057: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00ac: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_00ff: 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_0123: Expected O, but got Unknown if (!((Object)_bg != (Object)null)) { _bg = new Texture2D(1, 1, (TextureFormat)4, false); _bg.SetPixel(0, 0, new Color(0.05f, 0.02f, 0.08f, 0.82f)); _bg.Apply(); GUIStyle val = new GUIStyle { fontSize = 15, fontStyle = (FontStyle)1 }; val.normal.textColor = new Color(1f, 0.85f, 0.2f); _title = val; GUIStyle val2 = new GUIStyle { fontSize = 13 }; val2.normal.textColor = Color.white; _row = val2; GUIStyle val3 = new GUIStyle { fontSize = 13, fontStyle = (FontStyle)1 }; val3.normal.textColor = new Color(1f, 0.35f, 0.3f); _rowKlutz = val3; GUIStyle val4 = new GUIStyle { fontSize = 22, fontStyle = (FontStyle)1, alignment = (TextAnchor)4 }; val4.normal.textColor = new Color(1f, 0.9f, 0.4f); _banner = val4; } } } public static class Net { private static NetworkedEvent _stateEvent; private static NetworkedEvent _poofEvent; private static NetworkedEvent _pingEvent; private static NetworkedEvent _textEvent; private static bool _dirty; private static float _heartbeat; private const float HeartbeatSeconds = 2f; private static readonly RaiseEventOptions ToAll = new RaiseEventOptions { Receivers = (ReceiverGroup)1 }; public static CarnivalState State { get; private set; } = new CarnivalState(); public static bool IsAuthority { get { if (SemiFunc.IsMultiplayer()) { return PhotonNetwork.IsMasterClient; } return true; } } public static event Action OnStateChanged; public static event Action OnPoof; public static event Action OnPing; public static event Action OnBroadcast; public static void Init() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown _stateEvent = new NetworkedEvent("ChaosCarnival.State", (Action)OnStateEvent); _poofEvent = new NetworkedEvent("ChaosCarnival.Poof", (Action)OnPoofEvent); _pingEvent = new NetworkedEvent("ChaosCarnival.Ping", (Action)OnPingEvent); _textEvent = new NetworkedEvent("ChaosCarnival.Text", (Action)OnTextEvent); } public static void MarkDirty() { _dirty = true; } public static void ResetRound() { State = new CarnivalState(); MarkDirty(); } public static void ResetRoundPreservingKlutz() { string klutzName = State.KlutzName; State = new CarnivalState { KlutzName = klutzName }; MarkDirty(); } public static void Tick() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) if (!IsAuthority) { return; } _heartbeat -= Time.deltaTime; if (!_dirty && !(_heartbeat <= 0f)) { return; } _dirty = false; _heartbeat = 2f; try { _stateEvent.RaiseEvent((object)State.Pack(), ToAll, SendOptions.SendReliable); } catch (Exception ex) { Plugin.Log.LogError((object)("[Net] State broadcast failed: " + ex.Message)); } } public static void SendPoof(Vector3[] positions) { //IL_0021: 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) if (!IsAuthority || positions == null || positions.Length == 0) { return; } try { object[] array = new object[positions.Length]; for (int i = 0; i < positions.Length; i++) { array[i] = positions[i]; } _poofEvent.RaiseEvent((object)array, ToAll, SendOptions.SendReliable); } catch (Exception ex) { Plugin.Log.LogError((object)("[Net] Poof broadcast failed: " + ex.Message)); } } private static void OnStateEvent(EventData e) { try { State = CarnivalState.Unpack((object[])e.CustomData); Net.OnStateChanged?.Invoke(); } catch (Exception ex) { Plugin.Log.LogError((object)("[Net] Bad state payload: " + ex.Message)); } } public static void SendPing(int type, Vector3 position) { //IL_001f: 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) if (!IsAuthority) { return; } try { _pingEvent.RaiseEvent((object)new object[2] { type, position }, ToAll, SendOptions.SendReliable); } catch (Exception ex) { Plugin.Log.LogError((object)("[Net] Ping broadcast failed: " + ex.Message)); } } public static void Broadcast(string text, float seconds = 4f) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (!IsAuthority || string.IsNullOrEmpty(text)) { return; } try { _textEvent.RaiseEvent((object)new object[2] { text, seconds }, ToAll, SendOptions.SendReliable); } catch (Exception ex) { Plugin.Log.LogError((object)("[Net] Broadcast failed: " + ex.Message)); } } private static void OnTextEvent(EventData e) { try { object[] array = (object[])e.CustomData; Net.OnBroadcast?.Invoke((string)array[0], (float)array[1]); } catch (Exception ex) { Plugin.Log.LogError((object)("[Net] Bad broadcast payload: " + ex.Message)); } } private static void OnPingEvent(EventData e) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) try { object[] array = (object[])e.CustomData; Net.OnPing?.Invoke((int)array[0], (Vector3)array[1]); } catch (Exception ex) { Plugin.Log.LogError((object)("[Net] Bad ping payload: " + ex.Message)); } } private static void OnPoofEvent(EventData e) { //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) try { object[] array = (object[])e.CustomData; Vector3[] array2 = (Vector3[])(object)new Vector3[array.Length]; for (int i = 0; i < array.Length; i++) { array2[i] = (Vector3)array[i]; } Net.OnPoof?.Invoke(array2); } catch (Exception ex) { Plugin.Log.LogError((object)("[Net] Bad poof payload: " + ex.Message)); } } public static PlayerAvatar FindAvatar(int avatarViewID) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown if (avatarViewID < 0) { return null; } if (avatarViewID > 0) { PhotonView val = PhotonView.Find(avatarViewID); if ((Object)val != (Object)null) { PlayerAvatar component = ((Component)val).GetComponent(); if ((Object)component != (Object)null) { return component; } } } if ((Object)PlayerAvatar.instance != (Object)null) { return PlayerAvatar.instance; } return null; } public static GameObject FindViewObject(int viewID) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown if (viewID < 0) { return null; } PhotonView val = PhotonView.Find(viewID); if (!((Object)val != (Object)null)) { return null; } return ((Component)val).gameObject; } } public static class ObjLoader { private class Mtl { public Color Color = Color.gray; public string TexPath; } public static string AssetDir { get { string text = ""; try { string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); if (!string.IsNullOrEmpty(directoryName)) { text = Path.Combine(directoryName, "assets"); } } catch { } if (string.IsNullOrEmpty(text) || !Directory.Exists(text)) { text = Path.Combine(Paths.PluginPath, "BonelessProductions-ChaosCarnival", "assets"); } if (!Directory.Exists(text)) { text = Path.Combine(Paths.PluginPath, "ChaosCarnival", "assets"); } if (!Directory.Exists(text)) { try { string[] directories = Directory.GetDirectories(Paths.PluginPath, "assets", SearchOption.AllDirectories); foreach (string text2 in directories) { if (Directory.Exists(Path.Combine(text2, "models"))) { text = text2; break; } } } catch { } } return text; } } public static GameObject Load(string objPath, float scale = 1f, Shader customShader = null) { //IL_02f5: 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_0308: Expected O, but got Unknown //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_03fa: Expected O, but got Unknown //IL_047d: Unknown result type (might be due to invalid IL or missing references) //IL_0488: Expected O, but got Unknown //IL_0232: 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_041c: Expected O, but got Unknown //IL_04cf: Unknown result type (might be due to invalid IL or missing references) //IL_04d6: Expected O, but got Unknown //IL_0717: Unknown result type (might be due to invalid IL or missing references) //IL_071c: Unknown result type (might be due to invalid IL or missing references) //IL_0729: Unknown result type (might be due to invalid IL or missing references) //IL_0736: Unknown result type (might be due to invalid IL or missing references) //IL_073c: Unknown result type (might be due to invalid IL or missing references) //IL_0742: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Expected O, but got Unknown //IL_079a: Unknown result type (might be due to invalid IL or missing references) //IL_079f: Unknown result type (might be due to invalid IL or missing references) //IL_07ae: Unknown result type (might be due to invalid IL or missing references) //IL_07c9: Expected O, but got Unknown //IL_0649: Unknown result type (might be due to invalid IL or missing references) //IL_053c: Unknown result type (might be due to invalid IL or missing references) //IL_0541: Unknown result type (might be due to invalid IL or missing references) //IL_0542: Unknown result type (might be due to invalid IL or missing references) //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_054b: Unknown result type (might be due to invalid IL or missing references) //IL_0668: Unknown result type (might be due to invalid IL or missing references) //IL_0562: Unknown result type (might be due to invalid IL or missing references) //IL_0693: Unknown result type (might be due to invalid IL or missing references) //IL_069d: Unknown result type (might be due to invalid IL or missing references) //IL_06a2: Unknown result type (might be due to invalid IL or missing references) //IL_06a5: Expected O, but got Unknown //IL_06aa: Expected O, but got Unknown //IL_06ac: Unknown result type (might be due to invalid IL or missing references) //IL_06b3: Expected O, but got Unknown //IL_0687: Unknown result type (might be due to invalid IL or missing references) //IL_057e: Unknown result type (might be due to invalid IL or missing references) //IL_06ca: Unknown result type (might be due to invalid IL or missing references) //IL_06d4: Expected O, but got Unknown //IL_059a: Unknown result type (might be due to invalid IL or missing references) //IL_06eb: Unknown result type (might be due to invalid IL or missing references) //IL_06f5: Expected O, but got Unknown //IL_05b6: Unknown result type (might be due to invalid IL or missing references) //IL_05c6: Unknown result type (might be due to invalid IL or missing references) //IL_05df: Unknown result type (might be due to invalid IL or missing references) //IL_05ea: Expected O, but got Unknown //IL_05f3: Unknown result type (might be due to invalid IL or missing references) //IL_05fd: Expected O, but got Unknown //IL_0614: Unknown result type (might be due to invalid IL or missing references) //IL_061e: Expected O, but got Unknown //IL_0638: Unknown result type (might be due to invalid IL or missing references) //IL_0642: Expected O, but got Unknown try { if (!File.Exists(objPath)) { Plugin.Log.LogWarning((object)("[ObjLoader] Not found: " + objPath)); return null; } List positions = new List(); List normals = new List(); List uvs = new List(); Dictionary> dictionary = new Dictionary>(); Dictionary vertexMap = new Dictionary(); List finalVerts = new List(); List finalNorms = new List(); List finalUVs = new List(); bool anyNormals = false; string key = "default"; string mtlFile = null; CultureInfo inv = CultureInfo.InvariantCulture; foreach (string item4 in File.ReadLines(objPath)) { string text = item4.Trim(); if (text.Length == 0 || text[0] == '#') { continue; } string[] array = text.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); switch (array[0]) { case "mtllib": mtlFile = text.Substring(7).Trim(); break; case "usemtl": key = array[1]; break; case "v": positions.Add(new Vector3(0f - float.Parse(array[1], inv), float.Parse(array[2], inv), float.Parse(array[3], inv))); break; case "vn": normals.Add(new Vector3(0f - float.Parse(array[1], inv), float.Parse(array[2], inv), float.Parse(array[3], inv))); break; case "vt": uvs.Add(new Vector2(float.Parse(array[1], inv), (array.Length > 2) ? float.Parse(array[2], inv) : 0f)); break; case "f": { if (!dictionary.TryGetValue(key, out var value)) { List list = (dictionary[key] = new List()); value = list; } int item = Corner(array[1]); for (int i = 2; i < array.Length - 1; i++) { int item2 = Corner(array[i]); int item3 = Corner(array[i + 1]); value.Add(item); value.Add(item3); value.Add(item2); } break; } } } if (finalVerts.Count == 0) { Plugin.Log.LogWarning((object)"[ObjLoader] Empty mesh."); return null; } Mesh val = new Mesh { name = Path.GetFileNameWithoutExtension(objPath) }; if (finalVerts.Count > 65000) { val.indexFormat = (IndexFormat)1; } val.SetVertices(finalVerts); val.SetNormals(finalNorms); val.SetUVs(0, finalUVs); List list3 = new List(dictionary.Keys); val.subMeshCount = list3.Count; for (int j = 0; j < list3.Count; j++) { val.SetTriangles(dictionary[list3[j]], j); } if (!anyNormals) { val.RecalculateNormals(); } val.RecalculateBounds(); Dictionary dictionary2 = LoadMtl(objPath, mtlFile); Shader val2 = customShader ?? Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("HDRP/Lit") ?? Shader.Find("Standard") ?? Shader.Find("Sprites/Default"); if ((Object)val2 == (Object)null) { Material[] array2 = Resources.FindObjectsOfTypeAll(); foreach (Material val3 in array2) { if ((Object)val3 != (Object)null && (Object)val3.shader != (Object)null && (((Object)val3.shader).name.Contains("Lit") || ((Object)val3.shader).name.Contains("Standard"))) { val2 = val3.shader; break; } } } if ((Object)val2 == (Object)null) { val2 = Shader.Find("Sprites/Default") ?? Shader.Find("UI/Default") ?? Shader.Find("Hidden/Internal-Colored"); } Material[] array3 = (Material[])(object)new Material[list3.Count]; for (int l = 0; l < list3.Count; l++) { Material val4 = new Material(val2); Mtl mtl = null; if (dictionary2.TryGetValue(list3[l], out var value2)) { mtl = value2; } else if (dictionary2.Count > 0) { using Dictionary.Enumerator enumerator2 = dictionary2.GetEnumerator(); if (enumerator2.MoveNext()) { mtl = enumerator2.Current.Value; } } if (mtl != null) { Color val5 = (val4.color = mtl.Color); Color val6 = val5; if (val4.HasProperty("_BaseColor")) { val4.SetColor("_BaseColor", val6); } if (val4.HasProperty("_Color")) { val4.SetColor("_Color", val6); } if (val4.HasProperty("_MainColor")) { val4.SetColor("_MainColor", val6); } if (val4.HasProperty("_Tint")) { val4.SetColor("_Tint", val6); } Texture2D val7 = ((mtl.TexPath != null) ? LoadTexture(mtl.TexPath) : CreateSolidTexture(val6)); if ((Object)val7 != (Object)null) { val4.mainTexture = (Texture)val7; if (val4.HasProperty("_BaseMap")) { val4.SetTexture("_BaseMap", (Texture)val7); } if (val4.HasProperty("_MainTex")) { val4.SetTexture("_MainTex", (Texture)val7); } } } else { val4.color = Color.gray; if (val4.HasProperty("_BaseColor")) { val4.SetColor("_BaseColor", Color.gray); } if (val4.HasProperty("_Color")) { val4.SetColor("_Color", Color.gray); } Texture val8 = (Texture)CreateSolidTexture(Color.gray); Texture val9 = val8; val4.mainTexture = val8; Texture2D val10 = (Texture2D)val9; if (val4.HasProperty("_BaseMap")) { val4.SetTexture("_BaseMap", (Texture)val10); } if (val4.HasProperty("_MainTex")) { val4.SetTexture("_MainTex", (Texture)val10); } } array3[l] = val4; } GameObject val11 = new GameObject(((Object)val).name); val11.AddComponent().sharedMesh = val; ((Renderer)val11.AddComponent()).sharedMaterials = array3; val11.transform.localScale = Vector3.one * scale; ManualLogSource log = Plugin.Log; string text2 = $"[ObjLoader] Loaded \"{((Object)val).name}\": {finalVerts.Count} verts, "; object arg = list3.Count; string arg2 = (anyNormals ? "file" : "computed"); Bounds bounds = val.bounds; log.LogInfo((object)(text2 + $"{arg} mat(s), normals={arg2}, bounds {((Bounds)(ref bounds)).size}.")); return val11; int Corner(string token) { //IL_0085: 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_00b1: 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_00fa: Unknown result type (might be due to invalid IL or missing references) if (vertexMap.TryGetValue(token, out var value3)) { return value3; } string[] array4 = token.Split('/'); int index = int.Parse(array4[0], inv) - 1; int num = ((array4.Length > 1 && array4[1].Length > 0) ? (int.Parse(array4[1], inv) - 1) : (-1)); int num2 = ((array4.Length > 2 && array4[2].Length > 0) ? (int.Parse(array4[2], inv) - 1) : (-1)); finalVerts.Add(positions[index]); if (num2 >= 0 && num2 < normals.Count) { finalNorms.Add(normals[num2]); anyNormals = true; } else { finalNorms.Add(Vector3.up); } finalUVs.Add((num >= 0 && num < uvs.Count) ? uvs[num] : Vector2.zero); int num3 = finalVerts.Count - 1; vertexMap[token] = num3; return num3; } } catch (Exception arg3) { Plugin.Log.LogError((object)$"[ObjLoader] Failed loading {objPath}: {arg3}"); return null; } } private static Dictionary LoadMtl(string objPath, string mtlFile) { //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) Dictionary dictionary = new Dictionary(); try { if (string.IsNullOrEmpty(mtlFile)) { return dictionary; } string path = Path.GetDirectoryName(objPath) ?? ""; string path2 = Path.Combine(path, mtlFile); if (!File.Exists(path2)) { return dictionary; } CultureInfo invariantCulture = CultureInfo.InvariantCulture; Mtl mtl = null; foreach (string item in File.ReadLines(path2)) { string text = item.Trim(); if (text.StartsWith("newmtl ")) { mtl = new Mtl(); dictionary[text.Substring(7).Trim()] = mtl; } else if (mtl != null) { if (text.StartsWith("Kd ")) { string[] array = text.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); mtl.Color = new Color(float.Parse(array[1], invariantCulture), float.Parse(array[2], invariantCulture), float.Parse(array[3], invariantCulture)); } else if (text.StartsWith("map_Kd ")) { string path3 = text.Substring(7).Trim().Replace("\\", "/"); mtl.TexPath = Path.Combine(path, path3); } } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[ObjLoader] MTL parse failed: " + ex.Message)); } return dictionary; } private static Texture2D LoadTexture(string path) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown try { if (string.IsNullOrEmpty(path) || !File.Exists(path)) { return null; } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true); byte[] array = File.ReadAllBytes(path); MethodInfo methodInfo = AccessTools.Method(typeof(Texture2D), "LoadImage", new Type[1] { typeof(byte[]) }, (Type[])null); if (methodInfo != null && (bool)methodInfo.Invoke(val, new object[1] { array })) { return val; } MethodInfo methodInfo2 = AccessTools.Method("UnityEngine.ImageConversion:LoadImage", new Type[2] { typeof(Texture2D), typeof(byte[]) }, (Type[])null); if (methodInfo2 != null && (bool)methodInfo2.Invoke(null, new object[2] { val, array })) { return val; } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[ObjLoader] Texture load failed (" + path + "): " + ex.Message)); } return null; } private static Texture2D CreateSolidTexture(Color color) { //IL_0004: 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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false); val.SetPixel(0, 0, color); val.Apply(); return val; } } public static class Patches { private static readonly FieldInfo NameplateText = AccessTools.Field(typeof(WorldSpaceUIPlayerName), "text"); private static readonly FieldInfo NameplateAvatar = AccessTools.Field(typeof(WorldSpaceUIPlayerName), "playerAvatar"); private static readonly FieldInfo LastPlayerGrabbing = AccessTools.Field(typeof(PhysGrabObject), "lastPlayerGrabbing"); [HarmonyPatch(typeof(ValuableDirector), "VolumesAndSwitchSetup")] [HarmonyPostfix] public static void OnValuablesSpawned() { try { if (Plugin.Enabled && Net.IsAuthority && Plugin.IsAdventureLevel()) { Net.ResetRoundPreservingKlutz(); Curses.HostRoundSetup(); Lottery.HostRoundSetup(); Meltdown.HostRoundSetup(); Snitch.HostRoundSetup(); Blackout.HostRoundSetup(); Portals.HostRoundSetup(); Roulette.HostRoundSetup(); CustomItems.HostRoundRoll(); TestMode.QueuePlacement(); Plugin.Log.LogInfo((object)"[Round] New round initialized."); } } catch (Exception arg) { Plugin.Log.LogError((object)$"OnValuablesSpawned: {arg}"); } } [HarmonyPatch(typeof(RunManager), "ChangeLevel")] [HarmonyPrefix] public static void OnLevelChange() { try { if (Plugin.Enabled && Net.IsAuthority) { Klutz.HostRoundEnd(); Lottery.HostRoundEnd(); Meltdown.HostRoundEnd(); Blackout.HostRoundEnd(); Curses.HostCleanup(); } } catch (Exception arg) { Plugin.Log.LogError((object)$"OnLevelChange: {arg}"); } } [HarmonyPatch(typeof(PhysGrabObject), "GrabStarted")] [HarmonyPostfix] public static void OnGrabStarted(PhysGrabObject __instance, PhysGrabber player) { try { Curses.HostOnGrab(__instance, player); Meltdown.HostOnGrab(__instance, player); Roulette.HostOnGrab(__instance, player); TestMode.HostOnGrab(__instance); } catch (Exception arg) { Plugin.Log.LogError((object)$"OnGrabStarted: {arg}"); } } [HarmonyPatch(typeof(PhysGrabObject), "GrabEnded")] [HarmonyPostfix] public static void OnGrabEnded(PhysGrabObject __instance) { try { Curses.HostOnRelease(__instance); } catch (Exception arg) { Plugin.Log.LogError((object)$"OnGrabEnded: {arg}"); } } [HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "BreakRPC")] [HarmonyPrefix] public static void OnItemBreak(PhysGrabObjectImpactDetector __instance, float valueLost, PhotonMessageInfo _info, PhysGrabObject ___physGrabObject) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Expected O, but got Unknown try { if (Plugin.Enabled && (Object)___physGrabObject != (Object)null && Net.State.PossessedPlayerViewID != -1) { PhotonView component = ((Component)___physGrabObject).GetComponent(); if ((Object)component != (Object)null && component.ViewID == Net.State.CursedViewID) { Curses.RestorePossession(); if (Net.IsAuthority) { Curses.HostClearPossession(); } } } if (!Plugin.Enabled || !Net.IsAuthority || valueLost <= 0f) { return; } string playerName = null; if (_info.Sender != null && !string.IsNullOrEmpty(_info.Sender.NickName)) { playerName = _info.Sender.NickName; } else if ((Object)___physGrabObject != (Object)null && LastPlayerGrabbing != null) { object value = LastPlayerGrabbing.GetValue(___physGrabObject); PlayerAvatar val = (PlayerAvatar)((value is PlayerAvatar) ? value : null); if ((Object)val != (Object)null) { playerName = Fx.GetField(val, "playerName"); } } Klutz.HostRecordBreak(playerName, valueLost); } catch (Exception arg) { Plugin.Log.LogError((object)$"OnItemBreak: {arg}"); } } [HarmonyPatch(typeof(WorldSpaceUIPlayerName), "Update")] [HarmonyPostfix] public static void OnNameplateUpdate(WorldSpaceUIPlayerName __instance) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown try { if (Plugin.Enabled) { object obj = NameplateText?.GetValue(__instance); object obj2 = ((obj is TextMeshProUGUI) ? obj : null); object obj3 = NameplateAvatar?.GetValue(__instance); Klutz.DecorateNameplate(avatar: (PlayerAvatar)((obj3 is PlayerAvatar) ? obj3 : null), text: (TextMeshProUGUI)obj2); } } catch { } } [HarmonyPatch(typeof(PlayerHealth), "Hurt")] [HarmonyPrefix] public static bool OnPlayerHurt(PlayerHealth __instance) { try { return WeenieBox.BlockLocalDamage(__instance); } catch { return true; } } [HarmonyPatch(typeof(Enemy), "SetChaseTarget")] [HarmonyPrefix] public static bool OnEnemySetChaseTarget(Enemy __instance, PlayerAvatar playerAvatar) { try { return WeenieBox.BlockChaseTarget(__instance, playerAvatar); } catch { return true; } } [HarmonyPatch(typeof(ItemInfoUI), "ItemInfoText")] [HarmonyPrefix] public static void OnItemInfoText(ItemAttributes _itemAttributes, ref string message) { try { Lottery.DecorateItemInfo(_itemAttributes, ref message); Meltdown.DecorateItemInfo(_itemAttributes, ref message); Roulette.DecorateItemInfo(_itemAttributes, ref message); } catch { } } [HarmonyPatch(typeof(ExtractionPoint), "DestroyAllPhysObjectsInHaulList")] [HarmonyPrefix] public static void OnExtractionCashout() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown try { if (Net.State.PossessedPlayerViewID != -1 && Net.State.CursedViewID != -1) { GameObject val = Net.FindViewObject(Net.State.CursedViewID); if ((Object)val != (Object)null) { List list = (((Object)RoundDirector.instance != (Object)null) ? Fx.GetField>(RoundDirector.instance, "dollarHaulList") : null); if (list != null && list.Contains(val)) { Curses.RestorePossession(); if (Net.IsAuthority) { Curses.HostClearPossession(); } } } } Roulette.HostOnExtraction(); Lottery.HostOnExtractionCashout(); } catch (Exception arg) { Plugin.Log.LogError((object)$"OnExtractionCashout: {arg}"); } } [HarmonyPatch(typeof(ItemGun), "ShootBulletRPC")] [HarmonyPostfix] public static void OnGunShot(ItemGun __instance, Vector3 _endPosition) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) try { Portals.HostOnGunShot(__instance, _endPosition); } catch (Exception arg) { Plugin.Log.LogError((object)$"OnGunShot: {arg}"); } } [HarmonyPatch(typeof(ItemHealthPack), "Update")] [HarmonyPrefix] public static bool OnHealthPackUpdate(ItemHealthPack __instance) { try { if (JumperCables.HandleUse(__instance)) { return false; } if (PowerUp.HandleUse(__instance)) { return false; } if (WeenieBox.HandleUse(__instance)) { return false; } } catch (Exception arg) { Plugin.Log.LogError((object)$"OnHealthPackUpdate: {arg}"); } return true; } [HarmonyPatch(typeof(EnemyGnomeDirector), "Update")] [HarmonyPostfix] public static void OnGnomeDirectorUpdate() { try { Curses.HostRetargetGoblins(); } catch { } } [HarmonyPatch(typeof(PhysGrabCart), "Start")] [HarmonyPostfix] public static void OnCartStart(PhysGrabCart __instance) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown try { ItemAttributes component = ((Component)__instance).GetComponent(); if (((Object)component != (Object)null && CustomItems.IsWeenieBox(component)) || WeenieBox.DeployingTimer > 0f) { ((Component)__instance).gameObject.AddComponent(); Plugin.Log.LogInfo((object)"[Weenie] Attached WeenieBoxController to spawned physical cart."); } } catch (Exception arg) { Plugin.Log.LogError((object)$"OnCartStart: {arg}"); } } } [BepInPlugin("com.chaoscarnival.repo", "ChaosCarnival", "1.0.27")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public static ConfigEntry CfgEnabled; public static ConfigEntry CfgCurses; public static ConfigEntry CfgCurseFarts; public static ConfigEntry CfgCurseTiny; public static ConfigEntry CfgCurseJitters; public static ConfigEntry CfgCurseDecay; public static ConfigEntry CfgCurseRadiation; public static ConfigEntry CfgCurseConfession; public static ConfigEntry CfgCurseSloth; public static ConfigEntry CfgCurseHelium; public static ConfigEntry CfgCurseBlind; public static ConfigEntry CfgCurseMagnet; public static ConfigEntry CfgCursePossession; public static ConfigEntry CfgInfectionSeconds; public static ConfigEntry CfgKlutz; public static ConfigEntry CfgWeenieBox; public static ConfigEntry CfgWeenieBoxRadius; public static ConfigEntry CfgClownNoseId; public static ConfigEntry CfgNoseScale; public static ConfigEntry CfgMeltdown; public static ConfigEntry CfgMeltdownInterval; public static ConfigEntry CfgFartMinInterval; public static ConfigEntry CfgFartMaxInterval; public static ConfigEntry CfgVoiceVibrato; public static ConfigEntry CfgTestMode; public static ConfigEntry CfgFeatureChance; public static ConfigEntry CfgShopChance; public static ConfigEntry CfgHud; public static ConfigEntry CfgGoblinGroups; public static ConfigEntry CfgBlackout; public static ConfigEntry CfgBlackoutInterval; public static ConfigEntry CfgBlackoutDuration; public static ConfigEntry CfgSnitch; public static ConfigEntry CfgSnitchUnmaskAfter; public static ConfigEntry CfgRoulette; public static ConfigEntry CfgPortalGun; public static ConfigEntry CfgPortalView; private Harmony _harmony; public static Plugin Instance { get; private set; } public static ManualLogSource Log { get; private set; } public static bool Enabled { get { if (CfgEnabled != null) { return CfgEnabled.Value; } return true; } } public static bool FeatureRoll() { if (!TestMode.On) { return Random.value <= CfgFeatureChance.Value; } return true; } private void Awake() { //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Expected O, but got Unknown //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Expected O, but got Unknown //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Expected O, but got Unknown //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Expected O, but got Unknown //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Expected O, but got Unknown //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Expected O, but got Unknown //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Expected O, but got Unknown //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Expected O, but got Unknown //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Expected O, but got Unknown //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Expected O, but got Unknown //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_043f: Expected O, but got Unknown //IL_043a: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Expected O, but got Unknown //IL_0486: Unknown result type (might be due to invalid IL or missing references) //IL_0495: Expected O, but got Unknown //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_049a: Expected O, but got Unknown //IL_04e8: Unknown result type (might be due to invalid IL or missing references) //IL_04f7: Expected O, but got Unknown //IL_04f2: Unknown result type (might be due to invalid IL or missing references) //IL_04fc: Expected O, but got Unknown //IL_052a: Unknown result type (might be due to invalid IL or missing references) //IL_0539: Expected O, but got Unknown //IL_0534: Unknown result type (might be due to invalid IL or missing references) //IL_053e: Expected O, but got Unknown //IL_0581: Unknown result type (might be due to invalid IL or missing references) //IL_0590: Expected O, but got Unknown //IL_058b: Unknown result type (might be due to invalid IL or missing references) //IL_0595: Expected O, but got Unknown //IL_060f: Unknown result type (might be due to invalid IL or missing references) //IL_0619: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; CfgEnabled = ((BaseUnityPlugin)this).Config.Bind("General", "Enabled", true, "Master toggle for all ChaosCarnival features."); CfgCurses = ((BaseUnityPlugin)this).Config.Bind("Cursed Item", "Enabled", true, "One random valuable per round is cursed (red glow) with a RANDOM curse from the pool below. All curses come with Fart Goblins."); CfgCurseFarts = ((BaseUnityPlugin)this).Config.Bind("Cursed Item", "Curse-BubbleGuts", true, "Pool: farts through the holder's voice with matching voice vibrato."); CfgCurseTiny = ((BaseUnityPlugin)this).Config.Bind("Cursed Item", "Curse-Tiny", true, "Pool: holder shrinks to half size with a squeaky voice."); CfgCurseJitters = ((BaseUnityPlugin)this).Config.Bind("Cursed Item", "Curse-Jitters", true, "Pool: holder's movement randomly lurches and stutters."); CfgCurseDecay = ((BaseUnityPlugin)this).Config.Bind("Cursed Item", "Curse-Decay", true, "Pool: holder's health ticks down (never below 1 HP)."); CfgCurseRadiation = ((BaseUnityPlugin)this).Config.Bind("Cursed Item", "Curse-Radiation", true, "Pool: holder emits toxic glow that INFECTS nearby players; contagious, drains health."); CfgCurseConfession = ((BaseUnityPlugin)this).Config.Bind("Cursed Item", "Curse-Confession", true, "Pool: the holder's character periodically blurts embarrassing TTS confessions."); CfgCurseSloth = ((BaseUnityPlugin)this).Config.Bind("Cursed Item", "Curse-Sloth", true, "Pool: holder moves in slow motion with a deep sluggish voice."); CfgCurseHelium = ((BaseUnityPlugin)this).Config.Bind("Cursed Item", "Curse-Helium", true, "Pool: holder goes floaty (most gravity cancelled) with a helium voice."); CfgCurseBlind = ((BaseUnityPlugin)this).Config.Bind("Cursed Item", "Curse-Blind", true, "Pool: crushing tunnel vision for the holder."); CfgCurseMagnet = ((BaseUnityPlugin)this).Config.Bind("Cursed Item", "Curse-Magnet", true, "Pool: nearby loose loot is dragged toward the holder. Property damage likely."); CfgCursePossession = ((BaseUnityPlugin)this).Config.Bind("Cursed Item", "Curse-Possession", true, "Pool: traps the player as the item in 3rd person view; microphone speech shakes the item."); CfgInfectionSeconds = ((BaseUnityPlugin)this).Config.Bind("Cursed Item", "InfectionSeconds", 12f, new ConfigDescription("How long a radiation infection lasts after last contact.", (AcceptableValueBase)new AcceptableValueRange(4f, 60f), Array.Empty())); CfgFartMinInterval = ((BaseUnityPlugin)this).Config.Bind("Fart Curse", "FartMinInterval", 1.2f, "Minimum seconds between farts while holding the cursed item."); CfgFartMaxInterval = ((BaseUnityPlugin)this).Config.Bind("Fart Curse", "FartMaxInterval", 2.8f, "Maximum seconds between farts while holding the cursed item."); CfgVoiceVibrato = ((BaseUnityPlugin)this).Config.Bind("Fart Curse", "VoiceVibrato", true, "Wobble the holder's actual voice in time with each fart."); CfgKlutz = ((BaseUnityPlugin)this).Config.Bind("Klutz", "Enabled", true, "Track item damage; the round's worst offender gets a clown nose and a [Klutz] tag."); CfgWeenieBox = ((BaseUnityPlugin)this).Config.Bind("Weenie Hiding Box", "Enabled", true, "Spawn a purchasable Weenie Hiding Box: players squatting flat inside it are safe and unseen."); CfgWeenieBoxRadius = ((BaseUnityPlugin)this).Config.Bind("Weenie Hiding Box", "Radius", 1.8f, new ConfigDescription("How close (meters) you must be to the box center to be protected.", (AcceptableValueBase)new AcceptableValueRange(1f, 4f), Array.Empty())); CfgMeltdown = ((BaseUnityPlugin)this).Config.Bind("Meltdown Contraband", "Enabled", true, "Mid-round loot race: a blue-glowing valuable's huge value melts every second until first grab locks it."); CfgMeltdownInterval = ((BaseUnityPlugin)this).Config.Bind("Meltdown Contraband", "IntervalSeconds", 200f, new ConfigDescription("Seconds between contraband drops after the first.", (AcceptableValueBase)new AcceptableValueRange(60f, 600f), Array.Empty())); CfgClownNoseId = ((BaseUnityPlugin)this).Config.Bind("Klutz", "ClownNoseCosmeticId", 315, "Cosmetic ID force-equipped on the Klutz (default: clown nose)."); CfgNoseScale = ((BaseUnityPlugin)this).Config.Bind("Klutz", "NoseScale", 2f, new ConfigDescription("Size multiplier for the Klutz's clown nose. 1 = normal, 2 = double.", (AcceptableValueBase)new AcceptableValueRange(1f, 5f), Array.Empty())); CfgTestMode = ((BaseUnityPlugin)this).Config.Bind("Testing", "TestMode", false, "PLAYTESTING ONLY: teleports special items to the spawn room (frozen until grabbed) and speeds up the first Contraband drop. Turn OFF for real runs."); CfgFeatureChance = ((BaseUnityPlugin)this).Config.Bind("Spawning", "SpecialItemChance", 0.25f, new ConfigDescription("Chance (0-1) for EACH special item (cursed, lottery, snitch, contraband, safety container, roulette token) to appear in a level. Test Mode forces all on.", (AcceptableValueBase)new AcceptableValueRange(0f, 1f), Array.Empty())); CfgShopChance = ((BaseUnityPlugin)this).Config.Bind("Spawning", "ShopItemChance", 0.25f, new ConfigDescription("Chance (0-1) for EACH custom purchasable (Jumper Cables, Portal Gun, Chaos Power-Up) to be available per level's shop stock.", (AcceptableValueBase)new AcceptableValueRange(0f, 1f), Array.Empty())); CfgHud = ((BaseUnityPlugin)this).Config.Bind("HUD", "TallyOverlay", true, "Show the live Accident Tally + current Klutz while the map tool is open, and always while dead."); CfgGoblinGroups = ((BaseUnityPlugin)this).Config.Bind("Cursed Item", "GoblinGroups", 1, new ConfigDescription("Fart Goblin GROUPS spawned on grab (each group is several gnomes).", (AcceptableValueBase)new AcceptableValueRange(1, 4), Array.Empty())); CfgBlackout = ((BaseUnityPlugin)this).Config.Bind("Blackout Protocol", "Enabled", true, "Periodic lights-out events: level goes dark, loot glows, enemies hunt by hints."); CfgBlackoutInterval = ((BaseUnityPlugin)this).Config.Bind("Blackout Protocol", "IntervalSeconds", 240f, new ConfigDescription("Seconds between blackouts after the first.", (AcceptableValueBase)new AcceptableValueRange(90f, 600f), Array.Empty())); CfgBlackoutDuration = ((BaseUnityPlugin)this).Config.Bind("Blackout Protocol", "DurationSeconds", 20f, new ConfigDescription("How long each blackout lasts.", (AcceptableValueBase)new AcceptableValueRange(10f, 60f), Array.Empty())); CfgSnitch = ((BaseUnityPlugin)this).Config.Bind("The Snitch", "Enabled", true, "One unmarked valuable rats out its carrier to every monster while carried."); CfgSnitchUnmaskAfter = ((BaseUnityPlugin)this).Config.Bind("The Snitch", "UnmaskAfterScreams", 4, new ConfigDescription("Publicly reveal the snitch after this many screams.", (AcceptableValueBase)new AcceptableValueRange(2, 10), Array.Empty())); CfgRoulette = ((BaseUnityPlugin)this).Config.Bind("Extraction Roulette", "Enabled", true, "Every completed extraction spins a wheel: jackpots, taxes, monster naps, healing waves."); CfgPortalGun = ((BaseUnityPlugin)this).Config.Bind("Portal Gun", "Enabled", true, "Shop weapon that shoots linked portals. Players (not items) travel entry -> exit."); CfgPortalView = ((BaseUnityPlugin)this).Config.Bind("Portal Gun", "SeeThroughPortals", true, "Render a live view of the other side on each portal (small perf cost: two 256px cameras)."); SoundBank.Bootstrap(); Net.Init(); Roulette.Init(); _harmony = new Harmony("com.chaoscarnival.repo"); _harmony.PatchAll(typeof(Patches)); Log.LogInfo((object)string.Format("{0} v{1} loaded. Enabled={2}", "ChaosCarnival", "1.0.27", Enabled)); } public static bool IsAdventureLevel() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown RunManager instance = RunManager.instance; if ((Object)instance != (Object)null && instance.levels != null && (Object)instance.levelCurrent != (Object)null) { return instance.levels.Contains(instance.levelCurrent); } return false; } private void Update() { if (!Enabled) { return; } try { CustomItems.TryRegister(); } catch { } if (!IsAdventureLevel()) { return; } try { Net.Tick(); Curses.Tick(); Curses.HostTick(); Klutz.Tick(); Lottery.Tick(); Lottery.HostTick(); WeenieBox.Tick(); Meltdown.Tick(); Meltdown.HostTick(); Blackout.Tick(); Blackout.HostTick(); Snitch.HostTick(); Roulette.Tick(); Roulette.HostTick(); Portals.Tick(); Portals.HostTick(); PowerUp.Tick(); PowerUp.HostTick(); TestMode.Tick(); } catch (Exception arg) { if (Time.frameCount % 300 == 0) { Log.LogError((object)$"Update tick error: {arg}"); } } } private void LateUpdate() { if (!Enabled || !IsAdventureLevel()) { return; } try { Curses.LateTick(); } catch { } } private void OnGUI() { if (!Enabled || !IsAdventureLevel()) { return; } try { Hud.Draw(); } catch { } } } public static class PluginInfo { public const string GUID = "com.chaoscarnival.repo"; public const string NAME = "ChaosCarnival"; public const string VERSION = "1.0.1"; } public class SoundBank : MonoBehaviour { [CompilerGenerated] private sealed class _003CLoadSingleFileWeb_003Ed__16 : IEnumerator, IEnumerator, IDisposable { private int _003C_003E1__state; private object _003C_003E2__current; public string file; public AudioType type; public Action callback; private AudioClip _003Cclip_003E5__2; private UnityWebRequest _003Creq_003E5__3; object IEnumerator.Current { [DebuggerHidden] get { return _003C_003E2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return _003C_003E2__current; } } [DebuggerHidden] public _003CLoadSingleFileWeb_003Ed__16(int _003C_003E1__state) { this._003C_003E1__state = _003C_003E1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = _003C_003E1__state; if (num == -3 || num == 1) { try { } finally { _003C_003Em__Finally1(); } } _003Cclip_003E5__2 = null; _003Creq_003E5__3 = null; _003C_003E1__state = -2; } private bool MoveNext() { //IL_003a: 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_0062: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Invalid comparison between Unknown and I4 try { switch (_003C_003E1__state) { default: return false; case 0: { _003C_003E1__state = -1; string absoluteUri = new Uri(file).AbsoluteUri; _003Cclip_003E5__2 = null; _003Creq_003E5__3 = UnityWebRequestMultimedia.GetAudioClip(absoluteUri, type); _003C_003E1__state = -3; DownloadHandlerAudioClip val = (DownloadHandlerAudioClip)_003Creq_003E5__3.downloadHandler; if (val != null) { val.streamAudio = false; } _003Creq_003E5__3.timeout = 10; _003C_003E2__current = _003Creq_003E5__3.SendWebRequest(); _003C_003E1__state = 1; return true; } case 1: _003C_003E1__state = -3; if ((int)_003Creq_003E5__3.result == 1) { try { _003Cclip_003E5__2 = DownloadHandlerAudioClip.GetContent(_003Creq_003E5__3); } catch { } } _003C_003Em__Finally1(); _003Creq_003E5__3 = null; callback?.Invoke(_003Cclip_003E5__2); return false; } } catch { ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { return MoveNext(); } private void _003C_003Em__Finally1() { _003C_003E1__state = -1; if (_003Creq_003E5__3 != null) { ((IDisposable)_003Creq_003E5__3).Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static readonly List Farts = new List(); public static readonly List Carnival = new List(); public static readonly List Roulette = new List(); private bool _started; public static SoundBank Instance { get; private set; } public static bool Ready { get; private set; } public static void Bootstrap() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if (!((Object)Instance != (Object)null)) { GameObject val = new GameObject("ChaosCarnival.SoundBank"); Object.DontDestroyOnLoad((Object)val); Instance = val.AddComponent(); } } private void Awake() { if (!_started) { _started = true; LoadAll(); } } private void LoadAll() { string text = ""; try { string location = Assembly.GetExecutingAssembly().Location; if (!string.IsNullOrEmpty(location)) { string directoryName = Path.GetDirectoryName(location); if (!string.IsNullOrEmpty(directoryName)) { text = Path.Combine(directoryName, "sounds"); } } } catch { } if (string.IsNullOrEmpty(text) || !Directory.Exists(text)) { text = Path.Combine(Paths.PluginPath, "ChaosCarnival", "sounds"); } if (!Directory.Exists(text)) { try { string[] directories = Directory.GetDirectories(Paths.PluginPath, "sounds", SearchOption.AllDirectories); foreach (string text2 in directories) { if (Directory.Exists(Path.Combine(text2, "farts"))) { text = text2; break; } } } catch { } } Plugin.Log.LogInfo((object)("[SoundBank] Resolving audio directory to: " + text)); LoadFolder(Path.Combine(text, "farts"), Farts, "farts"); LoadFolder(Path.Combine(text, "carnival"), Carnival, "carnival"); LoadFolder(Path.Combine(text, "roulette"), Roulette, "roulette"); Ready = Farts.Count > 0 || Carnival.Count > 0 || Roulette.Count > 0; Plugin.Log.LogInfo((object)$"[SoundBank] Ready! Loaded farts={Farts.Count}, carnival={Carnival.Count}, roulette={Roulette.Count}"); } private void LoadFolder(string dir, List into, string folderName) { //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown if (!Directory.Exists(dir)) { return; } string[] files = Directory.GetFiles(dir, "*.*"); HashSet hashSet = new HashSet(StringComparer.OrdinalIgnoreCase); Array.Sort(files, delegate(string a, string b) { string text3 = Path.GetExtension(a).ToLowerInvariant(); string text4 = Path.GetExtension(b).ToLowerInvariant(); bool flag = text3 == ".wav"; bool flag2 = text4 == ".wav"; if (flag && !flag2) { return -1; } return (!flag && flag2) ? 1 : a.CompareTo(b); }); string[] array = files; foreach (string text in array) { string text2 = Path.GetExtension(text).ToLowerInvariant(); if (text2 != ".wav" && text2 != ".ogg" && text2 != ".mp3") { continue; } string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text); if (hashSet.Contains(fileNameWithoutExtension)) { continue; } AudioClip val = null; if (text2 == ".wav") { try { val = LoadWavFile(text); } catch { } } if ((Object)val != (Object)null) { hashSet.Add(fileNameWithoutExtension); ((Object)val).name = fileNameWithoutExtension; into.Add(val); Plugin.Log.LogInfo((object)$"[SoundBank] Loaded '{fileNameWithoutExtension}' into {folderName} ({val.length:F2}s)"); } else { Plugin.Log.LogWarning((object)("[SoundBank] Could not decode audio file: " + text)); } } } private IEnumerator LoadSingleFileWeb(string file, AudioType type, Action callback) { //IL_000e: 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) try { int num = default(int); switch (num) { case 0: { string absoluteUri = new Uri(file).AbsoluteUri; UnityWebRequest val = UnityWebRequestMultimedia.GetAudioClip(absoluteUri, type); DownloadHandlerAudioClip val2 = (DownloadHandlerAudioClip)val.downloadHandler; if (val2 != null) { val2.streamAudio = false; } val.timeout = 10; val.SendWebRequest(); /*Error near IL_00f3: Unexpected return in MoveNext()*/; } case 1: { UnityWebRequest val = default(UnityWebRequest); AudioClip content = default(AudioClip); if ((int)val.result == 1) { try { content = DownloadHandlerAudioClip.GetContent(val); } catch { } } ((_003CLoadSingleFileWeb_003Ed__16)/*Error near IL_00c1: stateMachine*/)._003C_003Em__Finally1(); callback?.Invoke(content); break; } } } catch { ((IDisposable)/*Error near IL_00ea: stateMachine*/).Dispose(); throw; } yield break; } public static AudioClip LoadWavFile(string filePath) { byte[] array = File.ReadAllBytes(filePath); if (array.Length < 44) { return null; } if (array[0] != 82 || array[1] != 73 || array[2] != 70 || array[3] != 70) { return null; } if (array[8] != 87 || array[9] != 65 || array[10] != 86 || array[11] != 69) { return null; } int num = BitConverter.ToInt16(array, 22); int num2 = BitConverter.ToInt32(array, 24); int num3 = BitConverter.ToInt16(array, 34); for (int i = 12; i < array.Length - 8; i++) { if (array[i] != 100 || array[i + 1] != 97 || array[i + 2] != 116 || array[i + 3] != 97) { continue; } i += 4; int num4 = BitConverter.ToInt32(array, i); i += 4; int num5 = num3 / 8; if (num5 <= 0) { return null; } int num6 = num4 / num5; int num7 = num6 / num; float[] array2 = new float[num6]; switch (num3) { case 16: { int num9 = 0; for (int k = i; k < i + num4 && k < array.Length - 1; k += 2) { short num10 = BitConverter.ToInt16(array, k); array2[num9++] = (float)num10 / 32768f; } break; } case 32: { int num11 = 0; for (int l = i; l < i + num4 && l < array.Length - 3; l += 4) { array2[num11++] = BitConverter.ToSingle(array, l); } break; } case 8: { int num8 = 0; for (int j = i; j < i + num4 && j < array.Length; j++) { array2[num8++] = (float)(array[j] - 128) / 128f; } break; } } AudioClip obj = AudioClip.Create(Path.GetFileNameWithoutExtension(filePath), num7, num, num2, false); obj.SetData(array2, 0); return obj; } return null; } public static AudioClip RandomFart() { if (Farts.Count == 0) { return null; } return Farts[Random.Range(0, Farts.Count)]; } } public static class TestMode { private static float _pendingTimer = -1f; private static bool _placedCursed; private static bool _placedLottery; private static bool _placedCustoms; public static bool On { get { if (Plugin.Enabled) { return Plugin.CfgTestMode.Value; } return false; } } public static Vector3 Anchor { get; private set; } = Vector3.zero; public static void QueuePlacement() { if (On && Net.IsAuthority) { _placedCursed = false; _placedLottery = false; _placedCustoms = false; _pendingTimer = 2f; } } public static void Tick() { if (!On || !Net.IsAuthority || _pendingTimer < 0f) { return; } _pendingTimer -= Time.deltaTime; if (!(_pendingTimer > 0f)) { _pendingTimer = 1.2f; HostPlaceItems(); if (_placedCursed && _placedLottery && _placedCustoms) { _pendingTimer = -1f; } } } public static void HostPlaceItems() { //IL_000f: 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_001e: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010f: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_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_013c: 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) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: 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_0183: 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_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: 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_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: 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) if (!On || !Net.IsAuthority) { return; } Anchor = FindAnchor(); if (Anchor == Vector3.zero) { return; } if (!_placedCursed && Net.State.CursedViewID != -1 && Place(Net.State.CursedViewID, Anchor + Vector3.forward * 1.5f + Vector3.up * 0.2f)) { _placedCursed = true; } if (!_placedLottery && Net.State.LotteryViewID != -1 && Place(Net.State.LotteryViewID, Anchor + Vector3.left * 1.5f + Vector3.up * 0.2f)) { _placedLottery = true; } if (!_placedCustoms) { bool num = SpawnCustomItem("Jumper Cables", Anchor + Vector3.back * 1.2f + Vector3.up * 0.6f); bool flag = SpawnCustomItem("Portal Gun", Anchor + Vector3.back * 2f + Vector3.up * 0.6f); bool flag2 = SpawnCustomItem("Chaos Power-Up", Anchor + Vector3.back * 2.8f + Vector3.up * 0.6f); bool flag3 = SpawnCustomItem("Weenie hiding box", Anchor + Vector3.right * 1.5f + Vector3.up * 0.6f); ExtractionPoint val = Object.FindObjectOfType(); if ((Object)val != (Object)null) { SpawnCustomItem("Weenie hiding box", ((Component)val).transform.position + Vector3.right * 2.5f + Vector3.up * 1f); } if (num && flag && flag2 && flag3) { _placedCustoms = true; } } } public static void HostOnGrab(PhysGrabObject obj) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown if (On && Net.IsAuthority && !((Object)obj == (Object)null)) { Rigidbody component = ((Component)obj).GetComponent(); if ((Object)component != (Object)null && component.isKinematic) { component.isKinematic = false; } } } private static bool SpawnCustomItem(string itemName, Vector3 position) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown try { foreach (Item allItem in Items.AllItems) { if (!((Object)allItem == (Object)null) && !(allItem.itemName != itemName) && (Object)Items.SpawnItem(allItem, position, Quaternion.identity) != (Object)null) { Plugin.Log.LogInfo((object)("[Test] Dropped \"" + itemName + "\" at spawn.")); return true; } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[Test] Spawn \"" + itemName + "\" failed: " + ex.Message)); } return false; } public static bool Place(int viewID, Vector3 position, bool freeze = true) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_0023: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_0054: 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_0080: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) if (viewID == -1) { return false; } GameObject val = Net.FindViewObject(viewID); if ((Object)val == (Object)null) { return false; } val.transform.position = position; val.transform.rotation = Quaternion.identity; PhysGrabObject component = val.GetComponent(); if ((Object)component != (Object)null) { ((Component)component).transform.position = position; ((Component)component).transform.rotation = Quaternion.identity; } Rigidbody component2 = val.GetComponent(); if ((Object)component2 != (Object)null) { component2.position = position; component2.rotation = Quaternion.identity; component2.velocity = Vector3.zero; component2.angularVelocity = Vector3.zero; component2.isKinematic = freeze; } if (viewID == Net.State.ToiletViewID) { Net.State.ToiletPos = new float[3] { position.x, position.y, position.z }; Net.MarkDirty(); } return true; } private static Vector3 FindAnchor() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_005e: 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_00a3: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar instance = PlayerAvatar.instance; if ((Object)instance != (Object)null && ((Component)instance).transform.position != Vector3.zero) { return ((Component)instance).transform.position; } PlayerAvatar[] array = Object.FindObjectsOfType(); foreach (PlayerAvatar val in array) { if ((Object)val != (Object)null) { return ((Component)val).transform.position; } } SpawnPoint val2 = Object.FindObjectOfType(); if ((Object)val2 != (Object)null) { return ((Component)val2).transform.position; } LevelGenerator val3 = Object.FindObjectOfType(); if (!((Object)val3 != (Object)null)) { return Vector3.zero; } return ((Component)val3).transform.position; } private static void Chat(string msg) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown if ((Object)ChatManager.instance != (Object)null) { ChatManager.instance.ForceSendMessage(msg); } } } } namespace ChaosCarnival.Features { public static class Blackout { private static readonly Color LootGlow = new Color(0.9f, 0.75f, 0.35f); private static float _nextTimer = -1f; private static float _endTimer; private static float _huntTimer; private static bool _roundActive; private static bool _applied; private static readonly List _disabledLights = new List(); private static readonly List _lootLights = new List(); private static readonly List _playerLights = new List(); private static float _flickerTimer; private static int _flickerState; private static float _burstUntil; public static bool On { get { if (Plugin.Enabled) { return Plugin.CfgBlackout.Value; } return false; } } public static void HostRoundSetup() { if (Net.IsAuthority) { _roundActive = true; _nextTimer = (TestMode.On ? 30f : Random.Range(120f, 180f)); _endTimer = 0f; } } public static void HostRoundEnd() { _roundActive = false; if (Net.IsAuthority && Net.State.BlackoutActive) { Net.State.BlackoutActive = false; Net.MarkDirty(); } } public static void HostTick() { //IL_0077: Unknown result type (might be due to invalid IL or missing references) if (!On || !Net.IsAuthority || !_roundActive) { return; } if (Net.State.BlackoutActive) { _endTimer -= Time.deltaTime; _huntTimer -= Time.deltaTime; if (_huntTimer <= 0f) { _huntTimer = 5f; PlayerAvatar[] array = Object.FindObjectsOfType(); if (array.Length != 0) { PlayerAvatar val = array[Random.Range(0, array.Length)]; try { SemiFunc.EnemyInvestigate(((Component)val).transform.position, 30f, false); } catch { } } } if (_endTimer <= 0f) { Net.State.BlackoutActive = false; Net.MarkDirty(); _nextTimer = Plugin.CfgBlackoutInterval.Value; } } else { _nextTimer -= Time.deltaTime; if (_nextTimer <= 0f) { _endTimer = Plugin.CfgBlackoutDuration.Value; Net.State.BlackoutActive = true; Net.MarkDirty(); Net.Broadcast("⚡ BLACKOUT PROTOCOL — the lights are OUT!", 5f); } } } public static void Tick() { if (!On) { if (_applied) { Restore(); } return; } bool blackoutActive = Net.State.BlackoutActive; if (blackoutActive && !_applied) { Apply(); } else if (!blackoutActive && _applied) { Restore(); } if (!_applied || _playerLights.Count <= 0) { return; } _flickerTimer -= Time.deltaTime; if (!(_flickerTimer <= 0f)) { return; } switch (_flickerState) { case 0: if (Random.value < 0.65f) { _flickerState = 1; _burstUntil = Time.time + Random.Range(0.25f, 1.3f); } else { _flickerState = 2; _flickerTimer = Random.Range(0.15f, 0.9f); SetPlayerLights(on: false); } break; case 1: SetPlayerLights(Random.value > 0.45f); _flickerTimer = Random.Range(0.03f, 0.16f); if (Time.time > _burstUntil) { _flickerState = 0; SetPlayerLights(on: true); _flickerTimer = Random.Range(0.8f, 4.5f); } break; case 2: _flickerState = 0; SetPlayerLights(on: true); _flickerTimer = Random.Range(0.8f, 4.5f); break; } } private static void SetPlayerLights(bool on) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown foreach (Light playerLight in _playerLights) { if ((Object)playerLight != (Object)null) { ((Behaviour)playerLight).enabled = on; } } } private static void Apply() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown _applied = true; _disabledLights.Clear(); _lootLights.Clear(); try { Light[] array = Object.FindObjectsOfType(); foreach (Light val in array) { if (!((Object)val == (Object)null) && ((Behaviour)val).enabled && !((Object)((Component)val).gameObject).name.StartsWith("ChaosCarnival") && !(((Object)((Component)val).gameObject).name == "ChaosCarnival.GlowLight")) { if ((Object)((Component)val).GetComponentInParent() != (Object)null || (Object)((Component)val).GetComponentInParent() != (Object)null || (Object)((Component)val).GetComponentInParent() != (Object)null) { _playerLights.Add(val); continue; } ((Behaviour)val).enabled = false; _disabledLights.Add(val); } } Plugin.Log.LogInfo((object)$"[Blackout] Applied: {_disabledLights.Count} lights out, {_playerLights.Count} flickering player lights."); } catch (Exception arg) { Plugin.Log.LogError((object)$"[Blackout] Apply failed: {arg}"); } } private static void Restore() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown _applied = false; foreach (Light disabledLight in _disabledLights) { if ((Object)disabledLight != (Object)null) { ((Behaviour)disabledLight).enabled = true; } } foreach (Light playerLight in _playerLights) { if ((Object)playerLight != (Object)null) { ((Behaviour)playerLight).enabled = true; } } foreach (GameObject lootLight in _lootLights) { if ((Object)lootLight != (Object)null) { Object.Destroy((Object)lootLight); } } _disabledLights.Clear(); _playerLights.Clear(); _lootLights.Clear(); Plugin.Log.LogInfo((object)"[Blackout] Lights restored."); } private static void Chat(string msg) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown if ((Object)ChatManager.instance != (Object)null) { ChatManager.instance.ForceSendMessage(msg); } } } public enum CurseKind { BubbleGuts, Tiny, Jitters, Decay, Radiation, Confession, Sloth, Helium, Blind, Magnet, Possession } public static class Curses { private static readonly Color CurseRed; private static readonly Color GoblinGreen; private static readonly Color RadGreen; private static readonly string[] CurseNames; private static readonly string[] Confessions; private static int _glowedCursedID; private static readonly HashSet _glowedGoblinIDs; private static readonly HashSet _auraViewIDs; private static PlayerAvatar _scaledAvatar; private static float _fartTimer; private static float _jitterTimer; private static float _decayTimer; private static float _radDamageTimer; private static float _confessTimer; private static float _slothTimer; private static float _blindTimer; private static float _magnetPersistTimer; private static float _possessionTimer; private static PlayerAvatar _lastMagnetHolder; private static Camera _possessionCam; private static Camera _originalCam; private static float _possessionCamRotX; private static float _possessionCamRotY; private static EnemySetup _gnomeSetup; private static bool _gnomeSearched; private static bool _curseAnnounced; private static readonly List _goblins; private static readonly Dictionary _infection; private static readonly HashSet _announcedInfections; private static float _radScanTimer; private static GameObject _activeFartGO; private static readonly List _scaledTransforms; private static float _holderCheckTimer; public static bool On { get { if (Plugin.Enabled) { return Plugin.CfgCurses.Value; } return false; } } static Curses() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_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) CurseRed = new Color(1f, 0.1f, 0.05f); GoblinGreen = new Color(0.25f, 1f, 0.2f); RadGreen = new Color(0.5f, 1f, 0.15f); CurseNames = new string[11] { "CURSE OF THE BUBBLE GUTS", "CURSE OF THE TINY", "CURSE OF THE JITTERS", "CURSE OF DECAY", "CURSE OF RADIATION", "CURSE OF CONFESSION", "CURSE OF THE SLOTH", "CURSE OF HELIUM", "CURSE OF THE BLIND", "CURSE OF THE MAGNET", "CURSE OF POSSESSION" }; Confessions = new string[12] { "I have never returned a shopping cart.", "I am scared of the dark. And gnomes.", "I lick the batteries before I load them.", "I broke the vase last round and blamed the duck.", "My cart driving is terrible on purpose.", "I cried during the tutorial.", "The toilet is my best friend.", "I do not actually know what R.E.P.O. stands for.", "Sometimes I fake lag to avoid carrying.", "I sold your favorite item. It was me.", "I think the monsters have nice eyes.", "I whisper apologies to the loot when it breaks." }; _glowedCursedID = -1; _glowedGoblinIDs = new HashSet(); _auraViewIDs = new HashSet(); _magnetPersistTimer = 0f; _possessionTimer = 0f; _lastMagnetHolder = null; _possessionCamRotX = 15f; _possessionCamRotY = 45f; _goblins = new List(); _infection = new Dictionary(); _announcedInfections = new HashSet(); _scaledTransforms = new List(); Net.OnPoof += delegate(Vector3[] positions) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < positions.Length; i++) { Fx.Poof(positions[i], GoblinGreen); } }; } public static void HostRoundSetup() { if (On && Net.IsAuthority) { _curseAnnounced = false; _infection.Clear(); _announcedInfections.Clear(); if (!Plugin.FeatureRoll()) { Plugin.Log.LogInfo((object)"[Curse] No cursed item this level (roll)."); } else { TryPickCursedValuable(); } } } private static bool TryPickCursedValuable() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown ValuableObject[] array = Object.FindObjectsOfType(); if (array == null || array.Length == 0) { return false; } ValuableObject val = array[Random.Range(0, array.Length)]; PhotonView component = ((Component)val).GetComponent(); if ((Object)component == (Object)null) { return false; } Net.State.CursedViewID = component.ViewID; Net.State.CurseType = (int)RollCurse(); Net.MarkDirty(); try { float num = Mathf.Round(Mathf.Max(100f, Fx.GetField(val, "dollarValueOriginal")) * 3f); if (SemiFunc.IsMultiplayer() && (Object)component != (Object)null) { component.RPC("DollarValueSetRPC", (RpcTarget)0, new object[1] { num }); } else { val.DollarValueSetRPC(num, default(PhotonMessageInfo)); } Plugin.Log.LogInfo((object)$"[Curse] Picked \"{((Object)val).name}\" worth ${num:F0} (3x original base) carrying {CurseNames[Net.State.CurseType]}"); } catch (Exception ex) { Plugin.Log.LogWarning((object)("[Curse] Value sync failed: " + ex.Message)); Plugin.Log.LogInfo((object)("[Curse] Picked \"" + ((Object)val).name + "\" carrying " + CurseNames[Net.State.CurseType])); } return true; } private static CurseKind RollCurse() { List list = new List(); if (Plugin.CfgCurseFarts.Value) { list.Add(CurseKind.BubbleGuts); } if (Plugin.CfgCurseTiny.Value) { list.Add(CurseKind.Tiny); } if (Plugin.CfgCurseJitters.Value) { list.Add(CurseKind.Jitters); } if (Plugin.CfgCurseDecay.Value) { list.Add(CurseKind.Decay); } if (Plugin.CfgCurseRadiation.Value) { list.Add(CurseKind.Radiation); } if (Plugin.CfgCurseConfession.Value) { list.Add(CurseKind.Confession); } if (Plugin.CfgCurseSloth.Value) { list.Add(CurseKind.Sloth); } if (Plugin.CfgCurseHelium.Value) { list.Add(CurseKind.Helium); } if (Plugin.CfgCurseBlind.Value) { list.Add(CurseKind.Blind); } if (Plugin.CfgCurseMagnet.Value) { list.Add(CurseKind.Magnet); } if (Plugin.CfgCursePossession.Value) { list.Add(CurseKind.Possession); } if (list.Count == 0) { list.Add(CurseKind.BubbleGuts); } return list[Random.Range(0, list.Count)]; } public static void HostOnGrab(PhysGrabObject obj, PhysGrabber grabber) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_008e: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown if (!On || !Net.IsAuthority || (Object)obj == (Object)null || (Object)(grabber?.playerAvatar) == (Object)null) { return; } PhotonView component = ((Component)obj).GetComponent(); if ((!((Object)component != (Object)null) || component.ViewID != Net.State.CursedViewID) && (Net.State.CursedViewID == -1 || !((Object)((Component)obj).gameObject == (Object)Net.FindViewObject(Net.State.CursedViewID)))) { return; } PhotonView component2 = ((Component)grabber.playerAvatar).GetComponent(); int num = ((!((Object)component2 != (Object)null)) ? 1 : component2.ViewID); if (Net.State.CursedHolderViewID != num) { Net.State.CursedHolderViewID = num; if (Net.State.CurseType == 10 && Net.State.PossessedPlayerViewID == -1) { Net.State.PossessedPlayerViewID = num; _possessionTimer = 300f; } Net.MarkDirty(); string text = Fx.GetField(grabber.playerAvatar, "playerName") ?? "Someone"; if (!_curseAnnounced) { _curseAnnounced = true; Chat("[Curse] " + text + " Cursed: " + CurseNames[Net.State.CurseType] + "!"); } } if (_goblins.Count == 0 && Net.State.CurseType != 10) { HostSpawnGoblins(grabber.playerAvatar); } } public static void HostOnRelease(PhysGrabObject obj) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_005f: 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_007d: Expected O, but got Unknown //IL_007d: Expected O, but got Unknown if (On && Net.IsAuthority && !((Object)obj == (Object)null)) { PhotonView component = ((Component)obj).GetComponent(); if ((((Object)component != (Object)null && component.ViewID == Net.State.CursedViewID) || (Net.State.CursedViewID != -1 && (Object)((Component)obj).gameObject == (Object)Net.FindViewObject(Net.State.CursedViewID))) && (obj.playerGrabbing == null || obj.playerGrabbing.Count <= 0) && Net.State.CurseType != 10) { Net.State.CursedHolderViewID = -1; HostDespawnGoblins(poof: true); Net.MarkDirty(); } } } public static void HostCleanup() { HostDespawnGoblins(poof: false); RestoreTinyScale(); _infection.Clear(); _glowedCursedID = -1; _glowedGoblinIDs.Clear(); _auraViewIDs.Clear(); _magnetPersistTimer = 0f; _lastMagnetHolder = null; if (Net.State != null) { Net.State.PossessedPlayerViewID = -1; } } public static void HostTick() { if (!On || !Net.IsAuthority) { return; } if (Net.State.CursedViewID == -1) { if (Plugin.FeatureRoll()) { TryPickCursedValuable(); } return; } if (Net.State.PossessedPlayerViewID != -1) { _possessionTimer -= Time.deltaTime; if (_possessionTimer <= 0f) { HostKillPossessedPlayer(); } } HostValidateCurseHolder(); if (Net.State.CurseType == 4) { HostTickRadiation(); } } private static void HostValidateCurseHolder() { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown if (Net.State.CurseType == 10 || Net.State.CursedHolderViewID == -1) { return; } _holderCheckTimer -= Time.deltaTime; if (_holderCheckTimer > 0f) { return; } _holderCheckTimer = 1f; bool flag = false; GameObject val = Net.FindViewObject(Net.State.CursedViewID); if ((Object)val != (Object)null) { PhysGrabObject component = val.GetComponent(); if ((Object)component != (Object)null && component.playerGrabbing != null && component.playerGrabbing.Count > 0) { flag = true; } } if (!flag) { Net.State.CursedHolderViewID = -1; if ((Object)val == (Object)null) { Net.State.CursedViewID = -1; } HostDespawnGoblins(poof: true); Net.MarkDirty(); } } private static void HostKillPossessedPlayer() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown if (Net.State.PossessedPlayerViewID == -1) { return; } PlayerAvatar val = Net.FindAvatar(Net.State.PossessedPlayerViewID); if ((Object)val != (Object)null) { PlayerHealth val2 = ((Component)val).GetComponent() ?? ((Component)val).GetComponentInChildren(); if ((Object)val2 != (Object)null) { val2.Hurt(150, false, -1, false); } string text = Fx.GetField(val, "playerName") ?? "Someone"; Chat("[Curse] " + text + " ran out of time and died while possessed!"); } HostClearPossession(); } public static void HostClearPossession() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown if (Net.State.PossessedPlayerViewID != -1) { PlayerAvatar val = Net.FindAvatar(Net.State.PossessedPlayerViewID); if ((Object)val != (Object)null) { string text = Fx.GetField(val, "playerName") ?? "Someone"; Chat("[Curse] " + text + " has been freed from the possessed valuable!"); } Net.State.PossessedPlayerViewID = -1; Net.State.CursedHolderViewID = -1; Net.MarkDirty(); } } private static void HostTickRadiation() { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Expected O, but got Unknown //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) _radScanTimer -= Time.deltaTime; if (_radScanTimer > 0f) { return; } _radScanTimer = 0.5f; bool flag = false; PlayerAvatar[] array = Object.FindObjectsOfType(); if (Net.State.CursedHolderViewID != -1) { if (!_infection.ContainsKey(Net.State.CursedHolderViewID)) { flag = true; } _infection[Net.State.CursedHolderViewID] = Plugin.CfgInfectionSeconds.Value; } foreach (int item in new List(_infection.Keys)) { PlayerAvatar val = Net.FindAvatar(item); if ((Object)val == (Object)null) { continue; } PlayerAvatar[] array2 = array; foreach (PlayerAvatar val2 in array2) { if ((Object)val2 == (Object)null) { continue; } PhotonView component = ((Component)val2).GetComponent(); if (!((Object)component == (Object)null) && !_infection.ContainsKey(component.ViewID) && Vector3.Distance(((Component)val2).transform.position, ((Component)val).transform.position) < 2.2f) { _infection[component.ViewID] = Plugin.CfgInfectionSeconds.Value; flag = true; if (_announcedInfections.Add(component.ViewID)) { string text = Fx.GetField(val2, "playerName") ?? "Someone"; Chat("[Curse] " + text + " IRRADIATED!"); } } } } foreach (int item2 in new List(_infection.Keys)) { _infection[item2] -= 0.5f; if (_infection[item2] <= 0f) { _infection.Remove(item2); flag = true; } } if (flag) { int[] array3 = new int[_infection.Count]; _infection.Keys.CopyTo(array3, 0); Net.State.InfectedViewIDs = array3; Net.MarkDirty(); } } private static void HostSpawnGoblins(PlayerAvatar target) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0031: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected O, but got Unknown EnemySetup val = FindGnomeSetup(); if ((Object)val == (Object)null) { Plugin.Log.LogWarning((object)"[Curse] No gnome setup; goblins unavailable."); return; } List list = new List(); for (int i = 0; i < Plugin.CfgGoblinGroups.Value; i++) { Vector2 insideUnitCircle = Random.insideUnitCircle; Vector2 val2 = ((Vector2)(ref insideUnitCircle)).normalized * Random.Range(1.5f, 3f); Vector3 val3 = ((Component)target).transform.position + new Vector3(val2.x, 0.5f, val2.y); List list2 = Enemies.SpawnEnemy(val, val3, Quaternion.identity, false); if (list2 == null) { continue; } foreach (EnemyParent item in list2) { if (!((Object)item == (Object)null)) { _goblins.Add(((Component)item).gameObject); PhotonView val4 = ((Component)item).GetComponent() ?? ((Component)item).GetComponentInChildren(); if ((Object)val4 != (Object)null) { list.Add(val4.ViewID); } } } } Net.State.GoblinViewIDs = list.ToArray(); Net.MarkDirty(); } private static void HostDespawnGoblins(bool poof) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) if (_goblins.Count == 0 && Net.State.GoblinViewIDs.Length == 0) { return; } List list = new List(); foreach (GameObject goblin in _goblins) { if (!((Object)goblin == (Object)null)) { list.Add(goblin.transform.position); try { PhotonNetwork.Destroy(goblin); } catch { Object.Destroy((Object)goblin); } } } _goblins.Clear(); if (poof && list.Count > 0) { Net.SendPoof(list.ToArray()); } Net.State.GoblinViewIDs = Array.Empty(); Net.MarkDirty(); } public static void HostRetargetGoblins() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown //IL_0089: 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) if (On && Net.IsAuthority && Net.State.CursedHolderViewID != -1 && !((Object)EnemyGnomeDirector.instance == (Object)null)) { PlayerAvatar val = Net.FindAvatar(Net.State.CursedHolderViewID); if ((Object)val != (Object)null) { EnemyGnomeDirector instance = EnemyGnomeDirector.instance; instance.SetTarget(val); Fx.SetField(instance, "valuableTarget", null); Fx.SetField(instance, "currentState", (object)(State)5); Fx.SetField(instance, "attackPosition", ((Component)val).transform.position); Fx.SetField(instance, "attackVisionPosition", ((Component)val).transform.position); } } } private static EnemySetup FindGnomeSetup() { if (_gnomeSearched) { return _gnomeSetup; } _gnomeSearched = true; foreach (EnemySetup allEnemy in Enemies.AllEnemies) { if (allEnemy?.spawnObjects == null) { continue; } foreach (PrefabRef spawnObject in allEnemy.spawnObjects) { if (spawnObject != null && (((PrefabRef)(object)spawnObject).PrefabName ?? "").ToLowerInvariant().Contains("gnome")) { _gnomeSetup = allEnemy; return _gnomeSetup; } } } return _gnomeSetup; } public static void Tick() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_0041: 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_0055: Expected O, but got Unknown //IL_0055: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown if (On) { RenderGlows(); PlayerAvatar val = Net.FindAvatar(Net.State.CursedHolderViewID); CurseKind curseType = (CurseKind)Net.State.CurseType; if ((Object)_scaledAvatar != (Object)null && (curseType != CurseKind.Tiny || (Object)val != (Object)_scaledAvatar)) { RestoreTinyScale(); } if (Net.State.PossessedPlayerViewID == -1 && ((Object)_possessionCam != (Object)null || (Object)_originalCam != (Object)null)) { RestorePossession(); } switch (curseType) { case CurseKind.BubbleGuts: TickFarts(val); break; case CurseKind.Tiny: TickTiny(val); break; case CurseKind.Jitters: TickJitters(val); break; case CurseKind.Decay: TickDecay(val); break; case CurseKind.Radiation: TickRadiation(); break; case CurseKind.Confession: TickConfession(val); break; case CurseKind.Sloth: TickSloth(val); break; case CurseKind.Helium: TickHelium(val); break; case CurseKind.Blind: TickBlind(val); break; case CurseKind.Magnet: TickMagnet(val); break; case CurseKind.Possession: TickPossession(val); break; } } } public static void LateTick() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown if (On && Net.State.CurseType == 1) { PlayerAvatar val = Net.FindAvatar(Net.State.CursedHolderViewID); if ((Object)val != (Object)null) { TickTiny(val); } } } private static void RenderGlows() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_0045: 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: Expected O, but got Unknown //IL_00a1: Unknown result type (might be due to invalid IL or missing references) CarnivalState state = Net.State; if (state.CursedViewID != _glowedCursedID) { GameObject val = Net.FindViewObject(state.CursedViewID); if ((Object)val != (Object)null || state.CursedViewID == -1) { if ((Object)val != (Object)null) { Fx.Glow(val, CurseRed, 0.35f, 4f, 1.2f); } _glowedCursedID = state.CursedViewID; } } int[] goblinViewIDs = state.GoblinViewIDs; foreach (int num in goblinViewIDs) { if (!_glowedGoblinIDs.Contains(num)) { GameObject val2 = Net.FindViewObject(num); if (!((Object)val2 == (Object)null)) { Fx.Glow(val2, GoblinGreen, 0.3f, 2.5f, 1f); _glowedGoblinIDs.Add(num); } } } } private static void TickFarts(PlayerAvatar holder) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Expected O, but got Unknown if ((Object)holder == (Object)null || SoundBank.Farts.Count == 0) { _fartTimer = 0.5f; } else { if ((Object)_activeFartGO != (Object)null) { return; } _fartTimer -= Time.deltaTime; if (_fartTimer > 0f) { return; } AudioClip val = SoundBank.RandomFart(); if ((Object)val == (Object)null) { return; } float num = ((val.length > 0f) ? val.length : 2f); _fartTimer = num + Random.Range(2.5f, 5f); PlayerVoiceChat field = Fx.GetField(holder, "voiceChat"); Transform val2 = (((Object)field != (Object)null) ? ((Component)field).transform : ((Component)holder).transform); _activeFartGO = new GameObject("ChaosCarnival.Fart"); _activeFartGO.transform.SetParent(val2, false); AudioSource val3 = _activeFartGO.AddComponent(); val3.clip = val; val3.spatialBlend = 0f; val3.pitch = Random.Range(0.9f, 1.15f); val3.volume = Random.Range(0.85f, 1.1f); val3.Play(); Object.Destroy((Object)_activeFartGO, num + 0.2f); if (Plugin.CfgVoiceVibrato.Value && (Object)field != (Object)null) { try { field.OverridePitch(0.72f, 0.06f, 0.15f, num / val3.pitch, 0.16f, 26f); } catch { } } } } public static void RestoreTinyScale() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0024: Unknown result type (might be due to invalid IL or missing references) foreach (Transform scaledTransform in _scaledTransforms) { if ((Object)scaledTransform != (Object)null) { scaledTransform.localScale = Vector3.one; } } _scaledTransforms.Clear(); _scaledAvatar = null; } private static void TickTiny(PlayerAvatar holder) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0036: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_0099: Expected O, but got Unknown //IL_01e7: 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_0132: Expected O, but got Unknown //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Expected O, but got Unknown //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Expected O, but got Unknown //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Expected O, but got Unknown //IL_0237: Unknown result type (might be due to invalid IL or missing references) if ((Object)holder == (Object)null) { return; } if ((Object)_scaledAvatar != (Object)null && (Object)_scaledAvatar != (Object)holder) { RestoreTinyScale(); } _scaledAvatar = holder; List list = new List(); list.Add(((Component)holder).transform); PhotonView component = ((Component)holder).GetComponent(); if ((Object)component == (Object)null || component.IsMine || ((Object)PlayerAvatar.instance != (Object)null && (Object)PlayerAvatar.instance == (Object)holder)) { PlayerController instance = PlayerController.instance; if ((Object)instance != (Object)null && !list.Contains(((Component)instance).transform)) { list.Add(((Component)instance).transform); } } PlayerAvatarVisuals field = Fx.GetField(holder, "playerAvatarVisuals"); if ((Object)field != (Object)null) { if ((Object)field.meshParent != (Object)null && !list.Contains(field.meshParent.transform)) { list.Add(field.meshParent.transform); } if ((Object)field.playerCosmetics != (Object)null && !list.Contains(((Component)field.playerCosmetics).transform)) { list.Add(((Component)field.playerCosmetics).transform); } foreach (Transform item in ((Component)field).transform) { Transform val = item; if ((Object)val != (Object)null && !list.Contains(val)) { list.Add(val); } } } PlayerCosmetics componentInChildren = ((Component)holder).GetComponentInChildren(); if ((Object)componentInChildren != (Object)null && !list.Contains(((Component)componentInChildren).transform)) { list.Add(((Component)componentInChildren).transform); } Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(0.35f, 0.35f, 0.35f); foreach (Transform item2 in list) { if (!((Object)item2 == (Object)null)) { if (item2.localScale != val2) { item2.localScale = val2; } if (!_scaledTransforms.Contains(item2)) { _scaledTransforms.Add(item2); } } } PlayerVoiceChat field2 = Fx.GetField(holder, "voiceChat"); try { if ((Object)(object)field2 != (Object)null) { field2.OverridePitch(1.85f, 0.05f, 0.05f, 0.5f, 0f, 0f); } } catch { } } public static void RestorePossession() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_008f: 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_00a4: Expected O, but got Unknown //IL_00a4: Expected O, but got Unknown //IL_00be: 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) if ((Object)_originalCam != (Object)null) { ((Behaviour)_originalCam).enabled = true; _originalCam = null; } if ((Object)_possessionCam != (Object)null) { Object.Destroy((Object)((Component)_possessionCam).gameObject); _possessionCam = null; } PlayerAvatar[] array = Object.FindObjectsOfType(); foreach (PlayerAvatar val in array) { if (!((Object)val == (Object)null)) { PlayerVoiceChat componentInChildren = ((Component)val).GetComponentInChildren(true); if ((Object)componentInChildren != (Object)null && (Object)((Component)componentInChildren).transform.parent != (Object)((Component)val).transform) { ((Component)componentInChildren).transform.SetParent(((Component)val).transform, false); ((Component)componentInChildren).transform.localPosition = Vector3.zero; ((Component)componentInChildren).transform.localRotation = Quaternion.identity; } } } } private static void TickPossession(PlayerAvatar holder) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Expected O, but got Unknown //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Expected O, but got Unknown //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Expected O, but got Unknown //IL_029e: Expected O, but got Unknown //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_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_0213: 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_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_022c: 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_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_025d: 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_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Expected O, but got Unknown //IL_02ba: 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_016d: 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_0181: Expected O, but got Unknown //IL_0181: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00b6: 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_0362: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Expected O, but got Unknown //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) int possessedPlayerViewID = Net.State.PossessedPlayerViewID; if (possessedPlayerViewID == -1) { return; } PlayerAvatar val = Net.FindAvatar(possessedPlayerViewID); GameObject val2 = Net.FindViewObject(Net.State.CursedViewID); if ((Object)val2 == (Object)null || (Object)val == (Object)null) { return; } PhotonView component = ((Component)val).GetComponent(); bool flag = (Object)component != (Object)null && component.IsMine; if (flag) { PlayerController instance = PlayerController.instance; if ((Object)instance != (Object)null) { instance.OverrideSpeed(0f, 0.1f); if ((Object)instance.rb != (Object)null) { instance.rb.velocity = new Vector3(0f, instance.rb.velocity.y, 0f); } try { Fx.SetField(instance, "crouch", true); } catch { } } } Animator componentInChildren = ((Component)val).GetComponentInChildren(true); if ((Object)componentInChildren != (Object)null) { componentInChildren.SetBool("Crouch", true); componentInChildren.SetBool("Downed", true); } if (flag) { if ((Object)_possessionCam == (Object)null) { _possessionCam = new GameObject("ChaosCarnival.PossessionCam").AddComponent(); ((Component)_possessionCam).tag = "MainCamera"; Camera main = Camera.main; if ((Object)main != (Object)null && (Object)main != (Object)_possessionCam) { _possessionCam.CopyFrom(main); _originalCam = main; ((Behaviour)_originalCam).enabled = false; } } _possessionCamRotY += Input.GetAxis("Mouse X") * 3f; _possessionCamRotX -= Input.GetAxis("Mouse Y") * 3f; _possessionCamRotX = Mathf.Clamp(_possessionCamRotX, -10f, 80f); Quaternion val3 = Quaternion.Euler(_possessionCamRotX, _possessionCamRotY, 0f); Vector3 position = val2.transform.position - val3 * Vector3.forward * 3f + Vector3.up * 0.75f; ((Component)_possessionCam).transform.rotation = val3; ((Component)_possessionCam).transform.position = position; } PlayerVoiceChat componentInChildren2 = ((Component)val).GetComponentInChildren(true); if (!((Object)componentInChildren2 != (Object)null)) { return; } if ((Object)((Component)componentInChildren2).transform.parent != (Object)val2.transform) { ((Component)componentInChildren2).transform.SetParent(val2.transform, false); ((Component)componentInChildren2).transform.localPosition = Vector3.zero; ((Component)componentInChildren2).transform.localRotation = Quaternion.identity; } AudioSource val4 = ((Component)componentInChildren2).GetComponent() ?? ((Component)componentInChildren2).GetComponentInChildren(true); if (!((Object)val4 != (Object)null) || !val4.isPlaying) { return; } float[] array = new float[64]; try { val4.GetOutputData(array, 0); float num = 0f; for (int i = 0; i < array.Length; i++) { num += array[i] * array[i]; } float num2 = Mathf.Sqrt(num / (float)array.Length); if (num2 > 0.05f) { Rigidbody component2 = val2.GetComponent(); if ((Object)component2 != (Object)null) { Vector3 val5 = Random.onUnitSphere * (num2 * 1.5f); component2.AddForce(val5, (ForceMode)1); } } } catch { } } private static void TickJitters(PlayerAvatar holder) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Expected O, but got Unknown //IL_0130: 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_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) if ((Object)holder == (Object)null) { return; } PhotonView component = ((Component)holder).GetComponent(); if ((Object)component == (Object)null || (SemiFunc.IsMultiplayer() && !component.IsMine)) { return; } PlayerController instance = PlayerController.instance; if ((Object)instance == (Object)null) { return; } try { if ((Object)instance.rb != (Object)null) { Vector2 insideUnitCircle = Random.insideUnitCircle; instance.rb.AddForce(new Vector3(insideUnitCircle.x, Random.Range(-0.05f, 0.2f), insideUnitCircle.y) * 0.22f, (ForceMode)2); } GameDirector instance2 = GameDirector.instance; if ((Object)(object)instance2 != (Object)null) { CameraShake cameraShake = instance2.CameraShake; if ((Object)(object)cameraShake != (Object)null) { cameraShake.Shake(1.3f, 0.1f); } } _jitterTimer -= Time.deltaTime; if (_jitterTimer > 0f) { return; } _jitterTimer = Random.Range(0.9f, 2.2f); instance.OverrideSpeed(Random.Range(0.3f, 2.2f), 0.7f); if ((Object)instance.rb != (Object)null) { Vector2 insideUnitCircle2 = Random.insideUnitCircle; Vector2 normalized = ((Vector2)(ref insideUnitCircle2)).normalized; instance.rb.AddForce(new Vector3(normalized.x, 0.2f, normalized.y) * Random.Range(2.5f, 4.5f), (ForceMode)2); } GameDirector instance3 = GameDirector.instance; if ((Object)(object)instance3 != (Object)null) { CameraShake cameraShake2 = instance3.CameraShake; if ((Object)(object)cameraShake2 != (Object)null) { cameraShake2.Shake(3.5f, 0.4f); } } } catch { } } private static void TickDecay(PlayerAvatar holder) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if ((Object)holder == (Object)null) { return; } PhotonView component = ((Component)holder).GetComponent(); if ((Object)component == (Object)null || (SemiFunc.IsMultiplayer() && !component.IsMine)) { return; } _decayTimer -= Time.deltaTime; if (_decayTimer > 0f) { return; } _decayTimer = 3f; try { PlayerHealth playerHealth = holder.playerHealth; if ((Object)(object)playerHealth != (Object)null) { playerHealth.Hurt(3, true, -1, false); } } catch { } } private static void TickRadiation() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown CarnivalState state = Net.State; int[] infectedViewIDs = state.InfectedViewIDs; foreach (int num in infectedViewIDs) { if (!_auraViewIDs.Contains(num)) { PlayerAvatar val = Net.FindAvatar(num); if (!((Object)val == (Object)null)) { Fx.Aura(((Component)val).gameObject, RadGreen); _auraViewIDs.Add(num); } } } if (_auraViewIDs.Count > 0) { HashSet hashSet = new HashSet(state.InfectedViewIDs); foreach (int item in new List(_auraViewIDs)) { if (!hashSet.Contains(item)) { PlayerAvatar val2 = Net.FindAvatar(item); if ((Object)val2 != (Object)null) { Fx.RemoveAura(((Component)val2).gameObject); } _auraViewIDs.Remove(item); } } } PlayerAvatar instance = PlayerAvatar.instance; if ((Object)instance == (Object)null) { return; } PhotonView component = ((Component)instance).GetComponent(); if ((Object)component == (Object)null || Array.IndexOf(state.InfectedViewIDs, component.ViewID) < 0) { return; } _radDamageTimer -= Time.deltaTime; if (_radDamageTimer > 0f) { return; } _radDamageTimer = 4f; try { PlayerHealth playerHealth = instance.playerHealth; if ((Object)(object)playerHealth != (Object)null) { playerHealth.Hurt(3, true, -1, false); } } catch { } } private static void TickConfession(PlayerAvatar holder) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown if ((Object)holder == (Object)null) { _confessTimer = 4f; return; } PhotonView component = ((Component)holder).GetComponent(); if ((Object)component == (Object)null || (SemiFunc.IsMultiplayer() && !component.IsMine)) { return; } _confessTimer -= Time.deltaTime; if (_confessTimer > 0f) { return; } _confessTimer = Random.Range(18f, 32f); string text = Confessions[Random.Range(0, Confessions.Length)]; try { string text2 = Fx.GetField(holder, "playerName") ?? "Someone"; Net.Broadcast("[Confession] " + text2 + ": " + text); } catch (Exception ex) { Plugin.Log.LogWarning((object)("[Curse] Confession failed: " + ex.Message)); } } private static void TickSloth(PlayerAvatar holder) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown if ((Object)holder == (Object)null) { return; } PhotonView component = ((Component)holder).GetComponent(); bool flag = (Object)component != (Object)null && (!SemiFunc.IsMultiplayer() || component.IsMine); _slothTimer -= Time.deltaTime; if (_slothTimer > 0f) { return; } _slothTimer = 0.2f; if (flag && (Object)PlayerController.instance != (Object)null) { try { PlayerController.instance.OverrideSpeed(0.45f, 0.35f); PlayerController.instance.OverrideAnimationSpeed(0.55f, 0.2f, 0.2f, 0.35f); } catch { } } PlayerVoiceChat field = Fx.GetField(holder, "voiceChat"); try { if ((Object)(object)field != (Object)null) { field.OverridePitch(0.62f, 0.05f, 0.05f, 0.5f, 0f, 0f); } } catch { } } private static void TickHelium(PlayerAvatar holder) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) if ((Object)holder == (Object)null) { return; } PhotonView component = ((Component)holder).GetComponent(); if ((Object)component != (Object)null && (!SemiFunc.IsMultiplayer() || component.IsMine) && (Object)PlayerController.instance != (Object)null && (Object)PlayerController.instance.rb != (Object)null) { PlayerController.instance.rb.AddForce(Vector3.up * 7.4f * Time.deltaTime, (ForceMode)2); } PlayerVoiceChat field = Fx.GetField(holder, "voiceChat"); try { if ((Object)(object)field != (Object)null) { field.OverridePitch(1.45f, 0.05f, 0.05f, 0.5f, 0f, 0f); } } catch { } } private static void TickBlind(PlayerAvatar holder) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) if ((Object)holder == (Object)null) { return; } PhotonView component = ((Component)holder).GetComponent(); if ((Object)component == (Object)null || (SemiFunc.IsMultiplayer() && !component.IsMine)) { return; } _blindTimer -= Time.deltaTime; if (_blindTimer > 0f) { return; } _blindTimer = 0.8f; try { PostProcessing instance = PostProcessing.Instance; if ((Object)(object)instance != (Object)null) { instance.VignetteOverride(Color.black, 0.92f, 0.85f, 5f, 2f, 1.2f, ((Component)holder).gameObject); } } catch { } } private static void TickMagnet(PlayerAvatar holder) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_00bd: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar val = holder; if ((Object)val == (Object)null) { if (_magnetPersistTimer > 0f && (Object)_lastMagnetHolder != (Object)null) { _magnetPersistTimer -= Time.deltaTime; val = _lastMagnetHolder; } } else { _lastMagnetHolder = holder; _magnetPersistTimer = 60f; } if ((Object)val == (Object)null) { return; } ValuableObject[] array = Object.FindObjectsOfType(); foreach (ValuableObject val2 in array) { if ((Object)val2 == (Object)null) { continue; } PhotonView component = ((Component)val2).GetComponent(); if ((Object)component == (Object)null || component.ViewID == Net.State.CursedViewID) { continue; } Vector3 val3 = ((Component)val).transform.position - ((Component)val2).transform.position; float magnitude = ((Vector3)(ref val3)).magnitude; if (magnitude > 12f || magnitude < 0.8f) { continue; } PhysGrabObject component2 = ((Component)val2).GetComponent(); if (!((Object)component2 != (Object)null) || !Fx.GetField(component2, "grabbed")) { Rigidbody component3 = ((Component)val2).GetComponent(); if (!((Object)component3 == (Object)null) && !component3.isKinematic) { component3.AddForce(((Vector3)(ref val3)).normalized * 25f, (ForceMode)5); } } } } private static void Chat(string msg) { Net.Broadcast(msg); } } public static class CustomItems { public const string JumperCablesName = "Jumper Cables"; public const string PortalGunName = "Portal Gun"; public const string PowerUpName = "Chaos Power-Up"; public const string WeenieBoxName = "Weenie hiding box"; private static bool _registered; private static float _retryTimer; private static Item _jumperItem; private static Item _powerUpItem; private static Item _portalItem; private static Item _weenieItem; public static void HostRoundRoll() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown Item[] array = (Item[])(object)new Item[4] { _jumperItem, _powerUpItem, _portalItem, _weenieItem }; foreach (Item val in array) { if (!((Object)val == (Object)null)) { val.disabled = false; } } } public static void TryRegister() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) if (_registered) { return; } _retryTimer -= Time.deltaTime; if (_retryTimer > 0f) { return; } _retryTimer = 2f; if ((Object)StatsManager.instance == (Object)null) { return; } try { Item val = FindHealthPackTemplate(); if (!((Object)val == (Object)null)) { RegisterJumperCables(val); _powerUpItem = RegisterClone(val, "Chaos Power-Up", "Item Chaos Power-Up", "Weapon, full heal, flight and infinite stamina for 20 seconds. Then the crash hits.", new Color(1f, 0.8f, 0.1f), 8000, 14000); RegisterPortalGun(); RegisterWeenieBox(val); _registered = true; } } catch (Exception arg) { Plugin.Log.LogError((object)$"[CustomItems] Registration error: {arg}"); _registered = true; } } private static Item FindHealthPackTemplate() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown foreach (Item allItem in Items.AllItems) { if (!((Object)allItem == (Object)null) && (int)allItem.itemType == 8 && allItem.prefab != null && (Object)((PrefabRef)(object)allItem.prefab).Prefab != (Object)null) { return allItem; } } return null; } private static void RegisterJumperCables(Item template) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Expected O, but got Unknown //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Expected O, but got Unknown //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Expected O, but got Unknown //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Expected O, but got Unknown //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Expected O, but got Unknown //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: 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_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_021a: 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_0272: 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) Item val = Object.Instantiate(template); ((Object)val).name = "Item Jumper Cables"; val.itemName = "Jumper Cables"; val.itemNameLocalized = null; val.description = "Shock a fallen teammate back to life. Transfers 25 of YOUR health to them."; val.itemType = (itemType)8; val.maxAmount = 5; val.maxAmountInShop = 5; try { Fx.SetField(val.value, "valueMin", 4500); Fx.SetField(val.value, "valueMax", 7500); } catch { } GameObject val2 = Object.Instantiate(((PrefabRef)(object)template.prefab).Prefab); ((Object)val2).name = "Item Jumper Cables"; Object.DontDestroyOnLoad((Object)val2); val2.SetActive(false); ItemAttributes component = val2.GetComponent(); if ((Object)component == (Object)null) { Plugin.Log.LogError((object)"[CustomItems] Cloned prefab has no ItemAttributes; aborting."); Object.Destroy((Object)val2); return; } component.item = val; object obj2; if (!((Object)(((PrefabRef)(object)template.prefab)?.Prefab) != (Object)null)) { obj2 = null; } else { Renderer componentInChildren = ((PrefabRef)(object)template.prefab).Prefab.GetComponentInChildren(true); if ((Object)(object)componentInChildren == (Object)null) { obj2 = null; } else { Material sharedMaterial = componentInChildren.sharedMaterial; obj2 = (((Object)(object)sharedMaterial != (Object)null) ? sharedMaterial.shader : null); } } Shader customShader = (Shader)obj2; GameObject val3 = ObjLoader.Load(Path.Combine(ObjLoader.AssetDir, "models", "JumperCables.obj"), 1f, customShader); if ((Object)val3 != (Object)null) { MeshFilter component2 = val3.GetComponent(); Vector3 val4; if (!((Object)component2 != (Object)null) || !((Object)component2.sharedMesh != (Object)null)) { val4 = Vector3.one; } else { Bounds bounds = component2.sharedMesh.bounds; val4 = ((Bounds)(ref bounds)).size; } Vector3 val5 = val4; float num = Mathf.Max(new float[3] { val5.x, val5.y, val5.z }); if (num > 0.001f) { val3.transform.localScale = Vector3.one * (0.35f / num); } Renderer[] componentsInChildren = val2.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } val3.transform.SetParent(val2.transform, false); val3.transform.localPosition = Vector3.zero; val3.transform.localRotation = Quaternion.identity; componentsInChildren = val3.GetComponentsInChildren(true); for (int j = 0; j < componentsInChildren.Length; j++) { componentsInChildren[j].enabled = true; } SetLayerRecursively(val2, val2.layer); } else { Tint(val2, new Color(0.9f, 0.15f, 0.15f)); } PrefabRef obj3 = Items.RegisterItem(component); _jumperItem = val; if (obj3 != null) { Plugin.Log.LogInfo((object)"[CustomItems] Registered \"Jumper Cables\"."); } else { Plugin.Log.LogWarning((object)"[CustomItems] RegisterItem returned null for \"Jumper Cables\"."); } } private static Item RegisterClone(Item template, string itemName, string soName, string description, Color tint, int priceMin, int priceMax) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown Item val = Object.Instantiate(template); ((Object)val).name = soName; val.itemName = itemName; val.itemNameLocalized = null; val.description = description; val.maxAmount = 5; val.maxAmountInShop = 5; try { Fx.SetField(val.value, "valueMin", priceMin); Fx.SetField(val.value, "valueMax", priceMax); } catch { } GameObject val2 = Object.Instantiate(((PrefabRef)(object)template.prefab).Prefab); ((Object)val2).name = soName; Object.DontDestroyOnLoad((Object)val2); val2.SetActive(false); ItemAttributes component = val2.GetComponent(); if ((Object)component == (Object)null) { Object.Destroy((Object)val2); return null; } component.item = val; Tint(val2, tint); SetLayerRecursively(val2, val2.layer); PrefabRef val3 = Items.RegisterItem(component); Plugin.Log.LogInfo((object)((val3 != null) ? ("[CustomItems] Registered \"" + itemName + "\".") : ("[CustomItems] RegisterItem returned null for \"" + itemName + "\"."))); return val; } private static void RegisterPortalGun() { //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Expected O, but got Unknown //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Expected O, but got Unknown //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Expected O, but got Unknown //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Invalid comparison between Unknown and I4 //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Expected O, but got Unknown //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Expected O, but got Unknown //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Expected O, but got Unknown //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Expected O, but got Unknown //IL_0281: 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_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: 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_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027f: 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_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) Item val = null; foreach (Item allItem in Items.AllItems) { if (!((Object)allItem == (Object)null) && (int)allItem.itemType == 9 && allItem.prefab != null && !((Object)((PrefabRef)(object)allItem.prefab).Prefab == (Object)null) && !((Object)((PrefabRef)(object)allItem.prefab).Prefab.GetComponentInChildren(true) == (Object)null)) { val = allItem; break; } } if ((Object)val == (Object)null) { return; } Item val2 = Object.Instantiate(val); ((Object)val2).name = "Item Portal Gun"; val2.itemName = "Portal Gun"; val2.itemNameLocalized = null; val2.description = "Shoots portals. First shot: exit. Second shot: entry. Players only."; val2.maxAmount = 2; val2.maxAmountInShop = 2; try { Fx.SetField(val2.value, "valueMin", 30000); Fx.SetField(val2.value, "valueMax", 45000); } catch { } GameObject val3 = Object.Instantiate(((PrefabRef)(object)val.prefab).Prefab); ((Object)val3).name = "Item Portal Gun"; Object.DontDestroyOnLoad((Object)val3); val3.SetActive(false); ItemAttributes component = val3.GetComponent(); if ((Object)component == (Object)null) { Plugin.Log.LogError((object)"[CustomItems] Portal Gun clone has no ItemAttributes; aborting."); Object.Destroy((Object)val3); return; } component.item = val2; object obj2; if (!((Object)(((PrefabRef)(object)val.prefab)?.Prefab) != (Object)null)) { obj2 = null; } else { Renderer componentInChildren = ((PrefabRef)(object)val.prefab).Prefab.GetComponentInChildren(true); if ((Object)(object)componentInChildren == (Object)null) { obj2 = null; } else { Material sharedMaterial = componentInChildren.sharedMaterial; obj2 = (((Object)(object)sharedMaterial != (Object)null) ? sharedMaterial.shader : null); } } Shader customShader = (Shader)obj2; GameObject val4 = ObjLoader.Load(Path.Combine(ObjLoader.AssetDir, "models", "PortalGun.obj"), 1f, customShader); if ((Object)val4 != (Object)null) { MeshFilter component2 = val4.GetComponent(); Vector3 val5; if (!((Object)component2 != (Object)null) || !((Object)component2.sharedMesh != (Object)null)) { val5 = Vector3.one; } else { Bounds bounds = component2.sharedMesh.bounds; val5 = ((Bounds)(ref bounds)).size; } Vector3 val6 = val5; float num = Mathf.Max(new float[3] { val6.x, val6.y, val6.z }); if (num > 0.001f) { val4.transform.localScale = Vector3.one * (0.35f / num); } Renderer[] componentsInChildren = val3.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } val4.transform.SetParent(val3.transform, false); val4.transform.localPosition = Vector3.zero; val4.transform.localRotation = Quaternion.Euler(0f, 180f, 0f); componentsInChildren = val4.GetComponentsInChildren(true); for (int j = 0; j < componentsInChildren.Length; j++) { componentsInChildren[j].enabled = true; } SetLayerRecursively(val3, val3.layer); } else { Tint(val3, new Color(0.35f, 0.45f, 1f)); } ItemGun componentInChildren2 = val3.GetComponentInChildren(true); if ((Object)componentInChildren2 != (Object)null) { componentInChildren2.batteryDrainFullBar = true; componentInChildren2.batteryDrainFullBars = 2; } PrefabRef val7 = Items.RegisterItem(component); _portalItem = val2; Plugin.Log.LogInfo((object)((val7 != null) ? ("[CustomItems] Registered \"Portal Gun\" (cloned from \"" + val.itemName + "\").") : "[CustomItems] RegisterItem returned null for \"Portal Gun\".")); } private static void Tint(GameObject obj, Color color) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_005a: 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_0087: Unknown result type (might be due to invalid IL or missing references) try { Renderer[] componentsInChildren = obj.GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if ((Object)val == (Object)null || val.materials == null) { continue; } Material[] materials = val.materials; foreach (Material val2 in materials) { if (!((Object)val2 == (Object)null)) { if (val2.HasProperty("_Color")) { val2.color = color; } if (val2.HasProperty("_EmissionColor")) { val2.EnableKeyword("_EMISSION"); val2.SetColor("_EmissionColor", color * 1.2f); } } } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[CustomItems] Tint failed: " + ex.Message)); } } private static void SetLayerRecursively(GameObject obj, int layer) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown if ((Object)obj == (Object)null) { return; } obj.layer = layer; foreach (Transform item in obj.transform) { Transform val = item; if ((Object)val != (Object)null) { SetLayerRecursively(((Component)val).gameObject, layer); } } } public static bool IsJumperCables(ItemAttributes attributes) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown if ((Object)attributes != (Object)null && (Object)attributes.item != (Object)null) { return attributes.item.itemName == "Jumper Cables"; } return false; } public static bool IsWeenieBox(ItemAttributes attributes) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown if ((Object)attributes != (Object)null && (Object)attributes.item != (Object)null) { return attributes.item.itemName == "Weenie hiding box"; } return false; } public static Item GetCartItem() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown foreach (Item allItem in Items.AllItems) { if (!((Object)allItem == (Object)null) && (int)allItem.itemType == 12 && allItem.prefab != null && (Object)((PrefabRef)(object)allItem.prefab).Prefab != (Object)null) { return allItem; } } return null; } private static void RegisterWeenieBox(Item template) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) _weenieItem = RegisterClone(template, "Weenie hiding box", "Item Weenie Box", "Deployable hiding box. Fits in inventory. Press use to deploy a cart. Squat flat inside to become invisible. Lasts 15 minutes.", new Color(1f, 0.4f, 0.6f), 10000, 10000); } } public static class JumperCables { private const int TransferHealth = 25; private const float ReviveRange = 4f; public static bool HandleUse(ItemHealthPack pack) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_006b: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Expected O, but got Unknown //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Expected O, but got Unknown if (!Plugin.Enabled) { return false; } if (!CustomItems.IsJumperCables(Fx.GetField(pack, "itemAttributes"))) { return false; } if (!SemiFunc.IsMasterClientOrSingleplayer()) { return true; } ItemToggle field = Fx.GetField(pack, "itemToggle"); if ((Object)field == (Object)null || !field.toggleState) { return true; } if (Fx.GetField(pack, "used")) { return true; } PlayerAvatar val = SemiFunc.PlayerAvatarGetFromPhotonID(Fx.GetField(field, "playerTogglePhotonID")); if ((Object)val == (Object)null) { return true; } PlayerDeathHead val2 = FindNearestDeadHead(((Component)pack).transform.position); if ((Object)val2 == (Object)null || (Object)val2.playerAvatar == (Object)null) { Reject(pack, field, "[Jumper Cables] No fallen teammate in range. Get closer to the head."); return true; } int num = (((Object)val.playerHealth != (Object)null) ? Fx.GetField(val.playerHealth, "health") : 0); if ((Object)val.playerHealth != (Object)null && num <= 25) { Reject(pack, field, "[Jumper Cables] Not enough health to spare! You need more than 25 HP."); return true; } try { PlayerAvatar playerAvatar = val2.playerAvatar; playerAvatar.Revive(false); val.playerHealth.Hurt(25, true, -1, false); if ((Object)playerAvatar.playerHealth != (Object)null) { playerAvatar.playerHealth.HealOther(25, true); } string text = Fx.GetField(val, "playerName") ?? "Someone"; string text2 = Fx.GetField(playerAvatar, "playerName") ?? "a teammate"; Chat("[Jumper Cables] " + text + " jump-started " + text2 + " back to life! (-25 HP)"); Consume(pack, field); Plugin.Log.LogInfo((object)("[Jumper Cables] " + text + " revived " + text2 + ".")); } catch (Exception arg) { Plugin.Log.LogError((object)$"[Jumper Cables] Revive failed: {arg}"); } return true; } private static PlayerDeathHead FindNearestDeadHead(Vector3 from) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_003a: 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) PlayerDeathHead result = null; float num = 4f; PlayerDeathHead[] array = Object.FindObjectsOfType(); foreach (PlayerDeathHead val in array) { if (!((Object)val == (Object)null) && !((Object)val.playerAvatar == (Object)null)) { float num2 = Vector3.Distance(from, ((Component)val).transform.position); if (num2 < num) { num = num2; result = val; } } } return result; } private static void Consume(ItemHealthPack pack, ItemToggle toggle) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown try { ItemAttributes field = Fx.GetField(pack, "itemAttributes"); string text = (((Object)field != (Object)null) ? Fx.GetField(field, "instanceName") : null); if (!string.IsNullOrEmpty(text) && (Object)StatsManager.instance != (Object)null) { StatsManager.instance.ItemRemove(text); } Fx.SetField(pack, "used", true); PhotonView component = ((Component)pack).GetComponent(); if (SemiFunc.IsMultiplayer() && (Object)component != (Object)null) { component.RPC("UsedRPC", (RpcTarget)0, Array.Empty()); } toggle.ToggleDisable(true); } catch (Exception ex) { Plugin.Log.LogWarning((object)("[Jumper Cables] Consume failed: " + ex.Message)); } } private static void Reject(ItemHealthPack pack, ItemToggle toggle, string message) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown try { PhotonView component = ((Component)pack).GetComponent(); if (SemiFunc.IsMultiplayer() && (Object)component != (Object)null) { component.RPC("RejectRPC", (RpcTarget)0, Array.Empty()); } else { Fx.CallMethod(pack, "RejectRPC"); } toggle.ToggleItem(false, -1); Chat(message); } catch { } } private static void Chat(string msg) { Net.Broadcast(msg, 6f); } } public static class Klutz { private static readonly Dictionary _damage = new Dictionary(StringComparer.OrdinalIgnoreCase); private static readonly HashSet _nosed = new HashSet(); private static readonly HashSet _noseScaled = new HashSet(); private static string _nosedForName = ""; private static float _scaleRetryTimer; private const string ScaleMarker = "ChaosCarnival.NoseScaled"; private static float _tauntCooldown; private static int _scaleAttempts; public static bool On { get { if (Plugin.Enabled) { return Plugin.CfgKlutz.Value; } return false; } } public static void HostRecordBreak(string playerName, float valueLost) { if (On && Net.IsAuthority && !(valueLost <= 0f)) { if (string.IsNullOrEmpty(playerName)) { playerName = "Unknown Player"; } _damage.TryGetValue(playerName, out var value); _damage[playerName] = value + valueLost; PublishTally(); if (playerName.Equals(Net.State.KlutzName, StringComparison.OrdinalIgnoreCase) && Time.time > _tauntCooldown) { _tauntCooldown = Time.time + 25f; Chat(playerName + ": I like to break nice things!"); } } } private static void PublishTally() { List> list = new List>(_damage); list.Sort((KeyValuePair a, KeyValuePair b) => b.Value.CompareTo(a.Value)); int num = Mathf.Min(8, list.Count); string[] array = new string[num]; float[] array2 = new float[num]; for (int num2 = 0; num2 < num; num2++) { array[num2] = list[num2].Key; array2[num2] = list[num2].Value; } Net.State.TallyNames = array; Net.State.TallyDamage = array2; Net.MarkDirty(); } public static void HostRoundEnd() { if (!On || !Net.IsAuthority) { return; } string text = ""; float num = 0f; foreach (KeyValuePair item in _damage) { if (item.Value > num) { num = item.Value; text = item.Key; } } if (_damage.Count == 0) { Chat("[Accident Report] Clean record! Nothing was broken this round."); } else { Chat("=== ACCIDENT REPORT ==="); List> list = new List>(_damage); list.Sort((KeyValuePair a, KeyValuePair b) => b.Value.CompareTo(a.Value)); foreach (KeyValuePair item2 in list) { string arg = ((item2.Key == text) ? " << KLUTZ" : ""); Chat($"- {item2.Key}: ${item2.Value:F0} in damages{arg}"); } } Net.State.KlutzName = text; Net.MarkDirty(); _damage.Clear(); if (!string.IsNullOrEmpty(text)) { Chat("[Klutz] " + text + " earns the clown nose next round!"); } } public static void Tick() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown if (!On) { return; } string klutzName = Net.State.KlutzName; if (_nosedForName != klutzName) { _nosed.Clear(); _noseScaled.Clear(); _nosedForName = klutzName; } if (string.IsNullOrEmpty(klutzName)) { return; } PlayerAvatar[] array = Object.FindObjectsOfType(); foreach (PlayerAvatar val in array) { if (!((Object)val == (Object)null) && !_nosed.Contains(val)) { string field = Fx.GetField(val, "playerName"); if (!string.IsNullOrEmpty(field) && field.Equals(klutzName, StringComparison.OrdinalIgnoreCase) && TryApplyNose(val)) { _nosed.Add(val); } } } ScaleNoseTick(); } private static void ScaleNoseTick() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Expected O, but got Unknown //IL_0131: 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_0146: Unknown result type (might be due to invalid IL or missing references) float value = Plugin.CfgNoseScale.Value; if (Mathf.Approximately(value, 1f)) { return; } _scaleRetryTimer -= Time.deltaTime; if (_scaleRetryTimer > 0f) { return; } _scaleRetryTimer = 0.5f; foreach (PlayerAvatar item in _nosed) { if ((Object)item == (Object)null || _noseScaled.Contains(item)) { continue; } PlayerAvatarVisuals field = Fx.GetField(item, "playerAvatarVisuals"); PlayerCosmetics val = (((Object)field != (Object)null) ? field.playerCosmetics : ((Component)item).GetComponentInChildren()); if ((Object)val == (Object)null) { continue; } bool flag = false; Transform[] componentsInChildren = ((Component)val).GetComponentsInChildren(true); foreach (Transform val2 in componentsInChildren) { if ((Object)val2 == (Object)null) { continue; } string text = ((Object)val2).name.ToLowerInvariant(); if (text.Contains("nose") || text.Contains("clown")) { if ((Object)val2.Find("ChaosCarnival.NoseScaled") != (Object)null) { flag = true; break; } val2.localScale *= value; new GameObject("ChaosCarnival.NoseScaled").transform.SetParent(val2, false); _noseScaled.Add(item); Plugin.Log.LogInfo((object)$"[Klutz] Nose scaled x{value:F1} on {Net.State.KlutzName} (\"{((Object)val2).name}\")."); flag = true; break; } } if (flag) { continue; } _scaleAttempts++; if (_scaleAttempts == 8) { Plugin.Log.LogWarning((object)"[Klutz] Nose transform not found by name. Cosmetic rig dump:"); Cosmetic[] componentsInChildren2 = ((Component)val).GetComponentsInChildren(true); foreach (Cosmetic val3 in componentsInChildren2) { Plugin.Log.LogInfo((object)$"[Klutz] cosmetic: \"{((Object)val3).name}\" type={val3.type} active={((Component)val3).gameObject.activeSelf}"); } _noseScaled.Add(item); } } } private static bool TryApplyNose(PlayerAvatar avatar) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown try { PlayerAvatarVisuals field = Fx.GetField(avatar, "playerAvatarVisuals"); PlayerCosmetics val = (((Object)field != (Object)null) ? field.playerCosmetics : ((Component)avatar).GetComponentInChildren()); if ((Object)val == (Object)null) { return false; } List collection = Fx.GetField>(val, "cosmeticEquippedRaw") ?? new List(); int value = Plugin.CfgClownNoseId.Value; List list = new List(collection); if (!list.Contains(value)) { list.Add(value); } MethodInfo methodInfo = AccessTools.Method(typeof(PlayerCosmetics), "SetupCosmeticsLogic", (Type[])null, (Type[])null); if (methodInfo == null) { return false; } methodInfo.Invoke(val, new object[2] { list.ToArray(), true }); Plugin.Log.LogInfo((object)("[Klutz] Clown nose applied locally to " + Net.State.KlutzName + ".")); return true; } catch (Exception ex) { Plugin.Log.LogWarning((object)("[Klutz] Nose apply failed: " + ex.Message)); return false; } } public static void DecorateNameplate(TextMeshProUGUI text, PlayerAvatar avatar) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown if (!On || (Object)text == (Object)null || (Object)avatar == (Object)null) { return; } string klutzName = Net.State.KlutzName; if (!string.IsNullOrEmpty(klutzName)) { string field = Fx.GetField(avatar, "playerName"); if (!string.IsNullOrEmpty(field) && field.Equals(klutzName, StringComparison.OrdinalIgnoreCase) && !((TMP_Text)text).text.Contains("[Klutz]")) { ((TMP_Text)text).text = field + " [Klutz]"; } } } private static void Chat(string msg) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown if ((Object)ChatManager.instance != (Object)null) { ChatManager.instance.ForceSendMessage(msg); } } } public static class Lottery { private static readonly Color LotteryYellow = new Color(1f, 0.85f, 0.1f); private static float _baseValue; private static float _fluctuateTimer; private static bool _finished; private static int _glowedID = -1; private static AudioSource _music; private static int _musicForID = -1; public static bool On => Plugin.Enabled; public static void HostRoundSetup() { _finished = false; _baseValue = 0f; _musicForID = -1; if (On && Net.IsAuthority && Plugin.FeatureRoll()) { TryPickValuable(); } } private static bool TryPickValuable() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown ValuableObject[] array = Object.FindObjectsOfType(); if (array == null || array.Length < 2) { return false; } for (int i = 0; i < 20; i++) { ValuableObject val = array[Random.Range(0, array.Length)]; PhotonView component = ((Component)val).GetComponent(); if (!((Object)component == (Object)null) && component.ViewID != Net.State.CursedViewID) { _baseValue = Mathf.Max(100f, Fx.GetField(val, "dollarValueOriginal")); Net.State.LotteryViewID = component.ViewID; Net.State.LotteryValue = _baseValue; Net.MarkDirty(); Plugin.Log.LogInfo((object)$"[Lottery] Picked \"{((Object)val).name}\" (view {component.ViewID}), base ${_baseValue:F0}"); return true; } } return false; } public static void HostTick() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //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_00b5: Invalid comparison between Unknown and I4 //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Invalid comparison between Unknown and I4 //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Invalid comparison between Unknown and I4 //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Expected O, but got Unknown if (!On || !Net.IsAuthority || _finished) { return; } if (Net.State.LotteryViewID == -1) { if (Plugin.FeatureRoll()) { TryPickValuable(); } return; } GameObject val = Net.FindViewObject(Net.State.LotteryViewID); if ((Object)val == (Object)null) { Finish("[Lottery] Item destroyed!"); return; } bool flag = false; List list = (((Object)RoundDirector.instance != (Object)null) ? Fx.GetField>(RoundDirector.instance, "dollarHaulList") : null); if (list != null) { flag = list.Contains(val); } bool flag2 = false; ExtractionPoint val2 = Object.FindObjectOfType(); if ((Object)val2 != (Object)null) { State field = Fx.GetField(val2, "currentState"); flag2 = (int)field == 3 || (int)field == 7 || (int)field == 8; } if (flag && flag2) { float lotteryValue = Net.State.LotteryValue; string text = ((lotteryValue >= 0f) ? $"${lotteryValue:F0}" : $"-${0f - lotteryValue:F0}"); Finish("[Lottery] Cashed out: " + text + "!"); return; } _fluctuateTimer -= Time.deltaTime; if (!(_fluctuateTimer > 0f)) { _fluctuateTimer = 1.4f; ValuableObject component = val.GetComponent(); if (!((Object)component == (Object)null)) { int num = 1 + (((Object)RunManager.instance != (Object)null) ? RunManager.instance.levelsCompleted : 0); float num2 = -0.5f * _baseValue; float num3 = 2f * _baseValue * (float)num; float num4 = Mathf.Round(Random.Range(num2, num3) / 10f) * 10f; SetValueNetworked(component, num4); Net.State.LotteryValue = num4; Net.MarkDirty(); } } } public static void HostOnExtractionCashout() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown if (!On || !Net.IsAuthority || _finished || Net.State.LotteryViewID == -1) { return; } GameObject val = Net.FindViewObject(Net.State.LotteryViewID); if (!((Object)val == (Object)null)) { bool flag = false; List list = (((Object)RoundDirector.instance != (Object)null) ? Fx.GetField>(RoundDirector.instance, "dollarHaulList") : null); if (list != null) { flag = list.Contains(val); } if (flag) { float lotteryValue = Net.State.LotteryValue; string text = ((lotteryValue >= 0f) ? $"${lotteryValue:F0}" : $"-${0f - lotteryValue:F0}"); Finish("[Lottery] Cashed out: " + text + "!"); } } } public static void HostRoundEnd() { if (Net.IsAuthority && !_finished && Net.State.LotteryViewID != -1) { float lotteryValue = Net.State.LotteryValue; string text = ((lotteryValue >= 0f) ? $"${lotteryValue:F0}" : $"-${0f - lotteryValue:F0}"); Finish("[Lottery] Expired: " + text + "."); } } private static void Finish(string message) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown _finished = true; if ((Object)ChatManager.instance != (Object)null) { ChatManager.instance.ForceSendMessage(message); } } private static void SetValueNetworked(ValuableObject valuable, float value) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown try { PhotonView component = ((Component)valuable).GetComponent(); if (SemiFunc.IsMultiplayer() && (Object)component != (Object)null) { component.RPC("DollarValueSetRPC", (RpcTarget)0, new object[1] { value }); } else { valuable.DollarValueSetRPC(value, default(PhotonMessageInfo)); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[Lottery] Value sync failed: " + ex.Message)); } } public static void Tick() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) if (!On) { return; } CarnivalState state = Net.State; if (state.LotteryViewID != _glowedID) { GameObject val = Net.FindViewObject(state.LotteryViewID); if ((Object)val != (Object)null || state.LotteryViewID == -1) { if ((Object)val != (Object)null) { Fx.Glow(val, LotteryYellow, 0.35f, 4f, 1.2f); } _glowedID = state.LotteryViewID; } } RenderCarnivalMusic(); } private static void RenderCarnivalMusic() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Expected O, but got Unknown CarnivalState state = Net.State; if (state.LotteryViewID == -1 || _musicForID == state.LotteryViewID) { return; } GameObject val = Net.FindViewObject(state.LotteryViewID); if (!((Object)val == (Object)null) && SoundBank.Carnival.Count != 0) { PhysGrabObject component = val.GetComponent(); if ((Object)component != (Object)null && ((component.playerGrabbing != null && component.playerGrabbing.Count > 0) || Fx.GetField(component, "grabbed"))) { _musicForID = state.LotteryViewID; GameObject val2 = new GameObject("ChaosCarnival.CarnivalMusic"); val2.transform.SetParent(val.transform, false); _music = val2.AddComponent(); _music.clip = SoundBank.Carnival[0]; _music.loop = false; _music.spatialBlend = 0f; _music.volume = 1f; _music.Play(); Object.Destroy((Object)val2, _music.clip.length + 0.5f); } } } public static void DecorateItemInfo(ItemAttributes attributes, ref string message) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown if (On && !((Object)attributes == (Object)null) && Net.State.LotteryViewID != -1) { PhotonView component = ((Component)attributes).GetComponent(); if (!((Object)component == (Object)null) && component.ViewID == Net.State.LotteryViewID) { float lotteryValue = Net.State.LotteryValue; message = ((lotteryValue >= 0f) ? $"Lottery Amount (${lotteryValue:F0})" : $"Lottery Amount (-${0f - lotteryValue:F0})"); } } } } public static class Meltdown { private static readonly Color ContrabandBlue = new Color(0.25f, 0.55f, 1f); private static float _nextSpawnTimer; private static float _decayTimer; private static float _startValue; private static bool _roundActive; private static int _glowedID = -1; public static bool On { get { if (Plugin.Enabled) { return Plugin.CfgMeltdown.Value; } return false; } } public static void HostRoundSetup() { if (Net.IsAuthority) { _roundActive = Plugin.FeatureRoll(); _nextSpawnTimer = (TestMode.On ? 20f : Random.Range(60f, 120f)); } } public static void HostRoundEnd() { _roundActive = false; } public static void HostTick() { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown if (!On || !Net.IsAuthority || !_roundActive) { return; } CarnivalState state = Net.State; if (state.MeltdownViewID == -1 || state.MeltdownLocked) { _nextSpawnTimer -= Time.deltaTime; if (_nextSpawnTimer <= 0f) { _nextSpawnTimer = Plugin.CfgMeltdownInterval.Value; HostDeclareContraband(); } return; } _decayTimer -= Time.deltaTime; if (_decayTimer > 0f) { return; } _decayTimer = 1f; GameObject val = Net.FindViewObject(state.MeltdownViewID); ValuableObject val2 = (((Object)val != (Object)null) ? val.GetComponent() : null); if ((Object)val2 == (Object)null) { Chat("[Contraband] The contraband was destroyed. Nobody wins."); ClearActive(); return; } float num = Mathf.Round(_startValue * 0.05f); float num2 = (state.MeltdownValue = Mathf.Max(num, Mathf.Round((state.MeltdownValue - _startValue * 0.02f) / 10f) * 10f)); SetValueNetworked(val2, num2); Net.MarkDirty(); if (num2 <= num) { Chat($"[Contraband] Melted down to scrap (${num2:F0}). Too slow!"); LockActive(); } } private static void HostDeclareContraband() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0131: 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) CarnivalState state = Net.State; ValuableObject[] array = Object.FindObjectsOfType(); if (array == null || array.Length == 0) { return; } for (int i = 0; i < 25; i++) { ValuableObject val = array[Random.Range(0, array.Length)]; PhotonView component = ((Component)val).GetComponent(); if ((Object)component == (Object)null) { continue; } int viewID = component.ViewID; if (viewID == state.CursedViewID || viewID == state.LotteryViewID || viewID == state.ToiletViewID) { continue; } PhysGrabObject component2 = ((Component)val).GetComponent(); if (!((Object)component2 != (Object)null) || !Fx.GetField(component2, "grabbed")) { _startValue = Mathf.Round(Mathf.Max(100f, Fx.GetField(val, "dollarValueOriginal")) * 2.5f / 10f) * 10f; _decayTimer = 1f; state.MeltdownViewID = viewID; state.MeltdownValue = _startValue; state.MeltdownLocked = false; Net.MarkDirty(); SetValueNetworked(val, _startValue); if (TestMode.On && TestMode.Anchor != Vector3.zero) { TestMode.Place(viewID, TestMode.Anchor + Vector3.back * 1.5f + Vector3.up * 1f); } Plugin.Log.LogInfo((object)$"[Meltdown] Contraband view {viewID}, start ${_startValue:F0}"); break; } } } public static void HostOnGrab(PhysGrabObject obj, PhysGrabber grabber) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown if (!On || !Net.IsAuthority) { return; } CarnivalState state = Net.State; if (state.MeltdownViewID == -1 || state.MeltdownLocked || (Object)obj == (Object)null) { return; } PhotonView component = ((Component)obj).GetComponent(); if (!((Object)component == (Object)null) && component.ViewID == state.MeltdownViewID) { if ((Object)(grabber?.playerAvatar) != (Object)null) { Fx.GetField(grabber.playerAvatar, "playerName"); } LockActive(); } } private static void LockActive() { Net.State.MeltdownLocked = true; Net.MarkDirty(); } private static void ClearActive() { Net.State.MeltdownViewID = -1; Net.State.MeltdownValue = 0f; Net.State.MeltdownLocked = false; Net.MarkDirty(); } private static void SetValueNetworked(ValuableObject valuable, float value) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown try { PhotonView component = ((Component)valuable).GetComponent(); if (SemiFunc.IsMultiplayer() && (Object)component != (Object)null) { component.RPC("DollarValueSetRPC", (RpcTarget)0, new object[1] { value }); } else { valuable.DollarValueSetRPC(value, default(PhotonMessageInfo)); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[Meltdown] Value sync failed: " + ex.Message)); } } private static string CleanName(string raw) { return (raw ?? "item").Replace("(Clone)", "").Replace("Valuable ", "").Trim(); } public static void Tick() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) if (!On) { return; } CarnivalState state = Net.State; if (state.MeltdownViewID == _glowedID) { return; } GameObject val = Net.FindViewObject(state.MeltdownViewID); if ((Object)val != (Object)null || state.MeltdownViewID == -1) { if ((Object)val != (Object)null) { Fx.Glow(val, ContrabandBlue, 0.35f, 4f, 1.2f); } _glowedID = state.MeltdownViewID; } } public static void DecorateItemInfo(ItemAttributes attributes, ref string message) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown if (On && !((Object)attributes == (Object)null) && Net.State.MeltdownViewID != -1) { PhotonView component = ((Component)attributes).GetComponent(); if (!((Object)component == (Object)null) && component.ViewID == Net.State.MeltdownViewID) { message = (Net.State.MeltdownLocked ? $"Contraband — LOCKED (${Net.State.MeltdownValue:F0})" : $"Contraband — MELTING (${Net.State.MeltdownValue:F0})"); } } } private static void Chat(string msg) { Net.Broadcast(msg, 6f); } } public static class Portals { private class GunPair { public bool HasExit; public bool HasEntry; public Vector3 ExitPos; public Vector3 ExitDir; public Vector3 EntryPos; public Vector3 EntryDir; public float Timeout; } private class PortalVisual { public GameObject Root; public float[] For; } private const int RecordSize = 14; private static readonly Color ExitOrange = new Color(1f, 0.55f, 0.1f); private static readonly Color EntryBlue = new Color(0.2f, 0.55f, 1f); private static readonly Dictionary _gunPairs = new Dictionary(); private static readonly Dictionary _visuals = new Dictionary(); private static float _teleportCooldown; public static bool On { get { if (Plugin.Enabled) { return Plugin.CfgPortalGun.Value; } return false; } } public static void HostOnGunShot(ItemGun gun, Vector3 endPosition) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_00a7: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: 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_00dd: 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_0108: 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_0154: 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_015d: 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_010d: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: 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_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: 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_0183: 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_018c: 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) if (!On || !Net.IsAuthority || (Object)gun == (Object)null) { return; } ItemAttributes component = ((Component)gun).GetComponent(); if (!((Object)component == (Object)null) && !((Object)component.item == (Object)null) && !(component.item.itemName != "Portal Gun")) { PhotonView component2 = ((Component)gun).GetComponent(); int key = (((Object)component2 != (Object)null) ? component2.ViewID : 0); Vector3 val = (((Object)gun.gunMuzzle != (Object)null) ? gun.gunMuzzle.position : (endPosition + Vector3.up)); Vector3 val2 = val - endPosition; Vector3 val3 = ((Vector3)(ref val2)).normalized; Vector3 val4 = endPosition + val3 * 0.15f; if (val3.y > 0.65f) { Vector3 val5 = val - endPosition; val5.y = 0f; val3 = ((((Vector3)(ref val5)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val5)).normalized : Vector3.forward); val4 = endPosition + Vector3.up * 0.95f; } if (!_gunPairs.TryGetValue(key, out var value)) { value = new GunPair(); _gunPairs[key] = value; } if (!value.HasExit) { value.ExitPos = val4; value.ExitDir = val3; value.HasExit = true; Chat("[Portal Gun] First portal placed (orange)."); } else if (!value.HasEntry) { value.EntryPos = val4; value.EntryDir = val3; value.HasEntry = true; Chat("[Portal Gun] Second portal placed (blue). This gun's portals are TWO-WAY, players only, and fade in 5 minutes."); } else { value.ExitPos = val4; value.ExitDir = val3; value.HasExit = true; value.HasEntry = false; Chat("[Portal Gun] Portals reset — new orange portal placed."); } value.Timeout = 300f; SyncPairs(); } } private static void SyncPairs() { List list = new List(); foreach (KeyValuePair gunPair in _gunPairs) { GunPair value = gunPair.Value; if (value.HasExit) { int num = (value.HasExit ? 1 : 0) | (value.HasEntry ? 2 : 0); list.Add(gunPair.Key); list.Add(num); list.Add(value.ExitPos.x); list.Add(value.ExitPos.y); list.Add(value.ExitPos.z); list.Add(value.ExitDir.x); list.Add(value.ExitDir.y); list.Add(value.ExitDir.z); list.Add(value.EntryPos.x); list.Add(value.EntryPos.y); list.Add(value.EntryPos.z); list.Add(value.EntryDir.x); list.Add(value.EntryDir.y); list.Add(value.EntryDir.z); } } Net.State.PortalData = list.ToArray(); Net.MarkDirty(); } public static void HostRoundSetup() { _gunPairs.Clear(); } public static void HostTick() { if (!Net.IsAuthority || _gunPairs.Count == 0) { return; } bool flag = false; foreach (int item in new List(_gunPairs.Keys)) { GunPair gunPair = _gunPairs[item]; if (gunPair.Timeout > 0f) { gunPair.Timeout -= Time.deltaTime; if (gunPair.Timeout <= 0f) { _gunPairs.Remove(item); flag = true; } } } if (flag) { if (_gunPairs.Count == 0) { Chat("[Portal Gun] The portals fade away."); } SyncPairs(); } } public static void Tick() { //IL_0096: 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_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Expected O, but got Unknown //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Expected O, but got Unknown if (!On) { return; } float[] portalData = Net.State.PortalData; HashSet hashSet = new HashSet(); if (portalData != null && portalData.Length >= 14) { for (int i = 0; i + 14 <= portalData.Length; i += 14) { int num = (int)portalData[i]; int num2 = (int)portalData[i + 1]; if ((num2 & 1) != 0) { string text = $"{num}:exit"; hashSet.Add(text); EnsureVisual(text, new float[6] { portalData[i + 2], portalData[i + 3], portalData[i + 4], portalData[i + 5], portalData[i + 6], portalData[i + 7] }, ExitOrange, "ChaosCarnival.PortalExit"); } if ((num2 & 2) != 0) { string text2 = $"{num}:entry"; hashSet.Add(text2); EnsureVisual(text2, new float[6] { portalData[i + 8], portalData[i + 9], portalData[i + 10], portalData[i + 11], portalData[i + 12], portalData[i + 13] }, EntryBlue, "ChaosCarnival.PortalEntry"); } } } if (_visuals.Count > 0) { List list = new List(); foreach (KeyValuePair visual in _visuals) { if (!hashSet.Contains(visual.Key)) { list.Add(visual.Key); } } foreach (string item in list) { if ((Object)_visuals[item].Root != (Object)null) { Object.Destroy((Object)_visuals[item].Root); } _visuals.Remove(item); } } TeleportTick(portalData); } private static void EnsureVisual(string id, float[] data, Color color, string name) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown //IL_00a5: 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_0066: Expected O, but got Unknown //IL_00c6: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected O, but got Unknown //IL_010e: 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_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012e: 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_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Expected O, but got Unknown //IL_0165: Unknown result type (might be due to invalid IL or missing references) if (!_visuals.TryGetValue(id, out var value) || !((Object)value.Root != (Object)null) || value.For == null || value.For[0] != data[0] || value.For[1] != data[1] || value.For[2] != data[2]) { if (value != null && (Object)value.Root != (Object)null) { Object.Destroy((Object)value.Root); } Vector3 position = default(Vector3); ((Vector3)(ref position))..ctor(data[0], data[1], data[2]); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(data[3], data[4], data[5]); GameObject val2 = new GameObject(name); val2.transform.position = position; val2.transform.rotation = Quaternion.LookRotation((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? val : Vector3.forward); GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0); Object.Destroy((Object)obj.GetComponent()); obj.transform.SetParent(val2.transform, false); obj.transform.localScale = new Vector3(1.1f, 1.6f, 0.12f); Material material = new Material(Shader.Find("Sprites/Default")) { color = new Color(color.r, color.g, color.b, 0.55f) }; obj.GetComponent().material = material; Light obj2 = val2.AddComponent(); obj2.type = (LightType)2; obj2.color = color; obj2.range = 3.5f; obj2.intensity = 2.2f; obj2.shadows = (LightShadows)0; _visuals[id] = new PortalVisual { Root = val2, For = (float[])data.Clone() }; } } private static void TeleportTick(float[] data) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_00b4: 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_00c8: 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_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) if (_teleportCooldown > 0f) { _teleportCooldown -= Time.deltaTime; } else { if (data == null || data.Length < 14) { return; } PlayerAvatar instance = PlayerAvatar.instance; if ((Object)instance == (Object)null) { return; } Vector3 position = ((Component)instance).transform.position; Vector3 val = default(Vector3); Vector3 val2 = default(Vector3); Vector3 destDir = default(Vector3); for (int i = 0; i + 14 <= data.Length; i += 14) { if (((int)data[i + 1] & 3) != 3) { continue; } ((Vector3)(ref val))..ctor(data[i + 2], data[i + 3], data[i + 4]); ((Vector3)(ref val2))..ctor(data[i + 8], data[i + 9], data[i + 10]); Vector3 destPos; Vector3 fromPos; if (Vector3.Distance(position, val2) <= 1.3f) { destPos = val; ((Vector3)(ref destDir))..ctor(data[i + 5], data[i + 6], data[i + 7]); fromPos = val2; } else { if (!(Vector3.Distance(position, val) <= 1.3f)) { continue; } destPos = val2; ((Vector3)(ref destDir))..ctor(data[i + 11], data[i + 12], data[i + 13]); fromPos = val; } DoTeleport(instance, fromPos, destPos, destDir); break; } } } private static void DoTeleport(PlayerAvatar instance, Vector3 fromPos, Vector3 destPos, Vector3 destDir) { //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_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_0011: 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_0099: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_0104: 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_0121: 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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) Vector3 val = destPos + destDir * 1f; int mask = LayerMask.GetMask(new string[2] { "Default", "Map" }); RaycastHit val3 = default(RaycastHit); if (destDir.y < -0.5f) { RaycastHit val2 = default(RaycastHit); val = ((!Physics.Raycast(destPos + Vector3.down * 0.2f, Vector3.down, ref val2, 30f, mask)) ? (destPos + Vector3.down * 2f) : (((RaycastHit)(ref val2)).point + Vector3.up * 0.05f)); } else if (Physics.Raycast(val + Vector3.up * 0.5f, Vector3.down, ref val3, 5f, mask)) { val.y = ((RaycastHit)(ref val3)).point.y + 0.05f; } try { Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(destDir.x, 0f, destDir.z); instance.Spawn(val, Quaternion.LookRotation((((Vector3)(ref val4)).sqrMagnitude > 0.01f) ? val4 : Vector3.forward)); _teleportCooldown = 2.5f; Fx.Poof(fromPos, EntryBlue, 18); Fx.Poof(val, ExitOrange, 18); Plugin.Log.LogInfo((object)"[Portal] Teleported local player through the portal safely."); } catch (Exception ex) { Plugin.Log.LogWarning((object)("[Portal] Teleport failed: " + ex.Message)); _teleportCooldown = 2.5f; } } private static void Chat(string msg) { Net.Broadcast(msg); } } public static class PowerUp { private const float BuffSeconds = 20f; private const float PenaltySeconds = 10f; private const int WingsDelta = 10; private static readonly Color HotRed = new Color(1f, 0.25f, 0.05f); private static PlayerAvatar _auraAvatar; private static float _timer; private static string _steamID = ""; private static int _appliedWingsDelta; public static bool On => Plugin.Enabled; public static bool HandleUse(ItemHealthPack pack) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //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_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Expected O, but got Unknown //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Expected O, but got Unknown //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Expected O, but got Unknown if (!On) { return false; } ItemAttributes field = Fx.GetField(pack, "itemAttributes"); if ((Object)field == (Object)null || (Object)field.item == (Object)null || field.item.itemName != "Chaos Power-Up") { return false; } if (!SemiFunc.IsMasterClientOrSingleplayer()) { return true; } ItemToggle field2 = Fx.GetField(pack, "itemToggle"); if ((Object)field2 == (Object)null || !field2.toggleState || Fx.GetField(pack, "used")) { return true; } PlayerAvatar val = SemiFunc.PlayerAvatarGetFromPhotonID(Fx.GetField(field2, "playerTogglePhotonID")); if ((Object)val == (Object)null) { return true; } try { PhotonView component = ((Component)val).GetComponent(); string arg = Fx.GetField(val, "playerName") ?? "Someone"; _steamID = Fx.GetField(val, "steamID") ?? ""; PlayerHealth playerHealth = val.playerHealth; if ((Object)(object)playerHealth != (Object)null) { playerHealth.HealOther(200, true); } SpawnRandomWeapon(((Component)val).transform.position + ((Component)val).transform.forward * 1f + Vector3.up * 0.5f); if ((Object)PunManager.instance != (Object)null && !string.IsNullOrEmpty(_steamID)) { int num = PunManager.instance.UpgradePlayerTumbleWings(_steamID, 0); _appliedWingsDelta = PunManager.instance.UpgradePlayerTumbleWings(_steamID, 10) - num; } Net.State.PowerUpViewID = (((Object)component != (Object)null) ? component.ViewID : (-1)); Net.State.PowerUpPhase = 1; Net.MarkDirty(); _timer = 20f; Chat($"[Power-Up] {arg} is RED HOT: weapon, full heal, max flight, infinite stamina and jumps for {20f:F0}s!"); string field3 = Fx.GetField(field, "instanceName"); if (!string.IsNullOrEmpty(field3)) { StatsManager instance = StatsManager.instance; if ((Object)(object)instance != (Object)null) { instance.ItemRemove(field3); } } Fx.SetField(pack, "used", true); PhotonView component2 = ((Component)pack).GetComponent(); if (SemiFunc.IsMultiplayer() && (Object)component2 != (Object)null) { component2.RPC("UsedRPC", (RpcTarget)0, Array.Empty()); } field2.ToggleDisable(true); } catch (Exception arg2) { Plugin.Log.LogError((object)$"[Power-Up] Activate failed: {arg2}"); } return true; } public static void HostTick() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown if (!On || !Net.IsAuthority || Net.State.PowerUpPhase == 0) { return; } _timer -= Time.deltaTime; if (_timer > 0f) { return; } if (Net.State.PowerUpPhase == 1) { if (_appliedWingsDelta != 0 && (Object)PunManager.instance != (Object)null && !string.IsNullOrEmpty(_steamID)) { PunManager.instance.UpgradePlayerTumbleWings(_steamID, -_appliedWingsDelta); } _appliedWingsDelta = 0; Net.State.PowerUpPhase = 2; Net.MarkDirty(); _timer = 10f; Chat($"[Power-Up] Power expired! Stamina drained for {10f:F0}s!"); } else { Net.State.PowerUpPhase = 0; Net.State.PowerUpViewID = -1; Net.MarkDirty(); Chat("[Power-Up] Penalty over. Stamina recovering."); } } private static void SpawnRandomWeapon(Vector3 pos) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0096: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Invalid comparison between Unknown and I4 //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Invalid comparison between Unknown and I4 //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Invalid comparison between Unknown and I4 List list = new List(); foreach (Item allItem in Items.AllItems) { if (!((Object)allItem == (Object)null) && !allItem.disabled && !(allItem.itemName == "Portal Gun") && ((int)allItem.itemType == 9 || (int)allItem.itemType == 7 || (int)allItem.itemType == 15)) { list.Add(allItem); } } if (list.Count != 0) { Item val = list[Random.Range(0, list.Count)]; Items.SpawnItem(val, pos, Quaternion.identity); Plugin.Log.LogInfo((object)("[Power-Up] Spawned weapon: " + val.itemName)); } } public static void Tick() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown if (!On) { RenderAura(null); return; } CarnivalState state = Net.State; RenderAura((state.PowerUpPhase == 1) ? Net.FindAvatar(state.PowerUpViewID) : null); if (state.PowerUpPhase == 0) { return; } PlayerAvatar instance = PlayerAvatar.instance; if ((Object)instance == (Object)null) { return; } PhotonView component = ((Component)instance).GetComponent(); if ((Object)component == (Object)null || component.ViewID != state.PowerUpViewID) { return; } PlayerController instance2 = PlayerController.instance; if (!((Object)instance2 == (Object)null)) { if (state.PowerUpPhase == 1) { instance2.EnergyCurrent = instance2.EnergyStart; Fx.SetField(instance2, "JumpExtraCurrent", 9); } else { instance2.EnergyCurrent = 0f; } } } private static void RenderAura(PlayerAvatar target) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_0015: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0086: 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_00ac: 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_00bc: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown if ((Object)_auraAvatar == (Object)target) { return; } if ((Object)_auraAvatar != (Object)null) { Fx.RemoveAura(((Component)_auraAvatar).gameObject); Transform val = ((Component)_auraAvatar).transform.Find("ChaosCarnival.PowerLight"); if ((Object)val != (Object)null) { Object.Destroy((Object)((Component)val).gameObject); } } _auraAvatar = target; if (!((Object)target == (Object)null)) { Fx.Aura(((Component)target).gameObject, HotRed); GameObject val2 = new GameObject("ChaosCarnival.PowerLight"); val2.transform.SetParent(((Component)target).transform, false); val2.transform.localPosition = Vector3.up * 0.8f; Light obj = val2.AddComponent(); obj.type = (LightType)2; obj.color = HotRed; obj.range = 5f; obj.intensity = 2.6f; obj.shadows = (LightShadows)0; } } private static void Chat(string msg) { Net.Broadcast(msg); } } public static class Roulette { private static readonly Color TokenGold; private static float _roundStartTime; private static float _tokenSpawnTimer; private static int _glowedTokenID; private static string _lastTokenHolder; private static bool _spinPending; private static float _spinTimer; private static float _pendingHaulValue; private static bool _inited; private static float _sacrificeTimer; private static int _sacrificeViewID; private static string _sacrificeName; private static float _outbreakFartTimer; private static float _outbreakJitterTimer; private static float _outbreakHostTimer; private static GameObject _outbreakFartGO; public static bool On { get { if (Plugin.Enabled) { return Plugin.CfgRoulette.Value; } return false; } } public static void Init() { if (_inited) { return; } _inited = true; Net.OnPing += delegate(int type, Vector3 pos) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown if (type == 1) { Hud.StartSpin(8.4f); if (SoundBank.Roulette.Count != 0) { GameObject val = new GameObject("ChaosCarnival.RouletteSpin"); AudioSource val2 = val.AddComponent(); val2.clip = SoundBank.Roulette[0]; val2.spatialBlend = 0f; val2.volume = 0.95f; val2.Play(); Object.Destroy((Object)val, val2.clip.length + 0.5f); } } }; } static Roulette() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) _sacrificeViewID = -1; _sacrificeName = "Someone"; TokenGold = new Color(1f, 0.85f, 0.15f); _glowedTokenID = -1; _lastTokenHolder = "Someone"; Init(); } public static void HostOnGrab(PhysGrabObject obj, PhysGrabber grabber) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown if (!Net.IsAuthority || (Object)obj == (Object)null || (Object)(grabber?.playerAvatar) == (Object)null || Net.State.TokenViewID == -1) { return; } PhotonView component = ((Component)obj).GetComponent(); if (!((Object)component == (Object)null) && component.ViewID == Net.State.TokenViewID) { Rigidbody val = ((Component)obj).GetComponent() ?? ((Component)obj).GetComponentInChildren(); if ((Object)val != (Object)null && val.isKinematic) { val.isKinematic = false; } string text = Fx.GetField(grabber.playerAvatar, "playerName") ?? "Someone"; if (_lastTokenHolder == "Someone") { Net.Broadcast(text + " found the Barker's Token... feeling lucky?!", 6f); } _lastTokenHolder = text; } } public static void HostRoundSetup() { _roundStartTime = Time.time; _tokenSpawnTimer = (Plugin.FeatureRoll() ? 6f : (-1f)); _spinPending = false; _lastTokenHolder = "Someone"; _sacrificeViewID = -1; _sacrificeTimer = 0f; _outbreakHostTimer = 0f; if (Net.State != null) { Net.State.RouletteOutbreak = 0; } } public static void HostTick() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Expected O, but got Unknown //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Expected O, but got Unknown //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Expected O, but got Unknown //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Expected O, but got Unknown //IL_0180: 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_0194: 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_01de: Unknown result type (might be due to invalid IL or missing references) if (!On || !Net.IsAuthority) { return; } TickPendingSpin(); HostTickSacrifice(); HostTickOutbreak(); if (_tokenSpawnTimer <= 0f) { return; } _tokenSpawnTimer -= Time.deltaTime; if (_tokenSpawnTimer > 0f) { return; } _tokenSpawnTimer = -999f; try { PlayerAvatar instance = PlayerAvatar.instance; if ((Object)instance == (Object)null) { _tokenSpawnTimer = 2f; return; } PrefabRef val = null; foreach (PrefabRef allValuable in Valuables.AllValuables) { if (allValuable != null && (Object)((PrefabRef)(object)allValuable).Prefab != (Object)null) { val = allValuable; break; } } if (val == null) { return; } Vector3 val2 = ((Component)instance).transform.position + ((Component)instance).transform.forward * 1.5f + Vector3.up * 0.8f; GameObject val3 = Valuables.SpawnValuable(val, val2, Quaternion.identity); if ((Object)val3 == (Object)null) { return; } ValuableObject component = val3.GetComponent(); PhotonView component2 = val3.GetComponent(); if ((Object)component != (Object)null && (Object)component2 != (Object)null) { Rigidbody val4 = val3.GetComponent() ?? val3.GetComponentInChildren(); if ((Object)val4 != (Object)null) { val4.position = val2; val4.velocity = Vector3.zero; val4.angularVelocity = Vector3.zero; val4.isKinematic = true; } if (SemiFunc.IsMultiplayer()) { component2.RPC("DollarValueSetRPC", (RpcTarget)0, new object[1] { 100f }); } else { component.DollarValueSetRPC(100f, default(PhotonMessageInfo)); } Net.State.TokenViewID = component2.ViewID; Net.MarkDirty(); Chat("[The Barker] Psst. See my golden token? Toss it in with your haul... and the wheel shall spin. Or don't. Coward."); Plugin.Log.LogInfo((object)$"[Roulette] Barker token spawned (view {component2.ViewID})."); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[Roulette] Token spawn failed: " + ex.Message)); } } public static void Tick() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) if (Plugin.Enabled) { TickLocalOutbreak(); } if (!On) { return; } int tokenViewID = Net.State.TokenViewID; if (tokenViewID == _glowedTokenID) { return; } GameObject val = Net.FindViewObject(tokenViewID); if ((Object)val != (Object)null || tokenViewID == -1) { if ((Object)val != (Object)null) { Fx.Glow(val, TokenGold, 2.2f, 4f, 2.5f); } _glowedTokenID = tokenViewID; } } public static void HostOnExtraction() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown if (!On || !Net.IsAuthority || Time.time - _roundStartTime < 30f) { return; } List list = (((Object)RoundDirector.instance != (Object)null) ? Fx.GetField>(RoundDirector.instance, "dollarHaulList") : null); if (list == null || list.Count == 0) { return; } int tokenViewID = Net.State.TokenViewID; if (tokenViewID == -1) { return; } bool flag = false; foreach (GameObject item in list) { if (!((Object)item == (Object)null)) { PhotonView component = item.GetComponent(); if ((Object)component != (Object)null && component.ViewID == tokenViewID) { flag = true; break; } } } if (!flag) { return; } _pendingHaulValue = 0f; foreach (GameObject item2 in list) { ValuableObject val = (((Object)item2 != (Object)null) ? item2.GetComponent() : null); if ((Object)val != (Object)null) { _pendingHaulValue += Fx.GetField(val, "dollarValueCurrent"); } } Net.State.TokenViewID = -1; Net.MarkDirty(); Net.Broadcast(_lastTokenHolder + " has engaged ROULETTE MODE!", 8f); Net.SendPing(1, Vector3.zero); _spinPending = true; _spinTimer = 8.5f; } private static void TickPendingSpin() { if (_spinPending) { _spinTimer -= Time.deltaTime; if (!(_spinTimer > 0f)) { _spinPending = false; ResolveSpin(); } } } private static void ResolveSpin() { try { float value = Random.value; if (value < 0.1f) { AdjustHaul(2f, "JACKPOT!! The haul pays DOUBLE"); } else if (value < 0.21f) { AdjustHaul(1.5f, "Winner! The haul pays x1.5"); } else if (value < 0.31f) { Net.Broadcast("The wheel lands on... nothing. The house smiles.", 5f); } else if (value < 0.43f) { AdjustHaul(0.75f, "Carnival tax. The haul pays x0.75"); } else if (value < 0.5f) { AdjustHaul(0.5f, "BUST. Half the haul evaporates"); } else if (value < 0.57f) { MonsterNap(); } else if (value < 0.64f) { HealingWave(); } else if (value < 0.69f) { Bankrupt(); } else if (value < 0.74f) { Sacrifice(); } else if (value < 0.8f) { StartOutbreak(1); } else if (value < 0.85f) { GoldenRain(); } else if (value < 0.91f) { LightsOut(); } else if (value < 0.95f) { GraveRobber(); } else { StartOutbreak(2); } } catch (Exception arg) { Plugin.Log.LogError((object)$"[Roulette] Spin resolve failed: {arg}"); } } private static void AdjustHaul(float mult, string message) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown int num = Mathf.RoundToInt(_pendingHaulValue * (mult - 1f)); if ((Object)RoundDirector.instance != (Object)null && num != 0) { int field = Fx.GetField(RoundDirector.instance, "currentHaul"); Fx.SetField(RoundDirector.instance, "currentHaul", field + num); } string arg = ((num >= 0) ? "+" : "-"); Net.Broadcast($"{message} ({arg}${Mathf.Abs(num)})!", 6f); Plugin.Log.LogInfo((object)$"[Roulette] Resolved x{mult}: delta ${num} on ${_pendingHaulValue:F0} haul."); } private static void ApplyHaulMultiplier(float mult, string message) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown List list = (((Object)RoundDirector.instance != (Object)null) ? Fx.GetField>(RoundDirector.instance, "dollarHaulList") : null); if (list == null || list.Count == 0) { Chat(message + " (haul empty)"); return; } float num = 0f; foreach (GameObject item in list) { if ((Object)item == (Object)null) { continue; } ValuableObject component = item.GetComponent(); if (!((Object)component == (Object)null)) { float field = Fx.GetField(component, "dollarValueCurrent"); float num2 = Mathf.Round(field * mult); num += num2 - field; PhotonView component2 = ((Component)component).GetComponent(); if (SemiFunc.IsMultiplayer() && (Object)component2 != (Object)null) { component2.RPC("DollarValueSetRPC", (RpcTarget)0, new object[1] { num2 }); } else { component.DollarValueSetRPC(num2, default(PhotonMessageInfo)); } } } if ((Object)RoundDirector.instance != (Object)null && Mathf.Abs(num) > 0.5f) { int field2 = Fx.GetField(RoundDirector.instance, "currentHaul"); Fx.SetField(RoundDirector.instance, "currentHaul", field2 + Mathf.RoundToInt(num)); } Chat(message); Plugin.Log.LogInfo((object)$"[Roulette] Haul x{mult} (delta ${num:F0}, {list.Count} items)."); } private static void MonsterNap() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown int num = 0; Enemy[] array = Object.FindObjectsOfType(); foreach (Enemy val in array) { if (!((Object)val == (Object)null)) { try { val.Freeze(30f); num++; } catch { } } } Net.Broadcast($"MONSTER NAP! Every creature sleeps for 30 seconds. ({num} down)", 6f); } private static void HealingWave() { PlayerAvatar[] array = Object.FindObjectsOfType(); foreach (PlayerAvatar val in array) { try { if ((Object)(object)val != (Object)null) { PlayerHealth playerHealth = val.playerHealth; if ((Object)(object)playerHealth != (Object)null) { playerHealth.HealOther(100, true); } } } catch { } } Net.Broadcast("HEALING WAVE! The carnival loves you. Everyone patched up.", 6f); } private static void Bankrupt() { AdjustHaul(0f, "BANKRUPT! The house takes EVERYTHING"); } private static void Sacrifice() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown List list = new List(); PlayerAvatar[] array = Object.FindObjectsOfType(); foreach (PlayerAvatar val in array) { if (!((Object)val == (Object)null) && (((Object)val.playerHealth != (Object)null && Fx.GetField(val.playerHealth, "health") != 0) ? 1 : 0) > (false ? 1 : 0)) { list.Add(val); } } if (list.Count == 0) { Net.Broadcast("The House demanded a sacrifice... but found no one alive to take.", 6f); return; } PlayerAvatar obj = list[Random.Range(0, list.Count)]; PhotonView component = ((Component)obj).GetComponent(); _sacrificeViewID = (((Object)component != (Object)null) ? component.ViewID : (-1)); _sacrificeName = Fx.GetField(obj, "playerName") ?? "Someone"; _sacrificeTimer = 15f; Net.Broadcast("THE HOUSE DEMANDS A SACRIFICE! " + _sacrificeName + " self-destructs in 15 seconds. Their death pays out $20,000!", 8f); } private static void HostTickSacrifice() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown if (_sacrificeViewID == -1) { return; } _sacrificeTimer -= Time.deltaTime; PlayerAvatar val = Net.FindAvatar(_sacrificeViewID); if ((Object)val == (Object)null) { _sacrificeViewID = -1; } else if ((((Object)val.playerHealth != (Object)null && Fx.GetField(val.playerHealth, "health") != 0) ? 1 : 0) <= (false ? 1 : 0)) { PayoutSacrifice(died: true); } else { if (!(_sacrificeTimer <= 0f)) { return; } try { if ((Object)val.playerHealth != (Object)null) { val.playerHealth.Hurt(999, false, -1, false); } } catch { } PayoutSacrifice(died: true); } } private static void PayoutSacrifice(bool died) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown _ = _sacrificeViewID; _sacrificeViewID = -1; _sacrificeTimer = 0f; if (died) { if ((Object)RoundDirector.instance != (Object)null) { int field = Fx.GetField(RoundDirector.instance, "currentHaul"); Fx.SetField(RoundDirector.instance, "currentHaul", field + 20000); } Net.Broadcast(_sacrificeName + " paid the ultimate price! The House cashes in +$20,000.", 7f); } } private static void StartOutbreak(int kind) { Net.State.RouletteOutbreak = kind; _outbreakHostTimer = ((kind == 1) ? 12f : 10f); Net.MarkDirty(); if (kind == 1) { Net.Broadcast("BUBBLE GUTS OUTBREAK! The whole crew is ripping ass!", 7f); } else { Net.Broadcast("JITTER OUTBREAK! Everyone's legs stop taking orders!", 7f); } } private static void HostTickOutbreak() { if (Net.State.RouletteOutbreak != 0) { _outbreakHostTimer -= Time.deltaTime; if (_outbreakHostTimer <= 0f) { Net.State.RouletteOutbreak = 0; Net.MarkDirty(); } } } private static void GoldenRain() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_00a3: 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_00cb: 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_00d5: 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_00d9: 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_00ee: Expected O, but got Unknown try { IReadOnlyList allValuables = Valuables.AllValuables; if (allValuables == null || allValuables.Count == 0) { Net.Broadcast("Golden Rain fizzled — the carnival is out of prizes.", 5f); return; } List list = new List(); PlayerAvatar[] array = Object.FindObjectsOfType(); foreach (PlayerAvatar val in array) { if ((Object)val != (Object)null) { list.Add(val); } } int num = 0; for (int j = 0; j < 4; j++) { PrefabRef obj = allValuables[Random.Range(0, allValuables.Count)]; Vector3 val2 = ((list.Count > 0) ? ((Component)list[Random.Range(0, list.Count)]).transform.position : Vector3.zero) + new Vector3(Random.Range(-2f, 2f), 1.5f, Random.Range(-2f, 2f)); if ((Object)Valuables.SpawnValuable(obj, val2, Quaternion.identity) != (Object)null) { num++; } } Net.Broadcast($"GOLDEN RAIN! {num} fresh valuables rain down on the crew!", 7f); } catch (Exception arg) { Plugin.Log.LogError((object)$"[Roulette] Golden Rain failed: {arg}"); Net.Broadcast("Golden Rain sputtered out.", 5f); } } private static void LightsOut() { Net.State.BlackoutActive = true; Net.MarkDirty(); Net.Broadcast("LIGHTS OUT! The carnival cuts the power. Loot glows; something hunts.", 7f); } private static void GraveRobber() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown int num = 0; PlayerDeathHead[] array = Object.FindObjectsOfType(); foreach (PlayerDeathHead val in array) { if ((Object)val == (Object)null || (Object)val.playerAvatar == (Object)null) { continue; } try { PlayerAvatar playerAvatar = val.playerAvatar; playerAvatar.Revive(false); if ((Object)playerAvatar.playerHealth != (Object)null) { playerAvatar.playerHealth.HealOther(100, true); } num++; } catch { } } Net.Broadcast($"GRAVE ROBBER! The carnival drags {num} fallen crew back to life!", 7f); } private static void TickLocalOutbreak() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Expected O, but got Unknown //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: 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_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: 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_00dd: Expected O, but got Unknown //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Expected O, but got Unknown //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Expected O, but got Unknown int rouletteOutbreak = Net.State.RouletteOutbreak; if (rouletteOutbreak == 0) { return; } PlayerAvatar instance = PlayerAvatar.instance; if ((Object)instance == (Object)null) { return; } switch (rouletteOutbreak) { case 1: { if ((Object)_outbreakFartGO != (Object)null) { break; } _outbreakFartTimer -= Time.deltaTime; if (_outbreakFartTimer > 0f) { break; } AudioClip val = SoundBank.RandomFart(); if ((Object)val == (Object)null) { break; } float num = ((val.length > 0f) ? val.length : 2f); _outbreakFartTimer = num + Random.Range(1.5f, 3.5f); PlayerVoiceChat field = Fx.GetField(instance, "voiceChat"); Transform val2 = (((Object)field != (Object)null) ? ((Component)field).transform : ((Component)instance).transform); _outbreakFartGO = new GameObject("ChaosCarnival.OutbreakFart"); _outbreakFartGO.transform.SetParent(val2, false); AudioSource val3 = _outbreakFartGO.AddComponent(); val3.clip = val; val3.spatialBlend = 0f; val3.pitch = Random.Range(0.9f, 1.15f); val3.volume = Random.Range(0.85f, 1.1f); val3.Play(); Object.Destroy((Object)_outbreakFartGO, num + 0.2f); if (!Plugin.CfgVoiceVibrato.Value || !((Object)field != (Object)null)) { break; } try { field.OverridePitch(0.72f, 0.06f, 0.15f, num / val3.pitch, 0.16f, 26f); break; } catch { break; } } case 2: { PlayerController instance2 = PlayerController.instance; if ((Object)instance2 == (Object)null) { break; } if ((Object)instance2.rb != (Object)null) { Vector2 insideUnitCircle = Random.insideUnitCircle; instance2.rb.AddForce(new Vector3(insideUnitCircle.x, Random.Range(-0.05f, 0.2f), insideUnitCircle.y) * 0.22f, (ForceMode)2); } GameDirector instance3 = GameDirector.instance; if ((Object)(object)instance3 != (Object)null) { CameraShake cameraShake = instance3.CameraShake; if ((Object)(object)cameraShake != (Object)null) { cameraShake.Shake(1.1f, 0.1f); } } _outbreakJitterTimer -= Time.deltaTime; if (!(_outbreakJitterTimer > 0f)) { _outbreakJitterTimer = Random.Range(0.9f, 2.2f); instance2.OverrideSpeed(Random.Range(0.3f, 2.2f), 0.7f); if ((Object)instance2.rb != (Object)null) { Vector2 insideUnitCircle2 = Random.insideUnitCircle; Vector2 normalized = ((Vector2)(ref insideUnitCircle2)).normalized; instance2.rb.AddForce(new Vector3(normalized.x, 0.2f, normalized.y) * Random.Range(2.5f, 4.5f), (ForceMode)2); } } break; } } } public static void DecorateItemInfo(ItemAttributes attributes, ref string message) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown if (On && !((Object)attributes == (Object)null) && Net.State.TokenViewID != -1) { PhotonView component = ((Component)attributes).GetComponent(); if (!((Object)component == (Object)null) && component.ViewID == Net.State.TokenViewID) { message = "Barker's Golden Token (Roulette)"; } } } private static void Chat(string msg) { Net.Broadcast(msg, 6f); } } public static class Snitch { private static readonly Color SnitchRed; private static float _screamTimer; private static int _screamCount; private static bool _warned; private static bool _unmasked; public static bool On { get { if (Plugin.Enabled) { return Plugin.CfgSnitch.Value; } return false; } } static Snitch() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) SnitchRed = new Color(1f, 0.15f, 0.1f); Net.OnPing += delegate(int type, Vector3 pos) { //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) if (type == 0) { Fx.Poof(pos, SnitchRed, 14); } }; } public static void HostRoundSetup() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown if (!On || !Net.IsAuthority) { return; } _screamTimer = 0f; _screamCount = 0; _warned = (_unmasked = false); if (!Plugin.FeatureRoll()) { return; } ValuableObject[] array = Object.FindObjectsOfType(); if (array == null || array.Length < 4) { return; } for (int i = 0; i < 25; i++) { ValuableObject val = array[Random.Range(0, array.Length)]; PhotonView component = ((Component)val).GetComponent(); if (!((Object)component == (Object)null)) { int viewID = component.ViewID; CarnivalState state = Net.State; if (viewID != state.CursedViewID && viewID != state.LotteryViewID && viewID != state.ToiletViewID && viewID != state.MeltdownViewID) { state.SnitchViewID = viewID; Net.MarkDirty(); Plugin.Log.LogInfo((object)$"[Snitch] \"{((Object)val).name}\" (view {viewID}) is the snitch. Shhh."); break; } } } } public static void HostTick() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) if (!On || !Net.IsAuthority || Net.State.SnitchViewID == -1) { return; } GameObject val = Net.FindViewObject(Net.State.SnitchViewID); if ((Object)val == (Object)null) { return; } PhysGrabObject component = val.GetComponent(); if (!((Object)component != (Object)null) || !Fx.GetField(component, "grabbed")) { _screamTimer = Random.Range(6f, 10f); return; } _screamTimer -= Time.deltaTime; if (!(_screamTimer > 0f)) { _screamTimer = Random.Range(7f, 12f); _screamCount++; Net.SendPing(0, val.transform.position + Vector3.up * 0.5f); try { SemiFunc.EnemyInvestigate(val.transform.position, 40f, false); } catch { } if (!_warned) { _warned = true; Chat("[Snitch] Something is ratting you out!"); } else if (!_unmasked && _screamCount >= Plugin.CfgSnitchUnmaskAfter.Value) { _unmasked = true; Chat("[Snitch] Unmasked: \"" + CleanName(((Object)val).name) + "\"!"); } Plugin.Log.LogInfo((object)$"[Snitch] Scream #{_screamCount} at {val.transform.position}."); } } private static string CleanName(string raw) { return (raw ?? "item").Replace("(Clone)", "").Replace("Valuable ", "").Trim(); } private static void Chat(string msg) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown if ((Object)ChatManager.instance != (Object)null) { ChatManager.instance.ForceSendMessage(msg); } } } public static class WeenieBox { private static readonly Color WeeniePink = new Color(1f, 0.4f, 0.6f); public static float DeployingTimer = 0f; private static bool _insideBoxProne; public static void Tick() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_005d: 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) if (!Plugin.Enabled) { return; } if (DeployingTimer > 0f) { DeployingTimer -= Time.deltaTime; } PlayerAvatar instance = PlayerAvatar.instance; if ((Object)instance == (Object)null) { return; } bool flag = false; if (Fx.GetField(instance, "isCrawling")) { WeenieBoxController[] array = Object.FindObjectsOfType(); foreach (WeenieBoxController weenieBoxController in array) { if (Vector3.Distance(((Component)instance).transform.position, ((Component)weenieBoxController).transform.position) < 2f) { flag = true; break; } } } if (flag && !_insideBoxProne) { _insideBoxProne = true; Chat("I sooo scared. I am a weenie."); } else if (!flag && _insideBoxProne) { _insideBoxProne = false; } } public static bool BlockLocalDamage(PlayerHealth health) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Enabled) { return true; } try { PhotonView component = ((Component)health).GetComponent(); if ((Object)component != (Object)null && SemiFunc.IsMultiplayer() && !component.IsMine) { return true; } PlayerAvatar field = Fx.GetField(health, "playerAvatar"); if ((Object)field == (Object)null) { return true; } if (!Fx.GetField(field, "isCrawling")) { return true; } WeenieBoxController[] array = Object.FindObjectsOfType(); foreach (WeenieBoxController weenieBoxController in array) { if (Vector3.Distance(((Component)field).transform.position, ((Component)weenieBoxController).transform.position) < 2f) { return false; } } } catch { } return true; } public static bool BlockChaseTarget(Enemy enemy, PlayerAvatar target) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Enabled || (Object)target == (Object)null) { return true; } if (!Fx.GetField(target, "isCrawling")) { return true; } WeenieBoxController[] array = Object.FindObjectsOfType(); foreach (WeenieBoxController weenieBoxController in array) { if (Vector3.Distance(((Component)target).transform.position, ((Component)weenieBoxController).transform.position) < 2f) { Fx.SetField(enemy, "TargetPlayerAvatar", null); Fx.SetField(enemy, "TargetPlayerViewID", 0); return false; } } return true; } public static bool HandleUse(ItemHealthPack pack) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Expected O, but got Unknown //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Enabled) { return false; } if (!CustomItems.IsWeenieBox(Fx.GetField(pack, "itemAttributes"))) { return false; } ItemToggle field = Fx.GetField(pack, "itemToggle"); if ((Object)field == (Object)null || !field.toggleState) { return false; } if (Fx.GetField(pack, "used")) { return true; } PlayerAvatar val = SemiFunc.PlayerAvatarGetFromPhotonID(Fx.GetField(field, "playerTogglePhotonID")); if ((Object)val == (Object)null) { return false; } if (SemiFunc.IsMasterClientOrSingleplayer()) { Item cartItem = CustomItems.GetCartItem(); if ((Object)cartItem != (Object)null) { Vector3 val2 = ((Component)val).transform.position + ((Component)val).transform.forward * 1.5f + Vector3.up * 0.5f; DeployingTimer = 0.8f; if ((Object)Items.SpawnItem(cartItem, val2, Quaternion.identity) != (Object)null) { Plugin.Log.LogInfo((object)$"[Weenie] Deployed Weenie Box physical cart at {val2}"); } } } Fx.SetField(pack, "used", true); PhotonView component = ((Component)pack).GetComponent(); if ((Object)component != (Object)null && component.IsMine) { PhotonNetwork.Destroy(((Component)pack).gameObject); } else if (!SemiFunc.IsMultiplayer()) { Object.Destroy((Object)((Component)pack).gameObject); } return true; } private static void Chat(string msg) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown if ((Object)ChatManager.instance != (Object)null) { ChatManager.instance.ForceSendMessage(msg); } } } public class WeenieBoxController : MonoBehaviour { private float _lifetime = 900f; private void Start() { //IL_0015: 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_0032: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_003c: 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_0082: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.localScale = new Vector3(1f, 1f, 1f); Rigidbody component = ((Component)this).GetComponent(); if ((Object)component != (Object)null) { component.isKinematic = true; component.velocity = Vector3.zero; component.angularVelocity = Vector3.zero; } PhysGrabObject component2 = ((Component)this).GetComponent(); if ((Object)component2 != (Object)null) { ((Behaviour)component2).enabled = false; } Fx.Glow(((Component)this).gameObject, new Color(1f, 0.4f, 0.6f), 0.35f, 5f, 1.5f); } private void Update() { //IL_0025: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown _lifetime -= Time.deltaTime; if (_lifetime <= 0f) { Fx.Poof(((Component)this).transform.position, new Color(1f, 0.4f, 0.6f)); if (PhotonNetwork.IsMasterClient) { PhotonNetwork.Destroy(((Component)this).gameObject); } else if (!SemiFunc.IsMultiplayer()) { Object.Destroy((Object)((Component)this).gameObject); } } } } }