Decompiled source of GangBeastsChaosMod v3.0.1
Mod/GangBeastsChaos.dll
Decompiled 19 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using GangBeastsChaos; using Il2CppInterop.Runtime.InteropTypes.Arrays; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(ChaosMod), "Gang Beasts Chaos Mod", "3.0.1", "Mr Dude", null)] [assembly: MelonGame("Boneloaf", "Gang Beasts")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("GangBeastsChaos")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+553fedae83af96cf2662977cff16d1c98d810234")] [assembly: AssemblyProduct("GangBeastsChaos")] [assembly: AssemblyTitle("GangBeastsChaos")] [assembly: AssemblyVersion("1.0.0.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 GangBeastsChaos { public class ChaosMod : MelonMod { [Flags] private enum Need { None = 0, Bodies = 1, Lights = 2, Sources = 4, Colliders = 8, Tints = 0x10, Beasts = 0x20 } private class ChaosEffect { public string Category; public string Name; public string Group; public float DurMul = 1f; public Need Needs; public Action OnStart; public Action OnTick; public Action OnLate; public Action OnStop; } private class ActiveEffect { public ChaosEffect Effect; public float EndsAt; public float Duration; public bool Verified; public int Ticks; } private class Cache { public Action Scan; public float LastAt = -999f; public float Min = 1.5f; public float Interval = 1.5f; public float LastMs; public bool HasData; } private class ColliderSwap { public Collider C; public PhysicMaterial Orig; } private class Tint { public Renderer R; public string Prop; } private class Flame { public Transform Follow; public Rigidbody Body; public GameObject Obj; public Light Lamp; } private class Solid { public Rigidbody Rb; public Collider Col; public float Mass; public float Reach; } private float _interval = 25f; private float _duration = 45f; private float _firstDelay = 2f; private int _maxActive = 4; private bool _startOn; private const string Version = "3.0.1"; private bool _showHud = true; private bool _pauseInMenus = true; private bool _playerOnly = true; private string _hudCorner = "BottomRight"; private float _hudScale = 1f; private string[] _menuWords = new string[7] { "menu", "lobby", "boot", "load", "splash", "select", "customi" }; private KeyCode _kToggle = (KeyCode)287; private KeyCode _kNow = (KeyCode)284; private KeyCode _kClear = (KeyCode)290; private KeyCode _kHud = (KeyCode)285; private readonly HashSet<string> _disabled = new HashSet<string>(); private bool _enabled; private bool _hudOn = true; private float _nextEffectAt; private float _span = 25f; private string _sceneName = ""; private bool _sceneIsMenu = true; private float _offHintUntil; private ChaosEffect _next; private readonly List<string> _recent = new List<string>(); private readonly List<ChaosEffect> _all = new List<ChaosEffect>(); private readonly List<ActiveEffect> _active = new List<ActiveEffect>(); private readonly HashSet<string> _errLogged = new HashSet<string>(); private readonly Random _rng = new Random(); private float _fps = 60f; private float _worstWin; private float _worst; private float _worstAt; private float _modMs; private float _lastStartMs; private float _lastStartAt = -999f; private int _hit; private GUIStyle _style; private GUIStyle _big; private string _toast = ""; private float _toastAt = -999f; private Color _toastColor = Color.white; private string _status = ""; private float _statusAt = -999f; private float _statusLen = 2.5f; private Color _statusColor = Color.white; private readonly List<Transform> _beastRoots = new List<Transform>(); private readonly List<Rigidbody> _beastBodies = new List<Rigidbody>(); private int _dynCount; private List<Transform> _playerRoots = new List<Transform>(); private float _playerAt = -999f; private int _playerFallbackId; private Cache _cBodies; private Cache _cLights; private Cache _cSources; private Cache _cColliders; private Cache _cTints; private Rigidbody[] _bodies = (Rigidbody[])(object)new Rigidbody[0]; private Light[] _lights = (Light[])(object)new Light[0]; private AudioSource[] _sources = (AudioSource[])(object)new AudioSource[0]; private Collider[] _colliders = (Collider[])(object)new Collider[0]; private bool _legacyOk = true; private readonly HashSet<KeyCode> _held = new HashSet<KeyCode>(); private readonly HashSet<KeyCode> _pending = new HashSet<KeyCode>(); private GUIStyle _barStyle; private bool _textBars; private bool _gravTouched; private Vector3 _gravBase; private bool _timeTouched; private float _timeBase = 1f; private Vector3 _rollG; private readonly List<Rigidbody> _pBodies = new List<Rigidbody>(); private readonly List<float> _pMass = new List<float>(); private readonly List<float> _pDrag = new List<float>(); private readonly List<float> _pAngDrag = new List<float>(); private readonly List<Transform> _roots = new List<Transform>(); private readonly List<Vector3> _rootScale = new List<Vector3>(); private readonly List<ColliderSwap> _swaps = new List<ColliderSwap>(); private PhysicMaterial _chaosMat; private PhysicMaterial _ballMat; private float _fovBase = 60f; private bool _fovHeld; private Camera _cam; private readonly List<Light> _lsRef = new List<Light>(); private readonly List<Color> _lsColor = new List<Color>(); private readonly List<float> _lsIntensity = new List<float>(); private bool _fogHeld; private bool _fogWasOn; private Color _fogWasColor; private float _fogWasDensity; private FogMode _fogWasMode; private readonly List<Tint> _tints = new List<Tint>(); private MaterialPropertyBlock _block; private float _neonHue; private readonly List<AudioSource> _asRef = new List<AudioSource>(); private readonly List<float> _asPitch = new List<float>(); private float _volBase = 1f; private bool _volHeld; private readonly List<GameObject> _spawned = new List<GameObject>(); private MaterialPropertyBlock _propBlock; private Material _propMat; private bool _propMatTried; private readonly List<Flame> _flames = new List<Flame>(); private readonly List<Rigidbody> _bots = new List<Rigidbody>(); private List<Transform> _botTargets = new List<Transform>(); private readonly List<Vector3> _botPos = new List<Vector3>(); private readonly List<Solid> _solids = new List<Solid>(); private readonly List<Vector3> _solidPos = new List<Vector3>(); private readonly List<Vector3> _bodyPos = new List<Vector3>(); public override void OnInitializeMelon() { LoadConfig(); SetupCaches(); BuildEffects(); if (_disabled.Count > 0) { _all.RemoveAll((ChaosEffect e) => _disabled.Contains(e.Name)); } _enabled = _startOn; _hudOn = _showHud; ScheduleNext(_firstDelay); _next = PickNext(); _offHintUntil = Time.unscaledTime + 30f; ((MelonBase)this).LoggerInstance.Msg("Chaos Mod 3.0.1 loaded with " + _all.Count + " effects. " + ((object)Unsafe.As<KeyCode, KeyCode>(ref _kToggle)/*cast due to .constrained prefix*/).ToString() + " = chaos on/off, " + ((object)Unsafe.As<KeyCode, KeyCode>(ref _kNow)/*cast due to .constrained prefix*/).ToString() + " = chaos now, " + ((object)Unsafe.As<KeyCode, KeyCode>(ref _kClear)/*cast due to .constrained prefix*/).ToString() + " = clear, " + ((object)Unsafe.As<KeyCode, KeyCode>(ref _kHud)/*cast due to .constrained prefix*/).ToString() + " = bars."); } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { _sceneName = sceneName ?? ""; _sceneIsMenu = LooksLikeMenu(_sceneName); ((MelonBase)this).LoggerInstance.Msg("Scene '" + _sceneName + "' -> " + (_sceneIsMenu ? "MENU (chaos paused)" : "MATCH (chaos can run)")); _fovHeld = false; _fogHeld = false; ClearAll(); InvalidateCaches(); ScheduleNext(_firstDelay); _next = PickNext(); } private bool LooksLikeMenu(string scene) { if (string.IsNullOrEmpty(scene)) { return true; } string text = scene.ToLowerInvariant(); for (int i = 0; i < _menuWords.Length; i++) { if (_menuWords[i].Length > 0 && text.Contains(_menuWords[i])) { return true; } } return false; } public override void OnUpdate() { Stopwatch stopwatch = Stopwatch.StartNew(); try { UpdateInner(); } catch (Exception ex) { if (_errLogged.Add("update")) { ((MelonBase)this).LoggerInstance.Error("Chaos update failed: " + ex); } } stopwatch.Stop(); TrackFrame((float)stopwatch.Elapsed.TotalMilliseconds); } private void TrackFrame(float modMs) { float unscaledDeltaTime = Time.unscaledDeltaTime; float unscaledTime = Time.unscaledTime; if (unscaledDeltaTime > 0.0001f) { _fps = Mathf.Lerp(_fps, 1f / unscaledDeltaTime, 0.05f); } _modMs = Mathf.Lerp(_modMs, modMs, 0.1f); float num = unscaledDeltaTime * 1000f; if (num > _worstWin) { _worstWin = num; } if (unscaledTime - _worstAt > 5f) { _worst = _worstWin; _worstWin = 0f; _worstAt = unscaledTime; } if (num > 400f && unscaledTime - _lastStartAt < 2f) { ((MelonBase)this).LoggerInstance.Warning("Frame hitch of " + (int)num + " ms right after an effect started (mod part of this frame: " + (int)modMs + " ms)."); } } private void SetEnabled(bool on) { //IL_002a: 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_006e: Unknown result type (might be due to invalid IL or missing references) _enabled = on; if (!on) { ClearAll(); Status("CHAOS MOD OFF", new Color(1f, 0.3f, 0.25f, 1f), 2.5f); _offHintUntil = Time.unscaledTime + 3f; } else if (IsPaused()) { Status("CHAOS MOD ON v3.0.1 (starts when a match begins)", new Color(0.35f, 1f, 0.4f, 1f), 3.5f); ScheduleNext(_firstDelay); } else { Status("CHAOS MOD ON v3.0.1", new Color(0.35f, 1f, 0.4f, 1f), 2.5f); TriggerNow(); ScheduleNext(_interval); } ((MelonBase)this).LoggerInstance.Msg("Chaos mod " + (on ? "ON" : "OFF") + " (scene '" + _sceneName + "', " + (IsPaused() ? "menu" : "match") + ")"); } private void Status(string text, Color col, float seconds) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) _status = text; _statusAt = Time.unscaledTime; _statusLen = seconds; _statusColor = col; } private void UpdateInner() { //IL_0008: 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_0021: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) float unscaledTime = Time.unscaledTime; bool num = Pressed(_kToggle); bool flag = Pressed(_kNow); bool flag2 = Pressed(_kClear); if (Pressed(_kHud)) { _hudOn = !_hudOn; } if (num) { SetEnabled(!_enabled); } if (!_enabled) { return; } bool flag3 = IsPaused(); if (flag2) { ClearAll(); Status("ALL EFFECTS CLEARED", Color.white, 1.5f); } if (flag) { if (flag3) { Status("Chaos waits for a match", Color.white, 2f); } else { TriggerNow(); } } if (flag3) { _nextEffectAt += Time.unscaledDeltaTime; } else if (unscaledTime >= _nextEffectAt) { TriggerNow(); ScheduleNext(_interval); } for (int num2 = _active.Count - 1; num2 >= 0; num2--) { ActiveEffect activeEffect = _active[num2]; if (unscaledTime >= activeEffect.EndsAt) { SafeCall(activeEffect.Effect.OnStop); _active.RemoveAt(num2); } else if (activeEffect.Effect.OnTick != null) { RunChecked(activeEffect, activeEffect.Effect.OnTick); } } try { SolidsTick(); } catch (Exception ex) { if (_errLogged.Add("solids")) { ((MelonBase)this).LoggerInstance.Warning("Prop contact check failed: " + ex.Message); } } try { if (!flag3) { PhysicsGuard(); } } catch (Exception ex2) { if (_errLogged.Add("guard-fail")) { ((MelonBase)this).LoggerInstance.Warning("Physics guard failed: " + ex2.Message); } } if (!flag3) { PumpCaches(unscaledTime); } } public override void OnLateUpdate() { if (!_enabled) { return; } for (int i = 0; i < _active.Count; i++) { ChaosEffect effect = _active[i].Effect; if (effect.OnLate != null) { RunChecked(_active[i], effect.OnLate); } } } private void LoadConfig() { //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) try { MelonPreferences_Category obj = MelonPreferences.CreateCategory("GangBeastsChaos"); obj.SetFilePath("UserData/GangBeastsChaos.cfg"); MelonPreferences_Entry<float> val = obj.CreateEntry<float>("EffectInterval", 25f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); MelonPreferences_Entry<float> val2 = obj.CreateEntry<float>("EffectDuration", 45f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); MelonPreferences_Entry<float> val3 = obj.CreateEntry<float>("FirstEffectDelaySeconds", 2f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); MelonPreferences_Entry<int> val4 = obj.CreateEntry<int>("MaxActiveEffects", 4, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); MelonPreferences_Entry<bool> val5 = obj.CreateEntry<bool>("StartWithChaosOn", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); MelonPreferences_Entry<bool> val6 = obj.CreateEntry<bool>("ShowHud", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); MelonPreferences_Entry<bool> val7 = obj.CreateEntry<bool>("PauseInMenus", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); MelonPreferences_Entry<string> val8 = obj.CreateEntry<string>("MenuSceneWords", "menu,lobby,boot,load,splash,select,customi", (string)null, (string)null, false, false, (ValueValidator)null, (string)null); MelonPreferences_Entry<string> val9 = obj.CreateEntry<string>("HudCorner", "BottomRight", (string)null, (string)null, false, false, (ValueValidator)null, (string)null); MelonPreferences_Entry<float> val10 = obj.CreateEntry<float>("HudScale", 1f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); MelonPreferences_Entry<string> val11 = obj.CreateEntry<string>("KeyToggle", "F6", (string)null, (string)null, false, false, (ValueValidator)null, (string)null); MelonPreferences_Entry<string> val12 = obj.CreateEntry<string>("KeyChaosNow", "F3", (string)null, (string)null, false, false, (ValueValidator)null, (string)null); MelonPreferences_Entry<string> val13 = obj.CreateEntry<string>("KeyClearAll", "F9", (string)null, (string)null, false, false, (ValueValidator)null, (string)null); MelonPreferences_Entry<string> val14 = obj.CreateEntry<string>("KeyHud", "F4", (string)null, (string)null, false, false, (ValueValidator)null, (string)null); MelonPreferences_Entry<bool> val15 = obj.CreateEntry<bool>("PlayerOnlyEffects", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); MelonPreferences_Entry<string> val16 = obj.CreateEntry<string>("DisabledEffects", "", (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _interval = Mathf.Clamp(val.Value, 3f, 600f); _duration = Mathf.Clamp(val2.Value, 3f, 600f); _firstDelay = Mathf.Clamp(val3.Value, 0f, 120f); _maxActive = Mathf.Clamp(val4.Value, 1, 12); _startOn = val5.Value; _playerOnly = val15.Value; _showHud = val6.Value; _pauseInMenus = val7.Value; _hudScale = Mathf.Clamp(val10.Value, 0.5f, 2.5f); _hudCorner = (string.IsNullOrEmpty(val9.Value) ? "BottomRight" : val9.Value.Trim()); _kToggle = ParseKey(val11.Value, (KeyCode)287); _kNow = ParseKey(val12.Value, (KeyCode)284); _kClear = ParseKey(val13.Value, (KeyCode)290); _kHud = ParseKey(val14.Value, (KeyCode)285); if (!string.IsNullOrEmpty(val8.Value)) { string[] array = val8.Value.Split(','); for (int i = 0; i < array.Length; i++) { array[i] = array[i].Trim().ToLowerInvariant(); } _menuWords = array; } string value = val16.Value; if (!string.IsNullOrEmpty(value)) { string[] array2 = value.Split(','); for (int j = 0; j < array2.Length; j++) { string text = array2[j].Trim(); if (text.Length > 0) { _disabled.Add(text); } } } MelonPreferences.Save(); } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Warning("Could not load config, using defaults: " + ex.Message); } } private static KeyCode ParseKey(string s, KeyCode fallback) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) try { return (KeyCode)Enum.Parse(typeof(KeyCode), s, ignoreCase: true); } catch (Exception) { return fallback; } } private void ScheduleNext(float delay) { _nextEffectAt = Time.unscaledTime + delay; _span = Mathf.Max(0.1f, delay); } private bool IsPaused() { if (_pauseInMenus) { return _sceneIsMenu; } return false; } private bool IsActive(ChaosEffect e) { for (int i = 0; i < _active.Count; i++) { if (_active[i].Effect == e) { return true; } } return false; } private bool Ready(ChaosEffect e) { if ((e.Needs & Need.Bodies) != Need.None && (!_cBodies.HasData || _dynCount == 0)) { return false; } if ((e.Category == "Beasts" || (e.Needs & (Need.Tints | Need.Beasts)) != Need.None) && _beastRoots.Count == 0) { return false; } if ((e.Needs & Need.Lights) != Need.None && (!_cLights.HasData || _lights.Length == 0)) { return false; } if ((e.Needs & Need.Sources) != Need.None && (!_cSources.HasData || _sources.Length == 0)) { return false; } if ((e.Needs & Need.Colliders) != Need.None && (!_cColliders.HasData || _colliders.Length == 0)) { return false; } if ((e.Needs & Need.Tints) != Need.None && !_cTints.HasData) { return false; } return true; } private ChaosEffect PickNext() { List<ChaosEffect> list = new List<ChaosEffect>(); for (int i = 0; i < _all.Count; i++) { ChaosEffect chaosEffect = _all[i]; if (!IsActive(chaosEffect) && !_recent.Contains(chaosEffect.Name)) { list.Add(chaosEffect); } } if (list.Count == 0) { for (int j = 0; j < _all.Count; j++) { if (!IsActive(_all[j])) { list.Add(_all[j]); } } } if (list.Count == 0) { return null; } return list[_rng.Next(list.Count)]; } private ChaosEffect PickReady() { List<ChaosEffect> list = new List<ChaosEffect>(); for (int i = 0; i < _all.Count; i++) { ChaosEffect chaosEffect = _all[i]; if (!IsActive(chaosEffect) && !_recent.Contains(chaosEffect.Name) && Ready(chaosEffect)) { list.Add(chaosEffect); } } if (list.Count == 0) { for (int j = 0; j < _all.Count; j++) { if (!IsActive(_all[j]) && Ready(_all[j])) { list.Add(_all[j]); } } } if (list.Count == 0) { return null; } return list[_rng.Next(list.Count)]; } private void TriggerNow() { ChaosEffect chaosEffect = _next; bool flag = true; if (chaosEffect == null || IsActive(chaosEffect) || !Ready(chaosEffect)) { ChaosEffect chaosEffect2 = PickReady(); if (chaosEffect2 != null) { chaosEffect = chaosEffect2; flag = false; } else if (chaosEffect == null || IsActive(chaosEffect)) { chaosEffect = PickNext(); flag = true; } } if (chaosEffect != null) { StartEffect(chaosEffect); if (flag || _next == null || IsActive(_next)) { _next = PickNext(); } } } private void StartEffect(ChaosEffect effect) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) _toast = effect.Name; _toastAt = Time.unscaledTime; _toastColor = CatColor(effect.Category); if (effect.Group != null) { for (int num = _active.Count - 1; num >= 0; num--) { if (_active[num].Effect.Group == effect.Group) { SafeCall(_active[num].Effect.OnStop); _active.RemoveAt(num); } } } while (_active.Count >= _maxActive && _active.Count > 0) { SafeCall(_active[0].Effect.OnStop); _active.RemoveAt(0); } _hit = 0; Stopwatch stopwatch = Stopwatch.StartNew(); SafeCall(effect.OnStart); stopwatch.Stop(); _lastStartMs = (float)stopwatch.Elapsed.TotalMilliseconds; _lastStartAt = Time.unscaledTime; float num2 = _duration * effect.DurMul; _active.Add(new ActiveEffect { Effect = effect, EndsAt = Time.unscaledTime + num2, Duration = num2, Verified = (effect.OnStart != null && _hit > 0) }); _recent.Add(effect.Name); if (_recent.Count > 8) { _recent.RemoveAt(0); } ((MelonBase)this).LoggerInstance.Msg("Chaos: " + effect.Name + " (start " + stopwatch.ElapsedMilliseconds + " ms, changed " + _hit + ")"); if (effect.OnStart != null && effect.OnTick == null && effect.OnLate == null && _hit == 0) { ((MelonBase)this).LoggerInstance.Warning("Effect '" + effect.Name + "' changed nothing (no matching objects found)."); } if (stopwatch.ElapsedMilliseconds > 100) { ((MelonBase)this).LoggerInstance.Warning("Effect '" + effect.Name + "' started slowly (" + stopwatch.ElapsedMilliseconds + " ms). Please send this log line."); } } private void ClearAll() { for (int i = 0; i < _active.Count; i++) { SafeCall(_active[i].Effect.OnStop); } _active.Clear(); DestroySpawned(); RestoreGravity(); RestoreTime(); } private void RunChecked(ActiveEffect a, Action act) { if (a.Verified) { TickSafe(act, a.Effect.Name); return; } _hit = 0; TickSafe(act, a.Effect.Name); if (_hit > 0) { a.Verified = true; } else if (++a.Ticks >= 300) { a.Verified = true; ((MelonBase)this).LoggerInstance.Warning("Effect '" + a.Effect.Name + "' is running but changes nothing."); } } private void SafeCall(Action a) { if (a == null) { return; } try { a(); } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Error(ex.ToString()); } } private void TickSafe(Action a, string name) { try { a(); } catch (Exception ex) { if (_errLogged.Add(name)) { ((MelonBase)this).LoggerInstance.Error("Effect '" + name + "' tick failed: " + ex.Message); } } } private void RebuildBeasts() { _beastRoots.Clear(); _beastBodies.Clear(); _dynCount = 0; Dictionary<int, int> dictionary = new Dictionary<int, int>(); Dictionary<int, Transform> dictionary2 = new Dictionary<int, Transform>(); int[] array = new int[_bodies.Length]; for (int i = 0; i < _bodies.Length; i++) { Rigidbody val = _bodies[i]; if (!((Object)(object)val == (Object)null) && !val.isKinematic) { _dynCount++; Transform root = ((Component)val).transform.root; if (!((Object)(object)root == (Object)null)) { int key = (array[i] = ((Object)root).GetInstanceID()); dictionary.TryGetValue(key, out var value); dictionary[key] = value + 1; dictionary2[key] = root; } } } HashSet<int> hashSet = new HashSet<int>(); foreach (KeyValuePair<int, int> item in dictionary) { if (item.Value >= 6 && dictionary2[item.Key].childCount <= 60) { hashSet.Add(item.Key); _beastRoots.Add(dictionary2[item.Key]); } } for (int j = 0; j < _bodies.Length; j++) { if (array[j] != 0 && hashSet.Contains(array[j])) { _beastBodies.Add(_bodies[j]); } } } private List<Transform> TargetRoots() { Bodies(); List<Transform> list = new List<Transform>(_beastRoots); list.RemoveAll((Transform r) => (Object)(object)r == (Object)null); if (!_playerOnly || list.Count <= 1) { return list; } float unscaledTime = Time.unscaledTime; if (unscaledTime - _playerAt < 4f && _playerRoots.Count > 0) { bool flag = true; for (int num = 0; num < _playerRoots.Count; num++) { if ((Object)(object)_playerRoots[num] == (Object)null) { flag = false; } } if (flag) { return _playerRoots; } } _playerAt = unscaledTime; List<Transform> list2 = new List<Transform>(); Transform val = null; for (int num2 = 0; num2 < list.Count; num2++) { if (((Object)list[num2]).GetInstanceID() == _playerFallbackId) { val = list[num2]; } } if ((Object)(object)val == (Object)null) { val = list[0]; _playerFallbackId = ((Object)val).GetInstanceID(); } list2.Add(val); _playerRoots = list2; return list2; } private void SetupCaches() { _cBodies = new Cache { Min = 3f, Interval = 3f, Scan = delegate { _bodies = Il2CppArrayBase<Rigidbody>.op_Implicit(Object.FindObjectsOfType<Rigidbody>()); RebuildBeasts(); } }; _cLights = new Cache { Scan = delegate { _lights = Il2CppArrayBase<Light>.op_Implicit(Object.FindObjectsOfType<Light>()); } }; _cSources = new Cache { Scan = delegate { _sources = Il2CppArrayBase<AudioSource>.op_Implicit(Object.FindObjectsOfType<AudioSource>()); } }; _cColliders = new Cache { Scan = delegate { _colliders = Il2CppArrayBase<Collider>.op_Implicit(Object.FindObjectsOfType<Collider>()); } }; _cTints = new Cache { Scan = ScanTints }; } private void InvalidateCaches() { Cache[] array = new Cache[5] { _cBodies, _cLights, _cSources, _cColliders, _cTints }; for (int i = 0; i < array.Length; i++) { array[i].HasData = false; array[i].LastAt = -999f; } _bodies = (Rigidbody[])(object)new Rigidbody[0]; _beastRoots.Clear(); _beastBodies.Clear(); _dynCount = 0; _propMat = null; _propMatTried = false; _playerRoots = new List<Transform>(); _playerAt = -999f; _playerFallbackId = 0; _lights = (Light[])(object)new Light[0]; _sources = (AudioSource[])(object)new AudioSource[0]; _colliders = (Collider[])(object)new Collider[0]; _tints.Clear(); } private void RunScan(Cache c) { Stopwatch stopwatch = Stopwatch.StartNew(); try { c.Scan(); } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Error("Scene scan failed: " + ex.Message); } stopwatch.Stop(); c.LastMs = (float)stopwatch.Elapsed.TotalMilliseconds; c.LastAt = Time.unscaledTime; c.HasData = true; c.Interval = Mathf.Clamp(c.LastMs / 40f, c.Min, 30f); } private bool Stale(Cache c, float minAge) { if (!c.HasData) { return true; } return Time.unscaledTime - c.LastAt > Mathf.Max(minAge, c.Interval * 1.5f); } private void PumpCaches(float now) { Need need = Need.Bodies; for (int i = 0; i < _active.Count; i++) { need |= _active[i].Effect.Needs & (Need.Bodies | Need.Tints); } if (_next != null && _nextEffectAt - now < 4f) { need |= _next.Needs; } if (!TryPump(need, Need.Bodies, _cBodies, now) && !TryPump(need, Need.Lights, _cLights, now) && !TryPump(need, Need.Sources, _cSources, now) && !TryPump(need, Need.Colliders, _cColliders, now)) { TryPump(need, Need.Tints, _cTints, now); } } private bool TryPump(Need mask, Need flag, Cache c, float now) { if ((mask & flag) == 0) { return false; } if (c.HasData && now - c.LastAt < c.Interval) { return false; } RunScan(c); return true; } private Rigidbody[] Bodies() { if (Stale(_cBodies, 4f)) { RunScan(_cBodies); } return _bodies; } private Light[] Lights() { if (Stale(_cLights, 10f)) { RunScan(_cLights); } return _lights; } private AudioSource[] Sources() { if (Stale(_cSources, 10f)) { RunScan(_cSources); } return _sources; } private Collider[] Colliders() { if (Stale(_cColliders, 10f)) { RunScan(_cColliders); } return _colliders; } private void ForEachBody(Action<Rigidbody> f) { Rigidbody[] array = Bodies(); foreach (Rigidbody val in array) { if ((Object)(object)val != (Object)null && !val.isKinematic) { f(val); _hit++; } } } private Vector3 CenterOfBodies() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_008c: 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_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_0075: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.zero; int num = 0; List<Transform> list = TargetRoots(); for (int i = 0; i < list.Count; i++) { if (!((Object)(object)list[i] == (Object)null)) { val += RootPos(list[i]); num++; } } if (num == 0) { Rigidbody[] array = Bodies(); foreach (Rigidbody val2 in array) { if ((Object)(object)val2 != (Object)null) { val += val2.position; num++; } } } if (num <= 0) { return Vector3.zero; } return val / (float)num; } private static Color CatColor(string cat) { //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_020f: 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_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) return (Color)(cat switch { "Gravity" => new Color(0.35f, 0.65f, 1f, 0.95f), "Time" => new Color(1f, 0.85f, 0.2f, 0.95f), "Physics" => new Color(1f, 0.4f, 0.3f, 0.95f), "Beasts" => new Color(0.4f, 0.9f, 0.45f, 0.95f), "World" => new Color(0.2f, 0.85f, 0.85f, 0.95f), "Camera" => new Color(0.9f, 0.5f, 1f, 0.95f), "Visual" => new Color(1f, 0.55f, 0.85f, 0.95f), "Audio" => new Color(0.7f, 0.75f, 0.9f, 0.95f), "Props" => new Color(1f, 0.6f, 0.2f, 0.95f), _ => new Color(0.8f, 0.8f, 0.8f, 0.95f), }); } private bool Pressed(KeyCode k) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) bool result = false; if (_legacyOk) { try { result = Input.GetKeyDown(k); } catch (Exception) { _legacyOk = false; ((MelonBase)this).LoggerInstance.Msg("Old Input API is off in this game; reading hotkeys from the GUI event stream instead."); } } if (_pending.Remove(k)) { result = true; } return result; } private void CaptureKeys(Event ev) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Invalid comparison between Unknown and I4 //IL_000a: 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_0018: 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 ((int)ev.type == 4) { if ((int)ev.keyCode != 0 && _held.Add(ev.keyCode)) { _pending.Add(ev.keyCode); } } else if ((int)ev.type == 5) { _held.Remove(ev.keyCode); } } public override void OnGUI() { //IL_0067: 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_0011: Invalid comparison between Unknown and I4 //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 Event current = Event.current; if (current == null) { return; } if ((int)current.type == 4 || (int)current.type == 5) { CaptureKeys(current); } else { if ((int)current.type != 7) { return; } try { DrawAll(); } catch (Exception ex) { if (_errLogged.Add("gui")) { ((MelonBase)this).LoggerInstance.Error("Chaos GUI failed: " + ex.Message); } } finally { GUI.color = Color.white; } } } private void Guard(string name, Action act) { try { act(); } catch (Exception ex) { if (_errLogged.Add("gui-" + name)) { string text = ex.ToString(); ((MelonBase)this).LoggerInstance.Error("Chaos GUI part '" + name + "' failed: " + ((text.Length > 500) ? text.Substring(0, 500) : text)); } } } private void EnsureStyles() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown if (_style == null) { GUIStyle style = new GUIStyle(GUI.skin.label); GUIStyle big = new GUIStyle(GUI.skin.label); _style = style; _big = big; } _style.fontSize = Mathf.RoundToInt(15f * _hudScale); _big.fontSize = Mathf.RoundToInt(32f * _hudScale); } private void DrawAll() { Guard("styles", EnsureStyles); if (_style == null || _big == null) { return; } Guard("messages", DrawMessages); if (_enabled) { if (_hudOn) { Guard("bars", DrawBars); } } else if (_hudOn && Time.unscaledTime < _offHintUntil) { Guard("hint", DrawOffHint); } } private void DrawOffHint() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) DrawText(14f, (float)Screen.height - 30f * _hudScale, 520f, 26f * _hudScale, "Chaos mod is OFF. Press " + ((object)Unsafe.As<KeyCode, KeyCode>(ref _kToggle)/*cast due to .constrained prefix*/).ToString() + " to start.", _style, new Color(1f, 1f, 1f, 0.8f)); } private void DrawMessages() { //IL_00d0: 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) float num = Screen.width; float num2 = Screen.height; float unscaledTime = Time.unscaledTime; float num3 = unscaledTime - _statusAt; if (num3 >= 0f && num3 <= _statusLen) { float num4 = Mathf.Clamp01((_statusLen - num3) / 0.6f); float num5 = Mathf.Min(num - 20f, (float)_status.Length * 32f * _hudScale * 0.55f + 40f); DrawText((num - num5) * 0.5f, num2 * 0.22f, num5 + 40f, 46f * _hudScale, _status, _big, new Color(_statusColor.r, _statusColor.g, _statusColor.b, num4)); } if (_enabled) { float num6 = unscaledTime - _toastAt; if (num6 >= 0f && num6 <= 3f) { float num7 = Mathf.Clamp01((3f - num6) / 0.8f); float num8 = Mathf.Min(num - 20f, (float)_toast.Length * 32f * _hudScale * 0.55f + 40f); DrawText((num - num8) * 0.5f, num2 * 0.22f + 52f * _hudScale, num8 + 40f, 46f * _hudScale, _toast, _big, new Color(_toastColor.r, _toastColor.g, _toastColor.b, num7)); } } } private void DrawBars() { //IL_00f2: 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_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) float num = Screen.width; float num2 = Screen.height; float unscaledTime = Time.unscaledTime; bool num3 = IsPaused(); float hudScale = _hudScale; float num4 = 280f * hudScale; float num5 = 24f * hudScale; float num6 = 4f * hudScale; float num7 = 14f * hudScale; float num8 = (float)(1 + _active.Count) * (num5 + num6); bool num9 = _hudCorner.EndsWith("Right", StringComparison.OrdinalIgnoreCase); bool flag = _hudCorner.StartsWith("Bottom", StringComparison.OrdinalIgnoreCase); float num10 = (num9 ? (num - num4 - num7) : num7); float num11 = (flag ? (num2 - num8 - num7) : num7); float num12 = Mathf.Max(0f, _nextEffectAt - unscaledTime); float fraction = (num3 ? 0f : Mathf.Clamp01(1f - num12 / _span)); DrawBar(num10, num11, num4, num5, fraction, new Color(1f, 0.55f, 0.1f, 0.8f)); string text = (num3 ? "CHAOS ON - waiting for a match" : ("NEXT CHAOS IN " + Mathf.CeilToInt(num12) + "s")); DrawText(num10 + 8f * hudScale, num11 + 2f * hudScale, num4, num5, text, _style, Color.white); num11 += num5 + num6; for (int i = 0; i < _active.Count; i++) { ActiveEffect activeEffect = _active[i]; float num13 = Mathf.Max(0f, activeEffect.EndsAt - unscaledTime); Color val = CatColor(activeEffect.Effect.Category); DrawBar(num10, num11, num4, num5, Mathf.Clamp01(num13 / Mathf.Max(0.1f, activeEffect.Duration)), new Color(val.r, val.g, val.b, 0.75f)); DrawText(num10 + 8f * hudScale, num11 + 2f * hudScale, num4, num5, activeEffect.Effect.Name + " " + Mathf.CeilToInt(num13) + "s", _style, Color.white); num11 += num5 + num6; } } private bool EnsureBarStyle() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown if (_textBars) { return false; } if (_barStyle != null) { return true; } try { GUIStyle val = new GUIStyle(); val.normal.background = Texture2D.whiteTexture; _barStyle = val; return true; } catch (Exception ex) { _textBars = true; ((MelonBase)this).LoggerInstance.Warning("Filled bars are not available in this game, using text bars: " + ex.Message); return false; } } private void DrawBox(float x, float y, float w, float h, Color col) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (EnsureBarStyle()) { GUI.color = col; GUI.Label(new Rect(x, y, w, h), "", _barStyle); GUI.color = Color.white; } } private void DrawBar(float x, float y, float w, float h, float fraction, Color fill) { //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) fraction = Mathf.Clamp01(fraction); if (EnsureBarStyle()) { try { DrawBox(x, y, w, h, new Color(0f, 0f, 0f, 0.65f)); DrawBox(x + 2f, y + 2f, Mathf.Max(1f, (w - 4f) * fraction), h - 4f, fill); return; } catch (Exception ex) { _textBars = true; ((MelonBase)this).LoggerInstance.Warning("Filled bars failed, using text bars: " + ex.Message); } } int num = 10; int num2 = Mathf.RoundToInt((float)num * fraction); DrawText(x + w * 0.66f, y + 2f, w * 0.34f, h, "[" + new string('|', num2) + new string('.', num - num2) + "]", _style, fill); } private static void DrawText(float x, float y, float w, float h, string text, GUIStyle style, Color col) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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) GUI.color = new Color(0f, 0f, 0f, col.a); GUI.Label(new Rect(x + 1f, y + 1f, w, h), text, style); GUI.color = col; GUI.Label(new Rect(x, y, w, h), text, style); GUI.color = Color.white; } private void Add(string cat, string name, Need needs, Action start, Action tick = null, Action stop = null, string group = null, float durMul = 1f, Action late = null) { _all.Add(new ChaosEffect { Category = cat, Name = name, Needs = needs, OnStart = start, OnTick = tick, OnStop = stop, Group = group, DurMul = durMul, OnLate = late }); } private void BuildEffects() { Add("Gravity", "Moon Gravity", Need.None, delegate { //IL_0002: 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) SetGravity(GBase() * 0.2f); }, null, RestoreGravity, "gravity"); Add("Gravity", "Heavy Gravity", Need.None, delegate { //IL_0002: 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) SetGravity(GBase() * 3f); }, null, RestoreGravity, "gravity"); Add("Gravity", "Reverse Gravity", Need.None, delegate { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) SetGravity(-GBase() * 0.5f); }, null, RestoreGravity, "gravity"); Add("Gravity", "Sideways Gravity", Need.None, delegate { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) SetGravity(new Vector3(GBase().y, 0f, 0f)); }, null, RestoreGravity, "gravity"); Add("Gravity", "Zero Gravity", Need.None, delegate { //IL_0001: Unknown result type (might be due to invalid IL or missing references) SetGravity(Vector3.zero); }, null, RestoreGravity, "gravity"); Add("Gravity", "Gravity Roulette", Need.None, delegate { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) _rollG = Vector3.zero; }, delegate { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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_0027: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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: Unknown result type (might be due to invalid IL or missing references) if (_rollG == Vector3.zero || Time.frameCount % 150 == 0) { Vector3 onUnitSphere = Random.onUnitSphere; onUnitSphere.y = 0f - (Mathf.Abs(onUnitSphere.y) + 0.6f); Vector3 normalized = ((Vector3)(ref onUnitSphere)).normalized; Vector3 val = GBase(); _rollG = normalized * ((Vector3)(ref val)).magnitude; } SetGravity(Vector3.Lerp(Physics.gravity, _rollG, 0.04f)); }, RestoreGravity, "gravity"); Add("Gravity", "Gravity Waves", Need.None, null, delegate { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) SetGravity(GBase() * Mathf.Sin(Time.unscaledTime * 1.2f) * 0.9f); }, RestoreGravity, "gravity"); Add("Time", "Slow Motion", Need.None, delegate { SetTime(0.4f); }, null, RestoreTime, "time"); Add("Time", "Bullet Time", Need.None, delegate { SetTime(0.15f); }, null, RestoreTime, "time", 0.5f); Add("Time", "Fast Forward", Need.None, delegate { SetTime(1.8f); }, null, RestoreTime, "time"); Add("Time", "Turbo Time", Need.None, delegate { SetTime(2.5f); }, null, RestoreTime, "time", 0.6f); Add("Time", "Time Wobble", Need.None, null, delegate { SetTime(1f + Mathf.Sin(Time.unscaledTime * 2f) * 0.6f); }, RestoreTime, "time"); Add("Time", "Stutter Time", Need.None, null, delegate { SetTime((Time.frameCount / 20 % 2 == 0) ? 1f : 0.2f); }, RestoreTime, "time", 0.7f); Add("Physics", "Launch Everyone", Need.Bodies, delegate { ForEachBody(delegate(Rigidbody rb) { //IL_0001: 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) rb.AddForce(Vector3.up * 12f, (ForceMode)2); }); }, null, null, null, 0.15f); Add("Physics", "Super Jump", Need.Bodies, delegate { ForEachBody(delegate(Rigidbody rb) { //IL_0001: 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) rb.AddForce(Vector3.up * 22f, (ForceMode)2); }); }, null, null, null, 0.15f); Add("Physics", "Yeet Sideways", Need.Bodies, delegate { //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) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) Vector3 onUnitSphere = Random.onUnitSphere; onUnitSphere.y = 0.3f; Vector3 push = ((Vector3)(ref onUnitSphere)).normalized * 14f; ForEachBody(delegate(Rigidbody rb) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) rb.AddForce(push, (ForceMode)2); }); }, null, null, null, 0.15f); Add("Physics", "Spin Cycle", Need.Bodies, delegate { ForEachBody(delegate(Rigidbody rb) { //IL_0001: 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) rb.angularVelocity = Random.onUnitSphere * 20f; }); }, null, null, null, 0.15f); Add("Physics", "Freeze Everyone", Need.Bodies, delegate { ForEachBody(delegate(Rigidbody rb) { //IL_0001: 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) rb.velocity = Vector3.zero; rb.angularVelocity = Vector3.zero; }); }, null, null, null, 0.15f); Add("Physics", "Pinball", Need.Bodies, delegate { ForEachBody(delegate(Rigidbody rb) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_0025: Unknown result type (might be due to invalid IL or missing references) Vector3 onUnitSphere = Random.onUnitSphere; onUnitSphere.y = Mathf.Abs(onUnitSphere.y) * 0.5f; rb.AddForce(onUnitSphere * 11f, (ForceMode)2); }); }, null, null, null, 0.15f); Add("Physics", "Shockwave", Need.Bodies, delegate { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) Vector3 center = CenterOfBodies(); ForEachBody(delegate(Rigidbody rb) { //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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_0051: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) Vector3 val = rb.position - center; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = Random.onUnitSphere; } Vector3 val2 = ((Vector3)(ref val)).normalized + Vector3.up * 0.6f; rb.AddForce(((Vector3)(ref val2)).normalized * 18f, (ForceMode)2); }); }, null, null, null, 0.15f); Add("Physics", "Implosion", Need.Bodies, delegate { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) Vector3 center = CenterOfBodies(); ForEachBody(delegate(Rigidbody rb) { //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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_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) Vector3 val = center - rb.position; val.y = 0f; if (!(((Vector3)(ref val)).sqrMagnitude < 0.01f)) { rb.AddForce(((Vector3)(ref val)).normalized * 12f + Vector3.up * 3f, (ForceMode)2); } }); }, null, null, null, 0.15f); Add("Physics", "Constant Wind", Need.Bodies, null, delegate { //IL_002c: 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_003b: Unknown result type (might be due to invalid IL or missing references) Vector3 wind = new Vector3(Mathf.Sin(Time.time * 0.5f), 0f, Mathf.Cos(Time.time * 0.5f)) * 25f; ForEachBody(delegate(Rigidbody rb) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) rb.AddForce(wind, (ForceMode)5); }); }, null, "wind"); Add("Physics", "Magnet", Need.Bodies, null, delegate { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) Vector3 center = CenterOfBodies(); ForEachBody(delegate(Rigidbody rb) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0015: 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) Vector3 val = center - rb.position; rb.AddForce(((Vector3)(ref val)).normalized * 20f, (ForceMode)5); }); }, null, "wind"); Add("Physics", "Repulsor", Need.Bodies, null, delegate { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) Vector3 center = CenterOfBodies(); ForEachBody(delegate(Rigidbody rb) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0015: 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) Vector3 val = rb.position - center; rb.AddForce(((Vector3)(ref val)).normalized * 20f, (ForceMode)5); }); }, null, "wind"); Add("Physics", "Tornado", Need.Bodies, null, delegate { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) Vector3 center = CenterOfBodies(); ForEachBody(delegate(Rigidbody rb) { //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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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) Vector3 val = rb.position - center; val.y = 0f; if (!(((Vector3)(ref val)).sqrMagnitude < 0.01f)) { Vector3 val2 = Vector3.Cross(Vector3.up, val); Vector3 normalized = ((Vector3)(ref val2)).normalized; Vector3 val3 = normalized * 30f; val2 = -val; rb.AddForce(val3 + ((Vector3)(ref val2)).normalized * 10f + Vector3.up * 8f, (ForceMode)5); } }); }, null, "wind"); Add("Physics", "Jittery Everything", Need.Bodies, null, delegate { ForEachBody(delegate(Rigidbody rb) { //IL_0001: 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) rb.AddForce(Random.insideUnitSphere * 15f, (ForceMode)5); }); }); Add("Physics", "Earthquake", Need.Bodies, null, delegate { ForEachBody(delegate(Rigidbody rb) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) Vector2 insideUnitCircle = Random.insideUnitCircle; rb.AddForce(new Vector3(insideUnitCircle.x, 0.2f, insideUnitCircle.y) * 35f, (ForceMode)5); }); }, null, "quake"); Add("Beasts", "Feather Beasts", Need.Bodies, delegate { BodyPropsStart(0.25f, -1f, -1f); }, null, BodyPropsStop, "bodyprops"); Add("Beasts", "Lead Beasts", Need.Bodies, delegate { BodyPropsStart(5f, -1f, -1f); }, null, BodyPropsStop, "bodyprops"); Add("Beasts", "Underwater", Need.Bodies, delegate { BodyPropsStart(1f, 3f, 3f); }, null, BodyPropsStop, "bodyprops"); Add("World", "Bouncy World", Need.Colliders, delegate { SwapColliderMaterial(1f, 0.6f, (PhysicMaterialCombine)3, (PhysicMaterialCombine)0); }, null, RestoreColliderMaterial, "physmat"); Add("World", "Slippery World", Need.Colliders, delegate { SwapColliderMaterial(0f, 0.02f, (PhysicMaterialCombine)0, (PhysicMaterialCombine)2); }, null, RestoreColliderMaterial, "physmat"); Add("World", "Sticky World", Need.Colliders, delegate { SwapColliderMaterial(0f, 4f, (PhysicMaterialCombine)2, (PhysicMaterialCombine)3); }, null, RestoreColliderMaterial, "physmat"); Add("Camera", "Wide Angle", Need.None, delegate { FovBegin(); FovSet(110f); }, null, FovEnd, "fov", 1f, delegate { FovSet(110f); }); Add("Camera", "Zoom Zoom", Need.None, delegate { FovBegin(); FovSet(25f); }, null, FovEnd, "fov", 1f, delegate { FovSet(25f); }); Add("Camera", "Fisheye", Need.None, delegate { FovBegin(); FovSet(140f); }, null, FovEnd, "fov", 1f, delegate { FovSet(140f); }); Add("Camera", "FOV Breathing", Need.None, FovBegin, null, FovEnd, "fov", 1f, delegate { FovSet(_fovBase + 22f * Mathf.Sin(Time.unscaledTime * 1.6f)); }); Add("Camera", "Drunk Camera", Need.None, null, null, delegate { SetRoll(0f); }, "roll", 1f, delegate { SetRoll(Mathf.Sin(Time.unscaledTime * 1.3f) * 14f); }); Add("Camera", "Dutch Angle", Need.None, null, null, delegate { SetRoll(0f); }, "roll", 1f, delegate { SetRoll(25f); }); Add("Camera", "Camera Shake", Need.None, null, null, delegate { SetRoll(0f); }, "roll", 0.5f, delegate { SetRoll((Mathf.PerlinNoise(Time.unscaledTime * 18f, 0.5f) - 0.5f) * 10f); }); Add("Camera", "Barrel Roll", Need.None, null, null, delegate { SetRoll(0f); }, "roll", 0.5f, delegate { SetRoll(Time.unscaledTime * 40f % 360f); }); Add("Visual", "Disco Lights", Need.Lights, delegate { LightsStart(null, 1f); }, delegate { LightsHue(Mathf.Repeat(Time.unscaledTime * 0.5f, 1f)); }, LightsRestore, "lights"); Add("Visual", "Blackout", Need.Lights, delegate { LightsStart(null, 0.1f); }, null, LightsRestore, "lights", 0.6f); Add("Visual", "Blinding Light", Need.Lights, delegate { //IL_0001: Unknown result type (might be due to invalid IL or missing references) LightsStart(Color.white, 3f); }, null, LightsRestore, "lights", 0.6f); Add("Visual", "Sunset", Need.Lights, delegate { //IL_0010: Unknown result type (might be due to invalid IL or missing references) LightsStart((Color?)new Color(1f, 0.55f, 0.25f), 1f); }, null, LightsRestore, "lights"); Add("Visual", "Toxic Glow", Need.Lights, delegate { //IL_0010: Unknown result type (might be due to invalid IL or missing references) LightsStart((Color?)new Color(0.4f, 1f, 0.3f), 1.2f); }, null, LightsRestore, "lights"); Add("Visual", "Thick Fog", Need.None, delegate { //IL_0015: Unknown result type (might be due to invalid IL or missing references) FogStart(0.06f, new Color(0.6f, 0.62f, 0.66f)); }, null, FogStop, "fog"); Add("Visual", "Red Fog", Need.None, delegate { //IL_0015: Unknown result type (might be due to invalid IL or missing references) FogStart(0.05f, new Color(0.8f, 0.1f, 0.1f)); }, null, FogStop, "fog"); Add("Visual", "Rainbow Beasts", Need.Bodies | Need.Tints, null, delegate { if (Time.frameCount % 3 == 0) { TintApply((int i) => Color.HSVToRGB(Mathf.Repeat(Time.unscaledTime * 0.8f + (float)i * 0.07f, 1f), 0.9f, 1f)); } }, TintClear, "tint"); Add("Visual", "Neon Beasts", Need.Bodies | Need.Tints, delegate { _neonHue = Random.value; }, delegate { if (Time.frameCount % 10 == 0) { TintApply((int i) => Color.HSVToRGB(_neonHue, 1f, 1f)); } }, TintClear, "tint"); Add("Audio", "Chipmunk Voices", Need.Sources, PitchStart, delegate { PitchTick(1.6f); }, PitchStop, "audio"); Add("Audio", "Deep Voices", Need.Sources, PitchStart, delegate { PitchTick(0.6f); }, PitchStop, "audio"); Add("Audio", "Silence", Need.None, SilenceStart, null, SilenceStop, "audio", 0.4f); Add("Props", "Prop Rain", Need.Bodies, null, delegate { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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) if (Time.frameCount % 20 == 0) { SpawnProp((PrimitiveType)3, ScatterPos(CenterOfBodies(), 12f, 6f), Vector3.one * Random.Range(0.4f, 1.2f), RandomColor(), 1f, 20f); } }); Add("Props", "Capsule Storm", Need.Bodies, null, delegate { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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) if (Time.frameCount % 12 == 0) { SpawnProp((PrimitiveType)1, ScatterPos(CenterOfBodies(), 14f, 8f), Vector3.one * Random.Range(0.6f, 1.1f), RandomColor(), 8f, 20f); } }); Add("Props", "Ball Pit", Need.Bodies, delegate { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) Vector3 center = CenterOfBodies(); for (int i = 0; i < 25; i++) { SpawnProp((PrimitiveType)0, ScatterPos(center, 12f, 6f), Vector3.one * Random.Range(0.4f, 1.2f), RandomColor(), 1f, 25f); } }, null, null, null, 0.25f); Add("Props", "Anvil Drop", Need.Bodies, delegate { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) SpawnProp((PrimitiveType)3, CenterOfBodies() + Vector3.up * 15f, new Vector3(1.5f, 0.8f, 1f), new Color(0.2f, 0.2f, 0.22f), 80f, 30f); }, null, null, null, 0.25f); Add("Props", "Meteor Shower", Need.Bodies, null, delegate { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_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_0088: Unknown result type (might be due to invalid IL or missing references) if (Time.frameCount % 25 == 0) { Rigidbody component = SpawnProp((PrimitiveType)0, ScatterPos(CenterOfBodies(), 28f, 8f), Vector3.one * 1.2f, new Color(1f, 0.45f, 0.1f), 30f, 15f).GetComponent<Rigidbody>(); if ((Object)(object)component != (Object)null) { component.velocity = new Vector3(Random.Range(-4f, 4f), -22f, Random.Range(-4f, 4f)); } } }); Add("Props", "Giant Beach Ball", Need.Bodies, delegate { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) Collider component = SpawnProp((PrimitiveType)0, CenterOfBodies() + Vector3.up * 10f, Vector3.one * 3.5f, RandomColor(), 6f, 45f).GetComponent<Collider>(); if ((Object)(object)component != (Object)null) { component.sharedMaterial = BallMaterial(); } }, null, null, null, 0.3f); Add("Props", "Pillar Fall", Need.Bodies, delegate { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) Vector3 center = CenterOfBodies(); for (int i = 0; i < 8; i++) { SpawnProp((PrimitiveType)2, ScatterPos(center, 14f, 7f), new Vector3(0.7f, 3f, 0.7f), RandomColor(), 40f, 25f); } }, null, null, null, 0.25f); Add("Props", "Incoming Object", Need.Bodies | Need.Beasts, delegate { //IL_0030: 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_0050: Unknown result type (might be due to invalid IL or missing references) switch (_rng.Next(3)) { case 0: ShootAtBeast((PrimitiveType)0, 1.6f, 60f, 28f, new Color(0.25f, 0.25f, 0.28f)); break; case 1: ShootAtBeast((PrimitiveType)3, 1.4f, 50f, 26f, RandomColor()); break; default: ShootAtBeast((PrimitiveType)2, 1.2f, 45f, 26f, RandomColor()); break; } }, null, null, null, 0.2f); Add("Props", "Object Barrage", Need.Bodies | Need.Beasts, null, delegate { //IL_001c: Unknown result type (might be due to invalid IL or missing references) if (Time.frameCount % 100 == 0) { ShootAtBeast((PrimitiveType)0, 1.1f, 30f, 24f, RandomColor()); } }, null, null, 0.35f); Add("Beasts", "On Fire", Need.Bodies | Need.Tints | Need.Beasts, FireStart, FireTick, FireStop, "fire", 0.5f); Add("Props", "Bot Attack", Need.Bodies | Need.Beasts, delegate { BotsStart(3, 1.3f, 70f); }, BotsTick, BotsStop, "bots", 0.5f); Add("Props", "Bot Swarm", Need.Bodies | Need.Beasts, delegate { BotsStart(8, 0.8f, 25f); }, BotsTick, BotsStop, "bots", 0.4f); } private Vector3 GBase() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (!_gravTouched) { return Physics.gravity; } return _gravBase; } private void SetGravity(Vector3 g) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (!_gravTouched) { _gravBase = Physics.gravity; _gravTouched = true; } Physics.gravity = g; _hit++; } private void RestoreGravity() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (_gravTouched) { Physics.gravity = _gravBase; _gravTouched = false; } } private void SetTime(float t) { if (!(Time.timeScale <= 0.0001f) || _timeTouched) { if (!_timeTouched) { _timeBase = Time.timeScale; _timeTouched = true; } if (!(Time.timeScale <= 0.0001f)) { Time.timeScale = t; _hit++; } } } private void RestoreTime() { if (_timeTouched) { Time.timeScale = _timeBase; _timeTouched = false; } } private void BodyPropsStart(float massMul, float drag, float angDrag) { BodyPropsStop(); Bodies(); for (int i = 0; i < _beastBodies.Count; i++) { Rigidbody val = _beastBodies[i]; if (!((Object)(object)val == (Object)null)) { _hit++; _pBodies.Add(val); _pMass.Add(val.mass); _pDrag.Add(val.drag); _pAngDrag.Add(val.angularDrag); val.mass *= massMul; if (drag >= 0f) { val.drag = drag; } if (angDrag >= 0f) { val.angularDrag = angDrag; } } } } private void BodyPropsStop() { for (int i = 0; i < _pBodies.Count; i++) { Rigidbody val = _pBodies[i]; if (!((Object)(object)val == (Object)null)) { val.mass = _pMass[i]; val.drag = _pDrag[i]; val.angularDrag = _pAngDrag[i]; } } _pBodies.Clear(); _pMass.Clear(); _pDrag.Clear(); _pAngDrag.Clear(); } private void SizeStart() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) SizeStop(); Bodies(); for (int i = 0; i < _beastRoots.Count; i++) { Transform val = _beastRoots[i]; if (!((Object)(object)val == (Object)null)) { _hit++; _roots.Add(val); _rootScale.Add(val.localScale); } } } private void SizeApply(float factor) { //IL_002b: 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) for (int i = 0; i < _roots.Count; i++) { if ((Object)(object)_roots[i] != (Object)null) { _roots[i].localScale = _rootScale[i] * factor; } } } private void SizeStop() { SizeApply(1f); _roots.Clear(); _rootScale.Clear(); } private void SwapColliderMaterial(float bounce, float friction, PhysicMaterialCombine bounceCombine, PhysicMaterialCombine frictionCombine) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) RestoreColliderMaterial(); _chaosMat = new PhysicMaterial(); _chaosMat.bounciness = bounce; _chaosMat.dynamicFriction = friction; _chaosMat.staticFriction = friction; _chaosMat.bounceCombine = bounceCombine; _chaosMat.frictionCombine = frictionCombine; Collider[] array = Colliders(); foreach (Collider val in array) { if (!((Object)(object)val == (Object)null)) { _hit++; _swaps.Add(new ColliderSwap { C = val, Orig = val.sharedMaterial }); val.sharedMaterial = _chaosMat; } } } private void RestoreColliderMaterial() { for (int i = 0; i < _swaps.Count; i++) { ColliderSwap colliderSwap = _swaps[i]; if ((Object)(object)colliderSwap.C != (Object)null) { colliderSwap.C.sharedMaterial = colliderSwap.Orig; } } _swaps.Clear(); if ((Object)(object)_chaosMat != (Object)null) { Object.Destroy((Object)(object)_chaosMat); _chaosMat = null; } } private PhysicMaterial BallMaterial() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown if ((Object)(object)_ballMat == (Object)null) { _ballMat = new PhysicMaterial(); _ballMat.bounciness = 0.9f; _ballMat.dynamicFriction = 0.3f; _ballMat.staticFriction = 0.3f; _ballMat.bounceCombine = (PhysicMaterialCombine)3; } return _ballMat; } private Camera Cam() { if ((Object)(object)_cam != (Object)null && ((Behaviour)_cam).isActiveAndEnabled) { return _cam; } _cam = Camera.main; if ((Object)(object)_cam != (Object)null && ((Behaviour)_cam).isActiveAndEnabled) { return _cam; } _cam = null; Il2CppReferenceArray<Camera> allCameras = Camera.allCameras; float num = -9999f; for (int i = 0; i < ((Il2CppArrayBase<Camera>)(object)allCameras).Length; i++) { Camera val = ((Il2CppArrayBase<Camera>)(object)allCameras)[i]; if (!((Object)(object)val == (Object)null) && ((Behaviour)val).isActiveAndEnabled && !((Object)(object)val.targetTexture != (Object)null) && val.depth >= num) { num = val.depth; _cam = val; } } return _cam; } private void FovBegin() { Camera val = Cam(); if ((Object)(object)val != (Object)null) { _hit++; } if ((Object)(object)val != (Object)null && !_fovHeld) { _fovBase = val.fieldOfView; _fovHeld = true; } } private void FovSet(float v) { Camera val = Cam(); if ((Object)(object)val != (Object)null) { val.fieldOfView = v; _hit++; } } private void FovEnd() { if (_fovHeld) { FovSet(_fovBase); _fovHeld = false; } } private void SetRoll(float degrees) { //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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) Camera val = Cam(); if (!((Object)(object)val == (Object)null)) { Vector3 eulerAngles = ((Component)val).transform.eulerAngles; ((Component)val).transform.rotation = Quaternion.Euler(eulerAngles.x, eulerAngles.y, degrees); _hit++; } } private void LightsStart(Color? tint, float intensityMul) { //IL_003f: 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) LightsRestore(); Light[] array = Lights(); foreach (Light val in array) { if (!((Object)(object)val == (Object)null)) { _hit++; _lsRef.Add(val); _lsColor.Add(val.color); _lsIntensity.Add(val.intensity); if (tint.HasValue) { val.color = tint.Value; } val.intensity *= intensityMul; } } } private void LightsHue(float hue) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) Color color = Color.HSVToRGB(hue, 0.8f, 1f); for (int i = 0; i < _lsRef.Count; i++) { if ((Object)(object)_lsRef[i] != (Object)null) { _lsRef[i].color = color; } } } private void LightsRestore() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < _lsRef.Count; i++) { Light val = _lsRef[i]; if (!((Object)(object)val == (Object)null)) { val.color = _lsColor[i]; val.intensity = _lsIntensity[i]; } } _lsRef.Clear(); _lsColor.Clear(); _lsIntensity.Clear(); } private void FogStart(float density, Color color) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_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_0053: Unknown result type (might be due to invalid IL or missing references) FogStop(); _fogWasOn = RenderSettings.fog; _fogWasColor = RenderSettings.fogColor; _fogWasDensity = RenderSettings.fogDensity; _fogWasMode = RenderSettings.fogMode; _fogHeld = true; _hit++; RenderSettings.fog = true; RenderSettings.fogMode = (FogMode)2; RenderSettings.fogColor = color; RenderSettings.fogDensity = density; } private void FogStop() { //IL_0015: 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 (_fogHeld) { RenderSettings.fog = _fogWasOn; RenderSettings.fogColor = _fogWasColor; RenderSettings.fogDensity = _fogWasDensity; RenderSettings.fogMode = _fogWasMode; _fogHeld = false; } } private void ScanTints() { _tints.Clear(); List<Transform> list = TargetRoots(); for (int i = 0; i < list.Count; i++) { Transform val = list[i]; if ((Object)(object)val == (Object)null) { continue; } Il2CppArrayBase<Renderer> componentsInChildren = ((Component)val).GetComponentsInChildren<Renderer>(); for (int j = 0; j < componentsInChildren.Length; j++) { Renderer val2 = componentsInChildren[j]; if ((Object)(object)val2 == (Object)null) { continue; } Material sharedMaterial = val2.sharedMaterial; if (!((Object)(object)sharedMaterial == (Object)null)) { string text = (sharedMaterial.HasProperty("_Color") ? "_Color" : (sharedMaterial.HasProperty("_BaseColor") ? "_BaseColor" : null)); if (text != null) { _tints.Add(new Tint { R = val2, Prop = text }); } } } } } private void TintApply(Func<int, Color> colorFor) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) if (Stale(_cTints, 10f)) { RunScan(_cTints); } if (_block == null) { _block = new MaterialPropertyBlock(); } for (int i = 0; i < _tints.Count; i++) { Tint tint = _tints[i]; if (!((Object)(object)tint.R == (Object)null)) { _block.Clear(); _block.SetColor(tint.Prop, colorFor(i)); tint.R.SetPropertyBlock(_block); } } if (_tints.Count > 0) { _hit++; } } private void TintClear() { for (int i = 0; i < _tints.Count; i++) { Tint tint = _tints[i]; if ((Object)(object)tint.R != (Object)null) { tint.R.SetPropertyBlock((MaterialPropertyBlock)null); } } } private void PitchStart() { PitchStop(); AudioSource[] array = Sources(); for (int i = 0; i < array.Length; i++) { if (!((Object)(object)array[i] == (Object)null)) { _hit++; _asRef.Add(array[i]); _asPitch.Add(array[i].pitch); } } } private void PitchTick(float pitch) { if (Time.frameCount % 6 != 0) { return; } for (int i = 0; i < _asRef.Count; i++) { if ((Object)(object)_asRef[i] != (Object)null) { _asRef[i].pitch = pitch; } } } private void PitchStop() { for (int i = 0; i < _asRef.Count; i++) { if ((Object)(object)_asRef[i] != (Object)null) { _asRef[i].pitch = _asPitch[i]; } } _asRef.Clear(); _asPitch.Clear(); } private void SilenceStart() { if (!_volHeld) { _volBase = AudioListener.volume; _volHeld = true; } AudioListener.volume = 0f; _hit++; } private void SilenceStop() { if (_volHeld) { AudioListener.volume = _volBase; _volHeld = false; } } private Material PropMaterial() { if ((Object)(object)_propMat != (Object)null) { return _propMat; } if (_propMatTried) { return null; } _propMatTried = true; try { Material val = null; if (_beastRoots.Count > 0 && (Object)(object)_beastRoots[0] != (Object)null) { Il2CppArrayBase<Renderer> componentsInChildren = ((Component)_beastRoots[0]).GetComponentsInChildren<Renderer>(); for (int i = 0; i < componentsInChildren.Length; i++) { if (!((Object)(object)_propMat == (Object)null)) { break; } Material val2 = (((Object)(object)componentsInChildren[i] != (Object)null) ? componentsInChildren[i].sharedMaterial : null); if ((Object)(object)val2 != (Object)null && (val2.HasProperty("_Color") || val2.HasProperty("_BaseColor"))) { _propMat = val2; } } if ((Object)(object)_propMat != (Object)null) { return _propMat; } } Il2CppArrayBase<Renderer> val3 = Object.FindObjectsOfType<Renderer>(); int num = Mathf.Min(val3.Length, 800); for (int j = 0; j < num; j++) { Renderer val4 = val3[j]; if ((Object)(object)val4 == (Object)null || !val4.enabled) { continue; } Material sharedMaterial = val4.sharedMaterial; if (!((Object)(object)sharedMaterial == (Object)null) && (sharedMaterial.HasProperty("_Color") || sharedMaterial.HasProperty("_BaseColor"))) { if ((Object)(object)sharedMaterial.mainTexture == (Object)null) { _propMat = sharedMaterial; break; } if ((Object)(object)val == (Object)null) { val = sharedMaterial; } } } if ((Object)(object)_propMat == (Object)null) { _propMat = val; } } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Warning("Could not find a material for spawned objects: " + ex.Message); } return _propMat; } private Vector3 RootPos(Transform root) { //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_0009: 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_0075: 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_0044: 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) if ((Object)(object)root == (Object)null) { return Vector3.zero; } Vector3 val = Vector3.zero; int num = 0; for (int i = 0; i < _beastBodies.Count; i++) { Rigidbody val2 = _beastBodies[i]; if ((Object)(object)val2 != (Object)null && (Object)(object)((Component)val2).transform.root == (Object)(object)root) { val += val2.position; num++; } } if (num <= 0) { return root.position; } return val / (float)num; } private bool HasGround(float x, float z, float refY) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) RaycastHit val = default(RaycastHit); if (!Physics.Raycast(new Vector3(x, refY + 25f, z), Vector3.down, ref val, 60f)) { return false; } return ((RaycastHit)(ref val)).point.y > refY - 3f; } private Vector3 ScatterPos(Vector3 center, float height, float spread) { //IL_0097: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_003a: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) try { for (int i = 0; i < 12; i++) { float num = spread * ((i < 8) ? 1f : 0.4f); float num2 = center.x + Random.Range(0f - num, num); float num3 = center.z + Random.Range(0f - num, num); if (HasGround(num2, num3, center.y)) { return new Vector3(num2, center.y + height, num3); } } } catch (Exception ex) { if (_errLogged.Add("ground")) { ((MelonBase)this).LoggerInstance.Warning("Ground check failed: " + ex.Message); } } return center + Vector3.up * height; } private static Color RandomColor() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) return Random.ColorHSV(0f, 1f, 0.7f, 1f, 0.8f, 1f); } private void TrackSpawned(GameObject go) { _spawned.Add(go); if (_spawned.Count > 120) { _spawned.RemoveAll((GameObject g) => (Object)(object)g == (Object)null); } while (_spawned.Count > 160) { GameObject val = _spawned[0]; _spawned.RemoveAt(0); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } } } private GameObject SpawnProp(PrimitiveType type, Vector3 pos, Vector3 scale, Color color, float mass, float lifetime) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown _hit++; GameObject val = GameObject.CreatePrimitive(type); ((Object)val).name = "ChaosProp"; val.transform.position = pos; val.transform.localScale = scale; Renderer component = val.GetComponent<Renderer>(); if ((Object)(object)component != (Object)null) { Material val2 = PropMaterial(); if ((Object)(object)val2 != (Object)null) { component.sharedMaterial = val2; } Material sharedMaterial = component.sharedMaterial; string text = (((Object)(object)sharedMaterial != (Object)null && sharedMaterial.HasProperty("_BaseColor")) ? "_BaseColor" : "_Color"); if (_propBlock == null) { _propBlock = new MaterialPropertyBlock(); } _propBlock.Clear(); _propBlock.SetColor(text, color); component.SetPropertyBlock(_propBlock); } Rigidbody val3 = val.AddComponent<Rigidbody>(); val3.mass = mass; Object.Destroy((Object)(object)val, lifetime); Collider component2 = val.GetComponent<Collider>(); if ((Object)(object)component2 != (Object)null) { List<Solid> solids = _solids; Solid obj = new Solid { Rb = val3, Col = component2, Mass = mass }; Bounds bounds = component2.bounds; Vector3 extents = ((Bounds)(ref bounds)).extents; obj.Reach = ((Vector3)(ref extents)).magnitude + 0.6f; solids.Add(obj); } TrackSpawned(val); return val; } private void FireStart() { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) FireStop(); Bodies(); List<Transform> list = TargetRoots(); for (int i = 0; i < list.Count && i < 12; i++) { Transform val = list[i]; if ((Object)(object)val == (Object)null) { continue; } Rigidbody val2 = null; for (int j = 0; j < _beastBodies.Count; j++) { Rigidbody val3 = _beastBodies[j]; if ((Object)(object)val3 != (Object)null && (Object)(object)((Component)val3).transform.root == (Object)(object)val) { val2 = val3; break; } } Flame flame = new Flame { Follow = (((Object)(object)val2 != (Object)null) ? ((Component)val2).transform : val), Body = val2 }; flame.Obj = new GameObject("ChaosFire"); flame.Obj.transform.position = flame.Follow.position; flame.Lamp = flame.Obj.AddComponent<Light>(); flame.Lamp.type = (LightType)2; flame.Lamp.color = new Color(1f, 0.45f, 0.1f); flame.Lamp.range = 7f; flame.Lamp.intensity = 4f; _flames.Add(flame); _hit++; } } private void FireTick() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_00b3: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) int frameCount = Time.frameCount; for (int i = 0; i < _flames.Count; i++) { Flame flame = _flames[i]; if (!((Object)(object)flame.Follow == (Object)null) && !((Object)(object)flame.Obj == (Object)null)) { Vector3 position = flame.Follow.position; flame.Obj.transform.position = position + Vector3.up * 0.8f; flame.Lamp.intensity = 2.5f + Random.value * 3.5f; if (frameCount % 4 == 0) { Ember(position); } if ((Object)(object)flame.Body != (Object)null && (frameCount + i * 13) % 55 == 0) { Vector3 insideUnitSphere = Random.insideUnitSphere; insideUnitSphere.y = Mathf.Abs(insideUnitSphere.y) + 0.8f; flame.Body.AddForce(insideUnitSphere * 5f, (ForceMode)2); } } } if (frameCount % 3 == 0) { float t = Random.value; TintApply((int k) => Color.Lerp(new Color(1f, 0.25f, 0.02f), new Color(1f, 0.85f, 0.15f), Mathf.Repeat(t + (float)k * 0.13f, 1f))); } } private void FireStop() { for (int i = 0; i < _flames.Count; i++) { if ((Object)(object)_flames[i].Obj != (Object)null) { Object.Destroy((Object)(object)_flames[i].Obj); } } _flames.Clear(); TintClear(); } private void Ember(Vector3 around) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_014a: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: 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_0172: 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_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0); Collider component = obj.GetComponent<Collider>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } obj.transform.position = around + Random.insideUnitSphere * 0.5f + Vector3.up * 0.3f; obj.transform.localScale = Vector3.one * Random.Range(0.15f, 0.35f); Renderer component2 = obj.GetComponent<Renderer>(); if ((Object)(object)component2 != (Object)null) { Material val = PropMaterial(); if ((Object)(object)val != (Object)null) { component2.sharedMaterial = val; } Material sharedMaterial = component2.sharedMaterial; string text = (((Object)(object)sharedMaterial != (Object)null && sharedMaterial.HasProperty("_BaseColor")) ? "_BaseColor" : "_Color"); if (_propBlock == null) { _propBlock = new MaterialPropertyBlock(); } _propBlock.Clear(); _propBlock.SetColor(text, Color.Lerp(new Color(1f, 0.3f, 0.02f), new Color(1f, 0.9f, 0.2f), Random.value)); component2.SetPropertyBlock(_propBlock); } Rigidbody obj2 = obj.AddComponent<Rigidbody>(); obj2.useGravity = false; obj2.mass = 0.05f; obj2.velocity = Vector3.up * Random.Range(1.5f, 3.5f) + Random.insideUnitSphere * 0.6f; Object.Destroy((Object)(object)obj, 0.8f); } private void BotsStart(int count, float size, float mass) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unkno