Decompiled source of ForgePerformance v1.0.1
plugins/ForgePerformance/ForgePerformance.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using AIGraph; using Agents; using AirParticleSystem; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using CellMenu; using CullingSystem; using Decals; using Enemies; using FX_EffectSystem; using ForgePerformance.LoadShedding; using GTFO.API; using Gear; using HarmonyLib; using IRF; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using LevelGeneration; using Microsoft.CodeAnalysis; using SNetwork; using UnityEngine; using UnityEngine.Rendering; using WindVolume; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("ForgePerformance")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1")] [assembly: AssemblyProduct("ForgePerformance")] [assembly: AssemblyTitle("ForgePerformance")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 ForgePerformance { [BepInPlugin("NAinfini.ForgePerformance", "Forge Performance", "1.0.1")] [BepInDependency("dev.gtfomodding.gtfo-api", ">=0.6.1")] public sealed class Plugin : BasePlugin { internal static bool Quitting; private Action? _quitting; private LoadSheddingController? _shedding; private LoadSheddingWatch? _sheddingWatch; private WindCapacityProtection? _wind; public override void Load() { Quitting = false; FileHashCache.Store = Path.Combine(Paths.CachePath, "ForgePerformance", "file-sha256.txt"); SheddingSettings sheddingSettings = SheddingConfiguration.Read(((BasePlugin)this).Config, delegate(string line) { ((BasePlugin)this).Log.LogInfo((object)line); }); if (sheddingSettings.WindCapacityProtection || sheddingSettings.WindNearest) { _wind = new WindCapacityProtection(((BasePlugin)this).Log, sheddingSettings); _wind.Install(); } SheddingHookPlan sheddingHookPlan = SheddingHookPlan.Create(sheddingSettings); if (sheddingHookPlan.HasShedding) { _shedding = new LoadSheddingController(((BasePlugin)this).Log, sheddingHookPlan); _shedding.Install(); _sheddingWatch = ((BasePlugin)this).AddComponent<LoadSheddingWatch>(); } if (_wind != null || _shedding != null) { _quitting = DelegateSupport.ConvertDelegate<Action>((Delegate)new Action(OnQuitting)); Application.quitting += _quitting; } } private void OnQuitting() { Quitting = true; try { _wind?.Finish(); } catch (Exception ex) { ((BasePlugin)this).Log.LogError((object)("Wind capacity quit cleanup failed: " + ex)); } try { _shedding?.EndLevel(); } catch (Exception ex2) { ((BasePlugin)this).Log.LogError((object)("Load shedding quit restore failed: " + ex2)); } } public override bool Unload() { if (Quitting) { return true; } Exception failure = null; WindCapacityProtection wind = _wind; if (wind != null && Cleanup(wind.Dispose)) { _wind = null; } LoadSheddingController shedding = _shedding; if (shedding != null && Cleanup(shedding.Dispose)) { _shedding = null; } LoadSheddingWatch sheddingWatch = _sheddingWatch; if (sheddingWatch != null && Cleanup(delegate { ((Behaviour)sheddingWatch).enabled = false; })) { _sheddingWatch = null; } Action quitting = _quitting; if (quitting != null && Cleanup(delegate { Application.quitting -= quitting; })) { _quitting = null; } if (failure != null) { throw failure; } return true; bool Cleanup(Action action) { try { action(); return true; } catch (Exception ex) { failure = ((failure == null) ? ex : new AggregateException(failure, ex)); return false; } } } } } namespace ForgePerformance.LoadShedding { internal sealed class AmbientDustSuppression { private sealed record AmbientState(AmbientParticles Particles, int Count, bool Enabled); private sealed record AirState(AirParticleSystem Particles, float Throttle, bool Enabled); private readonly Dictionary<IntPtr, AmbientState> _ambient = new Dictionary<IntPtr, AmbientState>(); private readonly Dictionary<IntPtr, AirState> _air = new Dictionary<IntPtr, AirState>(); internal long Changed; internal long Restored; internal long SkippedSimulation; internal long SkippedAirCommands; internal int Seen => _ambient.Count + _air.Count; internal void BeginLevel() { Changed = (Restored = (SkippedSimulation = (SkippedAirCommands = 0L))); } internal void Ambient(AmbientParticles particles) { if (!((Object)(object)particles == (Object)null) && !_ambient.ContainsKey(((Il2CppObjectBase)particles).Pointer)) { _ambient.Add(((Il2CppObjectBase)particles).Pointer, new AmbientState(particles, particles.instanceCount, ((Behaviour)particles).enabled)); if (particles.instanceCount != 0 || ((Behaviour)particles).enabled) { Changed++; } particles.instanceCount = 0; ((Behaviour)particles).enabled = false; } } internal void Air(AirParticleSystem particles) { if (!((Object)(object)particles == (Object)null) && !_air.ContainsKey(((Il2CppObjectBase)particles).Pointer)) { _air.Add(((Il2CppObjectBase)particles).Pointer, new AirState(particles, particles.m_throttle, ((Behaviour)particles).enabled)); if (particles.m_throttle != 0f || ((Behaviour)particles).enabled) { Changed++; } particles.m_throttle = 0f; ((Behaviour)particles).enabled = false; } } internal bool SimulateAmbient() { SkippedSimulation++; return false; } internal bool CollectAir() { SkippedAirCommands++; return false; } internal bool PrewarmAir() { SkippedSimulation++; return false; } internal void EndLevel() { Exception ex = null; foreach (AmbientState value in _ambient.Values) { try { if ((Object)(object)value.Particles == (Object)null) { continue; } bool flag = false; try { if (value.Count != 0 && value.Particles.instanceCount == 0) { value.Particles.instanceCount = value.Count; if (value.Count > 0) { value.Particles.ResetSystem(); } flag = true; } } finally { if (value.Enabled && !((Behaviour)value.Particles).enabled) { ((Behaviour)value.Particles).enabled = true; flag = true; } } if (flag) { Restored++; } } catch (Exception ex2) { if (ex == null) { ex = ex2; } } } foreach (AirState value2 in _air.Values) { try { if ((Object)(object)value2.Particles == (Object)null) { continue; } bool flag2 = false; try { if (value2.Throttle != 0f && value2.Particles.m_throttle == 0f) { value2.Particles.m_throttle = value2.Throttle; value2.Particles.NotifyConfigChange(); flag2 = true; } } finally { if (value2.Enabled && !((Behaviour)value2.Particles).enabled) { ((Behaviour)value2.Particles).enabled = true; flag2 = true; } } if (flag2) { Restored++; } } catch (Exception ex3) { if (ex == null) { ex = ex3; } } } _ambient.Clear(); _air.Clear(); if (ex != null) { throw ex; } } } internal sealed class ClosedDoorDepth { private sealed class Door { internal readonly LG_Door_Sync Sync; internal readonly LG_WeakDoor_Anim? Anim; internal Action<pDoorState, bool>? OnState; internal Action? OnClosed; internal byte Status; internal bool Covering; internal bool Released; internal Door(LG_Door_Sync sync, LG_WeakDoor_Anim? anim) { Sync = sync; Anim = anim; } } internal const int PortalIsOpen = 296; internal const int CameraCullAgent = 24; internal const int CullerCurrentNode = 48; private readonly int _depth; private readonly List<Door> _doors = new List<Door>(); private int _version; private IntPtr _cameraField; private IntPtr[] _nodePointers = Array.Empty<IntPtr>(); private IntPtr[] _edgePointers = Array.Empty<IntPtr>(); private int[] _edgeDoor = Array.Empty<int>(); private bool[] _open = Array.Empty<bool>(); private bool[] _closedDoor = Array.Empty<bool>(); private IntPtr[] _flipped = Array.Empty<IntPtr>(); private DoorDepthGraph? _graph; private IntPtr _lastNode; private int _lastVersion = -1; private int _flippedCount; private bool _failed; private long _noSync; private long _shared; private long _released; private long _recomputes; private long _framesLimited; private long _closesTotal; private long _maximumClosed; private long _failures; internal (long Doors, long NoSync, long Shared, long Released, long Nodes, long Portals, long Recomputes, long FramesLimited, long ClosesTotal, long MaximumClosed, long Failures) Counts => (Doors: _doors.Count, NoSync: _noSync, Shared: _shared, Released: _released, Nodes: _nodePointers.Length, Portals: _edgePointers.Length, Recomputes: _recomputes, FramesLimited: _framesLimited, ClosesTotal: _closesTotal, MaximumClosed: _maximumClosed, Failures: _failures); internal ClosedDoorDepth(int depth) { _depth = depth; } internal void BuildDone() { EndLevel(); List<AIG_CourseNode> s_allNodes = AIG_CourseNode.s_allNodes; if (s_allNodes == null) { return; } HashSet<IntPtr> hashSet = new HashSet<IntPtr>(); Dictionary<IntPtr, int> dictionary = new Dictionary<IntPtr, int>(); Dictionary<IntPtr, int> dictionary2 = new Dictionary<IntPtr, int>(); HashSet<IntPtr> hashSet2 = new HashSet<IntPtr>(); for (int i = 0; i < s_allNodes.Count; i++) { AIG_CourseNode obj = s_allNodes[i]; List<AIG_CoursePortal> val = ((obj != null) ? obj.m_portals : null); if (val == null) { continue; } for (int j = 0; j < val.Count; j++) { AIG_CoursePortal val2 = val[j]; if (val2 == null || !hashSet.Add(((Il2CppObjectBase)val2).Pointer)) { continue; } iLG_Door_Core door = val2.m_door; C_Portal cullPortal = val2.m_cullPortal; if (door == null || cullPortal == null) { continue; } if (!dictionary2.TryGetValue(((Il2CppObjectBase)door).Pointer, out var value)) { value = Track(door); dictionary2.Add(((Il2CppObjectBase)door).Pointer, value); } if (value >= 0) { if (dictionary.TryGetValue(((Il2CppObjectBase)cullPortal).Pointer, out var value2) && value2 != value) { hashSet2.Add(((Il2CppObjectBase)cullPortal).Pointer); _shared++; } dictionary[((Il2CppObjectBase)cullPortal).Pointer] = value; } } } foreach (IntPtr item in hashSet2) { dictionary.Remove(item); } if (_doors.Count != 0) { BuildGraph(s_allNodes, dictionary); } } private int Track(iLG_Door_Core core) { //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Expected I4, but got Unknown //IL_0148: Unknown result type (might be due to invalid IL or missing references) LG_WeakDoor val = ((Il2CppObjectBase)core).TryCast<LG_WeakDoor>(); LG_SecurityDoor val2 = (((Object)(object)val == (Object)null) ? ((Il2CppObjectBase)core).TryCast<LG_SecurityDoor>() : null); Component val3 = (((Object)(object)val != (Object)null) ? val.m_syncComp : ((val2 != null) ? val2.m_syncComp : null)); LG_Door_Sync val4 = (((Object)(object)val3 == (Object)null) ? null : ((Il2CppObjectBase)val3).TryCast<LG_Door_Sync>()); if ((Object)(object)val4 == (Object)null) { _noSync++; return -1; } object obj; if (val == null) { obj = null; } else { Component animComp = val.m_animComp; obj = ((animComp != null) ? ((Il2CppObjectBase)animComp).TryCast<LG_WeakDoor_Anim>() : null); } LG_WeakDoor_Anim val5 = (LG_WeakDoor_Anim)obj; Door door = new Door(val4, val5); door.OnState = DelegateSupport.ConvertDelegate<Action<pDoorState, bool>>((Delegate)(Action<pDoorState, bool>)delegate(pDoorState state, bool dropIn) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) Changed(door, state, dropIn); }); if ((Object)(object)val5 != (Object)null) { door.OnClosed = DelegateSupport.ConvertDelegate<Action>((Delegate)(Action)delegate { AnimationClosed(door); }); } _doors.Add(door); val4.OnDoorStateChange += door.OnState; if ((Object)(object)val5 != (Object)null) { val5.OnDoorIsClosed += door.OnClosed; } pDoorState currentSyncState = val4.GetCurrentSyncState(); byte b = (byte)(int)currentSyncState.status; door.Status = b; Apply(door, DoorCullingPolicy.OnState(b, b, currentSyncState.damageTaken > 0f, dropIn: true)); return _doors.Count - 1; } private void Changed(Door door, pDoorState state, bool dropIn) { //IL_000a: 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: Expected I4, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) try { if (!door.Released) { byte status = (byte)(int)state.status; DoorCullingPolicy.Portal decision = DoorCullingPolicy.OnState(door.Status, status, state.damageTaken > 0f, dropIn); door.Status = status; Apply(door, decision); } } catch (Exception error) { Fail(error); } } private void AnimationClosed(Door door) { try { if (!door.Released && DoorCullingPolicy.Covers(door.Status) && !door.Covering) { door.Covering = true; _version++; } } catch (Exception error) { Fail(error); } } private void Apply(Door door, DoorCullingPolicy.Portal decision) { bool flag = decision == DoorCullingPolicy.Portal.Close; if (decision == DoorCullingPolicy.Portal.Release) { door.Released = true; _released++; } if (door.Covering != flag || decision == DoorCullingPolicy.Portal.Release) { door.Covering = flag; _version++; } } private void BuildGraph(List<AIG_CourseNode> courseNodes, Dictionary<IntPtr, int> portalDoor) { Dictionary<IntPtr, int> index = new Dictionary<IntPtr, int>(); List<C_Node> nodes = new List<C_Node>(); Queue<C_Node> pending = new Queue<C_Node>(); for (int i = 0; i < courseNodes.Count; i++) { AIG_CourseNode obj = courseNodes[i]; Add((obj != null) ? obj.m_cullNode : null); } List<C_Portal> list = new List<C_Portal>(); HashSet<IntPtr> hashSet = new HashSet<IntPtr>(); while (pending.Count != 0) { List<C_Portal> portals = pending.Dequeue().m_portals; if (portals == null) { continue; } for (int j = 0; j < portals.Count; j++) { C_Portal val = portals[j]; if (val != null && hashSet.Add(((Il2CppObjectBase)val).Pointer)) { Add(val.m_backwardsNode); Add(val.m_forwardsNode); if (val.m_backwardsNode != null && val.m_forwardsNode != null) { list.Add(val); } } } } int[] array = new int[list.Count]; int[] array2 = new int[list.Count]; _edgePointers = new IntPtr[list.Count]; _edgeDoor = new int[list.Count]; for (int k = 0; k < list.Count; k++) { array[k] = index[((Il2CppObjectBase)list[k].m_backwardsNode).Pointer]; array2[k] = index[((Il2CppObjectBase)list[k].m_forwardsNode).Pointer]; _edgePointers[k] = ((Il2CppObjectBase)list[k]).Pointer; _edgeDoor[k] = (portalDoor.TryGetValue(((Il2CppObjectBase)list[k]).Pointer, out var value) ? value : (-1)); } _nodePointers = new IntPtr[nodes.Count]; for (int l = 0; l < nodes.Count; l++) { _nodePointers[l] = ((Il2CppObjectBase)nodes[l]).Pointer; } _open = new bool[list.Count]; _closedDoor = new bool[list.Count]; _flipped = new IntPtr[list.Count]; _graph = new DoorDepthGraph(nodes.Count, array, array2); _cameraField = IL2CPP.GetIl2CppField(Il2CppClassPointerStore<C_Camera>.NativeClassPtr, "Current"); if (_cameraField == IntPtr.Zero) { throw new MissingFieldException("C_Camera", "Current"); } _lastNode = IntPtr.Zero; _lastVersion = -1; void Add(C_Node? node) { if (node != null && !index.ContainsKey(((Il2CppObjectBase)node).Pointer)) { index.Add(((Il2CppObjectBase)node).Pointer, nodes.Count); nodes.Add(node); pending.Enqueue(node); } } } internal unsafe void BeforeVisibility() { if (_graph == null || _failed) { return; } try { IntPtr zero = IntPtr.Zero; IL2CPP.il2cpp_field_static_get_value(_cameraField, (void*)(&zero)); if (zero == IntPtr.Zero) { return; } IntPtr intPtr = Marshal.ReadIntPtr(zero, 24); if (intPtr == IntPtr.Zero) { return; } IntPtr intPtr2 = Marshal.ReadIntPtr(intPtr, 48); if (intPtr2 != _lastNode || _version != _lastVersion) { Recompute(intPtr2); } for (int i = 0; i < _graph.CloseCount; i++) { IntPtr intPtr3 = _edgePointers[_graph.Closed(i)]; if (Marshal.ReadByte(intPtr3, 296) == 1) { Marshal.WriteByte(intPtr3, 296, 0); _flipped[_flippedCount++] = intPtr3; } } if (_flippedCount != 0) { _framesLimited++; _closesTotal += _flippedCount; if (_flippedCount > _maximumClosed) { _maximumClosed = _flippedCount; } } } catch (Exception error) { AfterVisibility(); Fail(error); } } internal void AfterVisibility() { for (int i = 0; i < _flippedCount; i++) { if (Marshal.ReadByte(_flipped[i], 296) == 0) { Marshal.WriteByte(_flipped[i], 296, 1); } } _flippedCount = 0; } private void Recompute(IntPtr node) { _lastNode = node; _lastVersion = _version; _recomputes++; int camera = Array.IndexOf(_nodePointers, node); for (int i = 0; i < _edgePointers.Length; i++) { _open[i] = Marshal.ReadByte(_edgePointers[i], 296) == 1; int num = _edgeDoor[i]; _closedDoor[i] = num >= 0 && _doors[num].Covering; } _graph.Compute(camera, _open, _closedDoor, _depth); } private void Fail(Exception error) { _failed = true; if (_failures++ == 0L) { LoadSheddingController.Current?.LogExtraFailure("closed-door-depth", error.GetType().Name + ": " + error.Message); } } internal void EndLevel() { Exception ex = null; try { AfterVisibility(); } catch (Exception ex2) { if (ex == null) { ex = ex2; } } foreach (Door door in _doors) { try { if ((Object)(object)door.Sync != (Object)null && door.OnState != null) { door.Sync.OnDoorStateChange -= door.OnState; } } catch (Exception ex3) { if (ex == null) { ex = ex3; } } try { if ((Object)(object)door.Anim != (Object)null && door.OnClosed != null) { door.Anim.OnDoorIsClosed -= door.OnClosed; } } catch (Exception ex4) { if (ex == null) { ex = ex4; } } } _doors.Clear(); _graph = null; _failed = false; _nodePointers = Array.Empty<IntPtr>(); _edgePointers = Array.Empty<IntPtr>(); _edgeDoor = Array.Empty<int>(); _open = (_closedDoor = Array.Empty<bool>()); _flipped = Array.Empty<IntPtr>(); _noSync = (_shared = (_released = (_recomputes = (_framesLimited = (_closesTotal = (_maximumClosed = (_failures = 0L))))))); if (ex != null) { throw ex; } } } internal enum DecorationClass { Unknown, Gameplay, VisualRotator, CombatDecal, StaticGeneralLight } internal enum DecorationUse { Shadow, Distance, Animation, Decal, Light } [Flags] internal enum DecorationRisk { None = 0, UnknownComponent = 1, Gameplay = 2, Collider = 4, BlocksSight = 8, AnimationEvents = 0x10, RootMotion = 0x20, StateBehaviour = 0x40, ControlledLight = 0x80, PlayerLight = 0x100, UnverifiedLightReceiver = 0x200 } internal static class DecorationClassifier { internal const string NonOccludingShaderName = "Legacy Shaders/Particles/Additive"; internal const string ShaderAssetSha256 = "3BBBDC31F2D9C0A30BD2098A6710606D72708F6F73986D4D10F5A21EE7490CE6"; internal static bool NonOccludingShader(string name, bool verifiedAsset, bool supported, int passes, int queue) { if (verifiedAsset && supported && passes == 1 && queue >= 3000) { return name == "Legacy Shaders/Particles/Additive"; } return false; } internal static bool Allows(DecorationClass identity, DecorationRisk risks, DecorationUse use) { if ((risks & (DecorationRisk.UnknownComponent | DecorationRisk.Gameplay | DecorationRisk.Collider | DecorationRisk.AnimationEvents | DecorationRisk.RootMotion | DecorationRisk.StateBehaviour)) != DecorationRisk.None) { return false; } return use switch { DecorationUse.Shadow => identity == DecorationClass.VisualRotator, DecorationUse.Distance => identity == DecorationClass.VisualRotator && (risks & DecorationRisk.BlocksSight) == 0, DecorationUse.Animation => identity == DecorationClass.VisualRotator && (risks & (DecorationRisk.AnimationEvents | DecorationRisk.RootMotion | DecorationRisk.StateBehaviour)) == 0, DecorationUse.Decal => identity == DecorationClass.CombatDecal, DecorationUse.Light => identity == DecorationClass.StaticGeneralLight && (risks & (DecorationRisk.ControlledLight | DecorationRisk.PlayerLight | DecorationRisk.UnverifiedLightReceiver)) == 0, _ => false, }; } internal static bool IsVisualComponent(string type) { switch (type) { case "UnityEngine.Transform": case "UnityEngine.MeshRenderer": case "UnityEngine.MeshFilter": case "UnityEngine.SkinnedMeshRenderer": case "UnityEngine.Animator": case "LG_AnimatorRotator": case "LG_Culler": return true; default: return false; } } internal static bool IsDecalComponent(string type) { switch (type) { case "UnityEngine.Transform": case "FX_EffectSystem.FX_Decal": case "Decals.Decal": return true; default: return false; } } internal static bool CombatImpact(int group) { if (group >= 1) { return group <= 16; } return false; } } internal static class DecorationPolicy { internal static float Lifetime(float original, float maximum) { if (!float.IsFinite(original) || original <= 0f) { throw new ArgumentOutOfRangeException("original"); } if (!float.IsFinite(maximum) || maximum <= 0f) { throw new ArgumentOutOfRangeException("maximum"); } return Math.Min(original, maximum); } internal static bool Beyond(float squaredDistance, float limit) { if (float.IsFinite(squaredDistance)) { return squaredDistance > limit * limit; } return false; } internal static bool KeepLight(bool decorative, ref int count, int limit) { if (!decorative) { return true; } return count++ < limit; } } internal sealed class DecalBudget<T> where T : class { private readonly T?[] _values; private readonly float[] _expires; internal int Count { get; private set; } internal DecalBudget(int capacity) { if (capacity < 1 || capacity > 4096) { throw new ArgumentOutOfRangeException("capacity"); } _values = new T[capacity]; _expires = new float[capacity]; } internal void Add(T value, float expires, Action<T> retire) { Remove(value); if (Count == _values.Length) { Take(0, retire); } _values[Count] = value; _expires[Count++] = expires; } internal void Expire(float now, Action<T> retire) { for (int num = Count - 1; num >= 0; num--) { if (now >= _expires[num]) { Take(num, retire); } } } internal void Remove(T value) { for (int i = 0; i < Count; i++) { if (_values[i] == value) { RemoveAt(i); break; } } } internal void Clear() { Array.Clear(_values, 0, Count); Count = 0; } private void Take(int index, Action<T> retire) { T obj = _values[index]; RemoveAt(index); retire(obj); } private void RemoveAt(int index) { Array.Copy(_values, index + 1, _values, index, Count - index - 1); Array.Copy(_expires, index + 1, _expires, index, Count - index - 1); _values[--Count] = null; } } internal sealed class DecorationShedding { internal sealed class VisualEntry { internal readonly LG_AnimatorRotator Rotator; internal readonly GameObject Body; internal readonly C_CullBucket Culler; internal readonly DecorationRisk Risks; internal readonly bool ShadowEligible; internal readonly List<(SkinnedMeshRenderer, bool)> Skins = new List<(SkinnedMeshRenderer, bool)>(); internal readonly List<(Animator, AnimatorCullingMode)> Animators = new List<(Animator, AnimatorCullingMode)>(); internal bool Hidden; internal bool Culled; internal bool Shadowed; internal VisualEntry(LG_AnimatorRotator rotator, C_CullBucket culler, DecorationRisk risks, bool shadowEligible) { Rotator = rotator; Body = ((Component)rotator).gameObject; Culler = culler; Risks = risks; ShadowEligible = shadowEligible; } } private sealed class LightEntry { internal readonly C_Light Light; internal readonly CL_Light Cluster; internal DecorationRisk Risks; internal List<C_Light>? List; internal bool Touched; internal bool Dropped; internal int OriginalIndex; internal int OriginalActiveId; internal long Sequence; internal LightEntry(C_Light light, DecorationRisk risks) { Light = light; Cluster = light.m_clusterLight; Risks = risks; } } private sealed record DecalEntry(IntPtr Key, FX_Decal Effect, float Lifetime, float Fade, float End); internal sealed class ShadowScope : ListScope<C_Cullable> { private readonly RemovalPlan<VisualEntry>?[] _plans = new RemovalPlan<VisualEntry>[3]; private readonly List<C_Cullable>?[] _lists = new List<C_Cullable>[3]; private int _tracked; internal bool UsesPlans; internal void Track(RemovalPlan<VisualEntry> plan, List<C_Cullable> list) { _plans[_tracked] = plan; _lists[_tracked++] = list; } internal new int Restore() { int result = base.Restore(); for (int i = 0; i < _tracked; i++) { _plans[i].Reverted(NativeList<C_Cullable>.VersionOf(((Il2CppObjectBase)_lists[i]).Pointer)); _plans[i] = null; _lists[i] = null; } _tracked = 0; UsesPlans = false; return result; } } internal class ListScope<T> where T : Il2CppObjectBase { private readonly (List<T> list, int index, T value)[] _removed = new(List<T>, int, T)[4096]; private int _count; internal bool Active; internal void Remove(List<T> list, int index, T value) { if (_count == _removed.Length) { throw new InvalidOperationException("Decoration list exceeds 4096 removals."); } _removed[_count++] = (list: list, index: index, value: value); list.RemoveAt(index); } internal int Restore() { int count = _count; while (_count != 0) { (List<T>, int, T) tuple = _removed[_count - 1]; tuple.Item1.Insert(tuple.Item2, tuple.Item3); _removed[--_count] = default((List<T>, int, T)); } Active = false; return count; } } private readonly LoadSheddingController _owner; private readonly Dictionary<IntPtr, VisualEntry> _visuals = new Dictionary<IntPtr, VisualEntry>(); private readonly Dictionary<IntPtr, LightEntry> _lights = new Dictionary<IntPtr, LightEntry>(); private readonly Dictionary<IntPtr, DecalEntry> _decals = new Dictionary<IntPtr, DecalEntry>(); private readonly Dictionary<IntPtr, DecorationClass> _classified = new Dictionary<IntPtr, DecorationClass>(); private readonly Dictionary<IntPtr, DecorationRisk> _decalRisks = new Dictionary<IntPtr, DecorationRisk>(); private readonly HashSet<IntPtr> _controlledLights = new HashSet<IntPtr>(); private readonly long[] _classes = new long[5]; private readonly DecalBudget<DecalEntry> _decalBudget; private readonly Action<DecalEntry> _retire; private int _impactDepth; private long _shadowSeen; private long _shadowChanged; private long _shadowRestored; private long _shadowCalls; private long _shadowPlanHits; private long _shadowPlanMisses; private long _cullSeen; private long _cullChanged; private long _cullRestored; private long _cullCalls; private long _cullReleased; private List<C_Cullable>? _nativeShown; private readonly HashSet<IntPtr> _shown = new HashSet<IntPtr>(); private int _shownVersion; private bool _shownRead; private long _animationSeen; private long _animationChanged; private long _animationRestored; private long _decalSeen; private long _decalChanged; private long _decalSkipped; private long _decalRestored; private long _decalRetired; private long _lightSeen; private long _lightChanged; private long _lightSkipped; private long _lightRestored; private long _lightReleased; private long _visibilitySequence; private bool _lightReferencesResolved; private long _inspectionFailures; private string _inspectionReason = "none"; private readonly bool _shaderAssetVerified; private readonly string _shaderAssetReason = "disabled"; private Shader? _nonOccludingShader; private readonly LightEntry?[] _lightCandidates = new LightEntry[64]; private readonly ShadowScope[] _shadowScopes = new ShadowScope[4] { new ShadowScope(), new ShadowScope(), new ShadowScope(), new ShadowScope() }; private readonly List<VisualEntry> _distanceCandidates = new List<VisualEntry>(); private readonly List<VisualEntry> _hiddenByDistance = new List<VisualEntry>(); private readonly Dictionary<IntPtr, RemovalPlan<VisualEntry>> _shadowPlans = new Dictionary<IntPtr, RemovalPlan<VisualEntry>>(); private SheddingSettings Settings => _owner.Settings; internal DecorationShedding(LoadSheddingController owner) { _owner = owner; _decalBudget = new DecalBudget<DecalEntry>(owner.Settings.DecalLimit); _retire = Retire; if (!owner.Settings.DecorationCulling) { return; } try { _shaderAssetVerified = FileHashCache.Sha256(Path.Combine(Paths.GameRootPath, "GTFO_Data", "globalgamemanagers.assets")) == "3BBBDC31F2D9C0A30BD2098A6710606D72708F6F73986D4D10F5A21EE7490CE6"; _shaderAssetReason = (_shaderAssetVerified ? "verified_single_additive_pass" : "asset_fingerprint_mismatch"); } catch (Exception ex) { _shaderAssetReason = "asset_unavailable:" + ex.GetType().Name + ": " + ex.Message; } } private DecorationRisk Hierarchy(GameObject root, bool decal = false) { try { return InspectHierarchy(root, decal); } catch (Exception ex) { _inspectionFailures++; _inspectionReason = ex.GetType().Name + ": " + ex.Message; return DecorationRisk.UnknownComponent; } } private DecorationRisk InspectHierarchy(GameObject root, bool decal) { DecorationRisk decorationRisk = DecorationRisk.None; foreach (Component componentsInChild in root.GetComponentsInChildren<Component>(true)) { if ((Object)(object)componentsInChild == (Object)null) { decorationRisk |= DecorationRisk.UnknownComponent; continue; } if ((Object)(object)((Il2CppObjectBase)componentsInChild).TryCast<Collider>() != (Object)null || (Object)(object)((Il2CppObjectBase)componentsInChild).TryCast<Rigidbody>() != (Object)null) { decorationRisk |= DecorationRisk.Collider; } string fullName = ((Object)componentsInChild).GetIl2CppType().FullName; if (!(decal ? DecorationClassifier.IsDecalComponent(fullName) : DecorationClassifier.IsVisualComponent(fullName))) { decorationRisk |= DecorationRisk.UnknownComponent; } Animator val = ((Il2CppObjectBase)componentsInChild).TryCast<Animator>(); if ((Object)(object)val != (Object)null) { if (val.hasRootMotion || val.applyRootMotion) { decorationRisk |= DecorationRisk.RootMotion; } if (val.hasBoundPlayables || ((Il2CppArrayBase<ScriptableObject>)(object)val.InternalGetBehaviours(Il2CppType.Of<StateMachineBehaviour>())).Length != 0) { decorationRisk |= DecorationRisk.StateBehaviour; } RuntimeAnimatorController runtimeAnimatorController = val.runtimeAnimatorController; if ((Object)(object)runtimeAnimatorController == (Object)null) { decorationRisk |= DecorationRisk.UnknownComponent; } else { foreach (AnimationClip item in (Il2CppArrayBase<AnimationClip>)(object)runtimeAnimatorController.animationClips) { if ((Object)(object)item == (Object)null || ((Il2CppArrayBase<AnimationEvent>)(object)item.events).Length != 0) { decorationRisk |= DecorationRisk.AnimationEvents; } } } } Renderer val2 = ((Il2CppObjectBase)componentsInChild).TryCast<Renderer>(); if (!((Object)(object)val2 != (Object)null)) { continue; } foreach (Material item2 in (Il2CppArrayBase<Material>)(object)val2.sharedMaterials) { if ((Object)(object)item2 == (Object)null || (Object)(object)item2.shader == (Object)null || (Object)(object)_nonOccludingShader == (Object)null || ((Il2CppObjectBase)item2.shader).Pointer != ((Il2CppObjectBase)_nonOccludingShader).Pointer || !DecorationClassifier.NonOccludingShader(((Object)item2.shader).name, _shaderAssetVerified, item2.shader.isSupported, item2.passCount, item2.renderQueue)) { decorationRisk |= DecorationRisk.BlocksSight; } } } if (!decal) { decorationRisk |= ParentRisk(root.transform); } return decorationRisk; } private static DecorationRisk ParentRisk(Transform start) { DecorationRisk decorationRisk = DecorationRisk.None; Transform parent = start.parent; while ((Object)(object)parent != (Object)null && !((Object)(object)((Component)parent).GetComponent<LG_Geomorph>() != (Object)null)) { foreach (Component component in ((Component)parent).GetComponents<Component>()) { if ((Object)(object)component == (Object)null || ((Object)component).GetIl2CppType().FullName != "UnityEngine.Transform") { decorationRisk |= DecorationRisk.Gameplay; } } parent = parent.parent; } return decorationRisk; } private static bool OwnedRenderers(List<Renderer>? renderers, Transform root) { if (renderers == null) { return false; } Enumerator<Renderer> enumerator = renderers.GetEnumerator(); while (enumerator.MoveNext()) { Renderer current = enumerator.Current; if ((Object)(object)current == (Object)null || (Object)(object)((Component)current).transform == (Object)null || (((Il2CppObjectBase)((Component)current).transform).Pointer != ((Il2CppObjectBase)root).Pointer && !((Component)current).transform.IsChildOf(root))) { return false; } } return true; } internal void CameraBefore() { if (!_owner.Active) { return; } List<VisualEntry> hiddenByDistance = _hiddenByDistance; if (hiddenByDistance.Count == 0) { return; } ReadShown(); try { for (int i = 0; i < hiddenByDistance.Count; i++) { VisualEntry visualEntry = hiddenByDistance[i]; if (visualEntry.Hidden && !((Object)(object)visualEntry.Rotator == (Object)null)) { RestoreVisibility(visualEntry); } } } finally { _shownRead = false; _shown.Clear(); } hiddenByDistance.Clear(); } private void ReadShown() { List<C_Cullable> nativeShown = _nativeShown; if (nativeShown == null) { return; } IntPtr pointer = ((Il2CppObjectBase)nativeShown).Pointer; _shownVersion = NativeList<C_Cullable>.VersionOf(pointer); int i = 0; for (int num = NativeList<C_Cullable>.Count(pointer); i < num; i++) { if (_visuals.TryGetValue(NativeList<C_Cullable>.Item(pointer, i), out VisualEntry value) && value.Hidden) { _shown.Add(((Il2CppObjectBase)value.Culler).Pointer); } } _shownRead = true; } private bool Listed(C_CullBucket culler) { List<C_Cullable> nativeShown = _nativeShown; if (nativeShown == null) { return false; } if (_shownRead && NativeList<C_Cullable>.VersionOf(((Il2CppObjectBase)nativeShown).Pointer) == _shownVersion) { return _shown.Contains(((Il2CppObjectBase)culler).Pointer); } return nativeShown.Contains((C_Cullable)(object)culler); } private void RestoreVisibility(VisualEntry entry) { if (entry.Body.activeInHierarchy && NativeReads.IsRegistered((C_Cullable)(object)entry.Culler) && Listed(entry.Culler)) { ((C_Cullable)entry.Culler).Show(); _cullRestored++; } else { _cullReleased++; } entry.Hidden = false; } internal void CameraAfter() { //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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) if (!_owner.Active || _owner.IsRefused(SheddingCut.DecorationCulling)) { return; } ClusteredRendering current = ClusteredRendering.Current; Camera val = ((current != null) ? current.m_camera : null); if ((Object)(object)val == (Object)null) { return; } Vector3 position = ((Component)val).transform.position; List<VisualEntry> distanceCandidates = _distanceCandidates; for (int i = 0; i < distanceCandidates.Count; i++) { VisualEntry visualEntry = distanceCandidates[i]; if ((Object)(object)visualEntry.Rotator == (Object)null || !NativeReads.IsShown((C_Cullable)(object)visualEntry.Culler)) { continue; } _cullCalls++; if (DecorationPolicy.Beyond(SqrDistance(NativeReads.Bounds((C_Cullable)(object)visualEntry.Culler), position), Settings.CullDistance)) { ((C_Cullable)visualEntry.Culler).HideSafe(); if (!visualEntry.Hidden) { _hiddenByDistance.Add(visualEntry); } visualEntry.Hidden = true; if (!visualEntry.Culled) { visualEntry.Culled = true; _cullChanged++; } } } } private static float SqrDistance(Bounds bounds, Vector3 point) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0014: 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_0020: 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_002d: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) Vector3 center = bounds.m_Center; Vector3 extents = bounds.m_Extents; float num = point.x - Math.Clamp(point.x, center.x - extents.x, center.x + extents.x); float num2 = point.y - Math.Clamp(point.y, center.y - extents.y, center.y + extents.y); float num3 = point.z - Math.Clamp(point.z, center.z - extents.z, center.z + extents.z); return num * num + num2 * num2 + num3 * num3; } internal ShadowScope? Shadows(CL_ShadowGenerator generator) { if (!_owner.Active || _owner.IsRefused(SheddingCut.DecorationShadows)) { return null; } ShadowScope shadowScope = null; bool flag = false; ShadowScope[] shadowScopes = _shadowScopes; foreach (ShadowScope shadowScope2 in shadowScopes) { if (shadowScope2.Active) { flag = true; } else if (shadowScope == null) { shadowScope = shadowScope2; } } if (shadowScope == null) { throw new InvalidOperationException("Decoration shadow nesting exceeds four calls."); } shadowScope.Active = true; shadowScope.UsesPlans = !flag; try { FilterShadows(generator.StaticCullables, shadowScope); FilterShadows(generator.MovingCullables, shadowScope); FilterShadows(generator.DynamicCullables, shadowScope); return shadowScope; } catch { shadowScope.Restore(); throw; } } private void FilterShadows(List<C_Cullable> list, ShadowScope scope) { if (list == null) { return; } if (!scope.UsesPlans) { ScanShadows(list, scope, null); return; } IntPtr pointer = ((Il2CppObjectBase)list).Pointer; int version = NativeList<C_Cullable>.VersionOf(pointer); int count = NativeList<C_Cullable>.Count(pointer); if (!_shadowPlans.TryGetValue(pointer, out RemovalPlan<VisualEntry> value)) { value = (_shadowPlans[pointer] = new RemovalPlan<VisualEntry>()); } if (value.Matches(pointer, version, count)) { _shadowPlanHits++; for (int i = 0; i < value.Length; i++) { scope.Remove(list, value.IndexAt(i), (C_Cullable)(object)value.ItemAt(i).Culler); _shadowCalls++; } } else { _shadowPlanMisses++; value.Begin(pointer, version, count); ScanShadows(list, scope, value); value.Commit(); } scope.Track(value, list); } private void ScanShadows(List<C_Cullable> list, ShadowScope scope, RemovalPlan<VisualEntry>? plan) { IntPtr pointer = ((Il2CppObjectBase)list).Pointer; for (int num = NativeList<C_Cullable>.Count(pointer) - 1; num >= 0; num--) { if (_visuals.TryGetValue(NativeList<C_Cullable>.Item(pointer, num), out VisualEntry value) && value.ShadowEligible && DecorationClassifier.Allows(DecorationClass.VisualRotator, value.Risks, DecorationUse.Shadow)) { scope.Remove(list, num, (C_Cullable)(object)value.Culler); _shadowCalls++; plan?.Add(num, value); if (!value.Shadowed) { value.Shadowed = true; _shadowChanged++; } } } } internal int ImpactBegin(FX_GroupName group) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected I4, but got Unknown int impactDepth = _impactDepth; _impactDepth = ((_owner.Active && DecorationClassifier.CombatImpact((int)group)) ? (impactDepth + 1) : 0); return impactDepth; } internal void ImpactEnd(int previous) { _impactDepth = previous; } internal void DecalPlay(FX_Decal effect) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (!_owner.Active || (Object)(object)effect == (Object)null || (Object)(object)effect.m_decal == (Object)null) { return; } _decalSeen++; Decal decal = effect.m_decal; DecorationClass decorationClass = ((_impactDepth != 0 && (int)decal.m_decalType == 0) ? DecorationClass.CombatDecal : DecorationClass.Unknown); Classify(((Il2CppObjectBase)decal).Pointer, decorationClass); if (decorationClass != DecorationClass.CombatDecal) { _decalSkipped++; return; } if (!_decalRisks.TryGetValue(((Il2CppObjectBase)effect).Pointer, out var value)) { value = (_decalRisks[((Il2CppObjectBase)effect).Pointer] = Hierarchy(((Component)effect).gameObject, decal: true)); } if (!DecorationClassifier.Allows(decorationClass, value, DecorationUse.Decal) || !float.IsFinite(effect.m_uniqueLifeTime) || effect.m_uniqueLifeTime <= 0f || (effect.m_feedMaterialLife && (!float.IsFinite(effect.m_feedMaterialLifeStartAt) || effect.m_feedMaterialLifeStartAt <= 0f || (Object)(object)effect.m_instancedMaterialRef == (Object)null))) { _decalSkipped++; return; } DecalReturn(effect); float uniqueLifeTime = effect.m_uniqueLifeTime; float num = DecorationPolicy.Lifetime(uniqueLifeTime, Settings.DecalLifetime); DecalEntry value2 = new DecalEntry(((Il2CppObjectBase)effect).Pointer, effect, uniqueLifeTime, effect.m_fadeoutMod, Time.time + uniqueLifeTime); _decals.Add(((Il2CppObjectBase)effect).Pointer, value2); effect.m_uniqueLifeTime = num; if (effect.m_feedMaterialLife && effect.m_feedMaterialLifeStartAt > 0f && (Object)(object)effect.m_instancedMaterialRef != (Object)null) { effect.m_fadeoutMod = 1f / effect.m_feedMaterialLifeStartAt / num; effect.m_instancedMaterialRef.SetFloat(FX_Decal.s_decalLifeIDHash, effect.m_fadeoutMod); } _decalBudget.Add(value2, Time.time + num, _retire); _decalChanged++; } internal void DecalReturn(FX_Decal effect) { if (_decals.Remove(((Il2CppObjectBase)effect).Pointer, out DecalEntry value)) { _decalBudget.Remove(value); RestoreDecal(value); } } private void RestoreDecal(DecalEntry entry) { FX_Decal effect = entry.Effect; if (!((Object)(object)effect == (Object)null)) { effect.m_uniqueLifeTime = entry.Lifetime; effect.m_fadeoutMod = entry.Fade; ((FX_EffectContent)effect).m_endTime = entry.End; if (effect.m_feedMaterialLife && (Object)(object)effect.m_instancedMaterialRef != (Object)null) { effect.m_instancedMaterialRef.SetFloat(FX_Decal.s_decalLifeIDHash, entry.Fade); effect.m_instancedMaterialRef.SetFloat(FX_Decal.s_decalLifeEndIDHash, entry.End); } _decalRestored++; } } private void Retire(DecalEntry entry) { if ((Object)(object)entry.Effect == (Object)null) { _decals.Remove(entry.Key); return; } _decalRetired++; ((FX_EffectBase_Poolable)entry.Effect).ReturnToPool(); } internal void TickDecals() { _decalBudget.Expire(Time.time, _retire); } private void ScanLights() { _lightReferencesResolved = true; Scan("light-generators", delegate { foreach (LG_PowerGeneratorCluster item in Object.FindObjectsOfType<LG_PowerGeneratorCluster>()) { ControlledLights(item.m_lightCollection); } }); Scan("light-reactors", delegate { foreach (LG_WardenObjective_Reactor item2 in Object.FindObjectsOfType<LG_WardenObjective_Reactor>()) { ControlledLights(item2.m_lightCollection); MarkLights(item2.m_lightsWhenOn); MarkLights(item2.m_lightsWhenOff); } EnvironmentStateManager current2 = EnvironmentStateManager.Current; if ((Object)(object)current2 == (Object)null) { _lightReferencesResolved = false; } else { ControlledLights(current2.m_expeditionLightCollection); } }); Scan("light-sequences", delegate { foreach (LG_RoomLightSequencer item3 in Object.FindObjectsOfType<LG_RoomLightSequencer>()) { if (item3.m_sequence == null) { _lightReferencesResolved = false; } else { foreach (LG_RoomLightSequenceData item4 in (Il2CppArrayBase<LG_RoomLightSequenceData>)(object)item3.m_sequence) { if (item4 == null) { _lightReferencesResolved = false; } else { MarkLights(item4.Lights); } } } } }); Scan("light-overrides", delegate { foreach (LG_LightSettingsOverride item5 in Object.FindObjectsOfType<LG_LightSettingsOverride>()) { MarkLights(item5.m_selectedLights); } }); Scan("light-end-rooms", delegate { foreach (TGA_End_Room item6 in Object.FindObjectsOfType<TGA_End_Room>()) { MarkLights(item6.m_allLightsToDisable); } }); Scan("light-ambient-find", delegate { foreach (LG_SpotLightAmbient item7 in Object.FindObjectsOfType<LG_SpotLightAmbient>()) { LG_SpotLightAmbient one = item7; _owner.Work.Add("light", delegate { if (_owner.Active) { _owner.SetupCut(SheddingCut.DecorationLights, delegate { ScanLight(one); }); } }); } }); void Scan(string name, Action scan) { _owner.Work.Add(name, delegate { _owner.SetupCut(SheddingCut.DecorationLights, scan); }); } } private void ScanLight(LG_SpotLightAmbient light) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)light == (Object)null) { return; } C_Light c_Light = ((LG_Light)light).GetC_Light(); if (c_Light == null || _lights.ContainsKey(((Il2CppObjectBase)c_Light).Pointer)) { return; } DecorationRisk decorationRisk = ((!_lightReferencesResolved) ? DecorationRisk.UnverifiedLightReceiver : DecorationRisk.None); if ((int)((LG_Light)light).m_category != 0 || !c_Light.IsStatic || c_Light.LightUpdator != null) { decorationRisk |= DecorationRisk.ControlledLight; } if (_controlledLights.Contains(((Il2CppObjectBase)light).Pointer)) { decorationRisk |= DecorationRisk.ControlledLight; } C_LightDynamic obj = ((Il2CppObjectBase)c_Light).TryCast<C_LightDynamic>(); if ((obj == null || !obj.IsFPSPlayerLight) && !((Object)(object)c_Light.m_clusterLight == (Object)null)) { CL_SpotLight obj2 = ((Il2CppObjectBase)c_Light.m_clusterLight).TryCast<CL_SpotLight>(); if (obj2 == null || !obj2.IsFPSFlashlight) { goto IL_00b7; } } decorationRisk |= DecorationRisk.PlayerLight; goto IL_00b7; IL_00b7: foreach (Component componentsInChild in ((Component)light).GetComponentsInChildren<Component>(true)) { bool flag = (Object)(object)componentsInChild == (Object)null; if (!flag) { bool flag2; switch (((Object)componentsInChild).GetIl2CppType().FullName) { case "UnityEngine.Transform": case "UnityEngine.Light": case "LevelGeneration.LG_SpotLightAmbient": case "CL_SpotLight": flag2 = true; break; default: flag2 = false; break; } flag = !flag2; } if (flag) { decorationRisk |= DecorationRisk.UnknownComponent; } } decorationRisk |= ParentRisk(((Component)light).transform); LightEntry value = new LightEntry(c_Light, decorationRisk); _lights.Add(((Il2CppObjectBase)c_Light).Pointer, value); Classify(((Il2CppObjectBase)c_Light).Pointer, DecorationClassifier.Allows(DecorationClass.StaticGeneralLight, decorationRisk, DecorationUse.Light) ? DecorationClass.StaticGeneralLight : (((decorationRisk & (DecorationRisk.Gameplay | DecorationRisk.ControlledLight | DecorationRisk.PlayerLight)) != DecorationRisk.None) ? DecorationClass.Gameplay : DecorationClass.Unknown)); _lightSeen++; } private void MarkLights(Il2CppReferenceArray<LG_Light>? lights) { if (lights == null) { _lightReferencesResolved = false; return; } foreach (LG_Light item in (Il2CppArrayBase<LG_Light>)(object)lights) { if ((Object)(object)item == (Object)null) { _lightReferencesResolved = false; } else { MarkLight(item); } } } private void MarkLight(LG_Light light) { _controlledLights.Add(((Il2CppObjectBase)light).Pointer); C_Light c_Light = light.GetC_Light(); if (c_Light != null && _lights.TryGetValue(((Il2CppObjectBase)c_Light).Pointer, out LightEntry value)) { value.Risks |= DecorationRisk.ControlledLight; Classify(((Il2CppObjectBase)c_Light).Pointer, DecorationClass.Gameplay); } } internal void ControlledLights(LG_LightCollection? collection) { if (!_owner.Active || _owner.IsRefused(SheddingCut.DecorationLights)) { return; } if (((collection != null) ? collection.collectedLights : null) == null) { _lightReferencesResolved = false; return; } Enumerator<CollectedLight> enumerator = collection.collectedLights.GetEnumerator(); while (enumerator.MoveNext()) { CollectedLight current = enumerator.Current; if ((Object)(object)((current != null) ? current.light : null) == (Object)null) { _lightReferencesResolved = false; } else { MarkLight(current.light); } } } internal void LightsAfter() { if (!_owner.Active || _owner.IsRefused(SheddingCut.DecorationLights)) { return; } _visibilitySequence++; if (!_lightReferencesResolved) { return; } int count = 0; GatherLights(C_CullingManager.VisibleSpotLights, ref count); GatherLights(C_CullingManager.VisiblePointLights, ref count); for (int i = 1; i < count; i++) { LightEntry lightEntry = _lightCandidates[i]; int num = i; while (num > 0 && lightEntry.Light.m_priority > _lightCandidates[num - 1].Light.m_priority) { _lightCandidates[num] = _lightCandidates[num - 1]; num--; } _lightCandidates[num] = lightEntry; } int count2 = 0; for (int j = 0; j < count; j++) { if (DecorationPolicy.KeepLight(decorative: true, ref count2, Settings.LightLimit)) { continue; } LightEntry lightEntry2 = _lightCandidates[j]; lightEntry2.OriginalActiveId = lightEntry2.Cluster.ActiveID; lightEntry2.Cluster.ActiveID = -1; if (lightEntry2.List.Remove(lightEntry2.Light)) { if (!lightEntry2.Touched) { lightEntry2.Touched = true; _lightChanged++; } lightEntry2.Dropped = true; } } Array.Clear(_lightCandidates, 0, count); } private void GatherLights(List<C_Light> list, ref int count) { IntPtr pointer = ((Il2CppObjectBase)list).Pointer; for (int i = 0; i < NativeList<C_Light>.Count(pointer); i++) { if (!_lights.TryGetValue(NativeList<C_Light>.Item(pointer, i), out LightEntry value) || !DecorationClassifier.Allows(DecorationClass.StaticGeneralLight, value.Risks, DecorationUse.Light)) { _lightSkipped++; continue; } if (value.Dropped) { value.Dropped = false; _lightReleased++; } if (count == _lightCandidates.Length) { throw new InvalidOperationException("Native visible light capacity exceeded 64."); } value.List = list; value.OriginalIndex = i; value.Sequence = _visibilitySequence; _lightCandidates[count++] = value; } } private void RestoreLights() { int num = 0; foreach (LightEntry value in _lights.Values) { if (value.Dropped) { if (value.Sequence != _visibilitySequence || value.Light == null || !((C_Cullable)value.Light).IsRegistered || !((C_Cullable)value.Light).IsShown) { value.Dropped = false; _lightReleased++; } else { _lightCandidates[num++] = value; } } } for (int i = 1; i < num; i++) { LightEntry lightEntry = _lightCandidates[i]; int num2 = i; while (num2 > 0 && lightEntry.OriginalIndex < _lightCandidates[num2 - 1].OriginalIndex) { _lightCandidates[num2] = _lightCandidates[num2 - 1]; num2--; } _lightCandidates[num2] = lightEntry; } try { for (int j = 0; j < num; j++) { LightEntry lightEntry2 = _lightCandidates[j]; if (!lightEntry2.List.Contains(lightEntry2.Light)) { lightEntry2.List.Insert(lightEntry2.OriginalIndex, lightEntry2.Light); } lightEntry2.Cluster.ActiveID = lightEntry2.OriginalActiveId; lightEntry2.Dropped = false; _lightRestored++; } } finally { Array.Clear(_lightCandidates, 0, num); } } internal void EndLevel() { //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Invalid comparison between Unknown and I4 //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Invalid comparison between Unknown and I4 //IL_012d: Unknown result type (might be due to invalid IL or missing references) Exception ex = null; ShadowScope[] shadowScopes = _shadowScopes; foreach (ShadowScope shadowScope in shadowScopes) { try { _shadowRestored += shadowScope.Restore(); } catch (Exception ex2) { if (ex == null) { ex = ex2; } } } foreach (VisualEntry value in _visuals.Values) { if ((Object)(object)value.Rotator == (Object)null) { continue; } try { if (value.Hidden) { RestoreVisibility(value); } foreach (var (val, flag) in value.Skins) { if ((Object)(object)val != (Object)null && flag && !val.updateWhenOffscreen) { val.updateWhenOffscreen = flag; _animationRestored++; } } foreach (var (val2, val3) in value.Animators) { if ((Object)(object)val2 != (Object)null && (int)val3 != 2 && (int)val2.cullingMode == 2) { val2.cullingMode = val3; _animationRestored++; } } } catch (Exception ex3) { if (ex == null) { ex = ex3; } } } foreach (DecalEntry value2 in _decals.Values) { try { RestoreDecal(value2); } catch (Exception ex4) { if (ex == null) { ex = ex4; } } } try { RestoreLights(); } catch (Exception ex5) { if (ex == null) { ex = ex5; } } _decals.Clear(); _decalBudget.Clear(); _visuals.Clear(); _distanceCandidates.Clear(); _hiddenByDistance.Clear(); _shadowPlans.Clear(); _lights.Clear(); _controlledLights.Clear(); _nativeShown = null; if (ex != null) { _owner.RestorationFailed(); } Log(Settings.DecorationShadows, "decoration-shadows", _shadowSeen, _shadowChanged, _shadowRestored, "draws_skipped=" + _shadowCalls + "\tplan_hits=" + _shadowPlanHits + "\tplan_misses=" + _shadowPlanMisses); Log(Settings.DecorationCulling, "decoration-culling", _cullSeen, _cullChanged, _cullRestored, "distance_m=" + Settings.CullDistance + "\tchecks=" + _cullCalls + "\tnative_scope_released=" + _cullReleased + "\tshader_asset_verified=" + _shaderAssetVerified + "\tshader_found=" + ((Object)(object)_nonOccludingShader != (Object)null) + "\tshader_reason=" + _shaderAssetReason); Log(Settings.DecorationAnimation, "decoration-animation", _animationSeen, _animationChanged, _animationRestored, "skinning_offscreen=false\tanimator=CullCompletely"); Log(Settings.CombatDecals, "combat-decals", _decalSeen, _decalChanged, _decalRestored, "limit=" + Settings.DecalLimit + "\tlifetime_s=" + Settings.DecalLifetime + "\tclassified_skipped=" + _decalSkipped + "\tretired=" + _decalRetired); Log(Settings.DecorationLights, "decoration-lights", _lightSeen, _lightChanged, _lightRestored, "limit=" + Settings.LightLimit + "\tclassified_skipped=" + _lightSkipped + "\tcontrol_references_resolved=" + _lightReferencesResolved + "\tnative_scope_released=" + _lightReleased + "\trestore=visible_list_and_active_id;buffer_uploaded_by_native_next_frame"); if (Settings.DecorationShadows || Settings.DecorationCulling || Settings.DecorationAnimation || Settings.DecorationLights || Settings.CombatDecals) { for (int j = 0; j < _classes.Length; j++) { LoadSheddingController owner = _owner; long seen = _classes[j]; long changed = 0L; long restored = 0L; string[] obj = new string[6] { "class=", null, null, null, null, null }; DecorationClass decorationClass = (DecorationClass)j; obj[1] = decorationClass.ToString(); obj[2] = "\tinspection_failed="; obj[3] = _inspectionFailures.ToString(); obj[4] = "\tinspection_reason="; obj[5] = _inspectionReason; owner.LogItem("decoration-classification", seen, changed, restored, string.Concat(obj)); } } if (ex != null) { throw ex; } void Log(bool enabled, string item, long seen2, long changed2, long restored2, string extra) { if (enabled) { _owner.LogItem(item, seen2, changed2, restored2, extra); } } } internal Exception? ShadowRestore(ShadowScope? scope, Exception? error) { try { if (scope != null) { _shadowRestored += scope.Restore(); } return error; } catch (Exception ex) { _owner.RestorationFailed(); return (error == null) ? ex : new AggregateException(error, ex); } } internal void BeginLevel() { Array.Clear(_classes, 0, _classes.Length); _classified.Clear(); _decalRisks.Clear(); _shadowSeen = (_shadowChanged = (_shadowRestored = (_shadowCalls = (_shadowPlanHits = (_shadowPlanMisses = 0L))))); _cullSeen = (_cullChanged = (_cullRestored = (_cullCalls = 0L))); _cullReleased = 0L; _nativeShown = null; if (Settings.DecorationCulling) { _owner.SetupCut(SheddingCut.DecorationCulling, delegate { _nativeShown = C_CullingManager.GetCurrentlyShown(); }); } _animationSeen = (_animationChanged = (_animationRestored = 0L)); _decalSeen = (_decalChanged = (_decalSkipped = (_decalRestored = (_decalRetired = 0L)))); _lightSeen = (_lightChanged = (_lightSkipped = (_lightRestored = 0L))); _lightReleased = (_visibilitySequence = 0L); _impactDepth = 0; _inspectionFailures = 0L; _inspectionReason = "none"; } internal void ScanLevel() { if (_owner.Active) { if (Settings.DecorationCulling && _shaderAssetVerified && (Object)(object)_nonOccludingShader == (Object)null) { _owner.Work.Add("decoration-shader", ScanShader); } if ((Settings.DecorationShadows && !_owner.IsRefused(SheddingCut.DecorationShadows)) || (Settings.DecorationCulling && !_owner.IsRefused(SheddingCut.DecorationCulling)) || (Settings.DecorationAnimation && !_owner.IsRefused(SheddingCut.DecorationAnimation))) { _owner.Work.Add("decoration-find", ScanVisuals); } if (Settings.DecorationLights) { _owner.SetupCut(SheddingCut.DecorationLights, ScanLights); } } } private void ScanShader() { if (!_owner.Active || (Object)(object)_nonOccludingShader != (Object)null) { return; } _owner.SetupCut(SheddingCut.DecorationCulling, delegate { _nonOccludingShader = Shader.Find("Legacy Shaders/Particles/Additive"); int num = 0; foreach (Object item in (Il2CppArrayBase<Object>)(object)Resources.FindObjectsOfTypeAll(Il2CppType.Of<Shader>())) { if (item != (Object)null && item.name == "Legacy Shaders/Particles/Additive") { num++; if ((Object)(object)_nonOccludingShader == (Object)null || ((Il2CppObjectBase)item).Pointer != ((Il2CppObjectBase)_nonOccludingShader).Pointer) { num += 2; } } } if (num != 1) { _nonOccludingShader = null; _inspectionFailures++; _inspectionReason = "shader_identity_ambiguous_or_missing"; _owner.LogInspectionFailure(_inspectionReason); } }); } private void ScanVisuals() { foreach (LG_AnimatorRotator item in Object.FindObjectsOfType<LG_AnimatorRotator>()) { LG_AnimatorRotator one = item; _owner.Work.Add("decoration", delegate { if (!_owner.Active) { return; } try { RegisterVisual(one); } catch (Exception ex) { Exception ex2 = ex; Exception error = ex2; if (Settings.DecorationShadows) { _owner.SetupCut(SheddingCut.DecorationShadows, delegate { throw error; }); } if (Settings.DecorationCulling) { _owner.SetupCut(SheddingCut.DecorationCulling, delegate { throw error; }); } if (Settings.DecorationAnimation) { _owner.SetupCut(SheddingCut.DecorationAnimation, delegate { throw error; }); } } }); } } private void Classify(IntPtr identity, DecorationClass category) { if (_classified.TryGetValue(identity, out var value)) { if (value == category) { return; } _classes[(int)value]--; } _classified[identity] = category; _classes[(int)category]++; } private void RegisterVisual(LG_AnimatorRotator rotator) { //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Invalid comparison between Unknown and I4 if ((Object)(object)rotator == (Object)null || _classified.ContainsKey(((Il2CppObjectBase)rotator).Pointer)) { return; } DecorationRisk decorationRisk = Hierarchy(((Component)rotator).gameObject); C_CullBucket cullBucket = ((C_UpdateCuller)rotator).CullBucket; if (cullBucket == null || cullBucket.m_owner == null || ((Il2CppObjectBase)cullBucket.m_owner.gameObject).Pointer != ((Il2CppObjectBase)((Component)rotator).gameObject).Pointer) { decorationRisk |= DecorationRisk.UnknownComponent; } C_DynamicCuller val = ((cullBucket != null) ? ((Il2CppObjectBase)cullBucket).TryCast<C_DynamicCuller>() : null); if (val == null || (Object)(object)val.m_updateCuller == (Object)null || ((Il2CppObjectBase)val.m_updateCuller).Pointer != ((Il2CppObjectBase)rotator).Pointer || cullBucket.SpecialRenderableObjects == null || cullBucket.SpecialRenderableObjects.Count != 0 || ((C_Cullable)cullBucket).ExtraShadowRenderers == null || ((C_Cullable)cullBucket).ExtraShadowRenderers.Count != 0) { decorationRisk |= DecorationRisk.UnknownComponent; } if (cullBucket != null && (!OwnedRenderers(cullBucket.Renderers, ((Component)rotator).transform) || !OwnedRenderers(cullBucket.ShadowRenderers, ((Component)rotator).transform))) { decorationRisk |= DecorationRisk.UnknownComponent; } DecorationClass decorationClass = ((decorationRisk.HasFlag(DecorationRisk.Gameplay) || decorationRisk.HasFlag(DecorationRisk.Collider)) ? DecorationClass.Gameplay : ((!decorationRisk.HasFlag(DecorationRisk.UnknownComponent)) ? DecorationClass.VisualRotator : DecorationClass.Unknown)); if (decorationClass != DecorationClass.VisualRotator || cullBucket == null) { Classify(((Il2CppObjectBase)rotator).Pointer, decorationClass); if (Settings.DecorationShadows) { _shadowSeen++; } if (Settings.DecorationCulling) { _cullSeen++; } if (Settings.DecorationAnimation) { _animationSeen++; } return; } LG_Geomorph componentInParent = ((Component)rotator).GetComponentInParent<LG_Geomorph>(); VisualEntry entry = new VisualEntry(rotator, cullBucket, decorationRisk, (Object)(object)componentInParent != (Object)null && (int)componentInParent.m_assignedSubComplexFromZone != 11 && cullBucket.ShadowRenderers.Count != 0); Classify(((Il2CppObjectBase)rotator).Pointer, decorationClass); if (Settings.DecorationShadows) { _shadowSeen++; } if (Settings.DecorationCulling) { _cullSeen++; } if (Settings.DecorationAnimation) { _animationSeen++; } _visuals[((Il2CppObjectBase)cullBucket).Pointer] = entry; _shadowPlans.Clear(); if (DecorationClassifier.Allows(DecorationClass.VisualRotator, decorationRisk, DecorationUse.Distance)) { _distanceCandidates.Add(entry); } if (!Settings.DecorationAnimation || !DecorationClassifier.Allows(decorationClass, decorationRisk, DecorationUse.Animation)) { return; } _owner.SetupCut(SheddingCut.DecorationAnimation, delegate { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Invalid comparison between Unknown and I4 foreach (SkinnedMeshRenderer componentsInChild in ((Component)rotator).GetComponentsInChildren<SkinnedMeshRenderer>(true)) { entry.Skins.Add((componentsInChild, componentsInChild.updateWhenOffscreen)); if (componentsInChild.updateWhenOffscreen) { componentsInChild.updateWhenOffscreen = false; _animationChanged++; } } foreach (Animator componentsInChild2 in ((Component)rotator).GetComponentsInChildren<Animator>(true)) { entry.Animators.Add((componentsInChild2, componentsInChild2.cullingMode)); if ((int)componentsInChild2.cullingMode != 2) { componentsInChild2.cullingMode = (AnimatorCullingMode)2; _animationChanged++; } } }); } } internal static class DoorCullingPolicy { internal enum Portal { Open, Close, CloseWhenAnimationEnds, Release } internal const byte StatusNone = 0; internal const byte StatusOpen = 10; internal const byte StatusDestroyed = 11; internal const byte StatusOpening = 16; internal static bool Covers(byte status) { bool flag = ((status == 0 || (uint)(status - 10) <= 1u || status == 16) ? true : false); return !flag; } internal static Portal OnState(byte previous, byte status, bool damaged, bool dropIn) { if (damaged || status == 11) { return Portal.Release; } if (!Covers(status)) { return Portal.Open; } if (!dropIn && previous != 0 && !Covers(previous)) { return Portal.CloseWhenAnimationEnds; } return Portal.Close; } } internal sealed class DoorDepthGraph { internal readonly int NodeCount; internal readonly int EdgeCount; private readonly int[] _edgeA; private readonly int[] _edgeB; private readonly int[] _adjacencyStart; private readonly int[] _adjacency; private readonly int[] _depth; private readonly int[] _queue; private readonly int[] _close; internal int CloseCount { get; private set; } internal DoorDepthGraph(int nodeCount, int[] edgeA, int[] edgeB) { if (edgeA == null) { throw new ArgumentNullException("edgeA"); } if (edgeB == null) { throw new ArgumentNullException("edgeB"); } if (nodeCount < 0 || edgeA.Length != edgeB.Length) { throw new ArgumentException("Edge arrays differ in length."); } NodeCount = nodeCount; EdgeCount = edgeA.Length; _edgeA = edgeA; _edgeB = edgeB; _adjacencyStart = new int[nodeCount + 1]; for (int i = 0; i < EdgeCount; i++) { if ((uint)edgeA[i] >= (uint)nodeCount || (uint)edgeB[i] >= (uint)nodeCount) { throw new ArgumentOutOfRangeException("edgeA", "Edge " + i + " names a node outside the graph."); } _adjacencyStart[edgeA[i] + 1]++; _adjacencyStart[edgeB[i] + 1]++; } for (int j = 0; j < nodeCount; j++) { _adjacencyStart[j + 1] += _adjacencyStart[j]; } _adjacency = new int[EdgeCount * 2]; int[] array = new int[nodeCount]; for (int k = 0; k < EdgeCount; k++) { _adjacency[_adjacencyStart[edgeA[k]] + array[edgeA[k]]++] = k; _adjacency[_adjacencyStart[edgeB[k]] + array[edgeB[k]]++] = k; } _depth = new int[nodeCount]; _queue = new int[nodeCount]; _close = new int[EdgeCount]; } internal int Closed(int index) { return _close[index]; } internal int Depth(int node) { return _depth[node]; } internal void Compute(int camera, bool[] open, bool[] window, int limit) { if (open == null) { throw new ArgumentNullException("open"); } if (window == null) { throw new ArgumentNullException("window"); } if (open.Length < EdgeCount || window.Length < EdgeCount) { throw new ArgumentException("Edge state arrays are too short."); } if (limit < 1) { throw new ArgumentOutOfRangeException("limit"); } CloseCount = 0; Array.Fill(_depth, -1); if ((uint)camera >= (uint)NodeCount) { return; } int num = 0; int num2 = 0; _depth[camera] = 0; _queue[num2++] = camera; while (num < num2) { int num3 = _queue[num++]; for (int i = _adjacencyStart[num3]; i < _adjacencyStart[num3 + 1]; i++) { int num4 = _adjacency[i]; if (open[num4] && !window[num4]) { int num5 = ((_edgeA[num4] == num3) ? _edgeB[num4] : _edgeA[num4]); if (_depth[num5] < 0) { _depth[num5] = 0; _queue[num2++] = num5; } } } } int num6 = num2; num2 = 0; for (int j = 0; j < num6; j++) { int num7 = _queue[j]; for (int k = _adjacencyStart[num7]; k < _adjacencyStart[num7 + 1]; k++) { int num8 = _adjacency[k]; if (open[num8] && window[num8]) { int num9 = ((_edgeA[num8] == num7) ? _edgeB[num8] : _edgeA[num8]); if (_depth[num9] < 0) { _depth[num9] = 1; _queue[num6 + num2++] = num9; } } } } num = num6; num2 += num6; while (num < num2) { int num10 = _queue[num++]; int num11 = _depth[num10] + 1; if (num11 > limit + 1) { continue; } for (int l = _adjacencyStart[num10]; l < _adjacencyStart[num10 + 1]; l++) { int num12 = _adjacency[l]; if (open[num12]) { int num13 = ((_edgeA[num12] == num10) ? _edgeB[num12] : _edgeA[num12]); if (_depth[num13] < 0) { _depth[num13] = num11; _queue[num2++] = num13; } } } } for (int m = 0; m < EdgeCount; m++) { if (open[m]) { int num14 = _depth[_edgeA[m]]; int num15 = _depth[_edgeB[m]]; if ((num14 == limit && num15 == limit + 1) || (num15 == limit && num14 == limit + 1)) { _close[CloseCount++] = m; } } } } } internal sealed class ExtraCuts { private sealed class GraphicsValue<T> where T : struct { internal bool Captured; internal bool Changed; internal T Original; internal T Written; internal void Capture(T value) { Original = value; Written = value; Captured = true; } internal void Reset() { Captured = (Changed = false); Original = (Written = default(T)); } } private sealed class DecayHook { internal readonly Decay Decay; internal readonly Action Callback; internal int Generation; internal DecayHook(Decay decay, Action callback) { Decay = decay; Callback = callback; } } private sealed class MagazineDrop { internal Pool Pool; internal int Generation; } private readonly record struct DebrisState(bool ColliderEnabled, bool Dynamic, bool DetectCollisions); private readonly record struct MipState(Texture Texture, float Original); internal const float SpitterBias = 10f; private const int QueueCapacity = 256; private const float TickInterval = 0.25f; private const float MirrorOpacityVanilla = 0.4f; private const float ReflectionOpacityVanilla = 0.05f; private static readonly string[] SpitterTextures = new string[4] { "_MainTex", "_MetallicGlossMap", "_SSSMap", "_MainTex_B" }; private readonly LoadSheddingController _owner; private readonly SheddingSettings _settings; private readonly RenderCuts _render; private readonly GraphicsValue<float> _shadow = new GraphicsValue<float>(); private readonly GraphicsValue<bool> _soft = new GraphicsValue<bool>(); private StackTraceLogType _traceLog; private StackTraceLogType _traceWarning; private bool _traceTrimmed; private bool _mirrorSaved; private float _mirrorOpacity; private float _reflectionOpacity; private readonly DueQueue<Decay> _decayQueue = new DueQueue<Decay>(256); private readonly Dictionary<IntPtr, DecayHook> _decays = new Dictionary<IntPtr, DecayHook>(); private readonly DueQueue<DestructionObjects> _debrisQueue = new DueQueue<DestructionObjects>(256); private readonly Dictionary<IntPtr, DebrisState> _frozenDebris = new Dictionary<IntPtr, DebrisState>(); private readonly DueQueue<GameObject> _magazineQueue = new DueQueue<GameObject>(256); private readonly Dictionary<IntPtr, MagazineDrop> _magazines = new Dictionary<IntPtr, MagazineDrop>(); private readonly Dictionary<IntPtr, MipState> _spitterMips = new Dictionary<IntPtr, MipState>(); private readonly HashSet<IntPtr> _recycledGlue = new HashSet<IntPtr>(); private readonly Random _debrisRandom = new Random(); private float _nextTick; private int _failedItems; private int _glueFrame = -1; private long _decaySeen; private long _decayCleared; private long _decayReused; private long _decayDropped; private long _debrisSeen; private long _debrisFrozen; private long _debrisRestored; private long _debrisDropped; private long _leakAssets; private long _leakLights; private long _leakIrf; private long _leakEnemy; private long _leakTerminals; private long _leakMessages; private long _leakHeaders; private long _spitterSeen; private long _spitterChanged; private long _spitterRestored; private long _spitterDecals; private long _glueSeen; private long _glueRecycled; private long _recycleSeen; private long _recycleChanged; private long _magazineSeen; private long _magazineReturned; private long _magazineReused; private long _magazineDropped; private long _repellerSeen; private long _repellerHidden; private long _repellerRenderers; internal ExtraCuts(LoadSheddingController owner, SheddingSettings settings) { _owner = owner; _settings = settings; _render = new RenderCuts(owner, settings); } internal void Install() { //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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (_settings.StackTraceTrim) { _traceLog = Application.GetStackTraceLogType((LogType)3); _traceWarning = Application.GetStackTraceLogType((LogType)2); Application.SetStackTraceLogType((LogType)3, (StackTraceLogType)0); Application.SetStackTraceLogType((LogType)2, (StackTraceLogType)0); _traceTrimmed = true; _owner.LogItem("stack-trace-trim", 2L, 2L, 0L, "kinds=Log,Warning\terrors=unchanged"); } if (_settings.GuiMirrorOff) { ApplyMirror(off: true); } IrfCulling.Configure(_settings); } internal void Dispose() { //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) _render.Dispose(); IrfCulling.Reset(); MeleePacketReuse.Reset(); if (_traceTrimmed) { _traceTrimmed = false; Application.SetStackTraceLogType((LogType)3, _traceLog); Application.SetStackTraceLogType((LogType)2, _traceWarning); } if (_mirrorSaved) { ApplyMirror(off: false); } foreach (DecayHook value in _decays.Values) { if ((Object)(object)value.Decay != (Object)null) { value.Decay.OnDecaySafeToDespawnRenderer -= value.Callback; } } _decays.Clear(); } internal void BeginLevel() { _decaySeen = (_decayCleared = (_decayReused = (_decayDropped = 0L))); _debrisSeen = (_debrisFrozen = (_debrisRestored = (_debrisDropped = 0L))); _spitterSeen = (_spitterChanged = (_spitterRestored = (_spitterDecals = 0L))); _glueSeen = (_glueRecycled = (_recycleSeen = (_recycleChanged = 0L))); _magazineSeen = (_magazineReturned = (_magazineReused = (_magazineDropped = 0L))); _repellerSeen = (_repellerHidden = (_repellerRenderers = 0L)); _failedItems = 0; _nextTick = 0f; IrfCulling.BeginLevel(); _shadow.Reset(); _soft.Reset(); _owner.Work.Add("shadow-distance", delegate { Guard("graphics", ApplyShadowDistance); }); _owner.Work.Add("soft-particles", delegate { Guard("graphics", ApplySoftParticles); }); _render.BeginLevel(); } internal void BuildDone() { if (!_settings.LowQualitySpitter) { return; } Guard("low-quality-spitter", delegate { foreach (InfectionSpitter item in Object.FindObjectsOfType<InfectionSpitter>()) { SpitterAwake(item); } }); } private void ApplyShadowDistance() { if (!_settings.ShadowDistance) { return; } float shadowDistance = QualitySettings.shadowDistance; if (!_shadow.Captured || shadowDistance == _shadow.Original) { if (!_shadow.Captured) { _shadow.Capture(shadowDistance); } float num = ExtraPolicy.ShadowDistance(_shadow.Original, _settings.ShadowDistanceFactor); if (num != shadowDistance) { QualitySettings.shadowDistance = num; _shadow.Written = num; _shadow.Changed = true; } } } private void ApplySoftParticles() { if (!_settings.SoftParticlesOff) { return; } bool softParticles = QualitySettings.softParticles; if (!_soft.Captured || softParticles == _soft.Original) { if (!_soft.Captured) { _soft.Capture(softParticles); } if (softParticles) { QualitySettings.softParticles = false; _soft.Written = false; _soft.Changed = true; } } } internal void Tick() { float time = Time.time; if (time < _nextTick) { return; } _nextTick = time + 0.25f; if (_decayQueue.Count != 0) { try { DrainDecay(time); } catch (Exception error) { Failed("decay-cleanup", error); } } if (_debrisQueue.Count != 0) { try { DrainDebris(time); } catch (Exception error2) { Failed("debris-freeze", error2); } } if (_magazineQueue.Count == 0) { return; } try { DrainMagazines(time); } catch (Exception error3) { Failed("dropped-magazine", error3); } } private void DrainDecay(float now) { for (int i = 0; i < 8; i++) { if (!_decayQueue.TryTakeDue(now, out Decay item, out int tag)) { break; } if ((Object)(object)item == (Object)null) { continue; } if (!_decays.TryGetValue(((Il2CppObjectBase)item).Pointer, out DecayHook value) || value.Generation != tag) { _decayReused++; continue; } ParticleSystem particles = item.m_particles; if (!((Object)(object)particles == (Object)null)) { particles.Stop(true, (ParticleSystemStopBehavior)0); _decayCleared++; } } } private void DrainDebris(float now) { //IL_004f: 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) DestructionObjects item; int tag; for (int i = 0; i < 8 && _debrisQueue.TryTakeDue(now, out item, out tag); i++) { GameObject destructionObject = item.m_DestructionObject; if ((Object)(object)destructionObject == (Object)null) { continue; } Rigidbody component = destructionObject.GetComponent<Rigidbody>(); if ((Object)(object)component != (Object)null) { bool awake = !component.IsSleeping(); Vector3 velocity = component.velocity; if (ExtraPolicy.DebrisShouldWait(awake, ((Vector3)(ref velocity)).sqrMagnitude, tag)) { if (!_debrisQueue.Enqueue(item, now + 1f, tag + 1)) { _debrisDropped++; } continue; } } MeshCollider component2 = destructionObject.GetComponent<MeshCollider>(); DebrisState value = new DebrisState((Object)(object)component2 != (Object)null && ((Collider)component2).enabled, (Object)(object)component != (Object)null && !component.isKinematic, (Object)(object)component != (Object)null && component.detectCollisions); if ((Object)(object)component2 != (Object)null) { ((Collider)component2).enabled = false; } if ((Object)(object)component != (Object)null) { component.isKinematic = true; component.detectCollisions = false; } _frozenDebris[((Il2CppObjectBase)destructionObject).Pointer] = value; _debrisFrozen++; } } private void DrainMagazines(float now) { for (int i = 0; i < 8; i++) { if (!_magazineQueue.TryTakeDue(now, out GameObject item, out int tag)) { break; } if ((Object)(object)item == (Object)null) { continue; } if (!_magazines.TryGetValue(((Il2CppObjectBase)item).Pointer, out MagazineDrop value) || value.Generation != tag) { _magazineReused++; continue; } _magazines.Remove(((Il2CppObjectBase)item).Pointer); if (InUse(value.Pool, item)) { value.Pool.Return(item); _magazineReturned++; } } } private static bool InUse(Pool pool, GameObject magazine) { for (LinkedListNode<GameObject> val = pool.m_usedInstances?.First; val != null; val = val.Next) { GameObject value = val.Value; if (value != null && ((Il2CppObjectBase)value).Pointer == ((Il2CppObjectBase)magazine).Pointer) { return true; } } return false; } internal void EndLevel() { Exception first = null; Try(delegate { if (_shadow.Changed && QualitySettings.shadowDistance == _shadow.Written) { QualitySettings.shadowDistance = _shadow.Original; } if (_soft.Changed && !QualitySettings.softParticles) { QualitySettings.softParticles = _soft.Original; } }); Try(_render.EndLevel); Try(delegate { foreach (MipState value in _spitterMips.Values) { if ((Object)(object)value.Texture != (Object)null && value.Texture.mipMapBias == 10f) { value.Texture.mipMapBias = value.Original; _spitterRestored++; } } }); var (seen, changed, num, text) = IrfCulling.Counts; if (_settings.SummaryLog) { if (_settings.ShadowDistance) { _owner.LogItem("shadow-distance", _shadow.Captured ? 1 : 0, _shadow.Changed ? 1 : 0, _shadow.Changed ? 1 : 0, "original=" + F(_shadow.Original) + "\tfactor=" + F(_settings.ShadowDistanceFactor) + "\twritten=" + F(_shadow.Written) + "\tfloor_m=" + F(20f)); } if (_settings.SoftParticlesOff) { _owner.LogItem("soft-particles-off", _soft.Captured ? 1 : 0, _soft.Changed ? 1 : 0, _soft.Changed ? 1 : 0, "original=" + _soft.Original); } if (_settings.DecayCleanup) { _owner.LogItem("decay-cleanup", _decaySeen, _decayCleared, 0L, "hooked_decays=" + _decays.Count + "\treused_before_clear=" + _decayReused + "\tqueue_full_dropped=" + _decayDropped); } if (_settings.DebrisFreeze) { _owner.LogItem("debris-freeze", _debrisSeen, _debrisFrozen, _debrisRestored, "queue_full_dropped=" + _debrisDropped + "\tstill_moving_retries_max=" + 3); } if (_settings.LowQualitySpitter) { _owner.LogItem("low-quality-spitter", _spitterSeen, _spitterChanged, _spitterRestored, "decals_removed=" + _spitterDecals); } if (_settings.GlueSoundRecycle) { _owner.LogItem("glue-sound-recycle", _glueSeen, _glueRecycled, 0L, "scope=sound_player_only"); } if (_settings.DroppedMagazineCleanup) { _owner.LogItem("dropped-magazine", _magazineSeen, _magazineReturned, 0L, "after_s=" + F(_settings.DroppedMagazineSeconds) + "\treused_before_return=" + _magazineReused + "\tqueue_full_dropped=" + _magazineDropped + "\tto=native_pool"); } if (_settings.SpentFogRepellerCleanup) { _owner.LogItem("spent-fog-repeller", _repellerSeen, _repellerHidden, 0L, "renderers_hidden=" + _repellerRenderers + "\tby=local_force_rendering_off"); } if (_settings.CorpseRecycle) { _owner.LogItem("corpse-recycle", _recycleSeen, _recycleChanged, 0L, "cap_s=" + F(_settings.CorpseRecycleSeconds) + "\tdespawn=native"); } if (_settings.IrfOffscreenSkip) { _owner.LogItem("irf-offscreen-skip", seen, changed, 0L, "bounds=static_main_camera_frustum"); } if (_settings.IrfWorldCameraOnly) { _owner.LogItem("irf-world-camera-only", num, num, 0L, "camera=main"); } if (_settings.MeleePacketReuse) { var (seen2, changed2, num2) = MeleePacketReuse.Counts; _owner.LogItem("melee-packet-reuse", seen2, changed2, 0L, "shared_packets_adopted=" + num2 + "\tslots=kept_vanilla_indices"); } } if (text != null) { _owner.LogExtraFailure("irf-culling", text); } if (_failedItems != 0) { _owner.LogItem("extra-failures", _failedItems, 0L, 0L, "scope=level"); } _decayQueue.Clear(); _debrisQueue.Clear(); _frozenDebris.Clear(); _spitterMips.Clear(); _recycledGlue.Clear(); _magazineQueue.Clear(); _magazines.Clear(); PruneDecays(); if (first != null) { throw first; } void Try(Action action) { try { action(); } catch (Exception ex) { if (first == null) { first = ex; } } } } private void PruneDecays() { List<IntPtr> list = null; foreach (KeyValuePair<IntPtr, DecayHook> decay in _decays) { if ((Object)(object)decay.Value.Decay == (Object)null) { (list ?? (list = new List<IntPtr>())).Add(decay.Key); } } if (list == null) { return; } foreach (IntPtr item in list) { _decays.Remove(item); } } internal void DecayInitialized(Decay decay) { if ((Object)(object)decay == (Object)null) { return; } Guard("decay-cleanup", delegate { IntPtr key = ((Il2CppObjectBase)decay).Pointer; if (!_decays.TryGetValue(key, out DecayHook value)) { Action callback = DelegateSupport.ConvertDelegate<Action>((Delegate)(Action)delegate { DecaySafe(key); }); value = new DecayHook(decay, callback); _decays.Add(key, value); } value.Generation++; _decaySeen++; decay.OnDecaySafeToDespawnRenderer -= value.Callback; decay.OnDecaySafeToDespawnRenderer += value.Callback; }); } private void DecaySafe(IntPtr key) { try { if (_decays.TryGetValue(key, out DecayHook value) && !((Object)(object)value.Decay == (Object)null) && !_decayQueue.Enqueue(value.Decay, Time.time + 5f, value.Generation)) { _decayDropped++; } } catch (Exception error) { Failed("decay-cleanup", error); } } internal void DebrisStarting(DebrisSpawner spawner) { if ((Object)(object)spawner == (Object)null) { return; } Guard("debris-freeze", delegate { List<DestructionObjects> destructionObjects = spawner.m_destructionObjects; if (destructionObjects != null) { float time = Time.time; for (int i = 0; i < destructionObjects.Count; i++) { DestructionObjects val = destructionObjects[i]; GameObject val2 = ((val != null) ? val.m_DestructionObject : null); if (val != null && !((Object)(object)val2 == (Object)null)) { if (_frozenDebris.Remove(((Il2CppObjectBase)val2).Pointer, out var value)) { Unfreeze(val2, value); } float num = 3f + (float)(_debrisRandom.NextDouble() * 2.0); if (_debrisQueue.Enqueue(val, time + num)) { _debrisSeen++; } else { _debrisDropped++; } } } } }); } private void Unfreeze(GameObject go, DebrisState state) { MeshCollider component = go.GetComponent<MeshCollider>(); if ((Object)(object)component != (Object)null && state.ColliderEnabled) { ((Collider)component).enabled = true; } Rigidbody component2 = go.GetComponent<Rigidbody>(); if ((Object)(object)component2 != (Object)null) { component2.isKinematic = !state.Dynamic; component2.detectCollisions = state.DetectCollisions; } _debrisRestored++; } internal void LeakAfterLevel() { Guard("leak-cleanup", delegate { foreach (TextAsset item in Object.FindObjectsOfType<TextAsset>()) { if (((Il2CppArrayBase<byte>)(object)item.bytes).Length == 0) { Object.Destroy((Object)(object)item); _leakAssets++; } } PlayerGuiLayer playerLayer = GuiManager.PlayerLayer; PUI_WardenIntel val = ((playerLayer != null) ? playerLayer.m_wardenIntel : null); if ((Object)(object)val != (Object)null) { _leakMessages += val.m_subObjectiveMessageQueue?.Count ?? 0; val.ResetSubObjectiveMesssagQueue(); } long num = _leakAssets + _leakLights + _leakIrf + _leakEnemy + _leakTerminals + _leakMessages + _leakHeaders; _owner.LogItem("leak-cleanup", num, num, 0L, "text_assets=" + _leakAssets + "\teffect_lights=" + _leakLights + "\tinstanced_render=" + _leakIrf + "\tflyer_materials=" + _leakEnemy + "\tterminal_callbacks=" + _leakTerminals + "\thint_messages=" + _leakMessages + "\tmenu_headers=" + _leakHeaders); _leakAssets = (_leakLights = (_leakIrf = (_leakEnemy = (_leakTerminals = (_leakMessages = (_leakHeaders = 0L)))))); }); } internal void LeakTerminal(LG_ComputerTerminal terminal) { if (terminal == null) { return; } Guard("leak-cleanup", delegate { Action onFactoryBuildDone = LG_Factory.OnFactoryBuildDone; Il2CppReferenceArray<Delegate> val = ((onFactoryBuildDone != null) ? ((Delegate)onFactoryBuildDone).GetInvocationList() : null); if (val == null) { return; } IntPtr pointer = ((Il2CppObjectBase)terminal).Pointer; foreach (Delegate item in (Il2CppArrayBase<Delegate>)(object)val) { if (((item != null) ? item.Target : null) != null && !(((Il2CppObjectBase)item.Target).Pointer != pointer)) { LG_Factory.OnFactoryBuildDone -= ((Il2CppObjectBase)item).Cast<Action>(); _leakTerminals++; } } }); } internal void LeakScrollHeaders(CM_ScrollWindow window) { if ((Object)(object)window == (Object)null) { return; } Guard("leak-cleanup", delegate { Il2CppReferenceArray<CM_ScrollWindowHeader> headers = window.m_headers; List<CM_Item> items = window.m_nonContentItems; if (headers != null && items != null && items.Count != 0) { HashSet<IntPtr> hashSet = new HashSet<IntPtr>(); foreach (CM_ScrollWindowHeader item in (Il2CppArrayBase<CM_ScrollWindowHeader>)(object)headers) { if ((Object)(object)item != (Object)null) { hashSet.Add(((Il2CppObjectBase)item).Pointer); } } _leakHeaders += ReusePolicy.RemoveMatching(items.Count, (Func<int, IntPtr>)delegate(int i) { CM_Item obj = items[i]; return (obj == null) ? IntPtr.Zero : ((Il2CppObjectBase)obj).Pointer; }, (Action<int>)items.RemoveAt, hashSet); } }); } internal void MeleeSetup(MeleeWeaponFirstPerson weapon) { if (!((Object)(object)weapon == (Object)null)) { Guard("melee-packet-reuse", delegate { MeleePacketReuse.AfterSetup(weapon); }); } } internal void LeakEffectLights() { Guard("leak-cleanup", delegate { Il2CppReferenceArray<FX_PointLight> s_effectPointLights = FX_Manager.s_effectPointLights; if (s_effectPointLights != null) { foreach (FX_PointLight item in (Il2CppArrayBase<FX_PointLight>)(object)s_effectPointLights) { if ((Object)(object)item != (Object)null) { Object.Destroy((Object)(object)((Component)item).gameObject); _leakLights++; } } } FX_Manager.s_activeLights?.Clear(); FX_Manager.s_freeLights?.Clear(); }); } internal void LeakInstancedRender(InstancedRenderFeature feature) { if ((Object)(object)feature == (Object)null) { return; } Guard("leak-cleanup", delegate { if (!_owner.Active && !((Object)(object)((Component)feature).transform.parent == (Object)null)) { InstancedRenderFeatureRenderer renderer = feature.m_renderer; if (renderer != null && (Object)(object)renderer.m_compute != (Object)null) { Object.Destroy((Object)(object)renderer.m_compute); renderer.m_compute = null; _leakIrf++; } IRFController controller = feature.m_controller; Il2CppReferenceArray<Material> val = ((controller != null) ? controller.Materials : null); if (val != null) { foreach (Material item in (Il2CppArrayBase<Material>)(object)val) { if ((Object)(object)item != (Object)null) { Object.Destroy((Object)(object)item); _leakIrf++; } } } } }); } internal void LeakEnemy(EnemyAgent enemy) { if ((Object)(object)enemy == (Object)null) { return; } Guard("leak-cleanup", delegate { FlyerAnimationController componentInChildren = ((Component)enemy).GetComponentInChildren<FlyerAnimationController>(true); FleshBulbs val = ((componentInChildren != null) ? componentInChildren.m_fleshBulbs : null); if ((Object)(object)val != (Object)null && (Object)(object)val.m_material != (Object)null) { Object.Destroy((Object)(object)val.m_material); _leakEnemy++; } }); } internal void SpitterAwake(InfectionSpitter spitter) { if ((Object)(object)spitter == (Object)null) { return; } _spitterSeen++; Guard("low-quality-spitter", delegate { Renderer renderer = spitter.m_renderer; Material val = (((Object)(object)renderer == (Object)null) ? null : renderer.sharedMaterial); if ((Object)(object)val != (Object)null) { string[] spitterTextures = SpitterTextures; foreach (string text in spitterTextures) { if (val.HasProperty(text)) { Texture texture = val.GetTexture(text); if (!((Object)(object)texture == (Object)null) && !_spitterMips.ContainsKey(((Il2CppObjectBase)texture).Pointer)) { _spitterMips.Add(((Il2CppObjectBase)texture).Pointer, new MipState(texture, texture.mipMapBias)); texture.mipMapBias = 10f; } } } } Decal componentInChildren = ((Component)spitter).GetComponentInChildren<Decal>(true); if ((Object)(object)componentInChildren != (Object)null) { Object.Destroy((Object)(object)componentInChildren); _spitterDecals++; } _spitterChanged++; }); } internal void GlueDestroying(GlueGunProjectile projectile) { if ((Object)(object)projectile == (Object)null) { return; } _glueSeen++; Guard("glue-sound-recycle", delegate { int frameCount = Time.frameCount; if (frameCount != _glueFrame) { _glueFrame = frameCount; _recycledGlue.Clear(); } CellSoundPlayer sound = projectile.m_sound; if (sound != null && _recycledGlue.Add(((Il2CppObjectBase)projectile).Pointer)) { sound.Recycle(); _glueRecycled++; } }); } internal void MagazineDropped(Pool pool, GameObject magazine) { if (pool == null || (Object)(object)magazine == (Object)null) { return; } Guard("dropped-magazine", delegate { _magazineSeen++; if (!_magazines.TryGetValue(((Il2CppObjectBase)magazine).Pointer, out MagazineDrop valu