using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BraveDynamicTree; using Dungeonator; using Gunfiguration; using HarmonyLib; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using Mono.Collections.Generic; using MonoMod.Cil; using Pathfinding; using SGUI; using UnityEngine; using tk2dRuntime.TileMap; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace GGV { internal static class GGVDebug { [Conditional("DEBUG")] internal static void Log(string text) { Console.WriteLine("[GGV]: " + text); } [Conditional("DEBUG")] internal static void LogPatch(string text) { Console.WriteLine("[GGV]: " + text); } [Conditional("DEBUG")] internal static void Warn(string text) { ETGModConsole.Log((object)("" + text + ""), false); } } internal static class Dissect { internal static void DumpComponents(this GameObject g) { Component[] components = g.GetComponents(typeof(object)); foreach (Component val in components) { ETGModConsole.Log((object)(" " + ((object)val).GetType().Name), false); } } internal static void DumpFieldsAndProperties(T o) { FieldInfo[] fields = typeof(T).GetFields(); foreach (FieldInfo fieldInfo in fields) { Console.WriteLine($"field {fieldInfo.Name} = {fieldInfo.GetValue(o)}"); } foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(o)) { Console.WriteLine(" prop {0} = {1}", property.Name, property.GetValue(o)); } } internal static void CompareFieldsAndProperties(T o1, T o2) { FieldInfo[] fields = typeof(T).GetFields(); foreach (FieldInfo fieldInfo in fields) { try { if (fieldInfo.GetValue(o1) == null) { if (fieldInfo.GetValue(o2) != null) { goto IL_0068; } } else if (fieldInfo.GetValue(o2) == null || !fieldInfo.GetValue(o1).Equals(fieldInfo.GetValue(o2))) { goto IL_0068; } goto end_IL_001b; IL_0068: Console.WriteLine($"field {fieldInfo.Name} = {fieldInfo.GetValue(o1)} -> {fieldInfo.GetValue(o2)}"); end_IL_001b:; } catch (Exception) { Console.WriteLine(" prop {0} = {1} -> {2}", fieldInfo.Name, "ERROR", "ERROR"); } } foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(o1)) { try { if (property.GetValue(o1) == null) { if (property.GetValue(o2) != null) { goto IL_0136; } } else if (property.GetValue(o2) == null || !property.GetValue(o1).Equals(property.GetValue(o2))) { goto IL_0136; } goto end_IL_00e4; IL_0136: Console.WriteLine(" prop {0} = {1} -> {2}", property.Name, property.GetValue(o1), property.GetValue(o2)); end_IL_00e4:; } catch (Exception) { Console.WriteLine(" prop {0} = {1} -> {2}", property.Name, "ERROR", "ERROR"); } } Console.WriteLine(""); } internal static void DumpILInstruction(this Instruction c) { //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) try { ETGModConsole.Log((object)(" " + ETGMod.ToStringSafe((object)c)), false); } catch (Exception) { try { ILLabel val = null; if (val == null) { ILPatternMatchingExt.MatchBr(c, ref val); } if (val == null) { ILPatternMatchingExt.MatchBeq(c, ref val); } if (val == null) { ILPatternMatchingExt.MatchBge(c, ref val); } if (val == null) { ILPatternMatchingExt.MatchBgeUn(c, ref val); } if (val == null) { ILPatternMatchingExt.MatchBgt(c, ref val); } if (val == null) { ILPatternMatchingExt.MatchBgtUn(c, ref val); } if (val == null) { ILPatternMatchingExt.MatchBle(c, ref val); } if (val == null) { ILPatternMatchingExt.MatchBleUn(c, ref val); } if (val == null) { ILPatternMatchingExt.MatchBlt(c, ref val); } if (val == null) { ILPatternMatchingExt.MatchBltUn(c, ref val); } if (val == null) { ILPatternMatchingExt.MatchBrfalse(c, ref val); } if (val == null) { ILPatternMatchingExt.MatchBrtrue(c, ref val); } if (val == null) { ILPatternMatchingExt.MatchBneUn(c, ref val); } if (val != null) { string[] obj = new string[6] { " IL_", c.Offset.ToString("x4"), ": ", null, null, null }; OpCode opCode = c.OpCode; obj[3] = ((OpCode)(ref opCode)).Name; obj[4] = " IL_"; obj[5] = val.Target.Offset.ToString("x4"); ETGModConsole.Log((object)string.Concat(obj), false); } else { ETGModConsole.Log((object)"[UNKNOWN INSTRUCTION]", false); } } catch (Exception) { ETGModConsole.Log((object)" ", false); } } } internal static void DumpIL(this ILCursor cursor, string key) { //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) Enumerator enumerator = cursor.Instrs.GetEnumerator(); try { while (enumerator.MoveNext()) { enumerator.Current.DumpILInstruction(); } } finally { ((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } } } [HarmonyPatch] internal static class Patches { [HarmonyPatch] private static class OptimiseIntVectorPointcastPatch { private static bool _collideWithTriggers; private static int _rayMask; private static CollisionLayer? _sourceLayer; private static IntVector2 _point; private static ICollidableObject _tempResult; private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_POINTCAST) { return false; } return true; } private static MethodBase TargetMethod() { return typeof(PhysicsEngine).GetMethod("Pointcast", new Type[8] { typeof(IntVector2), typeof(SpeculativeRigidbody).MakeByRefType(), typeof(bool), typeof(bool), typeof(int), typeof(CollisionLayer?), typeof(bool), typeof(SpeculativeRigidbody[]) }); } private static bool CollideWithRigidBodyStatic(SpeculativeRigidbody rigidbody) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)rigidbody) || !((Behaviour)rigidbody).enabled) { return true; } List pixelColliders = rigidbody.GetPixelColliders(); for (int i = 0; i < pixelColliders.Count; i++) { PixelCollider val = pixelColliders[i]; if ((_collideWithTriggers || !val.IsTrigger) && val.CanCollideWith(_rayMask, _sourceLayer) && val.ContainsPixel(_point)) { _tempResult = (ICollidableObject)(object)rigidbody; return false; } } return true; } private static bool Prefix(PhysicsEngine __instance, ref bool __result, IntVector2 point, out SpeculativeRigidbody result, bool collideWithTiles, bool collideWithRigidbodies, int rayMask, CollisionLayer? sourceLayer, bool collideWithTriggers, params SpeculativeRigidbody[] ignoreList) { //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_012a: 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) if (collideWithTiles && Object.op_Implicit((Object)(object)__instance.TileMap)) { int num = default(int); int num2 = default(int); __instance.TileMap.GetTileAtPosition(Vector2.op_Implicit(PhysicsEngine.PixelToUnit(point)), ref num, ref num2); int tileMapLayerByName = BraveUtility.GetTileMapLayerByName("Collision Layer", __instance.TileMap); Tile tile = __instance.GetTile(num, num2, __instance.TileMap, tileMapLayerByName, "Collision Layer", GameManager.Instance.Dungeon.data); if (tile != null) { List pixelColliders = tile.GetPixelColliders(); for (int i = 0; i < pixelColliders.Count; i++) { PixelCollider val = pixelColliders[i]; if ((collideWithTriggers || !val.IsTrigger) && val.CanCollideWith(rayMask, sourceLayer) && val.ContainsPixel(point)) { result = null; __result = true; return false; } } } } if (collideWithRigidbodies) { _tempResult = null; _collideWithTriggers = collideWithTriggers; _rayMask = rayMask; _sourceLayer = sourceLayer; _point = point; b2AABB safeB2AABB = PhysicsEngine.GetSafeB2AABB(point, point); __instance.m_rigidbodyTree.Query(safeB2AABB, (Func)CollideWithRigidBodyStatic); if (__instance.CollidesWithProjectiles(rayMask, sourceLayer)) { __instance.m_projectileTree.Query(safeB2AABB, (Func)CollideWithRigidBodyStatic); } ICollidableObject tempResult = _tempResult; result = (SpeculativeRigidbody)(object)((tempResult is SpeculativeRigidbody) ? tempResult : null); __result = (Object)(object)result != (Object)null; return false; } result = null; __result = false; return false; } } [HarmonyPatch] private static class DungeonHandleAmbientPitVFXPatch { private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_PIT_VFX) { return false; } return true; } [HarmonyPatch(typeof(Dungeon), "HandleAmbientPitVFX")] private static IEnumerator Postfix(IEnumerator orig, Dungeon __instance) { return HandleAmbientPitVFXFast(__instance); } private static IEnumerator HandleAmbientPitVFXFast(Dungeon self) { self.m_ambientVFXProcessingActive = true; while (self.m_ambientVFXProcessingActive) { if (GameManager.Instance.IsLoadingLevel || (int)GameManager.Options.ShaderQuality == 0 || (int)GameManager.Options.ShaderQuality == 3) { yield return null; continue; } DungeonData data = self.data; if (data == null) { yield return null; continue; } CameraController mainCameraController = GameManager.Instance.MainCameraController; if (!Object.op_Implicit((Object)(object)mainCameraController)) { yield return null; continue; } CellData[][] cellData = data.cellData; IntVector2 val = Vector2Extensions.ToIntVector2(mainCameraController.MinVisiblePoint, (VectorConversions)0); IntVector2 val2 = Vector2Extensions.ToIntVector2(mainCameraController.MaxVisiblePoint, (VectorConversions)1); int num = Mathf.Max(val.x, 3); int num2 = Mathf.Max(val.y, 3); int num3 = Mathf.Min(val2.x, data.m_width - 3 - 1); int num4 = Mathf.Min(val2.y, data.m_height - 3 - 1); bool flag = (int)self.tileIndices.tilesetId == 128; bool flag2 = (int)self.tileIndices.tilesetId == 64; for (int i = num; i <= num3; i++) { for (int j = num2; j <= num4; j++) { if (flag) { CellData val3 = cellData[i][j + 2]; if (val3 == null || (int)val3.type != 4) { j += 2; continue; } } CellData val4 = cellData[i][j + 1]; if (val4 == null || (int)val4.type != 4) { j++; continue; } CellData val5 = cellData[i][j]; if (val5 == null || (int)val5.type != 4 || val5.fallingPrevented) { continue; } CellData val6 = cellData[i][j - 1]; if (val6 == null) { continue; } CellVisualData cellVisualData = val5.cellVisualData; if (cellVisualData.precludeAllTileDrawing) { continue; } DungeonMaterial val7 = self.roomMaterialDefinitions[cellVisualData.roomVisualTypeIndex]; if ((Object)(object)val7 == (Object)null) { continue; } if (!cellVisualData.HasTriggeredPitVFX) { cellVisualData.HasTriggeredPitVFX = true; cellVisualData.PitVFXCooldown = Random.Range(1f, val7.PitVFXMaxCooldown / 2f); cellVisualData.PitParticleCooldown = Random.Range(0f, 1f); } if (flag || (flag2 && val7.usesFacewallGrids)) { cellVisualData.PitParticleCooldown -= BraveTime.DeltaTime; if (cellVisualData.PitParticleCooldown <= 0f) { Vector3 val8 = Vector2Extensions.ToVector3ZisY(BraveUtility.RandomVector2(((IntVector2)(ref val5.position)).ToVector2(), ((IntVector2)(ref val5.position)).ToVector2() + Vector2.one), 0f); cellVisualData.PitParticleCooldown = Random.Range(0.35f, 0.95f); if (flag2) { GlobalSparksDoer.DoSingleParticle(val8, Vector3.zero, (float?)null, (float?)0.375f, (Color?)null, (SparksType)4); } else { RoomHandler parentRoom = val5.parentRoom; if (parentRoom != null && (int)parentRoom.area.PrototypeRoomCategory != 3) { GlobalSparksDoer.DoSingleParticle(val8, Vector3.up, (float?)null, (float?)null, (Color?)null, (SparksType)1); } } } } if (!val7.UsePitAmbientVFX || val7.AmbientPitVFX == null || (int)val6.type != 4) { continue; } if (cellVisualData.PitVFXCooldown > 0f) { cellVisualData.PitVFXCooldown -= BraveTime.DeltaTime; continue; } cellVisualData.PitVFXCooldown = Random.Range(val7.PitVFXMinCooldown, val7.PitVFXMaxCooldown); if (!(Random.value >= val7.ChanceToSpawnPitVFXOnCooldown)) { GameObject obj = val7.AmbientPitVFX[Random.Range(0, val7.AmbientPitVFX.Count)]; Vector3 position = obj.transform.position; SpawnManager.SpawnVFX(obj, Vector2Extensions.ToVector3ZisY(((IntVector2)(ref val5.position)).ToVector2(), 0f) + position + new Vector3(Random.Range(0.25f, 0.75f), Random.Range(0.25f, 0.75f), 2f), Quaternion.identity); } } } yield return null; } self.m_ambientVFXProcessingActive = false; } } [HarmonyPatch] private static class DungeonWidthAndHeightPatches { private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_DUNGEON_DIMS) { return false; } return true; } [HarmonyPatch(typeof(DungeonData), "ClearCachedCellData")] [HarmonyPostfix] private static void ClearCachedCellData(DungeonData __instance) { __instance.m_width = __instance.cellData.Length; __instance.m_height = __instance.cellData[0].Length; } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPostfix] private static void ClearCachedCellData(DungeonData __instance, CellData[][] data) { __instance.m_width = __instance.cellData.Length; __instance.m_height = __instance.cellData[0].Length; } [HarmonyPatch(typeof(DungeonData), "CheckInBounds", new Type[] { typeof(int), typeof(int) })] [HarmonyPatch(typeof(DungeonData), "CheckInBounds", new Type[] { typeof(IntVector2) })] [HarmonyPatch(typeof(DungeonData), "CheckInBounds", new Type[] { typeof(IntVector2), typeof(int) })] [HarmonyPatch(typeof(DungeonData), "CheckInBoundsAndValid", new Type[] { typeof(int), typeof(int) })] [HarmonyPatch(typeof(DungeonData), "CheckInBoundsAndValid", new Type[] { typeof(IntVector2) })] [HarmonyPatch(typeof(DungeonData), "FloodFillDungeonExterior")] [HarmonyPatch(typeof(DungeonData), "GenerateInterestingVisuals")] [HarmonyPatch(typeof(DungeonData), "CheckIntegrity")] [HarmonyPatch(typeof(DungeonData), "ExciseElbows")] [HarmonyPatch(typeof(DungeonData), "PostGenerationCleanup")] [HarmonyPatch(typeof(DungeonData), "GetRoomVisualTypeAtPosition", new Type[] { typeof(int), typeof(int) })] [HarmonyPatch(typeof(Minimap), "InitializeMinimap")] [HarmonyPatch(typeof(TileSpriteClipper), "ClipToTileBounds")] [HarmonyPatch(typeof(TK2DInteriorDecorator), "PlaceLightDecoration")] [HarmonyPatch(typeof(PhysicsEngine), "LateUpdate")] [HarmonyPatch(typeof(OcclusionLayer), "GetRValueForCell")] [HarmonyPatch(typeof(OcclusionLayer), "GetGValueForCell")] [HarmonyPatch(typeof(OcclusionLayer), "GetCellOcclusion")] [HarmonyPatch(typeof(RoomHandler), "StampCell", new Type[] { typeof(int), typeof(int), typeof(bool) })] [HarmonyPatch(typeof(RoomHandler), "StampCellAsExit")] [HarmonyILManipulator] private static void DungeonDataWidthAndHeightPatchesIL(ILContext il, MethodBase original) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); _ = original.DeclaringType; int num = 0; while (val.TryGotoNext((MoveType)0, new Func[1] { (Instruction instr) => ILPatternMatchingExt.MatchCallOrCallvirt(instr, "get_Width") })) { num++; val.Remove(); val.Emit(OpCodes.Ldfld, typeof(DungeonData).GetField("m_width", BindingFlags.Instance | BindingFlags.NonPublic)); } val.Index = 0; while (val.TryGotoNext((MoveType)0, new Func[1] { (Instruction instr) => ILPatternMatchingExt.MatchCallOrCallvirt(instr, "get_Height") })) { num++; val.Remove(); val.Emit(OpCodes.Ldfld, typeof(DungeonData).GetField("m_height", BindingFlags.Instance | BindingFlags.NonPublic)); } } } [HarmonyPatch] private static class MathOptimizations { private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_MATH) { return false; } return true; } [HarmonyPatch(typeof(BraveMathCollege), "ClosestPointOnRectangle")] [HarmonyPrefix] private static bool FastClosestPointOnRectanglePatch(Vector2 point, Vector2 origin, Vector2 dimensions, ref Vector2 __result) { //IL_0000: 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_000e: 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_001e: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) float x = point.x; float y = point.y; float x2 = origin.x; float num = x2 + dimensions.x; float y2 = origin.y; float num2 = y2 + dimensions.y; if (x <= x2) { __result = new Vector2(x2, (y < y2) ? y2 : ((y > num2) ? num2 : y)); } else if (x >= num) { __result = new Vector2(num, (y < y2) ? y2 : ((y > num2) ? num2 : y)); } else if (y <= y2) { __result = new Vector2((x < x2) ? x2 : ((x > num) ? num : x), y2); } else if (y >= num2) { __result = new Vector2((x < x2) ? x2 : ((x > num) ? num : x), num2); } else { float num3 = 0.5f * (x2 + num); float num4 = 0.5f * (y2 + num2); if (x < num3) { if (y < num4) { if (x - x2 < y - y2) { __result = new Vector2(x2, y); } else { __result = new Vector2(x, y2); } } else if (x - x2 < num2 - y) { __result = new Vector2(x2, y); } else { __result = new Vector2(x, num2); } } else if (y < num4) { if (num - x < y - y2) { __result = new Vector2(num, y); } else { __result = new Vector2(x, y2); } } else if (num - x < num2 - y) { __result = new Vector2(num, y); } else { __result = new Vector2(x, num2); } } return false; } [HarmonyPatch(typeof(PixelCollider), "TransformPixel")] [HarmonyPrefix] private static bool FastTransformPixelPatch(PixelCollider __instance, Vector2 pixel, Vector2 pivot, float rotation, Vector2 scale, ref Vector2 __result) { //IL_0000: 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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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) float num = pixel.x - pivot.x; float num2 = pixel.y - pivot.y; float num3 = rotation * ((float)Math.PI / 180f); float num4 = Mathf.Cos(num3); float num5 = Mathf.Sin(num3); __result = new Vector2((num * num4 - num2 * num5) * scale.x + pivot.x, (num * num5 + num2 * num4) * scale.y + pivot.y); return false; } [HarmonyPatch(typeof(b2AABB), "Combine", new Type[] { typeof(b2AABB) })] [HarmonyPrefix] private static bool Fastb2AABBCombine(ref b2AABB __instance, b2AABB aabb) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_004c: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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) //IL_0094: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) __instance.lowerBound.x = ((__instance.lowerBound.x < aabb.lowerBound.x) ? __instance.lowerBound.x : aabb.lowerBound.x); __instance.lowerBound.y = ((__instance.lowerBound.y < aabb.lowerBound.y) ? __instance.lowerBound.y : aabb.lowerBound.y); __instance.upperBound.x = ((__instance.upperBound.x > aabb.upperBound.x) ? __instance.upperBound.x : aabb.upperBound.x); __instance.upperBound.y = ((__instance.upperBound.y > aabb.upperBound.y) ? __instance.upperBound.y : aabb.upperBound.y); return false; } [HarmonyPatch(typeof(b2AABB), "Combine", new Type[] { typeof(b2AABB), typeof(b2AABB) })] [HarmonyPrefix] private static bool Fastb2AABBCombine(ref b2AABB __instance, b2AABB aabb1, b2AABB aabb2) { //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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_001e: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0066: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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) //IL_0095: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) __instance.lowerBound.x = ((aabb1.lowerBound.x < aabb2.lowerBound.x) ? aabb1.lowerBound.x : aabb2.lowerBound.x); __instance.lowerBound.y = ((aabb1.lowerBound.y < aabb2.lowerBound.y) ? aabb1.lowerBound.y : aabb2.lowerBound.y); __instance.upperBound.x = ((aabb1.upperBound.x > aabb2.upperBound.x) ? aabb1.upperBound.x : aabb2.upperBound.x); __instance.upperBound.y = ((aabb1.upperBound.y > aabb2.upperBound.y) ? aabb1.upperBound.y : aabb2.upperBound.y); return false; } } [HarmonyPatch] private static class DepthCheckOptimizations { private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_DEPTH_CHECKS) { return false; } return true; } [HarmonyPatch(typeof(tk2dBaseSprite), "UpdateZDepthInternal")] [HarmonyPrefix] private static bool FastUpdateZDepthInternal(tk2dBaseSprite __instance, float targetZValue, float currentYValue) { //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_0013: 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) __instance.IsZDepthDirty = false; Vector3 position = __instance.m_transform.position; if (position.z != targetZValue) { position.z = targetZValue; __instance.m_transform.position = position; } if (__instance.attachedRenderers == null || __instance.attachedRenderers.Count <= 0) { return false; } bool isPerpendicular = __instance.IsPerpendicular; for (int i = 0; i < __instance.attachedRenderers.Count; i++) { tk2dBaseSprite val = __instance.attachedRenderers[i]; if (!Object.op_Implicit((Object)(object)val) || (Object)(object)val.attachParent != (Object)(object)__instance) { __instance.attachedRenderers.RemoveAt(i--); continue; } val.UpdateZDepthAttached(targetZValue, currentYValue, isPerpendicular); if (!val.independentOrientation && isPerpendicular != val.IsPerpendicular) { val.IsPerpendicular = isPerpendicular; } } return false; } } [HarmonyPatch] private static class GUIHitTestOptimizations { private static bool Prepare(MethodBase original) { return false; } [HarmonyPatch(typeof(dfGUIManager), "HitTest")] [HarmonyPrefix] private static bool HitTestPatch(dfGUIManager __instance, Vector2 screenPosition, ref dfControl __result) { __result = null; if (GameManager.HasInstance && !GameManager.Instance.IsPaused && (!Object.op_Implicit((Object)(object)Minimap.m_instance) || !Minimap.Instance.m_isFullscreen) && !Foyer.DoIntroSequence && !Foyer.DoMainMenu) { return false; } return true; } } [HarmonyPatch] private static class ProjectileSpawnOptimizations { private static HashSet _ProcessedProjPrefabs = new HashSet(); private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_PROJ_STATUS) { return false; } return true; } [HarmonyPatch(typeof(SpawnManager), "SpawnProjectile", new Type[] { typeof(GameObject), typeof(Vector3), typeof(Quaternion), typeof(bool) })] [HarmonyPrefix] private static void SpawnManagerSpawnProjectilePatch(SpawnManager __instance, GameObject prefab, Vector3 position, Quaternion rotation, bool ignoresPools) { if (_ProcessedProjPrefabs.Contains(prefab)) { return; } Projectile component = prefab.GetComponent(); if (component != null) { if (!component.AppliesPoison) { component.healthEffect = null; } if (!component.AppliesSpeedModifier) { component.speedEffect = null; } if (!component.AppliesCharm) { component.charmEffect = null; } if (!component.AppliesFreeze) { component.freezeEffect = null; } if (!component.AppliesCheese) { component.cheeseEffect = null; } if (!component.AppliesBleed) { component.bleedEffect = null; } if (!component.AppliesFire) { component.fireEffect = null; } if (!component.baseData.UsesCustomAccelerationCurve) { component.baseData.AccelerationCurve = null; } _ProcessedProjPrefabs.Add(prefab); } } } [HarmonyPatch] private static class dfGUIEventOptimizations { private static readonly FieldInfo[] _NoFieldInfo = new FieldInfo[0]; private static readonly Dictionary _CachedFields = new Dictionary(); private static readonly BindingFlags _FieldFlags = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_GUI_EVENTS) { return false; } return true; } [HarmonyPatch(typeof(dfReflectionExtensions), "GetAllFields")] [HarmonyPrefix] private static bool dfReflectionExtensionsGetAllFieldsPatch(Type type, ref FieldInfo[] __result) { if ((object)type == null) { __result = _NoFieldInfo; return false; } if (_CachedFields.TryGetValue(type, out var value)) { __result = value; return false; } FieldInfo[] array = (_CachedFields[type] = (from f in type.GetFields(_FieldFlags).Concat(dfReflectionExtensions.GetAllFields(dfReflectionExtensions.GetBaseType(type))) where !f.IsDefined(typeof(HideInInspector), inherit: true) select f).ToArray()); __result = array; return false; } } [HarmonyPatch] private static class ItemLookupOptimizations { private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_ITEM_LOOKUPS) { return false; } return true; } [HarmonyPatch(typeof(PlayerController), "HasPassiveItem")] [HarmonyPrefix] private static bool PlayerControllerHasPassiveItemPatch(PlayerController __instance, int pickupId, ref bool __result) { for (int num = __instance.passiveItems.Count - 1; num >= 0; num--) { if (((PickupObject)__instance.passiveItems[num]).PickupObjectId == pickupId) { __result = true; return false; } } __result = false; return false; } [HarmonyPatch(typeof(PlayerController), "HasActiveItem")] [HarmonyPrefix] private static bool PlayerControllerHasActiveItemPatch(PlayerController __instance, int pickupId, ref bool __result) { for (int num = __instance.activeItems.Count - 1; num >= 0; num--) { if (((PickupObject)__instance.activeItems[num]).PickupObjectId == pickupId) { __result = true; return false; } } __result = false; return false; } } [HarmonyPatch] private static class LightCullingOptimizations { private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_LIGHT_CULL) { return false; } return true; } [HarmonyPatch(typeof(Pixelator), "LightCulled")] [HarmonyPrefix] private static bool PixelatorLightCulledPatch(Pixelator __instance, Vector2 lightPosition, Vector2 cameraPosition, float lightRange, float orthoSize, float aspect, ref bool __result) { //IL_0000: 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_0014: Unknown result type (might be due to invalid IL or missing references) float num = lightPosition.x - cameraPosition.x; float num2 = lightPosition.y - cameraPosition.y; float num3 = lightRange + orthoSize * __instance.LightCullFactor * aspect; __result = num * num + num2 * num2 > num3 * num3; return false; } } [HarmonyPatch] private static class FloodFillOptimizations { private static readonly Stack _FloodFillStack = new Stack(); private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_FLOOD_FILL) { return false; } return true; } [HarmonyPatch(typeof(DungeonData), "FloodFillDungeonExterior")] [HarmonyPrefix] private static bool FloodFillDungeonExteriorPatch(DungeonData __instance) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Invalid comparison between Unknown and I4 int width = __instance.m_width; int height = __instance.m_height; int num = Mathf.CeilToInt((float)(width * height) / 64f); if (num > _Bitfield.Length) { Array.Resize(ref _Bitfield, num); } for (int num2 = num - 1; num2 >= 0; num2--) { _Bitfield[num2] = 0uL; } CellData[][] cellData = __instance.cellData; if (cellData[0][0] != null) { cellData[0][0].isRoomInternal = false; } _Bitfield[0] = 1uL; _FloodFillStack.Push(IntVector2.Zero); while (_FloodFillStack.Count > 0) { IntVector2 val = _FloodFillStack.Pop(); for (int i = 0; i < IntVector2.Cardinals.Length; i++) { IntVector2 val2 = val + IntVector2.Cardinals[i]; int x = val2.x; int y = val2.y; if (x < 0 || y < 0 || x >= width || y >= height) { continue; } int num3 = y * width + x; int num4 = Mathf.FloorToInt((float)num3 / 64f); ulong num5 = (ulong)(1L << num3 % 64); if ((_Bitfield[num4] & num5) == num5) { continue; } _Bitfield[num4] |= num5; CellData val3 = cellData[x][y]; if (val3 != null) { if (((int)val3.type != 1 || val3.breakable) && !val3.isExitCell) { continue; } val3.isRoomInternal = false; } _FloodFillStack.Push(val2); } } return false; } } [HarmonyPatch] private static class GUINumberOptimizations { private const int _MAX_CACHED_NUMBER = 100000; private static readonly Dictionary _CachedNumberStrings = new Dictionary(); private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_NUMBERS) { return false; } return true; } [HarmonyPatch(typeof(SGUIIMBackend), "NextComponentName")] [HarmonyILManipulator] private static void SGUIIMBackendNextComponentNamePatch(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)0, new Func[1] { (Instruction instr) => ILPatternMatchingExt.MatchCall(instr, "ToString") })) { val.Remove(); val.CallPrivate(typeof(GUINumberOptimizations), "CachedStringForNumber"); } } private static string CachedStringForNumber(ref int n) { if (n > 100000) { return n.ToString(); } if (_CachedNumberStrings.TryGetValue(n, out var value)) { return value; } return _CachedNumberStrings[n] = n.ToString(); } } [HarmonyPatch] private static class TitleScreenOptimizations { private static bool _CheckForPlayer; private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_TITLE_SCREEN) { return false; } return true; } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPrefix] private static bool PrimaryPlayerPatch(GameManager __instance, ref PlayerController __result) { if (!_CheckForPlayer && !Object.op_Implicit((Object)(object)__instance.m_player) && !GameManager.Instance.IsLoadingLevel && (Foyer.DoIntroSequence || Foyer.DoMainMenu)) { __result = null; return false; } _CheckForPlayer = false; return true; } [HarmonyPatch(typeof(PlayerController), "Start")] [HarmonyPostfix] private static void PrimaryPlayerPatch(PlayerController __instance) { _CheckForPlayer = true; _ = GameManager.Instance.PrimaryPlayer; } } [HarmonyPatch] private static class SpriteChunkOptimizations { private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_CHUNK_CHECKS) { return false; } return true; } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPrefix] private static bool SpriteChunkIrrelevantToGameplayPatch(SpriteChunk __instance, ref bool __result) { DungeonData data = GameManager.Instance.Dungeon.data; int num = data.m_width - 1; int num2 = data.m_height - 1; int currentCellXOffset = RenderMeshBuilder.CurrentCellXOffset; int currentCellYOffset = RenderMeshBuilder.CurrentCellYOffset; int num3 = __instance.startX + currentCellXOffset; if (num3 < 0) { num3 = 0; } int num4 = __instance.startY + currentCellYOffset; if (num4 < 0) { num4 = 0; } int num5 = __instance.endX + currentCellXOffset; if (num5 > num) { num5 = num; } int num6 = __instance.endY + currentCellYOffset; if (num6 > num2) { num6 = num2; } CellData[][] cellData = data.cellData; for (int i = num3; i < num5; i++) { for (int j = num4; j < num6; j++) { CellData val = cellData[i][j]; if (val != null && val.distanceFromNearestRoom <= 15f) { __result = false; return false; } } } __result = true; return false; } } [HarmonyPatch] private static class PathingOptimizations { [HarmonyPatch(typeof(Pathfinder), "Walkable")] internal static class PathfinderWalkablePatch { private static HashSet _CheckedNodes = new HashSet(); private static bool Prefix(Pathfinder __instance, Vector2 start, Vector2 end, Vector2 extents, CellTypes passableCellTypes, bool canPassOccupied, IntVector2 clearance, bool ignoreWeightChecks, ref bool __result) { //IL_0000: 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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Invalid comparison between Unknown and I4 //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Invalid comparison between Unknown and I4 //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Invalid comparison between Unknown and I4 //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) float num = end.x - start.x; float num2 = end.y - start.y; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(num, num2); float num3 = num * num + num2 * num2; if (num3 < 0.040000003f) { __result = true; return false; } __result = false; int width = __instance.m_width; int height = __instance.m_height; _CheckedNodes.Clear(); float num4 = Mathf.Sqrt(num3); Vector2 val2 = val / (num4 / 0.2f); float num5 = float.MaxValue; float num6 = 0f; bool flag = false; bool flag2 = false; IntVector2 val3 = default(IntVector2); for (int i = 0; i < 4; i++) { int num7; int num8; switch (i) { case 0: num7 = (int)(start.x + extents.x); num8 = (int)(start.y + extents.y); ((IntVector2)(ref val3))..ctor(1, 1); break; case 1: num7 = (int)(start.x + extents.x); num8 = (int)(start.y - extents.y); ((IntVector2)(ref val3))..ctor(1, clearance.y); break; case 2: num7 = (int)(start.x - extents.x); num8 = (int)(start.y + extents.y); ((IntVector2)(ref val3))..ctor(clearance.x, 1); break; default: num7 = (int)(start.x - extents.x); num8 = (int)(start.y - extents.y); val3 = clearance; break; } if (num7 >= 0 && num7 < width && num8 >= 0 && num8 < height) { PathNode val4 = __instance.m_nodes[num7 + num8 * width]; float num9 = ((PathNode)(ref val4)).GetWeight(val3, passableCellTypes); if (num6 < num9) { num6 = num9; } if (((PathNode)(ref val4)).IsOccupied) { flag = true; } if ((int)((PathNode)(ref val4)).CellType == 4) { flag2 = true; } } } if (num6 > 0f) { num5 = num6; } Vector2 val5 = start; IntVector2 val6 = default(IntVector2); while (num4 >= 0f) { num6 = 0f; bool flag3 = false; bool flag4 = false; for (int j = 0; j < 4; j++) { int num10; int num11; switch (j) { case 0: num10 = (int)(val5.x + extents.x); num11 = (int)(val5.y + extents.y); ((IntVector2)(ref val6))..ctor(1, 1); break; case 1: num10 = (int)(val5.x + extents.x); num11 = (int)(val5.y - extents.y); ((IntVector2)(ref val6))..ctor(1, clearance.y); break; case 2: num10 = (int)(val5.x - extents.x); num11 = (int)(val5.y + extents.y); ((IntVector2)(ref val6))..ctor(clearance.x, 1); break; default: num10 = (int)(val5.x - extents.x); num11 = (int)(val5.y - extents.y); val6 = clearance; break; } int num12 = num10 + num11 * width; if (_CheckedNodes.Add(num12)) { if (num10 < 0 || num10 >= width || num11 < 0 || num11 >= height) { return false; } PathNode val7 = __instance.m_nodes[num12]; if (!canPassOccupied && !flag && ((PathNode)(ref val7)).IsOccupied) { return false; } CellType cellType = ((PathNode)(ref val7)).CellType; if ((((!flag2) ? passableCellTypes : (passableCellTypes | 4)) & cellType) == 0 && ((int)cellType != 4 || !val7.CellData.fallingPrevented || (passableCellTypes & 2) == 0)) { return false; } if (!ignoreWeightChecks && (float)((PathNode)(ref val7)).GetWeight(val6, passableCellTypes) > num5) { return false; } flag3 |= ((PathNode)(ref val7)).IsOccupied; flag4 = flag4 || (int)cellType == 4; float num13 = ((PathNode)(ref val7)).GetWeight(clearance, passableCellTypes); if (num6 < num13) { num6 = num13; } } } val5 += val2; num4 -= 0.2f; if (num5 > num6) { num5 = num6; } flag = flag && flag3; flag2 = flag2 && flag4; } __result = true; return false; } } [HarmonyPatch(typeof(BinaryHeap), "Clear")] internal static class BinaryHeapClearPatch { [HarmonyPrefix] private static bool Prefix(BinaryHeap __instance) { Array.Clear(__instance.m_data, 0, __instance.m_count); __instance.m_count = 0; return false; } } private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_PATH_RECALC) { return false; } return true; } [HarmonyPatch(typeof(Pathfinder), "RecalculateClearances", new Type[] { typeof(int), typeof(int), typeof(int), typeof(int) })] [HarmonyPrefix] private static bool RecalculateClearancesPatch(Pathfinder __instance, int minX, int minY, int maxX, int maxY) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Invalid comparison between Unknown and I4 //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Invalid comparison between Unknown and I4 //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Invalid comparison between Unknown and I4 //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Invalid comparison between Unknown and I4 //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Invalid comparison between Unknown and I4 //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Invalid comparison between Unknown and I4 //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Invalid comparison between Unknown and I4 //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Invalid comparison between Unknown and I4 //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Invalid comparison between Unknown and I4 //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Invalid comparison between Unknown and I4 //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Invalid comparison between Unknown and I4 PathNode[] nodes = __instance.m_nodes; int width = __instance.m_width; int height = __instance.m_height; int num = maxX + maxY * width; CellData cellData = nodes[num].CellData; if (cellData == null || cellData.isOccupied || (int)cellData.type == 1 || ((int)cellData.type == 4 && !cellData.fallingPrevented)) { nodes[num].SquareClearance = 0; } else { nodes[num].SquareClearance = 1; } for (int num2 = maxX - 1; num2 >= minX; num2--) { int num3 = num2 + maxY * width; _ = ref nodes[num3]; int num4 = nodes[num3 + 1].SquareClearance + 1; int num5 = 0; while (true) { if (num5 < num4) { int num6 = maxY + num5; if (num6 == height) { break; } CellData cellData2 = nodes[num2 + num6 * width].CellData; if (cellData2 == null || cellData2.isOccupied || (int)cellData2.type == 1 || ((int)cellData2.type == 4 && !cellData2.fallingPrevented)) { break; } num5++; continue; } int num7 = num2 + num4; if (num7 > width) { num7 = width; } for (int i = num2; i < num7; i++) { CellData cellData3 = nodes[i + (maxY + num4 - 1) * width].CellData; if (cellData3 == null || cellData3.isOccupied || (int)cellData3.type == 1 || ((int)cellData3.type == 4 && !cellData3.fallingPrevented)) { num5--; break; } } break; } nodes[num3].SquareClearance = num5; } for (int num8 = maxY - 1; num8 >= minY; num8--) { int num9 = maxX + num8 * width; _ = ref nodes[num9]; int num10 = nodes[num9 + width].SquareClearance + 1; int num11 = 0; while (true) { if (num11 < num10) { int num12 = maxX + num11; if (num12 == width) { break; } CellData cellData4 = nodes[num12 + num8 * width].CellData; if (cellData4 == null || cellData4.isOccupied || (int)cellData4.type == 1 || ((int)cellData4.type == 4 && !cellData4.fallingPrevented)) { break; } num11++; continue; } int num13 = num8 + num10; if (num13 > height) { num13 = height; } for (int j = num8; j < num13; j++) { CellData cellData5 = nodes[maxX + num10 - 1 + j * width].CellData; if (cellData5 == null || cellData5.isOccupied || (int)cellData5.type == 1 || ((int)cellData5.type == 4 && !cellData5.fallingPrevented)) { num11--; break; } } break; } nodes[num9].SquareClearance = num11; } for (int num14 = maxX - 1; num14 >= minX; num14--) { for (int num15 = maxY - 1; num15 >= minY; num15--) { int num16 = num14 + num15 * width; CellData cellData6 = nodes[num16].CellData; if (cellData6 == null || cellData6.isOccupied || (int)cellData6.type == 1 || ((int)cellData6.type == 4 && !cellData6.fallingPrevented)) { nodes[num16].SquareClearance = 0; } else { int num17 = nodes[num16 + width + 1].SquareClearance; int squareClearance = nodes[num16 + 1].SquareClearance; if (squareClearance < num17) { num17 = squareClearance; } int squareClearance2 = nodes[num16 + width].SquareClearance; if (squareClearance2 < num17) { num17 = squareClearance2; } int num18 = 1 + num17; int num19 = maxX - num14 + 1; int num20 = maxY - num15 + 1; int num21 = ((num19 > num20) ? num19 : num20); nodes[num16].SquareClearance = ((num18 < num21) ? num18 : num21); } } } return false; } } [HarmonyPatch] private static class SpriteVisiblityOptimizations { private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_VIS_CHECKS) { return false; } return true; } [HarmonyPatch(typeof(tk2dSpriteAnimator), "LateUpdate")] [HarmonyILManipulator] private static void tk2dSpriteAnimatorLateUpdatePatchIL(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)0, new Func[1] { (Instruction instr) => ILPatternMatchingExt.MatchCall(instr, "HandleVisibilityCheck") })) { val.Remove(); val.CallPrivate(typeof(SpriteVisiblityOptimizations), "FastHandleVisibilityCheck"); } } private static void FastHandleVisibilityCheck(tk2dSpriteAnimator animator) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (animator.alwaysUpdateOffscreen || !tk2dSpriteAnimator.InDungeonScene) { animator.m_isCurrentlyVisible = true; return; } Vector3 position = ((BraveBehaviour)animator).transform.position; float num = position.x - tk2dSpriteAnimator.CameraPositionThisFrame.x; float num2 = position.y - tk2dSpriteAnimator.CameraPositionThisFrame.y; animator.m_isCurrentlyVisible = num * num + num2 * num2 * 2.89f < 420f + animator.AdditionalCameraVisibilityRadius * animator.AdditionalCameraVisibilityRadius; } } [HarmonyPatch] private static class FastPauseMenu { private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_PAUSE) { return false; } return true; } [HarmonyPatch(typeof(Pixelator), "OnRenderImage")] [HarmonyPrefix] private static bool PixelatorOnRenderImagePatch(Pixelator __instance, RenderTexture source, RenderTexture target) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) if (!GameManager.HasInstance || !GameManager.Instance.IsPaused || GameManager.Instance.PreventPausing) { return true; } if (Object.op_Implicit((Object)(object)__instance.m_bloomer) && ((Behaviour)__instance.m_bloomer).enabled) { ((Behaviour)__instance.m_bloomer).enabled = false; } float num = Screen.height; Rect rect = __instance.m_camera.rect; float a = Mathf.Max(1f, Mathf.Min(20f, num * ((Rect)(ref rect)).height / 270f)); float a2 = Pixelator.Instance.ScaleTileScale / 3f * GameUIRoot.GameUIScalar; if (!a.Approximately(__instance.ScaleTileScale)) { __instance.CheckSize(); } else if (!a2.Approximately(GameUIRoot.Instance.m_manager.UIScale)) { __instance.CheckSize(); } BraveCameraUtility.MaintainCameraAspect(__instance.m_camera); Graphics.Blit((Texture)(object)Pixelator.m_smallBlackTexture, target); return false; } [HarmonyPatch(typeof(tk2dSpriteAnimator), "LateUpdate")] [HarmonyPatch(typeof(AIAnimator), "Update")] [HarmonyPatch(typeof(EmbersController), "Update")] [HarmonyPatch(typeof(PlayerHandController), "LateUpdate")] [HarmonyPatch(typeof(ShadowSystem), "LateUpdate")] [HarmonyPatch(typeof(KnockbackDoer), "Update")] [HarmonyPatch(typeof(GameUIBossHealthController), "LateUpdate")] [HarmonyPatch(typeof(CameraController), "LateUpdate")] [HarmonyILManipulator] private static void DontUpdateWhilePausedPatchIL(ILContext il) { //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_0024: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); ILLabel val2 = val.DefineLabel(); FieldInfo field = typeof(GameManager).GetField("mr_manager", BindingFlags.Static | BindingFlags.NonPublic); val.Emit(OpCodes.Ldsfld, field); val.Emit(OpCodes.Call, (MethodBase)typeof(Object).GetMethod("op_Implicit")); val.Emit(OpCodes.Brfalse, (object)val2); val.Emit(OpCodes.Ldsfld, field); val.Emit(OpCodes.Ldfld, typeof(GameManager).GetField("m_paused", BindingFlags.Instance | BindingFlags.NonPublic)); val.Emit(OpCodes.Brfalse, (object)val2); val.Emit(OpCodes.Ret); val.MarkLabel(val2); } private static bool CheckIfPaused() { if (GameManager.HasInstance) { return GameManager.Instance.IsPaused; } return false; } [HarmonyPatch(typeof(GameManager), "Update")] [HarmonyILManipulator] private static void GameManagerUpdatePatchIL(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)0, new Func[2] { (Instruction instr) => ILPatternMatchingExt.MatchLdcI4(instr, 0), (Instruction instr) => ILPatternMatchingExt.MatchStloc(instr, 1) })) { int index = val.Index + 1; val.Index = index; val.CallPrivate(typeof(FastPauseMenu), "IntMaxIfPaused"); } } private static int IntMaxIfPaused(int orig) { if (!GameManager.HasInstance || !GameManager.Instance.IsPaused) { return orig; } return int.MaxValue; } } [HarmonyPatch] private static class GetRandomAvailableCellPatch { private static List _StaticIntVectorList = new List(); private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_RANDOM_CELL) { return false; } return true; } private static List GetStaticIntVectorList() { _StaticIntVectorList.Clear(); return _StaticIntVectorList; } [HarmonyPatch(typeof(RoomHandler), "GetRandomAvailableCell")] [HarmonyILManipulator] private static void RoomHandlerGetRandomAvailableCellPatchIL(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)0, new Func[1] { (Instruction instr) => ILPatternMatchingExt.MatchNewobj>(instr) })) { val.Remove(); val.CallPrivate(typeof(GetRandomAvailableCellPatch), "GetStaticIntVectorList"); } } } [HarmonyPatch] private static class MarkupTokenizerMemoryLeakPatch { private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_TEXT_MARKUP) { return false; } return true; } [HarmonyPatch(typeof(dfMarkupTokenizer), "parseTag")] [HarmonyILManipulator] private static void dfMarkupTokenizerparseTagPatchIL(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)2, new Func[2] { (Instruction instr) => ILPatternMatchingExt.MatchCall(instr, "parseWhitespace"), (Instruction instr) => ILPatternMatchingExt.MatchPop(instr) })) { int index = val.Index - 1; val.Index = index; val.Remove(); val.Emit(OpCodes.Call, (MethodBase)typeof(dfMarkupToken).GetMethod("Release", BindingFlags.Instance | BindingFlags.Public)); } } } [HarmonyPatch] private static class RoomShuffleOffByOneFix { private static bool Prepare(MethodBase original) { if (!GGVConfig.FIX_SHUFFLE) { return false; } return true; } private static IEnumerable TargetMethods() { MethodInfo genShuffle = typeof(BraveUtility).GetMethod("GenerationShuffle", BindingFlags.Static | BindingFlags.Public); yield return genShuffle.MakeGenericMethod(typeof(int)); yield return genShuffle.MakeGenericMethod(typeof(IntVector2)); yield return genShuffle.MakeGenericMethod(typeof(Tuple)); yield return genShuffle.MakeGenericMethod(typeof(PrototypeRoomExit)); MethodInfo standardShuffle = typeof(BraveUtility).GetMethod("Shuffle", BindingFlags.Static | BindingFlags.Public); yield return standardShuffle.MakeGenericMethod(typeof(int)); yield return standardShuffle.MakeGenericMethod(typeof(IntVector2)); yield return standardShuffle.MakeGenericMethod(typeof(AIActor)); yield return standardShuffle.MakeGenericMethod(typeof(IPaydayItem)); } [HarmonyILManipulator] private static void GenerationShuffleFixIL(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0040: 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_0085: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)2, new Func[1] { (Instruction instr) => ILPatternMatchingExt.MatchLdloc(instr, 0) })) { val.Emit(OpCodes.Ldc_I4_1); val.Emit(OpCodes.Add); ILLabel forLabel = null; if (val.TryGotoNext((MoveType)0, new Func[1] { (Instruction instr) => ILPatternMatchingExt.MatchBgt(instr, ref forLabel) })) { val.Remove(); val.Emit(OpCodes.Bge, (object)forLabel); } } } } [HarmonyPatch] private static class DuctTapeFix { private static bool Prepare(MethodBase original) { if (!GGVConfig.FIX_DUCT_TAPE) { return false; } return true; } [HarmonyPatch(typeof(Gun), "CopyStateFrom")] [HarmonyPostfix] private static void DuctTapeSaveLoadPatch(Gun __instance, Gun other) { __instance.DuctTapeMergedGunIDs = other.DuctTapeMergedGunIDs; } } [HarmonyPatch] private static class QuickRestartFixes { private static bool Prepare(MethodBase original) { if (!GGVConfig.FIX_QUICK_RESTART) { return false; } return true; } [HarmonyPatch(typeof(GameManager), "QuickRestart")] [HarmonyILManipulator] private static void QuickRestartRoomCachePatch(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)2, new Func[2] { (Instruction instr) => ILPatternMatchingExt.MatchLdstr(instr, "Quick Restarting..."), (Instruction instr) => ILPatternMatchingExt.MatchCall(instr, "Log") })) { val.Emit(OpCodes.Ldarg_0); val.CallPrivate(typeof(QuickRestartFixes), "ForcePreprocessRunForQuickStart"); } } private static void ForcePreprocessRunForQuickStart(GameManager gm) { if (Object.op_Implicit((Object)(object)gm)) { gm.GlobalInjectionData.PreprocessRun(false); } } } [HarmonyPatch] private static class AmmoUIFixes { private static bool Prepare(MethodBase original) { if (!GGVConfig.FIX_AMMO_UI) { return false; } return true; } [HarmonyPatch(typeof(GameUIAmmoController), "UpdateAmmoUIForModule")] [HarmonyPostfix] private static void GameUIAmmoControllerUpdateAmmoUIForModulePatch(GameUIAmmoController __instance, ref dfTiledSprite currentAmmoFGSprite, ref dfTiledSprite currentAmmoBGSprite, List AddlModuleFGSprites, List AddlModuleBGSprites, dfSprite ModuleTopCap, dfSprite ModuleBottomCap, ProjectileModule module, Gun currentGun, ref AmmoType cachedAmmoTypeForModule, ref string cachedCustomAmmoTypeForModule, ref int cachedShotsInClip, bool didChangeGun, int numberRemaining) { if (AddlModuleBGSprites != null && AddlModuleBGSprites.Count >= 1 && AddlModuleFGSprites != null && AddlModuleFGSprites.Count >= 1) { ((dfControl)AddlModuleFGSprites[0]).ZOrder = ((dfControl)AddlModuleBGSprites[0]).ZOrder + 1; if ((Object)(object)currentAmmoFGSprite != (Object)null) { ((dfControl)currentAmmoFGSprite).ZOrder = ((dfControl)AddlModuleFGSprites[0]).ZOrder + 1; } } } } [HarmonyPatch] private static class OrbitalGunFixes { private static bool Prepare(MethodBase original) { if (!GGVConfig.FIX_ORBITAL_GUN) { return false; } return true; } [HarmonyPatch(typeof(HoveringGunController), "Initialize")] [HarmonyPostfix] private static void HoveringGunDoesntShootProperlyWhenCreatedWhileFacingLeftPatch(HoveringGunController __instance) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)__instance.m_owner) && Object.op_Implicit((Object)(object)((BraveBehaviour)__instance.m_owner).sprite) && ((BraveBehaviour)__instance.m_owner).sprite.FlipX) { Transform shootPointTransform = __instance.m_shootPointTransform; shootPointTransform.localPosition = Vector3Extensions.WithY(shootPointTransform.localPosition, 0f - shootPointTransform.localPosition.y); } } } [HarmonyPatch] private static class CoopTurboFixes { private static bool Prepare(MethodBase original) { if (!GGVConfig.FIX_COOP_TURBO) { return false; } return true; } [HarmonyPatch(typeof(PlayerController), "UpdateTurboModeStats")] [HarmonyILManipulator] private static void CoopTurboModeFixHookIL(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)2, new Func[2] { (Instruction instr) => ILPatternMatchingExt.MatchLdfld(instr, "m_turboSpeedModifier"), (Instruction instr) => instr.OpCode == OpCodes.Callvirt })) { val.Emit(OpCodes.Ldarg_0); val.CallPrivate(typeof(CoopTurboFixes), "RecalculateTurboStats"); if (val.TryGotoNext((MoveType)2, new Func[2] { (Instruction instr) => ILPatternMatchingExt.MatchLdfld(instr, "m_turboRollSpeedModifier"), (Instruction instr) => instr.OpCode == OpCodes.Callvirt })) { val.Emit(OpCodes.Ldarg_0); val.CallPrivate(typeof(CoopTurboFixes), "RecalculateTurboStats"); } } } private static void RecalculateTurboStats(PlayerController player) { player.stats.RecalculateStats(player, false, false); } } [HarmonyPatch] private static class BulletTrailFixes { private static bool Prepare(MethodBase original) { if (!GGVConfig.FIX_BULLET_TRAILS) { return false; } return true; } [HarmonyPatch(typeof(TrailController), "Update")] [HarmonyILManipulator] private static void TrailControllerUpdateIL(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)2, new Func[1] { (Instruction instr) => ILPatternMatchingExt.MatchCallvirt(instr, (MethodBase)typeof(LinkedList).GetMethod("get_Count")) })) { val.Emit(OpCodes.Ldarg_0); val.CallPrivate(typeof(BulletTrailFixes), "KeepTrailAliveWhenEmpty"); } } private static int KeepTrailAliveWhenEmpty(int oldCount, TrailController trail) { if (!trail.destroyOnEmpty) { return 999; } return oldCount; } } [HarmonyPatch] private static class BeamDamageCapPatch { private static bool Prepare(MethodBase original) { if (!GGVConfig.FIX_DAMAGE_CAPS) { return false; } return true; } [HarmonyPatch(typeof(BasicBeamController), "FrameUpdate")] [HarmonyILManipulator] private static void BasicBeamControllerFrameUpdateIL(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); for (int i = 0; i < 3; i++) { if (!val.TryGotoNext((MoveType)((i != 2) ? 2 : 0), new Func[1] { (Instruction instr) => ILPatternMatchingExt.MatchCallvirt(instr, "ApplyDamage") })) { return; } } if (val.TryGotoPrev((MoveType)2, new Func[1] { (Instruction instr) => ILPatternMatchingExt.MatchLdcI4(instr, 0) })) { val.Emit(OpCodes.Ldarg_0); val.CallPrivate(typeof(BeamDamageCapPatch), "BeamShouldIgnoreDamageCaps"); } } private static bool BeamShouldIgnoreDamageCaps(bool origVal, BasicBeamController beam) { if (!origVal) { if (Object.op_Implicit((Object)(object)((BraveBehaviour)beam).projectile)) { return ((BraveBehaviour)beam).projectile.ignoreDamageCaps; } return false; } return true; } } [HarmonyPatch] private static class EvolverDevolvePatch { private static bool Prepare(MethodBase original) { if (!GGVConfig.FIX_EVOLVER) { return false; } return true; } [HarmonyPatch(typeof(EvolverGunController), "OnDestroy")] [HarmonyPrefix] private static bool EvolverGunControllerOnDestroyPatch(EvolverGunController __instance) { __instance.Disengage(); return false; } } [HarmonyPatch] private static class AmmoDriftPatch { private static bool Prepare(MethodBase original) { if (!GGVConfig.FIX_AMMO_DRIFT) { return false; } return true; } [HarmonyPatch(typeof(GameUIAmmoController), "UpdateUIGun")] [HarmonyILManipulator] private static void BasicBeamControllerFrameUpdateIL(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)2, new Func[2] { (Instruction instr) => ILPatternMatchingExt.MatchLdfld(instr, "m_cachedGun"), (Instruction instr) => ILPatternMatchingExt.MatchCallvirt(instr, "get_InfiniteAmmo") })) { val.Emit(OpCodes.Ldarg_0); val.CallPrivate(typeof(AmmoDriftPatch), "WasReallyInfiniteAmmo"); } } private static bool WasReallyInfiniteAmmo(bool origVal, GameUIAmmoController self) { if (origVal) { return self.m_cachedMaxAmmo == int.MaxValue; } return false; } } [HarmonyPatch] private static class RepausePatch { private static bool Prepare(MethodBase original) { if (!GGVConfig.FIX_REPAUSE) { return false; } return true; } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyILManipulator] private static void GameManagerDepixelateCRIL(ILContext il, MethodBase original) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); Type ot = original.DeclaringType; if (val.TryGotoNext((MoveType)2, new Func[4] { (Instruction instr) => ILPatternMatchingExt.MatchLdarg(instr, 0), (Instruction instr) => ILPatternMatchingExt.MatchLdfld(instr, ot.GetEnumeratorField("$this")), (Instruction instr) => ILPatternMatchingExt.MatchCall(instr, "get_gameObject"), (Instruction instr) => ILPatternMatchingExt.MatchCall(instr, typeof(BraveTime), "ClearMultiplier") })) { ILLabel val2 = val.MarkLabel(); if (val.TryGotoPrev((MoveType)0, new Func[4] { (Instruction instr) => ILPatternMatchingExt.MatchLdarg(instr, 0), (Instruction instr) => ILPatternMatchingExt.MatchLdfld(instr, ot.GetEnumeratorField("$this")), (Instruction instr) => ILPatternMatchingExt.MatchCall(instr, "get_gameObject"), (Instruction instr) => ILPatternMatchingExt.MatchCall(instr, typeof(BraveTime), "ClearMultiplier") })) { val.Emit(OpCodes.Ldarg_0); val.Emit(OpCodes.Ldfld, ot.GetEnumeratorField("$this")); val.CallPrivate(typeof(RepausePatch), "IsActuallyStillPaused"); val.Emit(OpCodes.Brtrue, (object)val2); } } } private static bool IsActuallyStillPaused(GameManager instance) { return instance.m_paused; } } [HarmonyPatch] private static class MimicTransformationPatch { private static bool Prepare(MethodBase original) { if (!GGVConfig.FIX_MIMIC_CHEST) { return false; } return true; } [HarmonyPatch(typeof(Chest), "DoMimicTransformation")] [HarmonyPrefix] private static bool DoMimicTransformation(Chest __instance) { return !string.IsNullOrEmpty(__instance.MimicGuid); } } [HarmonyPatch] private static class HighStressPatch { private static bool Prepare(MethodBase original) { if (!GGVConfig.FIX_HIGH_STRESS) { return false; } return true; } [HarmonyPatch(typeof(GameUIHeartController), "UpdateHealth")] [HarmonyILManipulator] private static void GameUIHeartControllerUpdateHealthPatchIL(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); ILLabel afterNextShotKillsLabel = null; if (val.TryGotoNext((MoveType)2, new Func[3] { (Instruction instr) => ILPatternMatchingExt.MatchLdarg(instr, 1), (Instruction instr) => ILPatternMatchingExt.MatchLdfld(instr, "NextShotKills"), (Instruction instr) => ILPatternMatchingExt.MatchBrfalse(instr, ref afterNextShotKillsLabel) })) { val.Emit(OpCodes.Ldarg, 1); val.Emit(OpCodes.Ldloca, 0); val.Emit(OpCodes.Ldloca, 2); val.CallPrivate(typeof(HighStressPatch), "HighStressArmorFix"); val.Emit(OpCodes.Br, (object)afterNextShotKillsLabel); } } private static void HighStressArmorFix(HealthHaver hh, ref float health, ref float armor) { GameActor gameActor = ((BraveBehaviour)hh).gameActor; PlayerController val = (PlayerController)(object)((gameActor is PlayerController) ? gameActor : null); if (val != null && val.ForceZeroHealthState) { health = 0f; armor = 1f; } else { health = 0.5f; armor = 0f; } } } [HarmonyPatch] private static class BrickOfCashPatch { private static bool Prepare(MethodBase original) { if (!GGVConfig.FIX_BRICK_OF_CASH) { return false; } return true; } [HarmonyPatch(typeof(SecretRoomDoorBeer), "DoSnitchBrick")] [HarmonyILManipulator] private static void SecretRoomDoorBeerDoSnitchBrickPatchIL(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)2, new Func[1] { (Instruction instr) => ILPatternMatchingExt.MatchCall(instr, "GetIntVector2FromDirection") })) { val.Emit(OpCodes.Ldarg_0); val.CallPrivate(typeof(BrickOfCashPatch), "BrickOfCashFix"); } } private static IntVector2 BrickOfCashFix(IntVector2 origVal, SecretRoomDoorBeer secret) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 //IL_0026: 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_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 ((int)secret.exitDef.downstreamExit.referencedExit.exitDirection == 6) { return origVal + new IntVector2(-1, 0); } return origVal; } } [HarmonyPatch] private static class GunMagnificencePatch { private static bool Prepare(MethodBase original) { if (!GGVConfig.FIX_GUN_MAGNIFICENCE) { return false; } return true; } [HarmonyPatch(typeof(PickupObject), "HandleMagnficence")] [HarmonyPrefix] private static bool PickupObjectHandleMagnficencePatch(PickupObject __instance) { Gun val = (Gun)(object)((__instance is Gun) ? __instance : null); if (val != null && val.HasBeenPickedUp) { return false; } return true; } } [HarmonyPatch] private static class InfiniteBeamAmmoPatch { private static bool Prepare(MethodBase original) { if (!GGVConfig.FIX_INFINITE_BEAMS) { return false; } return true; } [HarmonyPatch(typeof(MagazineRack), "Update")] [HarmonyILManipulator] private static void MagazineRackUpdatePatchIL(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_005c: 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) ILCursor val = new ILCursor(il); ILLabel val2 = default(ILLabel); if (val.TryGotoNext((MoveType)1, new Func[2] { (Instruction instr) => ILPatternMatchingExt.MatchLdloc(instr, 0), (Instruction instr) => ILPatternMatchingExt.MatchBrtrue(instr, ref val2) })) { val.Emit(OpCodes.Ldarg_0); val.Emit(OpCodes.Ldloc_1); val.CallPrivate(typeof(InfiniteBeamAmmoPatch), "InfiniteBeamAmmoFix"); } } private static void InfiniteBeamAmmoFix(MagazineRack rack, PlayerController player) { if (!player.InfiniteAmmo.HasOverride("MagazineRack")) { return; } int playerIDX = player.PlayerIDX; if (playerIDX == 0 || playerIDX == 1) { int num = ((playerIDX == 0) ? rack.m_p1MaxGunAmmoThisFrame : rack.m_p2MaxGunAmmoThisFrame); int num2 = ((playerIDX == 0) ? rack.m_p1GunIDThisFrame : rack.m_p2GunIDThisFrame); Gun currentGun = ((GameActor)player).CurrentGun; if (currentGun != null && !currentGun.RequiresFundsToShoot && currentGun.CurrentAmmo < num && ((PickupObject)currentGun).PickupObjectId == num2) { currentGun.ammo = Mathf.Min(currentGun.AdjustedMaxAmmo, num); } } } } [HarmonyPatch] private static class CapedBulletKinPatch { private static bool Prepare(MethodBase original) { if (!GGVConfig.FIX_CAPED_BULLET_KIN) { return false; } return true; } [HarmonyPatch(typeof(UnlockPlayableBulletManBehavior), "Start")] [HarmonyPostfix] private static void UnlockPlayableBulletManBehaviorStartPatch(UnlockPlayableBulletManBehavior __instance) { ((BehaviorBase)__instance).m_updateEveryFrame = true; } } [HarmonyPatch] private static class FlakBulletsPatch { private static bool Prepare(MethodBase original) { if (!GGVConfig.FIX_FLAK_BULLETS) { return false; } return true; } [HarmonyPatch(typeof(ComplexProjectileModifier), "PostProcessProjectile")] [HarmonyILManipulator] private static void ComplexProjectileModifierPostProcessProjectilePatchIL(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)0, new Func[1] { (Instruction instr) => ILPatternMatchingExt.MatchStfld(instr, "PostprocessSpawnedProjectiles") })) { val.Emit(OpCodes.Ldarg_1); val.CallPrivate(typeof(FlakBulletsPatch), "FlakBulletsFix"); } } private static bool FlakBulletsFix(bool origVal, Projectile proj) { if (origVal) { return !proj.SpawnedFromOtherPlayerProjectile; } return false; } } [HarmonyPatch] private static class ScattershotPatch { private static bool Prepare(MethodBase original) { if (!GGVConfig.FIX_SCATTERSHOT) { return false; } return true; } [HarmonyPatch(typeof(GunVolleyModificationItem), "ModifyVolley")] [HarmonyILManipulator] private static void GunVolleyModificationItemModifyVolleyPatchIL(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)2, new Func[1] { (Instruction instr) => ILPatternMatchingExt.MatchStfld(instr, "ammoCost") })) { val.Emit(OpCodes.Ldloc, 7); val.CallPrivate(typeof(ScattershotPatch), "ScattershotFix"); } } private static void ScattershotFix(ProjectileModule mod) { //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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown if (mod.ammoCost > 0) { return; } List chargeProjectiles = mod.chargeProjectiles; if (chargeProjectiles == null) { return; } mod.chargeProjectiles = new List(chargeProjectiles.Count); foreach (ChargeProjectile item2 in chargeProjectiles) { ChargeProjectile item = new ChargeProjectile { ChargeTime = item2.ChargeTime, Projectile = item2.Projectile, UsedProperties = item2.UsedProperties, VfxPool = item2.VfxPool, LightIntensity = item2.LightIntensity, ScreenShake = item2.ScreenShake, OverrideShootAnimation = item2.OverrideShootAnimation, OverrideMuzzleFlashVfxPool = item2.OverrideMuzzleFlashVfxPool, MegaReflection = item2.MegaReflection, AdditionalWwiseEvent = item2.AdditionalWwiseEvent, AmmoCost = 0 }; mod.chargeProjectiles.Add(item); } } } [HarmonyPatch] private static class OrbitalBulletsPatch { private static bool Prepare(MethodBase original) { if (!GGVConfig.FIX_ORBITAL_BULLETS) { return false; } return true; } [HarmonyPatch(typeof(OrbitProjectileMotionModule), "Move")] [HarmonyPrefix] private static bool OrbitProjectileMotionModuleMovePatch(OrbitProjectileMotionModule __instance, Projectile source, Transform projectileTransform, tk2dBaseSprite projectileSprite, SpeculativeRigidbody specRigidbody, ref float m_timeElapsed, ref Vector2 m_currentDirection, bool Inverted, bool shouldRotate) { if (Object.op_Implicit((Object)(object)source)) { return ((Behaviour)source).isActiveAndEnabled; } return false; } } [HarmonyPatch] private static class StarpewPatch { private static bool Prepare(MethodBase original) { if (!GGVConfig.FIX_STARPEW) { return false; } PickupObject byId = PickupObjectDatabase.GetById(507); ((Gun)((byId is Gun) ? byId : null)).Volley.projectiles[5].numberOfShotsInClip = 100; return true; } } private static ulong[] _Bitfield = new ulong[10000]; [HarmonyPatch(typeof(BraveMemory), "EnsureHeapSize")] [HarmonyPrefix] private static void BraveMemoryEnsureHeapSizePatch(ref int kilobytes) { if (GGVConfig.PREALLOCATE_HEAP > 0) { kilobytes = GGVConfig.PREALLOCATE_HEAP * 1048576; } } } [HarmonyPatch] internal static class Gooptimizations { private class ExtraGoopData { private static ExtraGoopData _NullEGD = new ExtraGoopData(null); private static ExtraGoopData _CachedEGD = _NullEGD; private static List _AllEGDs = new List(); public DeadlyDeadlyGoopManager manager; public ulong[,,] goopedCellBitfield; public GoopPositionData[,] goopedCellGrid; public List allGoopedCells; private int _xChunks; private int _yChunks; private int _cachedWidth; private int _cachedHeight; private DungeonData _cachedDungeon; private Dictionary _allGoopedCellsIndices; private ExtraGoopData(DeadlyDeadlyGoopManager manager) { this.manager = manager; if (!((Object)(object)manager == (Object)null)) { DungeonData val = (_cachedDungeon = GameManager.Instance.Dungeon.data); _cachedWidth = val.m_width; _cachedHeight = val.m_height; _xChunks = Mathf.CeilToInt((float)_cachedWidth * 0.2f); _yChunks = Mathf.CeilToInt((float)_cachedHeight * 0.2f); goopedCellBitfield = new ulong[_xChunks, _yChunks, 7]; goopedCellGrid = new GoopPositionData[_cachedWidth << 2, _cachedHeight << 2]; allGoopedCells = new List(); _allGoopedCellsIndices = new Dictionary(); _AllEGDs.Add(this); } } private void Resize() { int width = _cachedDungeon.m_width; int height = _cachedDungeon.m_height; int num = Mathf.CeilToInt((float)width * 0.2f); int num2 = Mathf.CeilToInt((float)height * 0.2f); ulong[,,] array = new ulong[num, num2, 7]; for (int i = 0; i < _xChunks; i++) { for (int j = 0; j < _yChunks; j++) { for (int k = 0; k < 7; k++) { array[i, j, k] = goopedCellBitfield[i, j, k]; } } } _cachedWidth = width; _cachedHeight = height; _xChunks = num; _yChunks = num2; goopedCellBitfield = array; goopedCellGrid = new GoopPositionData[_cachedWidth << 2, _cachedHeight << 2]; foreach (GoopPositionData allGoopedCell in allGoopedCells) { goopedCellGrid[allGoopedCell.goopPosition.x, allGoopedCell.goopPosition.y] = allGoopedCell; } } internal static void ResizeAllBitfields() { for (int num = _AllEGDs.Count - 1; num >= 0; num--) { _AllEGDs[num].Resize(); } } internal static ExtraGoopData Get(DeadlyDeadlyGoopManager manager) { if ((Object)(object)_CachedEGD.manager == (Object)(object)manager) { return _CachedEGD; } for (int num = _AllEGDs.Count - 1; num >= 0; num--) { if (!((Object)(object)_AllEGDs[num].manager != (Object)(object)manager)) { return _CachedEGD = _AllEGDs[num]; } } return _CachedEGD = new ExtraGoopData(manager); } internal static void ClearLevelData() { _AllEGDs.Clear(); _CachedEGD = _NullEGD; } internal void AddGoop(GoopPositionData goop) { //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_0013: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) IntVector2 goopPosition = goop.goopPosition; int num = goopPosition.x % 20 * 20 + goopPosition.y % 20; goopedCellBitfield[(int)((float)goopPosition.x * 0.05f), (int)((float)goopPosition.y * 0.05f), num >> 6] |= (ulong)(1L << num); goopedCellGrid[goopPosition.x, goopPosition.y] = goop; int count = allGoopedCells.Count; allGoopedCells.Add(goop); _allGoopedCellsIndices[goop] = count; } internal void RemoveGoop(GoopPositionData goop) { //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_0018: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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) if (_allGoopedCellsIndices.TryGetValue(goop, out var value)) { IntVector2 goopPosition = goop.goopPosition; int num = goopPosition.x % 20 * 20 + goopPosition.y % 20; goopedCellBitfield[(int)((float)goopPosition.x * 0.05f), (int)((float)goopPosition.y * 0.05f), num >> 6] &= (ulong)(~(1L << num)); goopedCellGrid[goopPosition.x, goopPosition.y] = null; _allGoopedCellsIndices.Remove(goop); int index = allGoopedCells.Count - 1; allGoopedCells[value] = allGoopedCells[index]; _allGoopedCellsIndices[allGoopedCells[value]] = value; allGoopedCells.RemoveAt(index); } } } private const int CHUNK_SIZE = 5; private const float CHUNK_SIZE_F = 5f; private const float INV_CHUNK_SIZE_F = 0.2f; private const float GOOP_GRID_SIZE = 0.25f; private const int GG_SHIFT_BITS = 2; private const float INV_GOOP_GRID_SIZE = 4f; private const int CELLS_PER_CHUNK = 20; private const float CELLS_PER_CHUNK_F = 20f; private const float INV_CELLS_PER_CHUNK_F = 0.05f; private static readonly Color32 _Transparent = new Color32((byte)0, (byte)0, (byte)0, (byte)0); private static Queue _GoopsToElectrify = new Queue(); private static float _InvSqrRadius = 1f; private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_GOOP) { return false; } return true; } [HarmonyPatch(typeof(DeadlyDeadlyGoopManager), "ClearPerLevelData")] [HarmonyPostfix] private static void DeadlyDeadlyGoopManagerClearPerLevelDataPatch() { ExtraGoopData.ClearLevelData(); } [HarmonyPatch(typeof(DungeonData), "ClearCachedCellData")] [HarmonyPostfix] private static void ClearCachedCellData(DungeonData __instance) { __instance.m_width = __instance.cellData.Length; __instance.m_height = __instance.cellData[0].Length; ExtraGoopData.ResizeAllBitfields(); } [HarmonyPatch(typeof(DeadlyDeadlyGoopManager), "RebuildMeshUvsAndColors")] [HarmonyPrefix] private static bool DeadlyDeadlyGoopManagerRebuildMeshUvsAndColorsPatch(DeadlyDeadlyGoopManager __instance, int chunkX, int chunkY) { //IL_0052: 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_0064: 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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) Mesh chunkMesh = __instance.GetChunkMesh(chunkX, chunkY); for (int i = 0; i < __instance.m_colorArray.Length; i++) { __instance.m_colorArray[i].a = 0; } int num = chunkX * 20; int num2 = num + 20; int num3 = chunkY * 20; int num4 = num3 + 20; _ = __instance.m_goopedCells; GoopPositionData val = null; IntVector2 val2 = default(IntVector2); Vector2 val3 = __instance.m_uvMap[-1]; int count = __instance.m_centerUVOptions.Count; Vector2 value = default(Vector2); ExtraGoopData extraGoopData = ExtraGoopData.Get(__instance); ulong[,,] goopedCellBitfield = extraGoopData.goopedCellBitfield; int num5 = -1; Vector2 val4 = default(Vector2); for (int j = num; j < num2; j++) { val2.x = j; for (int k = num3; k < num4; k++) { num5++; if ((goopedCellBitfield[chunkX, chunkY, num5 >> 6] & (ulong)(1L << num5)) == 0L) { continue; } val2.y = k; val = extraGoopData.goopedCellGrid[j, k]; if (val != null && !(val.remainingLifespan <= 0f)) { int num6 = val.baseIndex; if (num6 < 0) { num6 = (val.baseIndex = __instance.GetGoopBaseIndex(val2, chunkX, chunkY)); } if (val.NeighborsAsInt == 255) { value = __instance.m_centerUVOptions[(int)((float)count * ((IntVector2)(ref val2)).GetHashedRandomValue())]; } else if (!__instance.m_uvMap.TryGetValue(val.NeighborsAsInt, out value) && !__instance.m_uvMap.TryGetValue(val.NeighborsAsIntFuckDiagonals, out value)) { value = val3; } __instance.m_uvArray[num6] = value; __instance.m_uvArray[num6 + 1] = new Vector2(value.x + 0.125f, value.y + 0f); __instance.m_uvArray[num6 + 2] = new Vector2(value.x + 0f, value.y + 0.125f); __instance.m_uvArray[num6 + 3] = new Vector2(value.x + 0.125f, value.y + 0.125f); if (__instance.goopDefinition.CanBeFrozen) { ((Vector2)(ref val4))..ctor((float)(val.IsFrozen ? 1 : 0), 0f); __instance.m_uv2Array[num6] = val4; __instance.m_uv2Array[num6 + 1] = val4; __instance.m_uv2Array[num6 + 2] = val4; __instance.m_uv2Array[num6 + 3] = val4; } __instance.AssignVertexColors(val, val2, chunkX, chunkY); } } } chunkMesh.uv = __instance.m_uvArray; chunkMesh.uv2 = __instance.m_uv2Array; chunkMesh.colors32 = __instance.m_colorArray; return false; } [HarmonyPatch(typeof(DeadlyDeadlyGoopManager), "LateUpdate")] [HarmonyPrefix] private static bool DeadlyDeadlyGoopManagerLateUpdatePatch(DeadlyDeadlyGoopManager __instance) { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_09b2: 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_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_05e3: Unknown result type (might be due to invalid IL or missing references) //IL_0535: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_06ae: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_06bc: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_03b6: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_06cc: Unknown result type (might be due to invalid IL or missing references) //IL_06d4: Unknown result type (might be due to invalid IL or missing references) //IL_06de: Unknown result type (might be due to invalid IL or missing references) //IL_0706: Unknown result type (might be due to invalid IL or missing references) //IL_0710: Unknown result type (might be due to invalid IL or missing references) //IL_0715: Unknown result type (might be due to invalid IL or missing references) //IL_071a: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_03ff: Unknown result type (might be due to invalid IL or missing references) //IL_042c: Unknown result type (might be due to invalid IL or missing references) //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Unknown result type (might be due to invalid IL or missing references) //IL_0450: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_0655: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_047a: Invalid comparison between Unknown and I4 //IL_0481: Unknown result type (might be due to invalid IL or missing references) //IL_0487: Invalid comparison between Unknown and I4 //IL_05a9: Unknown result type (might be due to invalid IL or missing references) //IL_093c: Unknown result type (might be due to invalid IL or missing references) //IL_093e: Unknown result type (might be due to invalid IL or missing references) //IL_0940: Unknown result type (might be due to invalid IL or missing references) //IL_094a: Unknown result type (might be due to invalid IL or missing references) //IL_08c3: Unknown result type (might be due to invalid IL or missing references) //IL_08cb: Unknown result type (might be due to invalid IL or missing references) //IL_08d4: Unknown result type (might be due to invalid IL or missing references) //IL_0901: Unknown result type (might be due to invalid IL or missing references) //IL_0906: Unknown result type (might be due to invalid IL or missing references) //IL_0923: Unknown result type (might be due to invalid IL or missing references) //IL_0925: Unknown result type (might be due to invalid IL or missing references) //IL_092d: Unknown result type (might be due to invalid IL or missing references) //IL_0836: Unknown result type (might be due to invalid IL or missing references) //IL_083e: Unknown result type (might be due to invalid IL or missing references) //IL_0847: Unknown result type (might be due to invalid IL or missing references) //IL_0874: Unknown result type (might be due to invalid IL or missing references) //IL_0879: Unknown result type (might be due to invalid IL or missing references) //IL_0896: Unknown result type (might be due to invalid IL or missing references) //IL_0898: Unknown result type (might be due to invalid IL or missing references) //IL_08a0: Unknown result type (might be due to invalid IL or missing references) //IL_0787: Unknown result type (might be due to invalid IL or missing references) //IL_078f: Unknown result type (might be due to invalid IL or missing references) //IL_0798: Unknown result type (might be due to invalid IL or missing references) //IL_07c5: Unknown result type (might be due to invalid IL or missing references) //IL_07ca: Unknown result type (might be due to invalid IL or missing references) //IL_07e7: Unknown result type (might be due to invalid IL or missing references) //IL_07e9: Unknown result type (might be due to invalid IL or missing references) //IL_07f1: Unknown result type (might be due to invalid IL or missing references) //IL_048e: Unknown result type (might be due to invalid IL or missing references) //IL_049f: Unknown result type (might be due to invalid IL or missing references) //IL_04a4: Unknown result type (might be due to invalid IL or missing references) //IL_04a9: Unknown result type (might be due to invalid IL or missing references) //IL_04ba: Unknown result type (might be due to invalid IL or missing references) //IL_04bf: Unknown result type (might be due to invalid IL or missing references) //IL_04c4: Unknown result type (might be due to invalid IL or missing references) //IL_098b: Unknown result type (might be due to invalid IL or missing references) //IL_0984: Unknown result type (might be due to invalid IL or missing references) if (Time.timeScale <= 0f || GameManager.Instance.IsPaused) { return false; } __instance.m_removalPositions.Clear(); bool flag = false; bool flag2 = false; __instance.m_currentUpdateBin = (__instance.m_currentUpdateBin + 1) % 4; __instance.m_deltaTimes.Enqueue(BraveTime.DeltaTime); float num = 0f; for (int i = 0; i < __instance.m_deltaTimes.Count; i++) { num += __instance.m_deltaTimes[i]; } ExtraGoopData extraGoopData = ExtraGoopData.Get(__instance); int count = extraGoopData.allGoopedCells.Count; for (int j = 0; j < count; j++) { GoopPositionData val = extraGoopData.allGoopedCells[j]; if (val.GoopUpdateBin != __instance.m_currentUpdateBin) { continue; } IntVector2 goopPosition = val.goopPosition; val.unfrozeLastFrame = false; if (__instance.goopDefinition.usesAmbientGoopFX && val.remainingLifespan > 0f && Random.value < __instance.goopDefinition.ambientGoopFXChance && val.SupportsAmbientVFX) { Vector3 val2 = ((IntVector2)(ref goopPosition)).ToVector3((float)goopPosition.y) * 0.25f; __instance.goopDefinition.ambientGoopFX.SpawnAtPosition(val2, 0f, (Transform)null, (Vector2?)null, (Vector2?)null, (float?)null, false, (SpawnMethod)null, (tk2dBaseSprite)null, false); } if (!val.IsOnFire && !val.IsElectrified && !__instance.goopDefinition.usesLifespan && !val.lifespanOverridden && !val.selfIgnites) { continue; } if (val.selfIgnites) { if (val.remainingTimeTilSelfIgnition <= 0f) { val.selfIgnites = false; __instance.IgniteCell(goopPosition); } else { val.remainingTimeTilSelfIgnition -= num; } } if (val.remainingLifespan > 0f) { if (!val.IsFrozen) { val.remainingLifespan -= num; } else { val.remainingFreezeTimer -= num; if (val.remainingFreezeTimer <= 0f) { val.hasBeenFrozen = 1; val.remainingLifespan = Mathf.Min(val.remainingLifespan, __instance.goopDefinition.fadePeriod); val.remainingLifespan -= num; } } if (__instance.goopDefinition.usesAcidAudio) { flag2 = true; } if (val.remainingLifespan < __instance.goopDefinition.fadePeriod && val.IsElectrified) { val.remainingLifespan = __instance.goopDefinition.fadePeriod; } if (val.remainingLifespan < __instance.goopDefinition.fadePeriod || val.remainingLifespan <= 0f) { __instance.SetDirty(goopPosition); val.IsOnFire = false; val.IsElectrified = false; val.HasPlayedFireIntro = false; val.HasPlayedFireOutro = false; if (val.remainingLifespan <= 0f) { __instance.m_removalPositions.Add(goopPosition); continue; } } if (val.IsElectrified) { val.remainingElectrifiedTime -= num; val.remainingElecTimer -= num; if (val.remainingElectrifiedTime <= 0f) { val.IsElectrified = false; val.remainingElectrifiedTime = 0f; } if (val.IsElectrified && (Object)(object)__instance.m_elecSystem != (Object)null && val.remainingElecTimer <= 0f && goopPosition.x % 2 == 0 && goopPosition.y % 2 == 0) { Vector3 val3 = ((IntVector2)(ref goopPosition)).ToVector3((float)goopPosition.y) * 0.25f + dfVectorExtensions.Quantize(new Vector3(Random.Range(0.125f, 0.375f), Random.Range(0.125f, 0.375f), 0.125f), 0.0625f); float num2 = Random.Range(0.75f, 1.5f); if (Random.value < 0.1f) { EmitParams val4 = default(EmitParams); ((EmitParams)(ref val4)).position = val3; ((EmitParams)(ref val4)).velocity = Vector3.zero; ((EmitParams)(ref val4)).startSize = __instance.m_fireSystem.startSize; ((EmitParams)(ref val4)).startLifetime = num2; ((EmitParams)(ref val4)).startColor = Color32.op_Implicit(__instance.m_fireSystem.startColor); ((EmitParams)(ref val4)).randomSeed = (uint)(Random.value * 4.2949673E+09f); EmitParams val5 = val4; __instance.m_elecSystem.Emit(val5, 1); if ((int)GameManager.Options.ShaderQuality != 0 && (int)GameManager.Options.ShaderQuality != 3) { GlobalSparksDoer.DoRandomParticleBurst(((int)GameManager.Options.ShaderQuality != 1) ? 10 : 4, val3 + new Vector3(-0.625f, -0.625f, 0f), val3 + new Vector3(0.625f, 0.625f, 0f), Vector3.up, 120f, 0.5f, (float?)null, (float?)null, (Color?)null, (SparksType)0); } } val.remainingElecTimer = num2 - 0.1f; } } if (val.IsFrozen) { if (val.totalOnFireTime < 0.5f || val.remainingLifespan < __instance.goopDefinition.fadePeriod) { __instance.SetColorDirty(goopPosition); } val.totalOnFireTime += num; if (val.totalOnFireTime >= __instance.goopDefinition.freezeSpreadTime) { for (int k = 0; k < val.neighborGoopData.Length; k++) { if (val.neighborGoopData[k] != null && !val.neighborGoopData[k].IsFrozen && val.neighborGoopData[k].hasBeenFrozen == 0) { if (Random.value < 0.2f) { __instance.FreezeCell(val.neighborGoopData[k].goopPosition); } else { val.totalFrozenTime = 0f; } } } } } if (val.IsOnFire) { flag = true; __instance.SetColorDirty(goopPosition); val.remainingFireTimer -= num; val.totalOnFireTime += num; if (val.totalOnFireTime >= __instance.goopDefinition.igniteSpreadTime) { for (int l = 0; l < val.neighborGoopData.Length; l++) { if (val.neighborGoopData[l] != null && !val.neighborGoopData[l].IsOnFire) { if (Random.value < 0.2f) { __instance.IgniteCell(val.neighborGoopData[l].goopPosition); } else { val.totalOnFireTime = 0f; } } } } } if (!((Object)(object)__instance.m_fireSystem != (Object)null) || !val.IsOnFire || !(val.remainingFireTimer <= 0f) || goopPosition.x % 2 != 0 || goopPosition.y % 2 != 0) { continue; } Vector3 val6 = ((IntVector2)(ref goopPosition)).ToVector3((float)goopPosition.y) * 0.25f + dfVectorExtensions.Quantize(new Vector3(Random.Range(0.125f, 0.375f), Random.Range(0.125f, 0.375f), 0.125f), 0.0625f); float num3 = Random.Range(1f, 1.5f); float num4 = Random.Range(0.75f, 1f); if (!val.HasPlayedFireOutro) { if (!val.HasPlayedFireOutro && val.remainingLifespan <= num4 + __instance.goopDefinition.fadePeriod && (Object)(object)__instance.m_fireOutroSystem != (Object)null) { num3 = num4; EmitParams val7 = default(EmitParams); ((EmitParams)(ref val7)).position = val6; ((EmitParams)(ref val7)).velocity = Vector3.zero; ((EmitParams)(ref val7)).startSize = __instance.m_fireSystem.startSize; ((EmitParams)(ref val7)).startLifetime = num4; ((EmitParams)(ref val7)).startColor = Color32.op_Implicit(__instance.m_fireSystem.startColor); ((EmitParams)(ref val7)).randomSeed = (uint)(Random.value * 4.2949673E+09f); EmitParams val8 = val7; __instance.m_fireOutroSystem.Emit(val8, 1); val.HasPlayedFireOutro = true; } else if (!val.HasPlayedFireIntro && (Object)(object)__instance.m_fireIntroSystem != (Object)null) { num3 = Random.Range(0.75f, 1f); EmitParams val9 = default(EmitParams); ((EmitParams)(ref val9)).position = val6; ((EmitParams)(ref val9)).velocity = Vector3.zero; ((EmitParams)(ref val9)).startSize = __instance.m_fireSystem.startSize; ((EmitParams)(ref val9)).startLifetime = num3; ((EmitParams)(ref val9)).startColor = Color32.op_Implicit(__instance.m_fireSystem.startColor); ((EmitParams)(ref val9)).randomSeed = (uint)(Random.value * 4.2949673E+09f); EmitParams val10 = val9; __instance.m_fireIntroSystem.Emit(val10, 1); val.HasPlayedFireIntro = true; } else { if (Random.value < 0.5f) { EmitParams val11 = default(EmitParams); ((EmitParams)(ref val11)).position = val6; ((EmitParams)(ref val11)).velocity = Vector3.zero; ((EmitParams)(ref val11)).startSize = __instance.m_fireSystem.startSize; ((EmitParams)(ref val11)).startLifetime = num3; ((EmitParams)(ref val11)).startColor = Color32.op_Implicit(__instance.m_fireSystem.startColor); ((EmitParams)(ref val11)).randomSeed = (uint)(Random.value * 4.2949673E+09f); EmitParams val12 = val11; __instance.m_fireSystem.Emit(val12, 1); } GlobalSparksDoer.DoRandomParticleBurst(Random.Range(3, 6), val6, val6, Vector3.up * 2f, 30f, 1f, (float?)null, (float?)Random.Range(0.5f, 1f), (Color?)((!__instance.goopDefinition.UsesGreenFire) ? Color.red : Color.green), (SparksType)0); } } val.remainingFireTimer = num3 - 0.125f; } else { __instance.m_removalPositions.Add(goopPosition); } } if (flag && !__instance.m_isPlayingFireAudio) { __instance.m_isPlayingFireAudio = true; AkSoundEngine.PostEvent("Play_ENV_oilfire_ignite_01", ((Component)GameManager.Instance.PrimaryPlayer).gameObject); } else if (!flag && __instance.m_isPlayingFireAudio) { __instance.m_isPlayingFireAudio = false; AkSoundEngine.PostEvent("Stop_ENV_oilfire_loop_01", ((Component)GameManager.Instance.PrimaryPlayer).gameObject); } if (flag2 && !__instance.m_isPlayingAcidAudio) { __instance.m_isPlayingAcidAudio = true; AkSoundEngine.PostEvent("Play_ENV_acidsizzle_loop_01", ((Component)GameManager.Instance.PrimaryPlayer).gameObject); } else if (!flag2 && __instance.m_isPlayingAcidAudio) { __instance.m_isPlayingAcidAudio = false; AkSoundEngine.PostEvent("Stop_ENV_acidsizzle_loop_01", ((Component)GameManager.Instance.PrimaryPlayer).gameObject); } __instance.RemoveGoopedPosition(__instance.m_removalPositions); for (int m = 0; m < __instance.m_dirtyFlags.GetLength(0); m++) { for (int n = 0; n < __instance.m_dirtyFlags.GetLength(1); n++) { if (__instance.m_dirtyFlags[m, n]) { if ((n * __instance.m_dirtyFlags.GetLength(0) + m) % 3 == Time.frameCount % 3) { bool flag3 = __instance.HasGoopedPositionCountForChunk(m, n); if (flag3) { __instance.RebuildMeshUvsAndColors(m, n); } __instance.m_dirtyFlags[m, n] = false; __instance.m_colorDirtyFlags[m, n] = false; if ((Object)(object)__instance.m_meshes[m, n] != (Object)null && !flag3) { Object.Destroy((Object)(object)((Component)__instance.m_mrs[m, n]).gameObject); Object.Destroy((Object)(object)__instance.m_meshes[m, n]); __instance.m_mrs[m, n] = null; __instance.m_meshes[m, n] = null; } } } else if (__instance.m_colorDirtyFlags[m, n] && (n * __instance.m_dirtyFlags.GetLength(0) + m) % 3 == Time.frameCount % 3) { bool flag4 = __instance.HasGoopedPositionCountForChunk(m, n); if (flag4) { __instance.RebuildMeshColors(m, n); } __instance.m_colorDirtyFlags[m, n] = false; if ((Object)(object)__instance.m_meshes[m, n] != (Object)null && !flag4) { Object.Destroy((Object)(object)((Component)__instance.m_mrs[m, n]).gameObject); Object.Destroy((Object)(object)__instance.m_meshes[m, n]); __instance.m_mrs[m, n] = null; __instance.m_meshes[m, n] = null; } } } } return false; } [HarmonyPatch(typeof(DeadlyDeadlyGoopManager), "RebuildMeshColors")] [HarmonyPrefix] private static bool DeadlyDeadlyGoopManagerRebuildMeshColorsPatch(DeadlyDeadlyGoopManager __instance, int chunkX, int chunkY) { //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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < __instance.m_colorArray.Length; i++) { __instance.m_colorArray[i] = _Transparent; } int num = chunkX * 20; int num2 = num + 20; int num3 = chunkY * 20; int num4 = num3 + 20; VertexColorRebuildResult val = (VertexColorRebuildResult)0; ExtraGoopData extraGoopData = ExtraGoopData.Get(__instance); ulong[,,] goopedCellBitfield = extraGoopData.goopedCellBitfield; int num5 = -1; Vector2 val3 = default(Vector2); for (int j = num; j < num2; j++) { for (int k = num3; k < num4; k++) { num5++; if ((goopedCellBitfield[chunkX, chunkY, num5 >> 6] & (ulong)(1L << num5)) == 0L) { continue; } GoopPositionData val2 = extraGoopData.goopedCellGrid[j, k]; if (val2 != null && !(val2.remainingLifespan < 0f)) { int num6 = val2.baseIndex; if (num6 < 0) { num6 = (val2.baseIndex = __instance.GetGoopBaseIndex(val2.goopPosition, chunkX, chunkY)); } if (__instance.goopDefinition.CanBeFrozen) { ((Vector2)(ref val3))..ctor((float)(val2.IsFrozen ? 1 : 0), 0f); __instance.m_uv2Array[num6] = val3; __instance.m_uv2Array[num6 + 1] = val3; __instance.m_uv2Array[num6 + 2] = val3; __instance.m_uv2Array[num6 + 3] = val3; } VertexColorRebuildResult val4 = __instance.AssignVertexColors(val2, val2.goopPosition, chunkX, chunkY); if (val4 > val) { val = val4; } } } } Mesh chunkMesh = __instance.GetChunkMesh(chunkX, chunkY); if (__instance.goopDefinition.CanBeFrozen) { chunkMesh.uv2 = __instance.m_uv2Array; } chunkMesh.colors32 = __instance.m_colorArray; return false; } [HarmonyPatch(typeof(DeadlyDeadlyGoopManager), "RemoveGoopedPosition", new Type[] { typeof(IntVector2) })] [HarmonyPrefix] private static bool DeadlyDeadlyGoopManagerRemoveGoopedPositionPatch(DeadlyDeadlyGoopManager __instance, IntVector2 entry) { //IL_0006: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) if (__instance.m_goopedCells.TryGetValue(entry, out var value)) { for (int i = 0; i < 8; i++) { GoopPositionData val = value.neighborGoopData[i]; if (val != null) { int num = (i + 4) % 8; val.neighborGoopData[num] = null; val.NeighborsAsIntFuckDiagonals = (val.NeighborsAsInt &= ~(1 << 7 - num)) & 0xAA; } } } else { for (int j = 0; j < 8; j++) { if (__instance.m_goopedCells.TryGetValue(entry + IntVector2.CardinalsAndOrdinals[j], out var value2)) { int num2 = (j + 4) % 8; value2.neighborGoopData[num2] = null; GoopPositionData obj = value2; GoopPositionData obj2 = value2; obj.NeighborsAsIntFuckDiagonals = (obj2.NeighborsAsInt &= ~(1 << 7 - num2)) & 0xAA; } } value = null; } __instance.m_goopedPositions.Remove(entry); __instance.m_goopedCells.Remove(entry); DeadlyDeadlyGoopManager.allGoopPositionMap.Remove(entry); __instance.SetDirty(entry); if (value != null) { ExtraGoopData.Get(__instance).RemoveGoop(value); } return false; } [HarmonyPatch(typeof(DeadlyDeadlyGoopManager), "HasGoopedPositionCountForChunk")] [HarmonyPrefix] private static bool FastHasGoopedPositionCountForChunk(DeadlyDeadlyGoopManager __instance, int chunkX, int chunkY, ref bool __result) { ExtraGoopData extraGoopData = ExtraGoopData.Get(__instance); for (int i = 0; i < 7; i++) { if (extraGoopData.goopedCellBitfield[chunkX, chunkY, i] != 0) { __result = true; return false; } } __result = false; return false; } [HarmonyPatch(typeof(DeadlyDeadlyGoopManager), "SetDirty")] [HarmonyPrefix] private static bool DeadlyDeadlyGoopManagerSetDirtyPatch(DeadlyDeadlyGoopManager __instance, IntVector2 goopPosition) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) int num = (int)((float)goopPosition.x * 0.05f); int num2 = (int)((float)goopPosition.y * 0.05f); bool[,] dirtyFlags = __instance.m_dirtyFlags; int length = dirtyFlags.GetLength(0); int length2 = dirtyFlags.GetLength(1); if (num < 0 || num >= length || num2 < 0 || num2 >= length2) { return false; } bool num3 = num > 0 && goopPosition.x % 20 == 0; bool flag = num < length - 1 && goopPosition.x % 20 == 19; bool flag2 = num2 > 0 && goopPosition.y % 20 == 0; bool flag3 = num2 < length2 - 1 && goopPosition.y % 20 == 19; dirtyFlags[num, num2] = true; if (num3) { dirtyFlags[num - 1, num2] = true; } if (flag) { dirtyFlags[num + 1, num2] = true; } if (flag2) { dirtyFlags[num, num2 - 1] = true; } if (flag3) { dirtyFlags[num, num2 + 1] = true; } if (num3 && flag2) { dirtyFlags[num - 1, num2 - 1] = true; } if (num3 && flag3) { dirtyFlags[num - 1, num2 + 1] = true; } if (flag && flag2) { dirtyFlags[num + 1, num2 - 1] = true; } if (flag && flag3) { dirtyFlags[num + 1, num2 + 1] = true; } return false; } [HarmonyPatch(typeof(DeadlyDeadlyGoopManager), "AssignVertexColors")] [HarmonyPrefix] private static bool DeadlyDeadlyGoopManagerAssignVertexColorsPatch(DeadlyDeadlyGoopManager __instance, GoopPositionData goopData, IntVector2 goopPos, int chunkX, int chunkY, ref VertexColorRebuildResult __result) { //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_000f: 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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_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_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_04ee: Unknown result type (might be due to invalid IL or missing references) //IL_04ef: Unknown result type (might be due to invalid IL or missing references) //IL_04fe: Unknown result type (might be due to invalid IL or missing references) //IL_04ff: Unknown result type (might be due to invalid IL or missing references) //IL_050e: Unknown result type (might be due to invalid IL or missing references) //IL_050f: Unknown result type (might be due to invalid IL or missing references) //IL_051e: Unknown result type (might be due to invalid IL or missing references) //IL_051f: Unknown result type (might be due to invalid IL or missing references) //IL_04ad: Unknown result type (might be due to invalid IL or missing references) //IL_04ae: Unknown result type (might be due to invalid IL or missing references) //IL_04bd: Unknown result type (might be due to invalid IL or missing references) //IL_04be: Unknown result type (might be due to invalid IL or missing references) //IL_04cd: Unknown result type (might be due to invalid IL or missing references) //IL_04ce: Unknown result type (might be due to invalid IL or missing references) //IL_04dd: Unknown result type (might be due to invalid IL or missing references) //IL_04df: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03ea: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_040e: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Unknown result type (might be due to invalid IL or missing references) //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_0446: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_0463: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_0472: Unknown result type (might be due to invalid IL or missing references) //IL_0480: Unknown result type (might be due to invalid IL or missing references) //IL_0488: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: 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) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) bool flag = false; Color32 val = __instance.goopDefinition.baseColor32; Color32 val2 = val; Color32 val3 = val; Color32 val4 = val; int baseIndex = goopData.baseIndex; if (goopData.IsOnFire) { val = __instance.goopDefinition.fireColor32; } else { Color32 igniteColor = __instance.goopDefinition.igniteColor32; for (int i = 0; i < 8; i++) { if (goopData.neighborGoopData[i] != null && goopData.neighborGoopData[i].IsOnFire) { flag = true; switch (i) { case 0: val3 = igniteColor; val4 = igniteColor; break; case 1: val4 = igniteColor; break; case 2: val4 = igniteColor; val2 = igniteColor; break; case 3: val2 = igniteColor; break; case 4: val2 = igniteColor; val = igniteColor; break; case 5: val = igniteColor; break; case 6: val = igniteColor; val3 = igniteColor; break; case 7: val3 = igniteColor; break; } } } } if (!goopData.IsOnFire && !flag) { if (goopData.IsFrozen) { val = __instance.goopDefinition.frozenColor32; } else { Vector2 val5 = default(Vector2); ((Vector2)(ref val5))..ctor(0.5f, 0f); Color32 prefreezeColor = __instance.goopDefinition.prefreezeColor32; for (int j = 0; j < 8; j++) { if (goopData.neighborGoopData[j] != null && goopData.neighborGoopData[j].IsFrozen) { flag = true; switch (j) { case 0: __instance.m_uv2Array[baseIndex + 2] = val5; val3 = prefreezeColor; __instance.m_uv2Array[baseIndex + 3] = val5; val4 = prefreezeColor; break; case 1: __instance.m_uv2Array[baseIndex + 3] = val5; val4 = prefreezeColor; break; case 2: __instance.m_uv2Array[baseIndex + 3] = val5; val4 = prefreezeColor; __instance.m_uv2Array[baseIndex + 1] = val5; val2 = prefreezeColor; break; case 3: __instance.m_uv2Array[baseIndex + 1] = val5; val2 = prefreezeColor; break; case 4: __instance.m_uv2Array[baseIndex + 1] = val5; val2 = prefreezeColor; __instance.m_uv2Array[baseIndex] = val5; val = prefreezeColor; break; case 5: __instance.m_uv2Array[baseIndex] = val5; val = prefreezeColor; break; case 6: __instance.m_uv2Array[baseIndex] = val5; val = prefreezeColor; __instance.m_uv2Array[baseIndex + 2] = val5; val3 = prefreezeColor; break; case 7: __instance.m_uv2Array[baseIndex + 2] = val5; val3 = prefreezeColor; break; } } } } } if (goopData.remainingLifespan < __instance.goopDefinition.fadePeriod) { float num = goopData.remainingLifespan / __instance.goopDefinition.fadePeriod; Color32 fadeColor = __instance.goopDefinition.fadeColor32; ((Color32)(ref val))..ctor((byte)((float)(int)fadeColor.r + (float)(val.r - fadeColor.r) * num), (byte)((float)(int)fadeColor.g + (float)(val.g - fadeColor.g) * num), (byte)((float)(int)fadeColor.b + (float)(val.b - fadeColor.b) * num), (byte)((float)(int)fadeColor.a + (float)(val.a - fadeColor.a) * num)); if (flag) { ((Color32)(ref val2))..ctor((byte)((float)(int)fadeColor.r + (float)(val2.r - fadeColor.r) * num), (byte)((float)(int)fadeColor.g + (float)(val2.g - fadeColor.g) * num), (byte)((float)(int)fadeColor.b + (float)(val2.b - fadeColor.b) * num), (byte)((float)(int)fadeColor.a + (float)(val2.a - fadeColor.a) * num)); ((Color32)(ref val3))..ctor((byte)((float)(int)fadeColor.r + (float)(val3.r - fadeColor.r) * num), (byte)((float)(int)fadeColor.g + (float)(val3.g - fadeColor.g) * num), (byte)((float)(int)fadeColor.b + (float)(val3.b - fadeColor.b) * num), (byte)((float)(int)fadeColor.a + (float)(val3.a - fadeColor.a) * num)); ((Color32)(ref val4))..ctor((byte)((float)(int)fadeColor.r + (float)(val4.r - fadeColor.r) * num), (byte)((float)(int)fadeColor.g + (float)(val4.g - fadeColor.g) * num), (byte)((float)(int)fadeColor.b + (float)(val4.b - fadeColor.b) * num), (byte)((float)(int)fadeColor.a + (float)(val4.a - fadeColor.a) * num)); } } if (flag) { __instance.m_colorArray[baseIndex] = val; __instance.m_colorArray[baseIndex + 1] = val2; __instance.m_colorArray[baseIndex + 2] = val3; __instance.m_colorArray[baseIndex + 3] = val4; } else { __instance.m_colorArray[baseIndex] = val; __instance.m_colorArray[baseIndex + 1] = val; __instance.m_colorArray[baseIndex + 2] = val; __instance.m_colorArray[baseIndex + 3] = val; } __result = (VertexColorRebuildResult)0; return false; } [HarmonyPatch(typeof(DeadlyDeadlyGoopManager), "HandleRecursiveElectrification")] [HarmonyPostfix] private static IEnumerator HandleRecursiveElectrificationPatch(IEnumerator orig, DeadlyDeadlyGoopManager __instance, IntVector2 cellIndex) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return HandleRecursiveElectrificationFast(__instance, cellIndex); } private static IEnumerator HandleRecursiveElectrificationFast(DeadlyDeadlyGoopManager __instance, IntVector2 cellIndex) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) GoopPositionData val = __instance.m_goopedCells[cellIndex]; if (!__instance.goopDefinition.CanBeElectrified || val.IsFrozen || val.remainingLifespan < __instance.goopDefinition.fadePeriod) { yield break; } uint currentSemaphore = (val.elecTriggerSemaphore = ++__instance.m_lastElecSemaphore); int num = 0; _GoopsToElectrify.Enqueue(val); while (_GoopsToElectrify.Count > 0) { GoopPositionData val2 = _GoopsToElectrify.Dequeue(); if (val2 == null) { continue; } if (!val2.IsFrozen && val2.remainingLifespan >= __instance.goopDefinition.fadePeriod) { if (!val2.IsElectrified) { val2.IsElectrified = true; val2.remainingElecTimer = 0f; } val2.remainingElectrifiedTime = __instance.goopDefinition.electrifiedTime; } for (int i = 0; i < 8; i++) { GoopPositionData val3 = val2.neighborGoopData[i]; if (val3 != null && val3.elecTriggerSemaphore < currentSemaphore && (!val3.IsElectrified || val3.remainingElectrifiedTime < __instance.goopDefinition.electrifiedTime - 0.01f)) { val3.elecTriggerSemaphore = currentSemaphore; _GoopsToElectrify.Enqueue(val3); } } if ((float)(++num) > 200f) { yield return null; num = 0; } } } [HarmonyPatch(typeof(DeadlyDeadlyGoopManager), "AddGoopedPosition")] [HarmonyPrefix] private static bool DeadlyDeadlyGoopManagerAddGoopedPositionPatch(DeadlyDeadlyGoopManager __instance, IntVector2 pos, float radiusFraction = 0f, bool suppressSplashes = false, int sourceId = -1, int sourceFrameCount = -1) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_006f: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_04dd: Unknown result type (might be due to invalid IL or missing references) //IL_04de: Unknown result type (might be due to invalid IL or missing references) //IL_04e4: Unknown result type (might be due to invalid IL or missing references) //IL_04e9: Unknown result type (might be due to invalid IL or missing references) //IL_0514: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Invalid comparison between Unknown and I4 //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Expected O, but got Unknown //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Invalid comparison between Unknown and I4 //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) if (GameManager.Instance.IsLoadingLevel) { return false; } Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor((float)pos.x * 0.25f, (float)pos.y * 0.25f); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(val.x + 0.125f, val.y + 0.125f); for (int i = 0; i < DeadlyDeadlyGoopManager.m_goopExceptions.Count; i++) { if (DeadlyDeadlyGoopManager.m_goopExceptions[i] != null) { Vector2 first = DeadlyDeadlyGoopManager.m_goopExceptions[i].First; float num = first.x - val2.x; float num2 = first.y - val2.y; if (num * num + num2 * num2 < DeadlyDeadlyGoopManager.m_goopExceptions[i].Second) { return false; } } } if (!__instance.m_goopedCells.TryGetValue(pos, out var value)) { IntVector2 val3 = default(IntVector2); ((IntVector2)(ref val3))..ctor((int)val.x, (int)val.y); DungeonData data = GameManager.Instance.Dungeon.data; if (val3.x < 0 || val3.y < 0 || val3.x >= data.m_width || val3.y >= data.m_height) { return false; } CellData val4 = data[val3]; if (val4 == null || val4.forceDisallowGoop || (val4.cellVisualData.absorbsDebris && __instance.goopDefinition.CanBeFrozen)) { return false; } if (__instance.goopDefinition.CanBeFrozen && val4.doesDamage) { val4.doesDamage = false; if ((Object)(object)data.m_sizzleSystem == (Object)null) { data.InitializeSizzleSystem(); } Vector3 val5 = ((IntVector2)(ref val3)).ToCenterVector3((float)val3.y); data.SpawnWorldParticle(data.m_sizzleSystem, val5 + Vector2Extensions.ToVector3ZUp(Random.insideUnitCircle, 0f) / 3f); if (Random.value < 0.5f) { data.SpawnWorldParticle(data.m_sizzleSystem, val5 + Vector2Extensions.ToVector3ZUp(Random.insideUnitCircle, 0f) / 3f); } } if ((int)val4.type != 2 && !val4.forceAllowGoop) { if (!val4.IsLowerFaceWall()) { return false; } if (((IntVector2)(ref pos)).GetHashedRandomValue() > 0.75f) { return false; } } bool flag = false; if (DeadlyDeadlyGoopManager.allGoopPositionMap.TryGetValue(pos, out var value2)) { GoopPositionData val6 = value2.m_goopedCells[pos]; int num3 = ((sourceFrameCount == -1) ? Time.frameCount : sourceFrameCount); if (val6.frameGooped > num3 || val6.eternal) { return false; } if (val6.IsOnFire) { flag = true; } value2.RemoveGoopedPosition(pos); } GoopPositionData val7 = new GoopPositionData(pos, __instance.m_goopedCells, __instance.goopDefinition.GetLifespan(radiusFraction)); val7.frameGooped = ((sourceFrameCount == -1) ? Time.frameCount : sourceFrameCount); val7.lastSourceID = sourceId; if (!suppressSplashes && DeadlyDeadlyGoopManager.m_DoGoopSpawnSplashes && Random.value < 0.02f) { if ((Object)(object)__instance.m_genericSplashPrefab == (Object)null) { ref GameObject genericSplashPrefab = ref __instance.m_genericSplashPrefab; Object obj = ResourceCache.Acquire("Global VFX/Generic_Goop_Splash"); genericSplashPrefab = (GameObject)(object)((obj is GameObject) ? obj : null); } GameObject obj2 = SpawnManager.SpawnVFX(__instance.m_genericSplashPrefab, Vector2Extensions.ToVector3ZUp(val, val.y), Quaternion.identity); obj2.GetComponent().usesOverrideMaterial = true; obj2.GetComponent().material.SetColor(DeadlyDeadlyGoopManager.TintColorPropertyID, Color32.op_Implicit(__instance.goopDefinition.baseColor32)); } val7.eternal = __instance.goopDefinition.eternal; val7.selfIgnites = __instance.goopDefinition.SelfIgnites; val7.remainingTimeTilSelfIgnition = __instance.goopDefinition.selfIgniteDelay; __instance.m_goopedPositions.Add(pos); __instance.m_goopedCells.Add(pos, val7); DeadlyDeadlyGoopManager.allGoopPositionMap.Add(pos, __instance); ExtraGoopData.Get(__instance).AddGoop(val7); GameManager.Instance.Dungeon.data.GetAbsoluteRoomFromPosition(val3).RegisterGoopManagerInRoom(__instance); if (val4.OnCellGooped != null) { val4.OnCellGooped(val4); } if ((int)val4.cellVisualData.floorType == 3) { __instance.FreezeCell(pos); } if (flag && __instance.goopDefinition.CanBeIgnited) { __instance.IgniteCell(pos); } __instance.SetDirty(pos); return false; } if (value.remainingLifespan < __instance.goopDefinition.fadePeriod) { __instance.SetDirty(pos); } if (value.IsOnFire && __instance.goopDefinition.ignitionChangesLifetime) { if (value.remainingLifespan > 0f) { value.remainingLifespan = __instance.goopDefinition.ignitedLifetime; } } else { if (!suppressSplashes && DeadlyDeadlyGoopManager.m_DoGoopSpawnSplashes && (value.lastSourceID < 0 || value.lastSourceID != sourceId) && Random.value < 0.001f) { if ((Object)(object)__instance.m_genericSplashPrefab == (Object)null) { ref GameObject genericSplashPrefab2 = ref __instance.m_genericSplashPrefab; Object obj3 = ResourceCache.Acquire("Global VFX/Generic_Goop_Splash"); genericSplashPrefab2 = (GameObject)(object)((obj3 is GameObject) ? obj3 : null); } GameObject obj4 = SpawnManager.SpawnVFX(__instance.m_genericSplashPrefab, Vector2Extensions.ToVector3ZUp(val, val.y), Quaternion.identity); obj4.GetComponent().usesOverrideMaterial = true; obj4.GetComponent().material.SetColor(DeadlyDeadlyGoopManager.TintColorPropertyID, Color32.op_Implicit(__instance.goopDefinition.baseColor32)); } float lifespan = __instance.goopDefinition.GetLifespan(radiusFraction); if (lifespan > value.remainingLifespan) { value.remainingLifespan = lifespan; } value.lifespanOverridden = true; value.HasPlayedFireOutro = false; value.hasBeenFrozen = 0; } value.lastSourceID = sourceId; return false; } [HarmonyPatch(typeof(DeadlyDeadlyGoopManager), "AddGoopPoints")] [HarmonyPrefix] private static bool DeadlyDeadlyGoopManagerAddGoopPointsPatch(DeadlyDeadlyGoopManager __instance, List points, float radius, Vector2 excludeCenter, float excludeRadius) { //IL_000c: 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_0026: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_0282: Unknown result type (might be due to invalid IL or missing references) if (radius == 0f) { return false; } float x = points[0].x; float x2 = points[0].x; float y = points[0].y; float y2 = points[0].y; for (int i = 1; i < points.Count; i++) { if (points[i].x < x) { x = points[i].x; } else if (points[i].x > x2) { x2 = points[i].x; } if (points[i].y < y) { y = points[i].y; } else if (points[i].y > y2) { y2 = points[i].y; } } int num = Mathf.FloorToInt((x - radius) * 4f); int num2 = Mathf.CeilToInt((x2 + radius) * 4f); int num3 = Mathf.FloorToInt((y - radius) * 4f); int num4 = Mathf.CeilToInt((y2 + radius) * 4f); int num5 = num2 - num + 1; int num6 = num4 - num3 + 1; DeadlyDeadlyGoopManager.s_goopPointRadius = radius * 4f; int radius2 = Mathf.RoundToInt(DeadlyDeadlyGoopManager.s_goopPointRadius); DeadlyDeadlyGoopManager.s_goopPointRadiusSquare = DeadlyDeadlyGoopManager.s_goopPointRadius * DeadlyDeadlyGoopManager.s_goopPointRadius; _InvSqrRadius = 1f / DeadlyDeadlyGoopManager.s_goopPointRadiusSquare; DeadlyDeadlyGoopManager.m_pointsArray.ReinitializeWithDefault(num5, num6, false, 1f, false); bool usesLifespan = __instance.goopDefinition.usesLifespan; for (int j = 0; j < points.Count; j++) { DeadlyDeadlyGoopManager.s_goopPointCenter.x = (int)(points[j].x * 4f) - num; DeadlyDeadlyGoopManager.s_goopPointCenter.y = (int)(points[j].y * 4f) - num3; FastSetCircle(DeadlyDeadlyGoopManager.m_pointsArray, DeadlyDeadlyGoopManager.s_goopPointCenter.x, DeadlyDeadlyGoopManager.s_goopPointCenter.y, radius2, value: true, usesLifespan); } int xMid = (int)(excludeCenter.x * 4f) - num; int yMid = (int)(excludeCenter.y * 4f) - num3; int radius3 = Mathf.RoundToInt(excludeRadius * 4f); FastSetCircle(DeadlyDeadlyGoopManager.m_pointsArray, xMid, yMid, radius3, value: false, updateFractions: false); bool[] bits = DeadlyDeadlyGoopManager.m_pointsArray.m_bits; float[] floats = DeadlyDeadlyGoopManager.m_pointsArray.m_floats; for (int k = 0; k < num5; k++) { for (int l = 0; l < num6; l++) { int num7 = k + l * DeadlyDeadlyGoopManager.m_pointsArray.m_width; if (bits[num7]) { __instance.AddGoopedPosition(new IntVector2(num + k, num3 + l), floats[num7], false, -1, -1); } } } return false; } private static void FastSetCircle(BitArray2D bitArray, int xMid, int yMid, int radius, bool value, bool updateFractions) { int num = radius; int num2 = 0; int num3 = 1 - num; float[] floats = bitArray.m_floats; bool[] bits = bitArray.m_bits; int width = bitArray.m_width; int height = bitArray.m_height; while (num2 <= num) { for (int i = 0; i < 2; i++) { int num4 = ((i == 0) ? num : num2); int num5 = ((i == 0) ? num2 : num); int num6 = yMid - num5; if (num6 < 0) { num6 = 0; } int num7 = yMid + num5; if (num7 >= height) { num7 = height - 1; } for (int j = 0; j < 2; j++) { int num8 = xMid + ((j == 0) ? num4 : (-num4)); if (num8 < 0 || num8 >= width) { continue; } float num9 = DeadlyDeadlyGoopManager.s_goopPointCenter.x - num8; float num10 = num9 * num9; for (int k = num6; k <= num7; k++) { int num11 = num8 + k * width; bits[num11] = value; if (!updateFractions) { continue; } float num12 = DeadlyDeadlyGoopManager.s_goopPointCenter.y - k; float num13 = num10 + num12 * num12; if (num13 >= DeadlyDeadlyGoopManager.s_goopPointRadiusSquare) { continue; } if (num13 < 0.25f) { floats[num11] = 0f; continue; } float num14 = num13 * _InvSqrRadius; float num15 = num14 * (2f * num14 - 5f * Mathf.Sqrt(num14) + 4f); if (num15 < floats[num11]) { floats[num11] = num15; } } } } num2++; if (num3 <= 0) { num3 += 2 * num2 + 1; continue; } num--; num3 += 2 * (num2 - num) + 1; } } } [HarmonyPatch] internal static class BuildForChunkOptimizer { private const int _MAX_MATS = 100; private static readonly List vertices = new List(); private static readonly List colors = new List(); private static readonly List uvs = new List(); private static readonly List usedMaterials = new List(); private static readonly List[] perMaterialTriangles = new List[100]; private static readonly Vector3[] defPositions = (Vector3[])(object)new Vector3[4]; private static bool firstBuild = true; private static int _TotalVertices = 0; private static Vector3[] verticesA = (Vector3[])(object)new Vector3[0]; private static Color[] colorsA = (Color[])(object)new Color[0]; private static Vector2[] uvsA = (Vector2[])(object)new Vector2[0]; private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_CHUNKBUILD) { return false; } return true; } [HarmonyPatch(typeof(RenderMeshBuilder), "BuildForChunk")] [HarmonyPrefix] private static bool RenderMeshBuilderBuildForChunkPatch(tk2dTileMap tileMap, SpriteChunk chunk, bool useColor, bool skipPrefabs, int baseX, int baseY, LayerInfo layerData) { //IL_008d: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0c97: Unknown result type (might be due to invalid IL or missing references) //IL_0caa: Unknown result type (might be due to invalid IL or missing references) //IL_0cb5: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_043f: Unknown result type (might be due to invalid IL or missing references) //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_0630: Unknown result type (might be due to invalid IL or missing references) //IL_0484: Unknown result type (might be due to invalid IL or missing references) //IL_048e: Unknown result type (might be due to invalid IL or missing references) //IL_049a: Unknown result type (might be due to invalid IL or missing references) //IL_049f: Unknown result type (might be due to invalid IL or missing references) //IL_063a: Unknown result type (might be due to invalid IL or missing references) //IL_063c: Unknown result type (might be due to invalid IL or missing references) //IL_050a: Unknown result type (might be due to invalid IL or missing references) //IL_0514: Unknown result type (might be due to invalid IL or missing references) //IL_051c: Unknown result type (might be due to invalid IL or missing references) //IL_0521: Unknown result type (might be due to invalid IL or missing references) //IL_052d: Unknown result type (might be due to invalid IL or missing references) //IL_0537: Unknown result type (might be due to invalid IL or missing references) //IL_0541: Unknown result type (might be due to invalid IL or missing references) //IL_0546: Unknown result type (might be due to invalid IL or missing references) //IL_054b: Unknown result type (might be due to invalid IL or missing references) //IL_0554: Unknown result type (might be due to invalid IL or missing references) //IL_0560: Unknown result type (might be due to invalid IL or missing references) //IL_0568: Unknown result type (might be due to invalid IL or missing references) //IL_056d: Unknown result type (might be due to invalid IL or missing references) //IL_0572: Unknown result type (might be due to invalid IL or missing references) //IL_057b: Unknown result type (might be due to invalid IL or missing references) //IL_0587: Unknown result type (might be due to invalid IL or missing references) //IL_0591: Unknown result type (might be due to invalid IL or missing references) //IL_0596: Unknown result type (might be due to invalid IL or missing references) //IL_059b: Unknown result type (might be due to invalid IL or missing references) //IL_059d: Unknown result type (might be due to invalid IL or missing references) //IL_05a1: Unknown result type (might be due to invalid IL or missing references) //IL_05a6: Unknown result type (might be due to invalid IL or missing references) //IL_05b1: Unknown result type (might be due to invalid IL or missing references) //IL_05bb: Unknown result type (might be due to invalid IL or missing references) //IL_05c0: Unknown result type (might be due to invalid IL or missing references) //IL_05c5: Unknown result type (might be due to invalid IL or missing references) //IL_0600: Unknown result type (might be due to invalid IL or missing references) //IL_0604: Unknown result type (might be due to invalid IL or missing references) //IL_0609: Unknown result type (might be due to invalid IL or missing references) //IL_060b: Unknown result type (might be due to invalid IL or missing references) //IL_060f: Unknown result type (might be due to invalid IL or missing references) //IL_0616: Unknown result type (might be due to invalid IL or missing references) //IL_061b: Unknown result type (might be due to invalid IL or missing references) //IL_0622: Unknown result type (might be due to invalid IL or missing references) //IL_04a9: Unknown result type (might be due to invalid IL or missing references) //IL_04b0: Unknown result type (might be due to invalid IL or missing references) //IL_0a91: Unknown result type (might be due to invalid IL or missing references) //IL_0a93: Unknown result type (might be due to invalid IL or missing references) //IL_0a95: Unknown result type (might be due to invalid IL or missing references) //IL_0a9a: Unknown result type (might be due to invalid IL or missing references) //IL_04e9: Unknown result type (might be due to invalid IL or missing references) //IL_04eb: Unknown result type (might be due to invalid IL or missing references) //IL_04f0: Unknown result type (might be due to invalid IL or missing references) //IL_04f7: Unknown result type (might be due to invalid IL or missing references) //IL_04b9: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: Unknown result type (might be due to invalid IL or missing references) //IL_0aa1: Unknown result type (might be due to invalid IL or missing references) //IL_0ab6: Unknown result type (might be due to invalid IL or missing references) //IL_0656: Unknown result type (might be due to invalid IL or missing references) //IL_065d: Unknown result type (might be due to invalid IL or missing references) //IL_04c9: Unknown result type (might be due to invalid IL or missing references) //IL_04d0: Unknown result type (might be due to invalid IL or missing references) //IL_0754: Unknown result type (might be due to invalid IL or missing references) //IL_075b: Unknown result type (might be due to invalid IL or missing references) //IL_0674: Unknown result type (might be due to invalid IL or missing references) //IL_067b: Unknown result type (might be due to invalid IL or missing references) //IL_04d9: Unknown result type (might be due to invalid IL or missing references) //IL_04e0: Unknown result type (might be due to invalid IL or missing references) //IL_06ae: Unknown result type (might be due to invalid IL or missing references) //IL_0698: Unknown result type (might be due to invalid IL or missing references) //IL_0a61: Unknown result type (might be due to invalid IL or missing references) //IL_0a6d: Unknown result type (might be due to invalid IL or missing references) //IL_0a74: Unknown result type (might be due to invalid IL or missing references) //IL_0a7c: Unknown result type (might be due to invalid IL or missing references) //IL_0a81: Unknown result type (might be due to invalid IL or missing references) //IL_0a83: Unknown result type (might be due to invalid IL or missing references) //IL_0a88: Unknown result type (might be due to invalid IL or missing references) //IL_0a8d: Unknown result type (might be due to invalid IL or missing references) //IL_08dc: Unknown result type (might be due to invalid IL or missing references) //IL_08e3: Unknown result type (might be due to invalid IL or missing references) //IL_0870: Unknown result type (might be due to invalid IL or missing references) //IL_087c: Unknown result type (might be due to invalid IL or missing references) //IL_0883: Unknown result type (might be due to invalid IL or missing references) //IL_088b: Unknown result type (might be due to invalid IL or missing references) //IL_0890: Unknown result type (might be due to invalid IL or missing references) //IL_0892: Unknown result type (might be due to invalid IL or missing references) //IL_0897: Unknown result type (might be due to invalid IL or missing references) //IL_0899: Unknown result type (might be due to invalid IL or missing references) //IL_089e: Unknown result type (might be due to invalid IL or missing references) //IL_08a3: Unknown result type (might be due to invalid IL or missing references) //IL_07ec: Unknown result type (might be due to invalid IL or missing references) //IL_0792: Unknown result type (might be due to invalid IL or missing references) //IL_079e: Unknown result type (might be due to invalid IL or missing references) //IL_07a5: Unknown result type (might be due to invalid IL or missing references) //IL_07ad: Unknown result type (might be due to invalid IL or missing references) //IL_07b2: Unknown result type (might be due to invalid IL or missing references) //IL_07b4: Unknown result type (might be due to invalid IL or missing references) //IL_07b9: Unknown result type (might be due to invalid IL or missing references) //IL_07bb: Unknown result type (might be due to invalid IL or missing references) //IL_07c0: Unknown result type (might be due to invalid IL or missing references) //IL_07c5: Unknown result type (might be due to invalid IL or missing references) //IL_06b3: Unknown result type (might be due to invalid IL or missing references) //IL_06bb: Unknown result type (might be due to invalid IL or missing references) //IL_06c6: Unknown result type (might be due to invalid IL or missing references) //IL_06cc: Invalid comparison between Unknown and I4 //IL_0a2b: Unknown result type (might be due to invalid IL or missing references) //IL_0a37: Unknown result type (might be due to invalid IL or missing references) //IL_0a3e: Unknown result type (might be due to invalid IL or missing references) //IL_0a4c: Unknown result type (might be due to invalid IL or missing references) //IL_0a51: Unknown result type (might be due to invalid IL or missing references) //IL_0a53: Unknown result type (might be due to invalid IL or missing references) //IL_0a58: Unknown result type (might be due to invalid IL or missing references) //IL_0a5d: Unknown result type (might be due to invalid IL or missing references) //IL_0901: Unknown result type (might be due to invalid IL or missing references) //IL_0909: Unknown result type (might be due to invalid IL or missing references) //IL_0913: Unknown result type (might be due to invalid IL or missing references) //IL_0919: Invalid comparison between Unknown and I4 //IL_07fb: Unknown result type (might be due to invalid IL or missing references) //IL_0802: Unknown result type (might be due to invalid IL or missing references) //IL_0808: Invalid comparison between Unknown and I4 //IL_06f0: Unknown result type (might be due to invalid IL or missing references) //IL_06f6: Invalid comparison between Unknown and I4 //IL_06dc: Unknown result type (might be due to invalid IL or missing references) //IL_094e: Unknown result type (might be due to invalid IL or missing references) //IL_0956: Unknown result type (might be due to invalid IL or missing references) //IL_0960: Unknown result type (might be due to invalid IL or missing references) //IL_0966: Invalid comparison between Unknown and I4 //IL_0926: Unknown result type (might be due to invalid IL or missing references) //IL_092e: Unknown result type (might be due to invalid IL or missing references) //IL_0938: Unknown result type (might be due to invalid IL or missing references) //IL_093e: Invalid comparison between Unknown and I4 //IL_0820: Unknown result type (might be due to invalid IL or missing references) //IL_082c: Unknown result type (might be due to invalid IL or missing references) //IL_0833: Unknown result type (might be due to invalid IL or missing references) //IL_083b: Unknown result type (might be due to invalid IL or missing references) //IL_0840: Unknown result type (might be due to invalid IL or missing references) //IL_0842: Unknown result type (might be due to invalid IL or missing references) //IL_0847: Unknown result type (might be due to invalid IL or missing references) //IL_0849: Unknown result type (might be due to invalid IL or missing references) //IL_084e: Unknown result type (might be due to invalid IL or missing references) //IL_0853: Unknown result type (might be due to invalid IL or missing references) //IL_0710: Unknown result type (might be due to invalid IL or missing references) //IL_071c: Unknown result type (might be due to invalid IL or missing references) //IL_0723: Unknown result type (might be due to invalid IL or missing references) //IL_072b: Unknown result type (might be due to invalid IL or missing references) //IL_0730: Unknown result type (might be due to invalid IL or missing references) //IL_0732: Unknown result type (might be due to invalid IL or missing references) //IL_0737: Unknown result type (might be due to invalid IL or missing references) //IL_0739: Unknown result type (might be due to invalid IL or missing references) //IL_073e: Unknown result type (might be due to invalid IL or missing references) //IL_0743: Unknown result type (might be due to invalid IL or missing references) //IL_0701: Unknown result type (might be due to invalid IL or missing references) //IL_0985: Unknown result type (might be due to invalid IL or missing references) //IL_098d: Unknown result type (might be due to invalid IL or missing references) //IL_09f5: Unknown result type (might be due to invalid IL or missing references) //IL_0a01: Unknown result type (might be due to invalid IL or missing references) //IL_0a08: Unknown result type (might be due to invalid IL or missing references) //IL_0a16: Unknown result type (might be due to invalid IL or missing references) //IL_0a1b: Unknown result type (might be due to invalid IL or missing references) //IL_0a1d: Unknown result type (might be due to invalid IL or missing references) //IL_0a22: Unknown result type (might be due to invalid IL or missing references) //IL_0a27: Unknown result type (might be due to invalid IL or missing references) //IL_09bb: Unknown result type (might be due to invalid IL or missing references) //IL_09c7: Unknown result type (might be due to invalid IL or missing references) //IL_09ce: Unknown result type (might be due to invalid IL or missing references) //IL_09d6: Unknown result type (might be due to invalid IL or missing references) //IL_09db: Unknown result type (might be due to invalid IL or missing references) //IL_09dd: Unknown result type (might be due to invalid IL or missing references) //IL_09e2: Unknown result type (might be due to invalid IL or missing references) //IL_09e4: Unknown result type (might be due to invalid IL or missing references) //IL_09e9: Unknown result type (might be due to invalid IL or missing references) //IL_09ee: Unknown result type (might be due to invalid IL or missing references) if (firstBuild) { for (int i = 0; i < 100; i++) { perMaterialTriangles[i] = new List(); } firstBuild = false; } Dungeon dungeon = GameManager.Instance.Dungeon; vertices.Clear(); colors.Clear(); uvs.Clear(); if (layerData.preprocessedFlags == null || layerData.preprocessedFlags.Length == 0) { layerData.preprocessedFlags = new bool[tileMap.width * tileMap.height]; } int[] spriteIds = chunk.spriteIds; Vector3 tileSize = tileMap.data.tileSize; int num = tileMap.SpriteCollectionInst.spriteDefinitions.Length; Object[] tilePrefabs = (Object[])(object)tileMap.data.tilePrefabs; Object[] array = tilePrefabs; tk2dSpriteDefinition firstValidDefinition = tileMap.SpriteCollectionInst.FirstValidDefinition; bool flag = firstValidDefinition != null && firstValidDefinition.normals != null && firstValidDefinition.normals.Length != 0; Color32 val = Color32.op_Implicit((!useColor || tileMap.ColorChannel == null) ? Color.white : tileMap.ColorChannel.clearColor); int num2 = default(int); int num3 = default(int); int num4 = default(int); int num5 = default(int); int num6 = default(int); int num7 = default(int); BuilderUtil.GetLoopOrder(tileMap.data.sortMethod, chunk.Width, chunk.Height, ref num2, ref num3, ref num4, ref num5, ref num6, ref num7); float num8 = default(float); float num9 = default(float); tileMap.data.GetTileOffset(ref num8, ref num9); int num10 = tileMap.SpriteCollectionInst.materials.Length; for (int j = 0; j < num10; j++) { perMaterialTriangles[j].Clear(); } IntVector2 val2 = default(IntVector2); ((IntVector2)(ref val2))..ctor(layerData.overrideChunkXOffset, layerData.overrideChunkYOffset); int num11 = tileMap.partitionSizeX + 1; Vector3 val3 = default(Vector3); IntVector2 val8 = default(IntVector2); Vector3 val19 = default(Vector3); Vector3 val20 = default(Vector3); Vector3 val21 = default(Vector3); Vector3 val22 = default(Vector3); for (int k = num5; k != num6; k += num7) { float num12 = (float)((baseY + k) & 1) * num8; for (int l = num2; l != num3; l += num4) { ((Vector3)(ref val3))..ctor(tileSize.x * ((float)l + num12), tileSize.y * (float)k, 0f); IntVector2 val4 = IntVector2.Zero; if (tileMap.isGungeonTilemap) { val4 = Vector3Extensions.IntXY(val3, (VectorConversions)2) + new IntVector2(baseX, baseY); if ((chunk.roomReference != null && !chunk.roomReference.ContainsPosition(val4 - val2)) || val4.y * tileMap.width + val4.x >= layerData.preprocessedFlags.Length || layerData.preprocessedFlags[val4.y * tileMap.width + val4.x]) { continue; } layerData.preprocessedFlags[val4.y * tileMap.width + val4.x] = true; } int num13 = spriteIds[k * chunk.Width + l]; int tileFromRawTile = BuilderUtil.GetTileFromRawTile(num13); if (tileFromRawTile < 0 || tileFromRawTile >= num || (skipPrefabs && Object.op_Implicit(array[tileFromRawTile]))) { continue; } tk2dSpriteDefinition val5 = tileMap.SpriteCollectionInst.spriteDefinitions[tileFromRawTile]; if (!layerData.ForceNonAnimating && val5.metadata.usesAnimSequence) { continue; } bool flag2 = BuilderUtil.IsRawTileFlagSet(num13, (tk2dTileFlags)16777216); bool flag3 = BuilderUtil.IsRawTileFlagSet(num13, (tk2dTileFlags)33554432); bool flag4 = BuilderUtil.IsRawTileFlagSet(num13, (tk2dTileFlags)67108864); ColorChunk val6 = ((!tileMap.isGungeonTilemap) ? tileMap.ColorChannel.GetChunk(Mathf.FloorToInt((float)baseX / (float)tileMap.partitionSizeX), Mathf.FloorToInt((float)baseY / (float)tileMap.partitionSizeY)) : tileMap.ColorChannel.GetChunk(Mathf.FloorToInt((float)val4.x / (float)tileMap.partitionSizeX), Mathf.FloorToInt((float)val4.y / (float)tileMap.partitionSizeY))); bool flag5 = useColor; if (val6 == null || (val6.colors.Length == 0 && val6.colorOverrides.GetLength(0) == 0)) { flag5 = false; } int count = vertices.Count; defPositions[0] = val5.position0; defPositions[1] = val5.position1; defPositions[2] = val5.position2; defPositions[3] = val5.position3; IntVector2 val7 = Vector3Extensions.IntXY(val3, (VectorConversions)2) + new IntVector2(baseX + RenderMeshBuilder.CurrentCellXOffset, baseY + RenderMeshBuilder.CurrentCellYOffset); bool flag6 = dungeon.data.CheckInBounds(val7, 1); ((IntVector2)(ref val8))..ctor(l, k); if (tileMap.isGungeonTilemap) { ((IntVector2)(ref val8))..ctor(val4.x % tileMap.partitionSizeX, val4.y % tileMap.partitionSizeY); } for (int m = 0; m < defPositions.Length; m++) { Vector3 val9 = BuilderUtil.ApplySpriteVertexTileFlags(tileMap, val5, defPositions[m], flag2, flag3, flag4); if (flag5) { Color32 val10 = val6.colorOverrides[val8.y * num11 + val8.x, m % 4]; if (tileMap.isGungeonTilemap && (val10.r != val.r || val10.g != val.g || val10.b != val.b || val10.a != val.a)) { Color item = Color32.op_Implicit(val10); colors.Add(item); } else { Color val11 = Color32.op_Implicit(val6.colors[val8.y * num11 + val8.x]); Color val12 = Color32.op_Implicit(val6.colors[val8.y * num11 + val8.x + 1]); Color val13 = Color32.op_Implicit(val6.colors[(val8.y + 1) * num11 + val8.x]); Color val14 = Color32.op_Implicit(val6.colors[(val8.y + 1) * num11 + (val8.x + 1)]); Vector3 val15 = val9 - val5.untrimmedBoundsDataCenter + tileMap.data.tileSize * 0.5f; float num14 = Mathf.Clamp01(val15.x / tileMap.data.tileSize.x); float num15 = Mathf.Clamp01(val15.y / tileMap.data.tileSize.y); Color item2 = Color.Lerp(Color.Lerp(val11, val12, num14), Color.Lerp(val13, val14, num14), num15); colors.Add(item2); } } else { colors.Add(Color.black); } Vector3 val16 = val3; if (tileMap.isGungeonTilemap) { if (flag6 && dungeon.data.isAnyFaceWall(val7.x, val7.y)) { Vector3 val17 = ((!dungeon.data.isFaceWallHigher(val7.x, val7.y)) ? new Vector3(0f, 0f, 1f) : new Vector3(0f, 0f, -1f)); CellData val18 = dungeon.data[val7]; if ((int)val18.diagonalWallType == 1) { val17.z += (1f - val9.x) * 2f; } else if ((int)val18.diagonalWallType == 4) { val17.z += val9.x * 2f; } val16 += new Vector3(0f, 0f, val3.y - val9.y) + val9 + val17; } else if (flag6 && dungeon.data.isTopDiagonalWall(val7.x, val7.y) && layerData.name == "Collision Layer") { ((Vector3)(ref val19))..ctor(0f, 0f, -3f); val16 += new Vector3(0f, 0f, val3.y + val9.y) + val9 + val19; } else if (layerData.name == "AOandShadows") { if (flag6 && dungeon.data[val7] != null && (int)dungeon.data[val7].type == 4) { ((Vector3)(ref val20))..ctor(0f, 0f, 2.5f); val16 += new Vector3(0f, 0f, val3.y + val9.y) + val9 + val20; } else { ((Vector3)(ref val21))..ctor(0f, 0f, 1f); val16 += new Vector3(0f, 0f, val3.y + val9.y) + val9 + val21; } } else if (layerData.name == "Pit Layer") { ((Vector3)(ref val22))..ctor(0f, 0f, 2f); if (dungeon.data.CheckInBounds(val7.x, val7.y + 2)) { if ((int)dungeon.data.cellData[val7.x][val7.y + 1].type != 4 || (int)dungeon.data.cellData[val7.x][val7.y + 2].type != 4) { bool flag7 = (int)dungeon.data.cellData[val7.x][val7.y + 1].type != 4; if (dungeon.debugSettings.WALLS_ARE_PITS && dungeon.data.cellData[val7.x][val7.y + 1].isExitCell) { flag7 = false; } if (flag7) { ((Vector3)(ref val22))..ctor(0f, 0f, 0f); } val16 += new Vector3(0f, 0f, val3.y - val9.y) + val9 + val22; } else { val16 += new Vector3(0f, 0f, val3.y + val9.y + 1f) + val9; } } else { val16 += new Vector3(0f, 0f, val3.y + val9.y + 1f) + val9; } } else { val16 += new Vector3(0f, 0f, val3.y + val9.y) + val9; } } else { val16 += val9; } vertices.Add(val16); uvs.Add(val5.uvs[m]); } bool flag8 = false; if (flag2) { flag8 = !flag8; } if (flag3) { flag8 = !flag8; } List list = perMaterialTriangles[val5.materialId]; for (int n = 0; n < val5.indices.Length; n++) { int num16 = ((!flag8) ? n : (val5.indices.Length - 1 - n)); list.Add(count + val5.indices[num16]); } } } if ((Object)(object)chunk.mesh == (Object)null) { chunk.mesh = tk2dUtil.CreateMesh(); } chunk.mesh.SetVertices(vertices); chunk.mesh.SetUVs(0, uvs); chunk.mesh.SetColors(colors); usedMaterials.Clear(); int num17 = 0; for (int num18 = 0; num18 < num10; num18++) { if (perMaterialTriangles[num18].Count != 0) { usedMaterials.Add(tileMap.SpriteCollectionInst.materialInsts[num18]); num17++; } } if (num17 > 0) { chunk.mesh.subMeshCount = num17; chunk.gameObject.GetComponent().materials = usedMaterials.ToArray(); int num19 = 0; for (int num20 = 0; num20 < num10; num20++) { if (perMaterialTriangles[num20].Count > 0) { chunk.mesh.SetTriangles(perMaterialTriangles[num20], num19++); } } } chunk.mesh.RecalculateBounds(); if (flag) { chunk.mesh.RecalculateNormals(); } if (tileMap.isGungeonTilemap) { chunk.gameObject.transform.position = Vector3Extensions.WithZ(chunk.gameObject.transform.position, (float)baseY + chunk.gameObject.transform.position.z); } chunk.gameObject.GetComponent().sharedMesh = chunk.mesh; return false; } } [HarmonyPatch] internal static class OcclusionOptimizations { private static readonly float[] WEIGHTS = new float[25] { 0.0144f, 0.03f, 0.036f, 0.03f, 0.0144f, 0.03f, 0.0625f, 0.075f, 0.0625f, 0.03f, 0.036f, 0.075f, 0.09f, 0.075f, 0.036f, 0.03f, 0.0625f, 0.075f, 0.0625f, 0.03f, 0.0144f, 0.03f, 0.036f, 0.03f, 0.0144f }; private static readonly float[] KERNEL = new float[5] { 0.12f, 0.25f, 0.3f, 0.25f, 0.12f }; private const float KERNEL_TOTAL = 1.0816f; private const int KW = 2; private static float[] _CachedOcclusions = null; private static float[] _CachedKernels = null; private static readonly List _NearbyRooms = new List(); private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_OCCLUSION) { return false; } return true; } [HarmonyPatch(typeof(OcclusionLayer), "GenerateOcclusionTexture")] [HarmonyPrefix] private static bool FastGenerateOcclusionTexture(OcclusionLayer __instance, int baseX, int baseY, DungeonData d, ref Texture2D __result) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Invalid comparison between Unknown and I4 //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Expected O, but got Unknown //IL_0479: Unknown result type (might be due to invalid IL or missing references) //IL_047e: Unknown result type (might be due to invalid IL or missing references) //IL_05a8: Unknown result type (might be due to invalid IL or missing references) //IL_05ad: Unknown result type (might be due to invalid IL or missing references) //IL_05f6: Unknown result type (might be due to invalid IL or missing references) //IL_05fb: Unknown result type (might be due to invalid IL or missing references) //IL_0756: Unknown result type (might be due to invalid IL or missing references) //IL_075c: Invalid comparison between Unknown and I4 //IL_061a: Unknown result type (might be due to invalid IL or missing references) //IL_0620: Invalid comparison between Unknown and I4 //IL_077b: Unknown result type (might be due to invalid IL or missing references) //IL_0781: Invalid comparison between Unknown and I4 //IL_07d1: Unknown result type (might be due to invalid IL or missing references) //IL_07d6: Unknown result type (might be due to invalid IL or missing references) //IL_07aa: Unknown result type (might be due to invalid IL or missing references) //IL_07b0: Invalid comparison between Unknown and I4 //IL_0699: Unknown result type (might be due to invalid IL or missing references) //IL_06a2: Unknown result type (might be due to invalid IL or missing references) //IL_06a8: Invalid comparison between Unknown and I4 __instance.m_gameManagerCached = GameManager.Instance; __instance.m_pixelatorCached = Pixelator.Instance; if (__instance.m_pixelatorCached.UseTexturedOcclusion) { return true; } __instance.cachedX = baseX; __instance.cachedY = baseY; __instance.m_allPlayersCached = GameManager.Instance.AllPlayers; __instance.m_playerOneDead = !Object.op_Implicit((Object)(object)__instance.m_gameManagerCached.PrimaryPlayer) || ((BraveBehaviour)__instance.m_gameManagerCached.PrimaryPlayer).healthHaver.IsDead; if ((int)__instance.m_gameManagerCached.CurrentGameType == 1) { __instance.m_playerTwoDead = !Object.op_Implicit((Object)(object)__instance.m_gameManagerCached.SecondaryPlayer) || ((BraveBehaviour)__instance.m_gameManagerCached.SecondaryPlayer).healthHaver.IsDead; } else { __instance.m_playerTwoDead = true; } int num = __instance.m_pixelatorCached.CurrentMacroResolutionX / 16 + 4; int num2 = __instance.m_pixelatorCached.CurrentMacroResolutionY / 16 + 4; int num3 = num * __instance.textureMultiplier; int num4 = num2 * __instance.textureMultiplier; int num5 = num3 * num4; CellData[][] cellData = d.cellData; int width = d.m_width; int height = d.m_height; int num6 = width * height; _NearbyRooms.Clear(); RoomHandler val = (__instance.m_playerOneDead ? null : __instance.m_allPlayersCached[0].m_currentRoom); if (val != null && val.connectedRooms != null) { for (int num7 = val.connectedRooms.Count - 1; num7 >= 0; num7--) { _NearbyRooms.Add(val.connectedRooms[num7]); } } RoomHandler val2 = (__instance.m_playerTwoDead ? null : __instance.m_allPlayersCached[1].m_currentRoom); if (val2 != null && val2 != val && val2.connectedRooms != null) { for (int num8 = val2.connectedRooms.Count - 1; num8 >= 0; num8--) { _NearbyRooms.Add(val2.connectedRooms[num8]); } } if ((Object)(object)__instance.m_occlusionTexture == (Object)null) { __instance.m_occlusionTexture = new Texture2D(num3, num4, (TextureFormat)5, false); ((Texture)__instance.m_occlusionTexture).filterMode = (FilterMode)1; ((Texture)__instance.m_occlusionTexture).wrapMode = (TextureWrapMode)1; } else if (((Texture)__instance.m_occlusionTexture).width != num3 || ((Texture)__instance.m_occlusionTexture).height != num4) { __instance.m_occlusionTexture.Resize(num3, num4); } if (__instance.m_colorCache == null || __instance.m_colorCache.Length != num5) { __instance.m_colorCache = (Color[])(object)new Color[num5]; } if (_CachedOcclusions == null) { _CachedOcclusions = new float[num6]; _CachedKernels = new float[num6]; for (int i = 0; i < num6; i++) { _CachedOcclusions[i] = -1f; _CachedKernels[i] = -1f; } } else if (_CachedOcclusions.Length < num6) { Array.Resize(ref _CachedOcclusions, num6); Array.Resize(ref _CachedKernels, num6); } int num9 = 0; int num10 = ((baseX > 2) ? (baseX - 2) : 0); int num11 = ((baseY > 2) ? (baseY - 2) : 0); int num12 = 2 + baseX + (num3 - 1) / __instance.textureMultiplier; if (num12 >= width) { num12 = width - 1; } int num13 = 2 + baseY + (num4 - 1) / __instance.textureMultiplier; if (num13 >= height) { num13 = height - 1; } for (int j = num10; j <= num12; j++) { CellData[] array = cellData[j]; for (int k = num11; k <= num13; k++) { int num14 = j * height + k; float num15 = array[k]?.occlusionData.cellOcclusion ?? 1f; if (_CachedOcclusions[num14] == num15) { continue; } int num16 = j + 2; if (num16 >= width) { num16 = width - 1; } int num17 = k + 2; if (num17 >= height) { num17 = height - 1; } int num18 = j - 2; if (num18 < 0) { num18 = 0; } int num19 = k - 2; if (num19 < 0) { num19 = 0; } for (int l = num18; l <= num16; l++) { for (int m = num19; m <= num17; m++) { _CachedKernels[l * height + m] = -1f; } } _CachedOcclusions[num14] = num15; num9++; } } if (!__instance.m_gameManagerCached.IsLoadingLevel) { int num20 = 0; for (int n = 0; n < num4; n++) { int num21 = baseY + n / __instance.textureMultiplier; for (int num22 = 0; num22 < num3; num22++) { int num23 = baseX + num22 / __instance.textureMultiplier; if (num23 < 0 || num21 < 0 || num23 >= d.m_width || num21 >= d.m_height) { __instance.m_colorCache[num20++] = Color.clear; continue; } int num24 = num23 * height + num21; CellData val3 = cellData[num23][num21]; float num25 = _CachedKernels[num24]; if (num25 == -1f) { num25 = (_CachedOcclusions[num24] = val3?.occlusionData.cellOcclusion ?? 1f); if (num23 >= 2 && num21 >= 2 && num23 < d.m_width - 2 && num21 < d.m_height - 2) { float num26 = 0f; int num27 = 0; for (int num28 = -2; num28 <= 2; num28++) { CellData[] array2 = cellData[num23 + num28]; for (int num29 = -2; num29 <= 2; num29++) { CellData val4 = array2[num21 + num29]; num26 += ((val4 != null) ? (val4.occlusionData.cellOcclusion * WEIGHTS[num27++]) : WEIGHTS[num27++]); } } float num30 = num26 / 1.0816f; if (num30 < num25) { num25 = num30; } } _CachedKernels[num24] = num25; } if (num25 >= 1f) { __instance.m_colorCache[num20++] = Color.clear; continue; } float num31 = ((num25 < 0f) ? 1f : (1f - num25 * num25)); if (val3 == null) { __instance.m_colorCache[num20++] = new Color(0f, 0f, 0f, num31); continue; } float num32 = 0f; if (!val3.isExitCell && ((int)val3.type != 1 || val3.IsAnyFaceWall())) { if (num21 >= 2) { CellData obj = cellData[num23][num21 - 2]; if (obj != null && obj.isExitCell) { goto IL_074d; } } if (num23 >= 1 && num23 <= d.m_width - 2 && num21 >= 3 && num21 <= d.m_height - 2) { RoomHandler val5 = val3.parentRoom ?? val3.nearestRoom; if (val5 == null) { goto IL_0746; } if ((int)val5.visibility == 0 || (int)val5.visibility == 3) { int num33 = _NearbyRooms.Count - 1; while (num33 >= 0) { if (_NearbyRooms[num33] != val5) { num33--; continue; } goto IL_0746; } if (!val3.isExitNonOccluder) { CellData obj2 = cellData[num23][num21 - 1]; if (obj2 == null || !obj2.isExitCell) { CellData obj3 = cellData[num23][num21 - 3]; if (obj3 == null || !obj3.isExitCell) { if (num23 > 1) { CellData obj4 = cellData[num23 - 1][num21]; if (obj4 != null && obj4.isExitCell) { goto IL_074d; } } CellData obj5 = cellData[num23 + 1][num21]; if (obj5 == null || !obj5.isExitCell) { goto IL_0746; } } } } } } } goto IL_074d; IL_0746: num32 = 1f; goto IL_074d; IL_074d: float num34 = 0f; if ((int)val3.type != 1 || val3.IsLowerFaceWall() || val3.IsUpperFacewall()) { RoomHandler nearestRoom = val3.nearestRoom; if ((int)nearestRoom.visibility == 2) { num34 = 1f * (1f - val3.occlusionData.minCellOccluionHistory); } else if (nearestRoom.hasEverBeenVisited && (int)nearestRoom.visibility != 3) { num34 = 1f; } } __instance.m_colorCache[num20++] = new Color(num32, num34, 0f, num31); } } } __instance.m_occlusionTexture.SetPixels(__instance.m_colorCache); __instance.m_occlusionTexture.Apply(); __result = __instance.m_occlusionTexture; return false; } } internal static class Extensions { private static Regex rx_enum_field = new Regex("^]+)(>__[0-9]+)?$", RegexOptions.Compiled); private static MethodInfo _WriteLine = typeof(Console).GetMethod("WriteLine", new Type[1] { typeof(string) }); internal static void CallPrivate(this ILCursor cursor, Type t, string name) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) cursor.Emit(OpCodes.Call, (MethodBase)t.GetMethod(name, BindingFlags.Static | BindingFlags.NonPublic)); } internal static void CallPublic(this ILCursor cursor, Type t, string name) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) cursor.Emit(OpCodes.Call, (MethodBase)t.GetMethod(name, BindingFlags.Static | BindingFlags.Public)); } public static FieldInfo GetEnumeratorField(this Type t, string s) { return AccessTools.GetDeclaredFields(t).Find(delegate(FieldInfo f) { foreach (Match item in rx_enum_field.Matches(f.Name)) { if (item.Groups[1].Value == s) { return true; } } return false; }); } [Conditional("DEBUG")] internal static void DebugPrint(this ILCursor cursor, string test) { //IL_0001: 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) cursor.Emit(OpCodes.Ldstr, test); cursor.Emit(OpCodes.Call, (MethodBase)_WriteLine); } internal static VariableDefinition DeclareLocal(this ILContext il) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown VariableDefinition val = new VariableDefinition(il.Import(typeof(T))); il.Body.Variables.Add(val); return val; } internal static VariableDefinition DeclareLocal(this ILContext il, Type t) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown VariableDefinition val = new VariableDefinition(il.Import(t)); il.Body.Variables.Add(val); return val; } internal static Func CreateGetter(this string fieldName) { FieldInfo field = typeof(S).GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic); DynamicMethod dynamicMethod = new DynamicMethod(field.ReflectedType.FullName + ".get_" + field.Name, typeof(T), new Type[1] { typeof(S) }, restrictedSkipVisibility: true); ILGenerator iLGenerator = dynamicMethod.GetILGenerator(); iLGenerator.Emit(OpCodes.Ldarg_0); iLGenerator.Emit(OpCodes.Ldfld, field); iLGenerator.Emit(OpCodes.Ret); return (Func)dynamicMethod.CreateDelegate(typeof(Func)); } internal static bool Approximately(this float a, float b, float threshold = 0.0001f) { float num = a - b; if (0f - threshold < num) { return num < threshold; } return false; } } internal static class GGVConfig { internal static bool FIX_DUCT_TAPE = true; internal static bool FIX_QUICK_RESTART = true; internal static bool FIX_SHUFFLE = true; internal static bool FIX_AMMO_UI = true; internal static bool FIX_ORBITAL_GUN = true; internal static bool FIX_COOP_TURBO = true; internal static bool FIX_BULLET_TRAILS = true; internal static bool FIX_DAMAGE_CAPS = true; internal static bool FIX_EVOLVER = true; internal static bool FIX_AMMO_DRIFT = true; internal static bool FIX_REPAUSE = true; internal static bool FIX_MIMIC_CHEST = true; internal static bool FIX_HIGH_STRESS = true; internal static bool FIX_BRICK_OF_CASH = true; internal static bool FIX_GUN_MAGNIFICENCE = true; internal static bool FIX_INFINITE_BEAMS = true; internal static bool FIX_CAPED_BULLET_KIN = true; internal static bool FIX_FLAK_BULLETS = true; internal static bool FIX_SCATTERSHOT = true; internal static bool FIX_ORBITAL_BULLETS = true; internal static bool FIX_STARPEW = true; internal static int PREALLOCATE_HEAP = 0; internal static bool OPT_PROJ_STATUS = true; internal static bool OPT_GUI_EVENTS = true; internal static bool OPT_NUMBERS = true; internal static bool OPT_FLOOD_FILL = true; internal static bool OPT_TRAILS = true; internal static bool OPT_LIGHT_CULL = true; internal static bool OPT_BEAMS = true; internal static bool OPT_PATH_RECALC = true; internal static bool OPT_CHUNK_CHECKS = true; internal static bool OPT_VIS_CHECKS = true; internal static bool OPT_OCCLUSION = true; internal static bool OPT_AMMO_DISPLAY = true; internal static bool OPT_PHYSICS_LEAK = true; internal static bool OPT_PIXEL_MOVE = true; internal static bool OPT_PIXEL_ROTATE = true; internal static bool OPT_PAUSE = true; internal static bool OPT_RANDOM_CELL = true; internal static bool OPT_TEXT_MARKUP = true; internal static bool OPT_MATH = true; internal static bool OPT_CHUNKBUILD = true; internal static bool OPT_LINEAR_CAST = true; internal static bool OPT_POINTCAST = true; internal static bool OPT_PIT_VFX = true; internal static bool OPT_ITEM_LOOKUPS = true; internal static bool OPT_DUNGEON_DIMS = true; internal static bool OPT_DEPTH_CHECKS = true; internal static bool OPT_GOOP = true; internal static bool OPT_MOUSE_EVENTS = true; internal static bool OPT_TITLE_SCREEN = true; internal static void Update() { PREALLOCATE_HEAP = 0; string text = ConfigMenu._Gunfig.Value("Preallocate Heap Memory"); if (text != "Default") { Console.WriteLine("parsing heapConfig=" + text); PREALLOCATE_HEAP = int.Parse(text.Split(new char[1] { 'G' })[0]); } FIX_DUCT_TAPE = "Enabled" == ConfigMenu._Gunfig.Value("Duct Tape Fix"); FIX_QUICK_RESTART = "Enabled" == ConfigMenu._Gunfig.Value("Quick Restart Fix"); FIX_SHUFFLE = "Enabled" == ConfigMenu._Gunfig.Value("Shuffle Fix"); FIX_AMMO_UI = "Enabled" == ConfigMenu._Gunfig.Value("Ammo UI Fix"); FIX_ORBITAL_GUN = "Enabled" == ConfigMenu._Gunfig.Value("Orbital Gun Fix"); FIX_COOP_TURBO = "Enabled" == ConfigMenu._Gunfig.Value("Co-op Turbo Mode Fix"); FIX_BULLET_TRAILS = "Enabled" == ConfigMenu._Gunfig.Value("Bullet Trail Fix"); FIX_DAMAGE_CAPS = "Enabled" == ConfigMenu._Gunfig.Value("Beam Damage Cap Fix"); FIX_EVOLVER = "Enabled" == ConfigMenu._Gunfig.Value("Evolver Devolve Fix"); FIX_AMMO_DRIFT = "Enabled" == ConfigMenu._Gunfig.Value("Ammo Drift Fix"); FIX_REPAUSE = "Enabled" == ConfigMenu._Gunfig.Value("Unpause / Repause Fix"); FIX_MIMIC_CHEST = "Enabled" == ConfigMenu._Gunfig.Value("Invalid Mimic Chest Fix"); FIX_HIGH_STRESS = "Enabled" == ConfigMenu._Gunfig.Value("High Stress Armor Fix"); FIX_BRICK_OF_CASH = "Enabled" == ConfigMenu._Gunfig.Value("Brick of Cash Fix"); FIX_GUN_MAGNIFICENCE = "Enabled" == ConfigMenu._Gunfig.Value("Gun Magnificence Fix"); FIX_INFINITE_BEAMS = "Enabled" == ConfigMenu._Gunfig.Value("Infinite Beam Ammo Fix"); FIX_CAPED_BULLET_KIN = "Enabled" == ConfigMenu._Gunfig.Value("Caped Bullet Kin Fix"); FIX_FLAK_BULLETS = "Enabled" == ConfigMenu._Gunfig.Value("Flak Bullets Fix"); FIX_SCATTERSHOT = "Enabled" == ConfigMenu._Gunfig.Value("Scattershot Fix"); FIX_ORBITAL_BULLETS = "Enabled" == ConfigMenu._Gunfig.Value("Orbital Bullets Fix"); FIX_STARPEW = "Enabled" == ConfigMenu._Gunfig.Value("Starpew Fix"); OPT_VIS_CHECKS = "Enabled" == ConfigMenu._Gunfig.Value("Optimize Visibility Checks"); OPT_OCCLUSION = "Enabled" == ConfigMenu._Gunfig.Value("Optimize Occlusion"); OPT_AMMO_DISPLAY = "Enabled" == ConfigMenu._Gunfig.Value("Optimize Ammo Display"); OPT_PAUSE = "Enabled" == ConfigMenu._Gunfig.Value("Optimize Pause Menu"); OPT_LIGHT_CULL = "Enabled" == ConfigMenu._Gunfig.Value("Optimize Light Culling"); OPT_BEAMS = "Enabled" == ConfigMenu._Gunfig.Value("Optimize Beams"); OPT_PATH_RECALC = "Enabled" == ConfigMenu._Gunfig.Value("Optimize Path Recalculations"); OPT_GUI_EVENTS = "Enabled" == ConfigMenu._Gunfig.Value("Optimize GUI Events"); OPT_NUMBERS = "Enabled" == ConfigMenu._Gunfig.Value("Optimize Numerical Strings"); OPT_FLOOD_FILL = "Enabled" == ConfigMenu._Gunfig.Value("Optimize Flood Filling"); OPT_TRAILS = "Enabled" == ConfigMenu._Gunfig.Value("Optimize Bullet Trails"); OPT_PROJ_STATUS = "Enabled" == ConfigMenu._Gunfig.Value("Optimize Projectile Prefabs"); OPT_CHUNK_CHECKS = "Enabled" == ConfigMenu._Gunfig.Value("Optimize Chunk Checks"); OPT_PHYSICS_LEAK = "Enabled" == ConfigMenu._Gunfig.Value("Optimize Linear Cast Pool"); OPT_PIXEL_MOVE = "Enabled" == ConfigMenu._Gunfig.Value("Optimize Pixel Movement Gen"); OPT_PIXEL_ROTATE = "Enabled" == ConfigMenu._Gunfig.Value("Optimize Pixel Rotation"); OPT_RANDOM_CELL = "Enabled" == ConfigMenu._Gunfig.Value("Optimize Random Cell Lookup"); OPT_TEXT_MARKUP = "Enabled" == ConfigMenu._Gunfig.Value("Optimize Text Markup"); OPT_MATH = "Enabled" == ConfigMenu._Gunfig.Value("Optimize Math"); OPT_CHUNKBUILD = "Enabled" == ConfigMenu._Gunfig.Value("Optimize Chunk Building"); OPT_LINEAR_CAST = "Enabled" == ConfigMenu._Gunfig.Value("Optimize Linear Cast"); OPT_POINTCAST = "Enabled" == ConfigMenu._Gunfig.Value("Optimize Pointcast"); OPT_PIT_VFX = "Enabled" == ConfigMenu._Gunfig.Value("Optimize Pit VFX"); OPT_ITEM_LOOKUPS = "Enabled" == ConfigMenu._Gunfig.Value("Optimize Item Lookups"); OPT_DUNGEON_DIMS = "Enabled" == ConfigMenu._Gunfig.Value("Optimize Dungeon Size Checks"); OPT_DEPTH_CHECKS = "Enabled" == ConfigMenu._Gunfig.Value("Optimize Sprite Depth Checks"); OPT_GOOP = "Enabled" == ConfigMenu._Gunfig.Value("Optimize Goop Updates"); OPT_MOUSE_EVENTS = "Enabled" == ConfigMenu._Gunfig.Value("Optimize GUI Mouse Events"); OPT_TITLE_SCREEN = "Enabled" == ConfigMenu._Gunfig.Value("Optimize Title Screen"); WriteLine($"PREALLOCATE_HEAP = {PREALLOCATE_HEAP} GB"); WriteLine($"FIX_DUCT_TAPE = {FIX_DUCT_TAPE}"); WriteLine($"FIX_QUICK_RESTART = {FIX_QUICK_RESTART}"); WriteLine($"FIX_ROOM_SHUFFLE = {FIX_SHUFFLE}"); WriteLine($"FIX_AMMO_UI = {FIX_AMMO_UI}"); WriteLine($"FIX_ORBITAL_GUN = {FIX_ORBITAL_GUN}"); WriteLine($"FIX_COOP_TURBO = {FIX_COOP_TURBO}"); WriteLine($"FIX_BULLET_TRAILS = {FIX_BULLET_TRAILS}"); WriteLine($"FIX_DAMAGE_CAPS = {FIX_DAMAGE_CAPS}"); WriteLine($"FIX_EVOLVER = {FIX_EVOLVER}"); WriteLine($"FIX_AMMO_DRIFT = {FIX_AMMO_DRIFT}"); WriteLine($"FIX_REPAUSE = {FIX_REPAUSE}"); WriteLine($"FIX_MIMIC_CHEST = {FIX_MIMIC_CHEST}"); WriteLine($"FIX_HIGH_STRESS = {FIX_HIGH_STRESS}"); WriteLine($"FIX_BRICK_OF_CASH = {FIX_BRICK_OF_CASH}"); WriteLine($"FIX_GUN_MAGNIFICENCE = {FIX_GUN_MAGNIFICENCE}"); WriteLine($"FIX_INFINITE_BEAMS = {FIX_INFINITE_BEAMS}"); WriteLine($"FIX_CAPED_BULLET_KIN = {FIX_CAPED_BULLET_KIN}"); WriteLine($"FIX_FLAK_BULLETS = {FIX_FLAK_BULLETS}"); WriteLine($"FIX_SCATTERSHOT = {FIX_SCATTERSHOT}"); WriteLine($"FIX_ORBITAL_BULLETS = {FIX_ORBITAL_BULLETS}"); WriteLine($"FIX_STARPEW = {FIX_STARPEW}"); WriteLine($"OPT_OCCLUSION = {OPT_OCCLUSION}"); WriteLine($"OPT_AMMO_DISPLAY = {OPT_AMMO_DISPLAY}"); WriteLine($"OPT_PAUSE = {OPT_PAUSE}"); WriteLine($"OPT_VIS_CHECKS = {OPT_VIS_CHECKS}"); WriteLine($"OPT_LIGHT_CULL = {OPT_LIGHT_CULL}"); WriteLine($"OPT_BEAMS = {OPT_BEAMS}"); WriteLine($"OPT_PATH_RECALC = {OPT_PATH_RECALC}"); WriteLine($"OPT_GUI_EVENTS = {OPT_GUI_EVENTS}"); WriteLine($"OPT_NUMBERS = {OPT_NUMBERS}"); WriteLine($"OPT_FLOOD_FILL = {OPT_FLOOD_FILL}"); WriteLine($"OPT_TRAILS = {OPT_TRAILS}"); WriteLine($"OPT_PROJ_STATUS = {OPT_PROJ_STATUS}"); WriteLine($"OPT_CHUNK_CHECKS = {OPT_CHUNK_CHECKS}"); WriteLine($"OPT_PHYSICS_LEAK = {OPT_PHYSICS_LEAK}"); WriteLine($"OPT_PIXEL_MOVE = {OPT_PIXEL_MOVE}"); WriteLine($"OPT_PIXEL_ROTATE = {OPT_PIXEL_ROTATE}"); WriteLine($"OPT_RANDOM_CELL = {OPT_RANDOM_CELL}"); WriteLine($"OPT_TEXT_MARKUP = {OPT_TEXT_MARKUP}"); WriteLine($"OPT_MATH = {OPT_MATH}"); WriteLine($"OPT_CHUNKBUILD = {OPT_CHUNKBUILD}"); WriteLine($"OPT_LINEAR_CAST = {OPT_LINEAR_CAST}"); WriteLine($"OPT_POINTCAST = {OPT_POINTCAST}"); WriteLine($"OPT_PIT_VFX = {OPT_PIT_VFX}"); WriteLine($"OPT_ITEM_LOOKUPS = {OPT_ITEM_LOOKUPS}"); WriteLine($"OPT_DUNGEON_DIMS = {OPT_DUNGEON_DIMS}"); WriteLine($"OPT_DEPTH_CHECKS = {OPT_DEPTH_CHECKS}"); WriteLine($"OPT_GOOP = {OPT_GOOP}"); WriteLine($"OPT_MOUSE_EVENTS = {OPT_MOUSE_EVENTS}"); WriteLine($"OPT_TITLE_SCREEN = {OPT_TITLE_SCREEN}"); } private static void WriteLine(string s) { Debug.Log((object)("[GGV] " + s)); } internal static void Update(string _unused1, string _unused2) { Update(); } } internal static class ConfigMenu { internal static Gunfig _Gunfig = null; internal const string BUG_FIX = "Bugfixes"; internal const string DUCT_TAPE = "Duct Tape Fix"; internal const string QUICK_RESTART = "Quick Restart Fix"; internal const string SHUFFLE = "Shuffle Fix"; internal const string AMMO_UI = "Ammo UI Fix"; internal const string ORBITAL_GUN = "Orbital Gun Fix"; internal const string COOP_TURBO = "Co-op Turbo Mode Fix"; internal const string BULLET_TRAILS = "Bullet Trail Fix"; internal const string DAMAGE_CAPS = "Beam Damage Cap Fix"; internal const string EVOLVER = "Evolver Devolve Fix"; internal const string AMMO_DRIFT = "Ammo Drift Fix"; internal const string REPAUSE = "Unpause / Repause Fix"; internal const string MIMIC_CHEST = "Invalid Mimic Chest Fix"; internal const string HIGH_STRESS = "High Stress Armor Fix"; internal const string BRICK_OF_CASH = "Brick of Cash Fix"; internal const string GUN_MAGNIFICENCE = "Gun Magnificence Fix"; internal const string INFINITE_BEAMS = "Infinite Beam Ammo Fix"; internal const string CAPED_BULLET_KIN = "Caped Bullet Kin Fix"; internal const string FLAK_BULLETS = "Flak Bullets Fix"; internal const string SCATTERSHOT = "Scattershot Fix"; internal const string ORBITAL_BULLETS = "Orbital Bullets Fix"; internal const string STARPEW = "Starpew Fix"; internal const string SAFE_OPT = "Safe Optimizations"; internal const string PREALLOCATE = "Preallocate Heap Memory"; internal const string OCCLUSION = "Optimize Occlusion"; internal const string AMMO_DISPLAY = "Optimize Ammo Display"; internal const string PAUSE = "Optimize Pause Menu"; internal const string VIS_CHECKS = "Optimize Visibility Checks"; internal const string LIGHT_CULL = "Optimize Light Culling"; internal const string BEAMS = "Optimize Beams"; internal const string PATH_RECALC = "Optimize Path Recalculations"; internal const string GUI_EVENTS = "Optimize GUI Events"; internal const string NUMBERS = "Optimize Numerical Strings"; internal const string FLOOD_FILL = "Optimize Flood Filling"; internal const string TRAILS = "Optimize Bullet Trails"; internal const string PIXEL_ROTATE = "Optimize Pixel Rotation"; internal const string PROJ_STATUS = "Optimize Projectile Prefabs"; internal const string CHUNK_CHECKS = "Optimize Chunk Checks"; internal const string PHYSICS_LEAK = "Optimize Linear Cast Pool"; internal const string PIXEL_MOVE = "Optimize Pixel Movement Gen"; internal const string RANDOM_CELL = "Optimize Random Cell Lookup"; internal const string TEXT_MARKUP = "Optimize Text Markup"; internal const string AGGR_OPT = "Aggressive Optimizations"; internal const string MATH = "Optimize Math"; internal const string CHUNKBUILD = "Optimize Chunk Building"; internal const string LINEAR_CAST = "Optimize Linear Cast"; internal const string POINTCAST = "Optimize Pointcast"; internal const string PIT_VFX = "Optimize Pit VFX"; internal const string ITEM_LOOKUPS = "Optimize Item Lookups"; internal const string DUNGEON_DIMS = "Optimize Dungeon Size Checks"; internal const string DEPTH_CHECKS = "Optimize Sprite Depth Checks"; internal const string GOOP = "Optimize Goop Updates"; internal const string EXPR_OPT = "Experimental Optimizations"; internal const string MOUSE_EVENTS = "Optimize GUI Mouse Events"; internal const string TITLE_SCREEN = "Optimize Title Screen"; private static readonly List DefaultEnabled = new List(2) { "Enabled", "Disabled" }; private static readonly List DefaultDisabled = new List(2) { "Disabled", "Enabled" }; internal static void Init() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) _Gunfig = Gunfig.Get(GunfigHelpers.WithColor("Gungeon Go Vroom", C.MOD_COLOR)); _Gunfig.AddLabel(GunfigHelpers.Magenta("All Changes are Applied on Next Restart")); Gunfig gunfig = _Gunfig.AddSubMenu("Bugfixes"); gunfig.FancyToggle("Duct Tape Fix", "Fixes duct-taped guns sometimes breaking\nwhen using the elevator save button."); gunfig.FancyToggle("Quick Restart Fix", "Fixes once-per-run rooms not properly\nresetting with Quick Restart, preventing them\nfrom respawning until visiting the Breach."); gunfig.FancyToggle("Shuffle Fix", "Fixes an off-by-one error in shuffling algorithms,\nmaking rooms always / never spawn in\nunintended situations, among other issues."); gunfig.FancyToggle("Ammo UI Fix", "Fixes a rendering issue with final projectiles\nin the ammo indicator causing them to render\nabove UI elements they shouldn't."); gunfig.FancyToggle("Orbital Gun Fix", "Fixes orbital guns visually firing from\nthe wrong location if created while the player\nis facing left."); gunfig.FancyToggle("Co-op Turbo Mode Fix", "Fixes co-op partner in turbo mode not\ngetting turbo mode speed buffs until\ntheir stats have changed at least once."); gunfig.FancyToggle("Bullet Trail Fix", "Fixes the trails of projectiles\ndisappearing if they travel too slowly\n(e.g., during timeslow effects)."); gunfig.FancyToggle("Beam Damage Cap Fix", "Fixes beams not ignoring boss damage caps\neven when set to do so. (No such\nbeam exists in vanilla, mostly for modded use)."); gunfig.FancyToggle("Evolver Devolve Fix", "Fixes Evolver devolving to its 2nd form\nafter dropping it, picking it back up,\nand killing 5 enemies to level it up."); gunfig.FancyToggle("Ammo Drift Fix", "Fixes ammo display drifting to the right when\na gun temporarily gets infinite ammo\n(e.g., from Magazine Rack)."); gunfig.FancyToggle("Unpause / Repause Fix", "Fixes game continuing to run if you\nunpause and quickly repause during menu\nfading animation."); gunfig.FancyToggle("Invalid Mimic Chest Fix", "Fixes errors caused by modded chests\nattempting to transform into mimics when no\ncorresponding mimic exists (mostly for modded use)."); gunfig.FancyToggle("High Stress Armor Fix", "Fixes no health or armor being displayed\nduring High Stress mode for Robot or\nother 0-health characters."); gunfig.FancyToggle("Brick of Cash Fix", "Fixes secret room Snitch spawned by Brick of Cash\nitem from spawning inside walls on\nthe right side of rooms."); gunfig.FancyToggle("Gun Magnificence Fix", "Fixes magnificence increasing when\npicking up a gun that has already been picked up."); gunfig.FancyToggle("Infinite Beam Ammo Fix", "Fixes beams depleting ammo even when under\nthe effects of Magazine Rack."); gunfig.FancyToggle("Caped Bullet Kin Fix", "Fixes Caped Bullet Kin taking longer to\ndespawn at higher frame rates."); gunfig.FancyToggle("Flak Bullets Fix", "Fixes Flak Bullets duplicating projectiles\ninfinitely when possessing multiple copies of\nthe item."); gunfig.FancyToggle("Scattershot Fix", "Fixes Scattershot consuming ammo for each projectile\nfired when firing charge projectiles\n(e.g., from Crescent Crossbow)."); gunfig.FancyToggle("Orbital Bullets Fix", "Fixes orbiting projectiles not properly deregistering\nthemselves when dying midair, eventually reducing\nthe orbital projectile cap to zero."); gunfig.FancyToggle("Starpew Fix", "Fixes Starpew's last two charge levels\nmissing two side projectiles after charging and\nfiring Starpew once."); Gunfig gunfig2 = _Gunfig.AddSubMenu("Safe Optimizations"); gunfig2.FancyMemList("Preallocate Heap Memory", "Preallocates RAM to avoid OS requests later.\nDefault uses Gungeon's default of about 200MB.\nHigher values result in fewer lag spikes."); gunfig2.FancyToggle("Optimize Occlusion", "Speeds up occlusion calculations by\nusing optimized algorithms and caching.\nSaves a large amount of CPU."); gunfig2.FancyToggle("Optimize Ammo Display", "Speeds up ammo display updates by\ncaching render data.\nSaves a large amount of RAM."); gunfig2.FancyToggle("Optimize Pause Menu", "Prevents a lot of unnecessary rendering\nwhile the game is paused.\nSaves a large amount of CPU while paused."); gunfig2.FancyToggle("Optimize Beams", "Pools beam bones to reduce memory usage and\noptimizes beam mesh rebuilding logic.\nSaves a significant amount of RAM and CPU."); gunfig2.FancyToggle("Optimize Light Culling", "Uses optimized inlined logic for\ndetermining whether lights should be culled.\nSaves a significant amount of CPU."); gunfig2.FancyToggle("Optimize Path Recalculations", "Optimizes clearance and walkability checks\nused for enemy pathing logic.\nSaves a modest amount of CPU."); gunfig2.FancyToggle("Optimize GUI Events", "Caches results of expensive lookups\nfor finding GUI event handlers.\nSaves a modest amount of RAM."); gunfig2.FancyToggle("Optimize Bullet Trails", "Pools bullet trail particles and vertex\ndata to reduce memory usage.\nSaves a modest amount of RAM."); gunfig2.FancyToggle("Optimize Pixel Rotation", "Optimizes pixel movement rotation\nused for pixel-perfect collisions.\nSaves a modest amount of RAM."); gunfig2.FancyToggle("Optimize Numerical Strings", "Caches strings for small numbers\nused frequently by SGUI's labels.\nSaves significant RAM while any console is open."); gunfig2.FancyToggle("Optimize Visibility Checks", "Speeds up sprite visibility checks\nby using inline arithmetic where possible.\nSaves a small amount of CPU."); gunfig2.FancyToggle("Optimize Flood Filling", "Uses an optimized flood fill algorithm\nfor floor post-processing.\nSaves a small amount of CPU and RAM."); gunfig2.FancyToggle("Optimize Projectile Prefabs", "Removes prefab effect data (e.g., poison) from\nprojectiles that never apply those effects.\nSaves a small amount of RAM."); gunfig2.FancyToggle("Optimize Chunk Checks", "Optimize checks for whether sprite chunks\nare relevant to gameplay.\nSaves a small amount of CPU."); gunfig2.FancyToggle("Optimize Linear Cast Pool", "Fixes a memory leak in Physics\ncalculations for pixel-perfect collisions.\nSaves a small amount of RAM."); gunfig2.FancyToggle("Optimize Pixel Movement Gen", "Optimizes pixel movement generator\nused for pixel-perfect collisions.\nSaves a small amount of CPU."); gunfig2.FancyToggle("Optimize Random Cell Lookup", "Optimizes function for getting\na random cell in a room.\nSaves a small amount of RAM."); gunfig2.FancyToggle("Optimize Text Markup", "Fixes a small memory leak when parsing\ntext markup (e.g., the infinite ammo symbol).\nSaves a small amount of RAM."); Gunfig gunfig3 = _Gunfig.AddSubMenu("Aggressive Optimizations"); gunfig3.FancyToggleOff("Optimize Goop Updates", "Speeds up goop updates by using\nfaster iterators and lookup algorithms.\nSaves a large amount of CPU."); gunfig3.FancyToggleOff("Optimize Math", "Speeds up some geometry calculations\nby using optimized algorithms.\nSaves a significant amount of CPU."); gunfig3.FancyToggleOff("Optimize Chunk Building", "Reuses temporary storage structures when\nrebuilding chunk data during level gen.\nSaves a significant amount of RAM."); gunfig3.FancyToggleOff("Optimize Linear Cast", "Speeds up linear cast physics calculations by\nusing inline arithmetic wherever possible.\nSaves a significant amount of CPU."); gunfig3.FancyToggleOff("Optimize Pointcast", "Speeds up pointcast physics calculations by\nusing inlined logic where possible.\nSaves a modest amount of CPU and RAM."); gunfig3.FancyToggleOff("Optimize Dungeon Size Checks", "Speeds up dungeon size lookups by\nusing fields instead of properties.\nSaves a modest amount of CPU."); gunfig3.FancyToggleOff("Optimize Sprite Depth Checks", "Speeds up attached sprite depth checks\nby caching property accesses.\nSaves a modest amount of CPU."); gunfig3.FancyToggleOff("Optimize Pit VFX", "Speeds up pit VFX calculations by skipping\nseveral redundant tile checks.\nSaves a small amount of CPU."); gunfig3.FancyToggleOff("Optimize Item Lookups", "Speeds up passive / active item lookups\nby skipping delegate creation.\nSaves a small amount of CPU and RAM."); _Gunfig.AddSubMenu("Experimental Optimizations").FancyToggleOff("Optimize Title Screen", "Prevents scanning for the player on\nthe title screen when no player exists.\nSaves a bit of CPU, but may break floor loads."); GGVConfig.Update(); Gunfig.OnAllModsLoaded = (Action)Delegate.Combine(Gunfig.OnAllModsLoaded, new Action(LateInit)); } private static void FancyToggle(this Gunfig gunfig, string toggleName, string toggleDesc) { string item = GunfigHelpers.Green(toggleDesc); gunfig.AddScrollBox(toggleName, DefaultEnabled, (string)null, (Action)null, new List(2) { item, item }, (Update)2); } private static void FancyToggleOff(this Gunfig gunfig, string toggleName, string toggleDesc) { string item = GunfigHelpers.Green(toggleDesc); gunfig.AddScrollBox(toggleName, DefaultDisabled, (string)null, (Action)null, new List(2) { item, item }, (Update)2); } private static void FancyMemList(this Gunfig gunfig, string toggleName, string toggleDesc) { string element = GunfigHelpers.Green(toggleDesc); List list = new List(11) { "Default", "1GB", "2GB", "3GB", "4GB", "5GB", "6GB", "7GB", "8GB", "9GB", "10GB" }; gunfig.AddScrollBox(toggleName, list, (string)null, (Action)null, Enumerable.Repeat(element, list.Count).ToList(), (Update)2); } private static void LateInit() { } } [HarmonyPatch] internal static class LinearCastOptimization { private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_LINEAR_CAST) { return false; } return true; } private static MethodBase TargetMethod() { return typeof(PixelCollider).GetMethod("LinearCast", new Type[6] { typeof(PixelCollider), typeof(IntVector2), typeof(List), typeof(LinearCastResult).MakeByRefType(), typeof(bool), typeof(float) }); } [HarmonyPrefix] private static bool PixelColliderLinearCastPatch(PixelCollider __instance, PixelCollider otherCollider, IntVector2 pixelsToMove, List stepList, out LinearCastResult result, bool traverseSlopes, float currentSlope, ref bool __result) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) if (!__instance.Enabled || (otherCollider.DirectionIgnorer != null && otherCollider.DirectionIgnorer(pixelsToMove))) { result = null; __result = false; return false; } int num = 0; int num2 = 0; int x = __instance.m_position.x; int y = __instance.m_position.y; int x2 = __instance.m_dimensions.x; int y2 = __instance.m_dimensions.y; int x3 = otherCollider.m_position.x; int y3 = otherCollider.m_position.y; int x4 = otherCollider.m_dimensions.x; int y4 = otherCollider.m_dimensions.y; int num3 = x3 + x4 - 1; int num4 = y3 + y4 - 1; int num5 = x3 - x; int num6 = y3 - y; int num7 = x2 - 1; int num8 = y2 - 1; int num9 = x3 - num7; int num10 = y3 - num8; float num11 = 0f; bool[] bits = __instance.m_bestPixels.m_bits; int width = __instance.m_bestPixels.m_width; bool isAabb = __instance.m_bestPixels.IsAabb; bool[] bits2 = otherCollider.m_bestPixels.m_bits; int width2 = otherCollider.m_bestPixels.m_width; bool isAabb2 = otherCollider.m_bestPixels.IsAabb; result = LinearCastResult.Pool.Allocate(); ((CastResult)result).MyPixelCollider = __instance; int count = stepList.Count; for (int i = 0; i < count; i++) { StepData val = stepList[i]; int x5 = val.deltaPos.x; int y5 = val.deltaPos.y; int num12 = num + x5; int num13 = num2 + y5; int num14 = x + num12; int num15 = y + num13; num11 += val.deltaTime; if (num14 < num9 || num14 > num3 || num15 < num10 || num15 > num4) { num = num12; num2 = num13; continue; } int num16 = x3 - num14; if (num16 < 0) { num16 = 0; } int num17 = y3 - num15; if (num17 < 0) { num17 = 0; } int num18 = num3 - num14; if (num18 > num7) { num18 = num7; } int num19 = num4 - num15; if (num19 > num8) { num19 = num8; } int num20 = num12 - num5; int num21 = num13 - num6; if (num16 < -num20) { num16 = -num20; } if (num17 < -num21) { num17 = -num21; } if (num18 >= x4 - num20) { num18 = x4 - num20 - 1; } if (num19 >= y4 - num21) { num19 = y4 - num21 - 1; } for (int j = num17; j <= num19; j++) { int num22 = j * width; int num23 = (num21 + j) * width2 + num20; for (int k = num16; k <= num18; k++) { if ((isAabb || bits[num22 + k]) && (isAabb2 || bits2[num23 + k])) { result.TimeUsed = num11; result.CollidedX = x5 != 0; result.CollidedY = y5 != 0; result.NewPixelsToMove = new IntVector2(num, num2); ((CastResult)result).OtherPixelCollider = otherCollider; ((CastResult)result).Contact = new Vector2(((float)(k + num14) + 0.5f) / 16f, ((float)(j + num15) + 0.5f) / 16f); ((CastResult)result).Normal = new Vector2((float)(-x5), (float)(-y5)); if (otherCollider.NormalModifier != null) { ((CastResult)result).Normal = otherCollider.NormalModifier(((CastResult)result).Normal); } __result = true; return false; } } } num = num12; num2 = num13; } result.NewPixelsToMove = new IntVector2(num, num2); __result = false; return false; } } [HarmonyPatch] internal static class LinearCastMemoryLeakFix { private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_PHYSICS_LEAK) { return false; } return true; } [HarmonyPatch(typeof(PhysicsEngine), "SingleCollision")] [HarmonyILManipulator] private static void PhysicsEngineSingleCollisionPatchIL(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); ILLabel val2 = default(ILLabel); if (val.TryGotoNext((MoveType)2, new Func[2] { (Instruction instr) => ILPatternMatchingExt.MatchCallvirt(instr, "LinearCast"), (Instruction instr) => ILPatternMatchingExt.MatchBrtrue(instr, ref val2) })) { val.Emit(OpCodes.Ldloca, 0); val.CallPrivate(typeof(LinearCastMemoryLeakFix), "FreeLCR"); } } private static void FreeLCR(ref LinearCastResult lcr) { if (lcr != null) { LinearCastResult.Pool.Free(ref lcr); } } } [HarmonyPatch] internal static class PixelMovementGeneratorOptimization { private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_PIXEL_MOVE) { return false; } return true; } [HarmonyPatch(typeof(PhysicsEngine), "PixelMovementGenerator", new Type[] { typeof(Vector2), typeof(Vector2), typeof(IntVector2), typeof(List) })] [HarmonyPrefix] private static bool FastPixelMovementGenerator(Vector2 remainder, Vector2 velocity, IntVector2 pixelsToMove, List stepList) { //IL_0004: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) int num = 0; int num2 = 0; int x = pixelsToMove.x; int y = pixelsToMove.y; int num3 = ((x > 0) ? 1 : ((x < 0) ? (-1) : 0)); int num4 = ((y > 0) ? 1 : ((y < 0) ? (-1) : 0)); float num5 = 1f / 32f * (float)num3; float num6 = 1f / 32f * (float)num4; float num7 = remainder.x; float num8 = remainder.y; float x2 = velocity.x; float y2 = velocity.y; float num9 = 1f / x2; float num10 = 1f / y2; IntVector2 val = default(IntVector2); ((IntVector2)(ref val))..ctor(num3, 0); IntVector2 val2 = default(IntVector2); ((IntVector2)(ref val2))..ctor(0, num4); stepList.Clear(); while (num != x || num2 != y) { float num11 = (num5 - num7) * num9; if (num11 < 0f) { num11 = 0f; } float num12 = (num6 - num8) * num10; if (num12 < 0f) { num12 = 0f; } if (num != x && (num2 == y || num11 < num12)) { num += num3; num7 = 0f - num5; num8 += num11 * y2; stepList.Add(new StepData(val, num11)); } else { num2 += num4; num7 += num12 * x2; num8 = 0f - num6; stepList.Add(new StepData(val2, num12)); } } return false; } } [HarmonyPatch] internal static class SetRotationAndScaleOptimization { private static readonly Vector2[] _Scratch = (Vector2[])(object)new Vector2[4]; private static readonly int[] _Scratch2 = new int[4]; private static readonly Vector2[] _ScratchVertices = (Vector2[])(object)new Vector2[4]; private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_PIXEL_ROTATE) { return false; } return true; } [HarmonyPatch(typeof(PixelCollider), "SetRotationAndScale")] [HarmonyPrefix] private static bool FastSetRotationAndScale(PixelCollider __instance, float rotation, Vector2 scale) { //IL_0008: 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_008d: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_0757: Unknown result type (might be due to invalid IL or missing references) //IL_0763: Unknown result type (might be due to invalid IL or missing references) //IL_078b: Unknown result type (might be due to invalid IL or missing references) //IL_0799: Unknown result type (might be due to invalid IL or missing references) BitArray2D val = ((rotation != 0f || scale.x != 1f || scale.y != 1f) ? __instance.m_modifiedPixels : __instance.m_basePixels); if (__instance.m_rotation == rotation && __instance.m_scale.x == scale.x && __instance.m_scale.y == scale.y && __instance.m_bestPixels == val && __instance.m_bestPixels != null && __instance.m_bestPixels.IsValid) { return false; } __instance.m_rotation = rotation; __instance.m_scale.x = scale.x; __instance.m_scale.y = scale.y; int width = __instance.m_basePixels.m_width; int height = __instance.m_basePixels.m_height; if (rotation == 0f && scale.x == 1f && scale.y == 1f) { __instance.m_bestPixels = __instance.m_basePixels; __instance.m_dimensions.x = width; __instance.m_dimensions.y = height; __instance.m_transformOffset.x = 0; __instance.m_transformOffset.y = 0; return false; } if (__instance.m_modifiedPixels == null) { __instance.m_modifiedPixels = new BitArray2D(false); } Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor((float)(-__instance.m_offset.x), (float)(-__instance.m_offset.y)); _Scratch[0].x = 0.5f; _Scratch[1].x = (float)width - 0.5f; _Scratch[2].x = (float)width - 0.5f; _Scratch[3].x = 0.5f; _Scratch[0].y = 0.5f; _Scratch[1].y = 0.5f; _Scratch[2].y = (float)height - 0.5f; _Scratch[3].y = (float)height - 0.5f; float num = rotation * ((float)Math.PI / 180f); float num2 = Mathf.Cos(num); float num3 = Mathf.Sin(num); for (int i = 0; i < 4; i++) { float num4 = _Scratch[i].x - val2.x; float num5 = _Scratch[i].y - val2.y; _Scratch[i].x = (num4 * num2 - num5 * num3) * scale.x + val2.x; _Scratch[i].y = (num4 * num3 + num5 * num2) * scale.y + val2.y; } float x = _Scratch[0].x; float x2 = _Scratch[0].x; float y = _Scratch[0].y; float y2 = _Scratch[0].y; for (int j = 1; j < 4; j++) { if (_Scratch[j].x < x) { x = _Scratch[j].x; } if (_Scratch[j].x > x2) { x2 = _Scratch[j].x; } if (_Scratch[j].y < y) { y = _Scratch[j].y; } if (_Scratch[j].y > y2) { y2 = _Scratch[j].y; } } int num6 = (int)Math.Floor(x); int num7 = (int)Math.Ceiling(x2); int num8 = (int)Math.Floor(y); int num9 = (int)Math.Ceiling(y2); int num10 = num7 - num6; int num11 = num9 - num8; BitArray2D modifiedPixels = __instance.m_modifiedPixels; modifiedPixels.m_width = num10; modifiedPixels.m_height = num11; int num12 = num10 * num11; if (modifiedPixels.m_bits == null || num12 > modifiedPixels.m_bits.Length) { modifiedPixels.m_bits = new bool[(int)((float)num12 * modifiedPixels.c_sizeScalar)]; } else { Array.Clear(modifiedPixels.m_bits, 0, num12); } modifiedPixels.IsValid = true; bool[] bits = modifiedPixels.m_bits; if (__instance.m_basePixels.IsAabb) { _Scratch[0].x -= num6; _Scratch[1].x -= num6; _Scratch[2].x -= num6; _Scratch[3].x -= num6; _Scratch[0].y -= num8; _Scratch[1].y -= num8; _Scratch[2].y -= num8; _Scratch[3].y -= num8; _Scratch2[0] = (_Scratch2[1] = (_Scratch2[2] = (_Scratch2[3] = 0))); for (int k = 0; k < num11; k++) { int num13 = 0; int num14 = 3; int l; for (l = 0; l < 4; l++) { if (((double)_Scratch[l].y < (double)k && (double)_Scratch[num14].y >= (double)k) || ((double)_Scratch[num14].y < (double)k && (double)_Scratch[l].y >= (double)k)) { _Scratch2[num13++] = (int)(_Scratch[l].x + ((float)k - _Scratch[l].y) / (_Scratch[num14].y - _Scratch[l].y) * (_Scratch[num14].x - _Scratch[l].x)); } num14 = l; } l = 0; while (l < num13 - 1) { if (_Scratch2[l] > _Scratch2[l + 1]) { int num15 = _Scratch2[l]; _Scratch2[l] = _Scratch2[l + 1]; _Scratch2[l + 1] = num15; if (l != 0) { l--; } } else { l++; } } for (l = 0; l < num13 && _Scratch2[l] < num10 - 1; l += 2) { if (_Scratch2[l + 1] > 0) { if (_Scratch2[l] < 0) { _Scratch2[l] = 0; } if (_Scratch2[l + 1] > num10 - 1) { _Scratch2[l + 1] = num10 - 1; } for (int m = _Scratch2[l]; m < _Scratch2[l + 1]; m++) { bits[m + k * num10] = true; } } } } } else { float num16 = val2.x - (float)num6; float num17 = val2.y - (float)num8; float num18 = (0f - rotation) * ((float)Math.PI / 180f); float num19 = Mathf.Cos(num18); float num20 = Mathf.Sin(num18); float num21 = 1f / scale.x; float num22 = 1f / scale.y; bool[] bits2 = __instance.m_basePixels.m_bits; int width2 = __instance.m_basePixels.m_width; for (int n = 0; n < num10; n++) { float num23 = (float)n + 0.5f - num16; for (int num24 = 0; num24 < num11; num24++) { float num25 = (float)num24 + 0.5f - num17; float num26 = (num23 * num19 - num25 * num20) * num21 + num16 + (float)num6; float num27 = (num23 * num20 + num25 * num19) * num22 + num17 + (float)num8; if (num26 < 0f || (int)num26 >= width || num27 < 0f || (int)num27 >= height) { bits[n + num24 * num10] = false; } else { bits[n + num24 * num10] = bits2[(int)num26 + (int)num27 * width2]; } } } } __instance.m_transformOffset.x = num6; __instance.m_transformOffset.y = num8; __instance.m_dimensions.x = num10; __instance.m_dimensions.y = num11; __instance.m_bestPixels = __instance.m_modifiedPixels; return false; } [HarmonyPatch(typeof(PixelCollider), "RegenerateFrom3dCollider")] [HarmonyILManipulator] private static void PixelColliderRegenerateFrom3dColliderPatchIL(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)0, new Func[2] { (Instruction instr) => ILPatternMatchingExt.MatchLdcI4(instr, 4), (Instruction instr) => ILPatternMatchingExt.MatchNewarr(instr) })) { val.RemoveRange(2); val.Emit(OpCodes.Ldsfld, typeof(SetRotationAndScaleOptimization).GetField("_ScratchVertices", BindingFlags.Static | BindingFlags.NonPublic)); } } } [HarmonyPatch] internal static class PointcastOptimizations { private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_POINTCAST) { return false; } return true; } [HarmonyPatch(typeof(PixelCollider), "AABBContainsPixel")] [HarmonyPrefix] private static bool PixelColliderAABBContainsPixelPatch(PixelCollider __instance, IntVector2 pixel, ref bool __result) { //IL_0001: 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_0033: 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) __result = pixel.x >= __instance.m_position.x && pixel.x < __instance.m_position.x + __instance.m_dimensions.x && pixel.y >= __instance.m_position.y && pixel.y < __instance.m_position.y + __instance.m_dimensions.y; return false; } [HarmonyPatch(typeof(PhysicsEngine), "Pointcast_CoarsePass")] [HarmonyPrefix] private static bool PhysicsEnginePointcast_CoarsePassPatch(PhysicsEngine __instance, ICollidableObject collidable, IntVector2 point, bool collideWithTriggers, int rayMask, CollisionLayer? sourceLayer, ref bool __result) { //IL_000e: 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) List pixelColliders = collidable.GetPixelColliders(); int count = pixelColliders.Count; int x = point.x; int y = point.y; for (int i = 0; i < count; i++) { PixelCollider val = pixelColliders[i]; if ((!val.IsTrigger || collideWithTriggers) && x >= val.m_position.x && x < val.m_position.x + val.m_dimensions.x && y >= val.m_position.y && y < val.m_position.y + val.m_dimensions.y && val.CanCollideWith(rayMask, sourceLayer) && (val.m_bestPixels.IsAabb || val.m_bestPixels.m_bits[x - val.m_position.x + (y - val.m_position.y) * val.m_bestPixels.m_width])) { __result = true; return false; } } __result = false; return false; } [HarmonyPatch(typeof(tk2dTileMap), "GetTileFracAtPosition")] [HarmonyPrefix] private static bool tk2dTileMapGetTileFracAtPositionPatch(tk2dTileMap __instance, Vector3 position, out float x, out float y, ref bool __result) { //IL_0001: 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) x = position.x; y = position.y; __result = x >= 0f && x <= (float)__instance.width && y >= 0f && y <= (float)__instance.height; return false; } [HarmonyPatch(typeof(tk2dTileMap), "GetTileAtPosition")] [HarmonyPrefix] private static bool tk2dTileMapGetTileAtPositionPatch(tk2dTileMap __instance, Vector3 position, out int x, out int y, ref bool __result) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_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) x = (int)position.x; y = (int)position.y; __result = position.x >= 0f && position.x <= (float)__instance.width && y >= 0 && y <= __instance.height; return false; } [HarmonyPatch(typeof(PhysicsEngine), "PixelToUnit", new Type[] { typeof(IntVector2) })] [HarmonyPrefix] private static bool PhysicsEnginePixelToUnitPatch(IntVector2 pixel, ref Vector2 __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_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) __result = new Vector2(0.0625f * (float)pixel.x, 0.0625f * (float)pixel.y); return false; } } public static class C { public static readonly bool DEBUG_BUILD = false; public const string MOD_NAME = "Gungeon Go Vroom"; public const string MOD_INT_NAME = "GungeonGoVroom"; public const string MOD_VERSION = "1.7.0"; public const string MOD_GUID = "pretzel.etg.ggv"; public const string MOD_PREFIX = "ggv"; public static readonly Color MOD_COLOR = new Color(0.4f, 0.4f, 0.7f); } [BepInPlugin("pretzel.etg.ggv", "GungeonGoVroom", "1.7.0")] [BepInDependency("etgmodding.etg.mtgapi", "1.9.2")] [BepInDependency("pretzel.etg.gunfig", "1.1.11")] public class Initialisation : BaseUnityPlugin { private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) try { Stopwatch stopwatch = Stopwatch.StartNew(); ConfigMenu.Init(); new Harmony("pretzel.etg.ggv").PatchAll(); stopwatch.Stop(); ETGModConsole.Log((object)("Initialized Gungeon Go Vroom v1.7.0 in " + (float)stopwatch.ElapsedMilliseconds / 1000f + " seconds"), false); } catch (Exception ex) { ETGModConsole.Log((object)ex.Message, false); ETGModConsole.Log((object)ex.StackTrace, false); } } } [HarmonyPatch] internal static class CustomTrailPooler { private class ScratchBuffer { private const int MAX_BUFFER = 20; private static readonly ScratchBuffer[] _Buffers = new ScratchBuffer[20]; private Vector3[] _vertices; private Vector2[] _uvs; private int[] _triangles; private Color[] _colors; public static void Obtain(int points, out Vector3[] vertices, out Vector2[] uvs, out int[] triangles, out Color[] colors) { int num = 0; int num2 = 1; while (points > num2) { num++; num2 *= 2; } ScratchBuffer scratchBuffer = _Buffers[num]; if (scratchBuffer == null) { scratchBuffer = (_Buffers[num] = new ScratchBuffer()); scratchBuffer._vertices = (Vector3[])(object)new Vector3[num2 * 2]; scratchBuffer._uvs = (Vector2[])(object)new Vector2[num2 * 2]; scratchBuffer._triangles = new int[(num2 - 1) * 6]; scratchBuffer._colors = (Color[])(object)new Color[num2 * 2]; } for (int i = 2 * points; i < 2 * num2; i++) { scratchBuffer._colors[i].a = 0f; } int num3 = (points - 1) * 6; int num4 = (num2 - 1) * 6; for (int j = num3; j < num4; j++) { scratchBuffer._triangles[j] = 0; } vertices = scratchBuffer._vertices; uvs = scratchBuffer._uvs; triangles = scratchBuffer._triangles; colors = scratchBuffer._colors; } } private static readonly LinkedList _PointPool = new LinkedList(); private static readonly LinkedList _ActiveNodes = new LinkedList(); private static readonly LinkedList> _ActiveTransforms = new LinkedList>(); private static readonly LinkedList> _InactiveTransforms = new LinkedList>(); private static readonly Dictionary>> _ActiveTransformMap = new Dictionary>>(); private const float _CLEANUP_RATE = 1f; private static float _NextCleanupTime = 0f; private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_TRAILS) { return false; } return true; } private static void CleanupOldTransforms(Transform currentTransform) { _ = _ActiveTransforms.Count; LinkedListNode> linkedListNode = _ActiveTransforms.First; while (linkedListNode != null) { LinkedListNode> linkedListNode2 = linkedListNode; linkedListNode = linkedListNode.Next; Tuple value = linkedListNode2.Value; Transform first = value.First; if (Object.op_Implicit((Object)(object)first) && ((Object)(object)first == (Object)(object)currentTransform || ((Component)first).gameObject.activeSelf || Object.op_Implicit((Object)(object)first.parent))) { continue; } Point[] second = value.Second; int num = second.Length; for (int i = 0; i < num && second[i] != null; i++) { second[i] = Return(second[i]); } if (Object.op_Implicit((Object)(object)first)) { CustomTrailRenderer component = ((Component)first).gameObject.GetComponent(); if (component != null) { component.numPoints = 0; } } _ActiveTransformMap.Remove(first); _ActiveTransforms.Remove(linkedListNode2); linkedListNode2.Value = null; _InactiveTransforms.AddLast(linkedListNode2); } } private static void RentElement(Point[] points, int index, Transform t) { //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown float realtimeSinceStartup = Time.realtimeSinceStartup; if (realtimeSinceStartup >= _NextCleanupTime) { CleanupOldTransforms(t); _NextCleanupTime = realtimeSinceStartup + 1f; } if (!_ActiveTransformMap.TryGetValue(t, out var value)) { if (_InactiveTransforms.Count == 0) { _InactiveTransforms.AddLast(new LinkedListNode>(null)); } value = _InactiveTransforms.Last; _InactiveTransforms.RemoveLast(); value.Value = new Tuple(t, points); _ActiveTransforms.AddLast(value); _ActiveTransformMap[t] = value; } if (_PointPool.Count == 0) { _PointPool.AddLast(new Point(t)); } LinkedListNode last = _PointPool.Last; _PointPool.RemoveLast(); Point value2 = last.Value; value2.position = t.position; value2.rotation = t.rotation; value2.timeCreated = BraveTime.ScaledTimeSinceStartup; last.Value = null; _ActiveNodes.AddLast(last); points[index] = value2; } private static Point Return(Point point) { LinkedListNode last = _ActiveNodes.Last; _ActiveNodes.RemoveLast(); last.Value = point; _PointPool.AddLast(last); return null; } private static void ReturnElement(Point[] points, int index) { points[index] = Return(points[index]); } [HarmonyPatch(typeof(CustomTrailRenderer), "Clear")] [HarmonyPrefix] private static void CustomTrailRendererClearPatch(CustomTrailRenderer __instance) { for (int num = __instance.numPoints - 1; num >= 0; num--) { __instance.points[num] = Return(__instance.points[num]); } __instance.numPoints = 0; } [HarmonyPatch(typeof(CustomTrailRenderer), "InsertPoint")] [HarmonyILManipulator] private static void CustomTrailRendererInsertPointPatchIL(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)0, new Func[2] { (Instruction instr) => ILPatternMatchingExt.MatchNewobj(instr), (Instruction instr) => ILPatternMatchingExt.MatchStelemRef(instr) })) { val.Remove(); val.Remove(); val.CallPrivate(typeof(CustomTrailPooler), "RentElement"); } } [HarmonyPatch(typeof(CustomTrailRenderer), "UpdateMesh")] [HarmonyPrefix] private static bool FastUpdateMesh(CustomTrailRenderer __instance) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_0467: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_047a: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Unknown result type (might be due to invalid IL or missing references) //IL_0440: Unknown result type (might be due to invalid IL or missing references) //IL_0450: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_0496: Unknown result type (might be due to invalid IL or missing references) //IL_049b: Unknown result type (might be due to invalid IL or missing references) //IL_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_04b9: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: Unknown result type (might be due to invalid IL or missing references) //IL_04c5: Unknown result type (might be due to invalid IL or missing references) //IL_05a0: Unknown result type (might be due to invalid IL or missing references) //IL_05a2: Unknown result type (might be due to invalid IL or missing references) //IL_05af: Unknown result type (might be due to invalid IL or missing references) //IL_05b1: Unknown result type (might be due to invalid IL or missing references) //IL_05b8: Unknown result type (might be due to invalid IL or missing references) //IL_05bd: Unknown result type (might be due to invalid IL or missing references) //IL_04de: Unknown result type (might be due to invalid IL or missing references) //IL_04ea: Unknown result type (might be due to invalid IL or missing references) //IL_04f1: Unknown result type (might be due to invalid IL or missing references) //IL_04f6: Unknown result type (might be due to invalid IL or missing references) //IL_050d: Unknown result type (might be due to invalid IL or missing references) //IL_0512: Unknown result type (might be due to invalid IL or missing references) //IL_05ff: Unknown result type (might be due to invalid IL or missing references) //IL_0606: Unknown result type (might be due to invalid IL or missing references) //IL_060d: Unknown result type (might be due to invalid IL or missing references) //IL_0612: Unknown result type (might be due to invalid IL or missing references) //IL_057d: Unknown result type (might be due to invalid IL or missing references) //IL_058c: Unknown result type (might be due to invalid IL or missing references) //IL_0593: Unknown result type (might be due to invalid IL or missing references) //IL_0598: Unknown result type (might be due to invalid IL or missing references) //IL_0532: Unknown result type (might be due to invalid IL or missing references) //IL_0537: Unknown result type (might be due to invalid IL or missing references) //IL_06e6: Unknown result type (might be due to invalid IL or missing references) //IL_06fa: Unknown result type (might be due to invalid IL or missing references) //IL_06ff: Unknown result type (might be due to invalid IL or missing references) //IL_0709: Unknown result type (might be due to invalid IL or missing references) //IL_0710: Unknown result type (might be due to invalid IL or missing references) //IL_0715: Unknown result type (might be due to invalid IL or missing references) //IL_071c: Unknown result type (might be due to invalid IL or missing references) //IL_0724: Unknown result type (might be due to invalid IL or missing references) //IL_0729: Unknown result type (might be due to invalid IL or missing references) //IL_072e: Unknown result type (might be due to invalid IL or missing references) //IL_0730: Unknown result type (might be due to invalid IL or missing references) //IL_0735: Unknown result type (might be due to invalid IL or missing references) //IL_0741: Unknown result type (might be due to invalid IL or missing references) //IL_0749: Unknown result type (might be due to invalid IL or missing references) //IL_074e: Unknown result type (might be due to invalid IL or missing references) //IL_0753: Unknown result type (might be due to invalid IL or missing references) //IL_0755: Unknown result type (might be due to invalid IL or missing references) //IL_075a: Unknown result type (might be due to invalid IL or missing references) //IL_0785: Unknown result type (might be due to invalid IL or missing references) //IL_078a: Unknown result type (might be due to invalid IL or missing references) //IL_079d: Unknown result type (might be due to invalid IL or missing references) //IL_07a2: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)__instance.mesh) || !Object.op_Implicit((Object)(object)((BraveBehaviour)__instance).renderer)) { Debug.LogError((object)("attempted to update CustomTrailRenderer mesh for object " + ((Object)((Component)__instance).gameObject).name + " without a mesh and/or renderer, selfdestructing -- tell Captain Pretzel!")); Component[] components = ((Component)__instance).gameObject.GetComponents(); foreach (Component val in components) { Debug.LogError((object)(" have component " + ((object)val).GetType().Name)); } Object.Destroy((Object)(object)__instance); return false; } if (Object.op_Implicit((Object)(object)__instance.specRigidbody)) { Quaternion rotation = ((BraveBehaviour)__instance.specRigidbody).transform.rotation; if (((Quaternion)(ref rotation)).eulerAngles.z != 0f) { Transform transform = ((BraveBehaviour)__instance).transform; rotation = ((BraveBehaviour)__instance.specRigidbody).transform.rotation; transform.localRotation = Quaternion.Euler(0f, 0f, 0f - ((Quaternion)(ref rotation)).eulerAngles.z); } } if (!__instance.emit) { __instance.emittingDone = true; } if (__instance.emittingDone) { __instance.emit = false; } int num = 0; for (int num2 = __instance.numPoints - 1; num2 >= 0; num2--) { Point val2 = __instance.points[num2]; if (val2 != null && val2.timeAlive < __instance.lifeTime) { break; } num++; } if (num > 1) { int num3 = __instance.numPoints - num + 1; while (__instance.numPoints > num3) { ReturnElement(__instance.points, __instance.numPoints - 1); __instance.numPoints--; } } if (__instance.numPoints > __instance.optimizeCount) { __instance.maxAngle += __instance.optimizeAngleInterval; __instance.maxVertexDistance += __instance.optimizeDistanceInterval; __instance.optimizeCount++; } if (__instance.emit) { if (__instance.numPoints == 0) { Point[] points = __instance.points; int i = __instance.numPoints; __instance.numPoints = i + 1; RentElement(points, i, ((BraveBehaviour)__instance).transform); Point[] points2 = __instance.points; i = __instance.numPoints; __instance.numPoints = i + 1; RentElement(points2, i, ((BraveBehaviour)__instance).transform); } if (__instance.numPoints == 1) { __instance.InsertPoint(); } bool flag = false; Vector3 val3 = __instance.points[1].position - ((BraveBehaviour)__instance).transform.position; float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude; if (sqrMagnitude > __instance.minVertexDistance * __instance.minVertexDistance) { if (sqrMagnitude > __instance.maxVertexDistance * __instance.maxVertexDistance) { flag = true; } else if (Quaternion.Angle(((BraveBehaviour)__instance).transform.rotation, __instance.points[1].rotation) > __instance.maxAngle) { flag = true; } } if (flag) { if (__instance.numPoints == __instance.points.Length) { Array.Resize(ref __instance.points, __instance.points.Length + 50); } __instance.InsertPoint(); } else { __instance.points[0].Update(((BraveBehaviour)__instance).transform); } } if (__instance.numPoints < 2) { ((BraveBehaviour)__instance).renderer.enabled = false; return false; } ((BraveBehaviour)__instance).renderer.enabled = true; __instance.lifeTimeRatio = ((__instance.lifeTime != 0f) ? (1f / __instance.lifeTime) : 0f); if (!__instance.emit) { return false; } ScratchBuffer.Obtain(__instance.numPoints, out var vertices, out var uvs, out var triangles, out var colors); float num4 = 1f / (__instance.points[__instance.numPoints - 1].timeAlive - __instance.points[0].timeAlive); for (int j = 0; j < __instance.numPoints; j++) { Point val4 = __instance.points[j]; float num5 = val4.timeAlive * __instance.lifeTimeRatio; Vector3 val5 = ((j == 0 && __instance.numPoints > 1) ? (__instance.points[j + 1].position - __instance.points[j].position) : ((j == __instance.numPoints - 1 && __instance.numPoints > 1) ? (__instance.points[j].position - __instance.points[j - 1].position) : ((__instance.numPoints <= 2) ? Vector3.right : ((__instance.points[j + 1].position - __instance.points[j].position + (__instance.points[j].position - __instance.points[j - 1].position)) * 0.5f)))); Color val6; if (__instance.colors.Length == 0) { val6 = Color.Lerp(Color.white, Color.clear, num5); } else if (__instance.colors.Length == 1) { val6 = Color.Lerp(__instance.colors[0], Color.clear, num5); } else if (__instance.colors.Length == 2) { val6 = Color.Lerp(__instance.colors[0], __instance.colors[1], num5); } else if (num5 <= 0f) { val6 = __instance.colors[0]; } else if (num5 >= 1f) { val6 = __instance.colors[__instance.colors.Length - 1]; } else { float num6 = num5 * (float)(__instance.colors.Length - 1); int num7 = Mathf.Min(__instance.colors.Length - 2, (int)Mathf.Floor(num6)); float num8 = Mathf.InverseLerp((float)num7, (float)(num7 + 1), num6); val6 = Color.Lerp(__instance.colors[num7], __instance.colors[num7 + 1], num8); } colors[j * 2] = val6; colors[j * 2 + 1] = val6; Vector3 val7 = val4.position; if (j > 0 && j == __instance.numPoints - 1) { float num9 = Mathf.InverseLerp(__instance.points[j - 1].timeAlive, val4.timeAlive, __instance.lifeTime); val7 = Vector3.Lerp(__instance.points[j - 1].position, val4.position, num9); } float num10; if (__instance.widths.Length == 0) { num10 = 1f; } else if (__instance.widths.Length == 1) { num10 = __instance.widths[0]; } else if (__instance.widths.Length == 2) { num10 = Mathf.Lerp(__instance.widths[0], __instance.widths[1], num5); } else if (num5 <= 0f) { num10 = __instance.widths[0]; } else if (num5 >= 1f) { num10 = __instance.widths[__instance.widths.Length - 1]; } else { float num11 = num5 * (float)(__instance.widths.Length - 1); int num12 = (int)Mathf.Floor(num11); float num13 = Mathf.InverseLerp((float)num12, (float)(num12 + 1), num11); num10 = Mathf.Lerp(__instance.widths[num12], __instance.widths[num12 + 1], num13); } val5 = Vector3Extensions.RotateBy(((Vector3)(ref val5)).normalized, Quaternion.Euler(0f, 0f, 90f)) * 0.5f * num10; vertices[j * 2] = val7 - ((BraveBehaviour)__instance).transform.position + val5; vertices[j * 2 + 1] = val7 - ((BraveBehaviour)__instance).transform.position - val5; float num14 = (val4.timeAlive - __instance.points[0].timeAlive) * num4; uvs[j * 2] = new Vector2(num14, 0f); uvs[j * 2 + 1] = new Vector2(num14, 1f); if (j > 0) { int num15 = (j - 1) * 6; int num16 = j * 2; triangles[num15] = num16 - 2; triangles[num15 + 1] = num16 - 1; triangles[num15 + 2] = num16; triangles[num15 + 3] = num16 + 1; triangles[num15 + 4] = num16; triangles[num15 + 5] = num16 - 1; } } __instance.mesh.Clear(); __instance.mesh.vertices = vertices; __instance.mesh.colors = colors; __instance.mesh.uv = uvs; __instance.mesh.triangles = triangles; return false; } } [HarmonyPatch] internal static class RaidenBeamPooler { private static readonly LinkedList _BonePool = new LinkedList(); private static int _TotalBones = 0; private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_BEAMS) { return false; } return true; } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPostfix] private static void NewBoneCounter() { } private static void RentAndAdd(LinkedList bones, Vector2 pos) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_0024: Expected O, but got Unknown if (_BonePool.Count == 0) { _BonePool.AddLast(new Bone(default(Vector2))); } LinkedListNode last = _BonePool.Last; _BonePool.RemoveLast(); Bone value = last.Value; value.pos = pos; value.normal = default(Vector2); bones.AddLast(last); } private static void ReturnAll(LinkedList bones) { if (bones != null) { while (bones.Count > 0) { LinkedListNode last = bones.Last; bones.RemoveLast(); _BonePool.AddLast(last); } } } private static bool ReplaceConstructor(this ILCursor cursor) { if (!cursor.TryGotoNext((MoveType)0, new Func[3] { (Instruction instr) => ILPatternMatchingExt.MatchNewobj(instr), (Instruction instr) => ILPatternMatchingExt.MatchCallvirt(instr, (MethodBase)typeof(LinkedList<>).MakeGenericType(typeof(Bone)).GetMethod("AddLast", new Type[1] { typeof(Bone) })), (Instruction instr) => ILPatternMatchingExt.MatchPop(instr) })) { return false; } cursor.Remove(); cursor.Remove(); cursor.Remove(); cursor.CallPrivate(typeof(RaidenBeamPooler), "RentAndAdd"); return true; } private static bool ReplaceClear(this ILCursor cursor) { if (!cursor.TryGotoNext((MoveType)0, new Func[1] { (Instruction instr) => ILPatternMatchingExt.MatchCallvirt(instr, (MethodBase)typeof(LinkedList<>).MakeGenericType(typeof(Bone)).GetMethod("Clear")) })) { return false; } cursor.Remove(); cursor.CallPrivate(typeof(RaidenBeamPooler), "ReturnAll"); return true; } [HarmonyPatch(typeof(RaidenBeamController), "DrawBezierCurve")] [HarmonyILManipulator] private static void StartPatch(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor cursor = new ILCursor(il); if (cursor.ReplaceConstructor()) { cursor.ReplaceConstructor(); } } [HarmonyPatch(typeof(RaidenBeamController), "HandleBeamFrame")] [HarmonyILManipulator] private static void HandleBeamFramePatch(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown ReplaceClear(new ILCursor(il)); } [HarmonyPatch(typeof(RaidenBeamController), "OnDestroy")] [HarmonyPrefix] private static void BasicBeamControllerOnDestroyPatch(RaidenBeamController __instance) { if (__instance.m_bones != null) { ReturnAll(__instance.m_bones); } } } [HarmonyPatch] internal static class ReverseBeamPooler { private static readonly LinkedList _BonePool = new LinkedList(); private static int _TotalBones = 0; private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_BEAMS) { return false; } return true; } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPostfix] private static void NewBoneCounter() { } private static void RentAndAdd(LinkedList bones, Vector2 pos) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_0024: Expected O, but got Unknown if (_BonePool.Count == 0) { _BonePool.AddLast(new Bone(default(Vector2))); } LinkedListNode last = _BonePool.Last; _BonePool.RemoveLast(); Bone value = last.Value; value.pos = pos; value.normal = default(Vector2); bones.AddLast(last); } private static void ReturnAll(LinkedList bones) { if (bones != null) { while (bones.Count > 0) { LinkedListNode last = bones.Last; bones.RemoveLast(); _BonePool.AddLast(last); } } } private static bool ReplaceConstructor(this ILCursor cursor) { if (!cursor.TryGotoNext((MoveType)0, new Func[3] { (Instruction instr) => ILPatternMatchingExt.MatchNewobj(instr), (Instruction instr) => ILPatternMatchingExt.MatchCallvirt(instr, (MethodBase)typeof(LinkedList<>).MakeGenericType(typeof(Bone)).GetMethod("AddLast", new Type[1] { typeof(Bone) })), (Instruction instr) => ILPatternMatchingExt.MatchPop(instr) })) { return false; } cursor.Remove(); cursor.Remove(); cursor.Remove(); cursor.CallPrivate(typeof(ReverseBeamPooler), "RentAndAdd"); return true; } private static bool ReplaceClear(this ILCursor cursor) { if (!cursor.TryGotoNext((MoveType)0, new Func[1] { (Instruction instr) => ILPatternMatchingExt.MatchCallvirt(instr, (MethodBase)typeof(LinkedList<>).MakeGenericType(typeof(Bone)).GetMethod("Clear")) })) { return false; } cursor.Remove(); cursor.CallPrivate(typeof(ReverseBeamPooler), "ReturnAll"); return true; } [HarmonyPatch(typeof(ReverseBeamController), "DrawBezierCurve")] [HarmonyILManipulator] private static void StartPatch(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor cursor = new ILCursor(il); if (cursor.ReplaceConstructor()) { cursor.ReplaceConstructor(); } } [HarmonyPatch(typeof(ReverseBeamController), "HandleBeamFrame")] [HarmonyILManipulator] private static void HandleBeamFramePatch(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown ReplaceClear(new ILCursor(il)); } [HarmonyPatch(typeof(ReverseBeamController), "OnDestroy")] [HarmonyPrefix] private static void BasicBeamControllerOnDestroyPatch(ReverseBeamController __instance) { if (__instance.m_bones != null) { ReturnAll(__instance.m_bones); } } } [HarmonyPatch] internal static class BasicBeamPooler { private static readonly LinkedList _BonePool = new LinkedList(); private static int _TotalBones = 0; private static readonly Type _BoneListType = typeof(LinkedList<>).MakeGenericType(typeof(BeamBone)); private static readonly MethodInfo _AddFirstBone = _BoneListType.GetMethod("AddFirst", new Type[1] { typeof(BeamBone) }); private static readonly MethodInfo _AddLastBone = _BoneListType.GetMethod("AddLast", new Type[1] { typeof(BeamBone) }); private static readonly MethodInfo _AddBeforeBone = _BoneListType.GetMethod("AddBefore", new Type[2] { typeof(LinkedListNode), typeof(BeamBone) }); private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_BEAMS) { return false; } return true; } private static LinkedListNode RentInt(float posX, float rotationAngle, int subtileNum) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown if (_BonePool.Count == 0) { _BonePool.AddLast(new BeamBone(0f, 0f, 0)); } LinkedListNode? last = _BonePool.Last; _BonePool.RemoveLast(); BeamBone value = last.Value; value.PosX = posX; value.RotationAngle = rotationAngle; value.Position = default(Vector2); value.Velocity = default(Vector2); value.SubtileNum = subtileNum; value.HomingRadius = 0f; value.HomingAngularVelocity = 0f; value.HomingDampenMotion = false; return last; } private static void RentIntAndAddFirst(LinkedList bones, float posX, float rotationAngle, int subtileNum) { bones.AddFirst(RentInt(posX, rotationAngle, subtileNum)); } private static void RentIntAndAddLast(LinkedList bones, float posX, float rotationAngle, int subtileNum) { bones.AddLast(RentInt(posX, rotationAngle, subtileNum)); } private static LinkedListNode RentVec(float posX, Vector2 position, Vector2 velocity) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown if (_BonePool.Count == 0) { _BonePool.AddLast(new BeamBone(0f, 0f, 0)); } LinkedListNode? last = _BonePool.Last; _BonePool.RemoveLast(); BeamBone value = last.Value; value.PosX = posX; value.RotationAngle = 0f; value.Position = position; value.Velocity = velocity; value.SubtileNum = 0; value.HomingRadius = 0f; value.HomingAngularVelocity = 0f; value.HomingDampenMotion = false; return last; } private static void RentVecAndAddLast(LinkedList bones, float posX, Vector2 position, Vector2 velocity) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) bones.AddLast(RentVec(posX, position, velocity)); } private static LinkedListNode RentCopy(BeamBone other) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown if (_BonePool.Count == 0) { _BonePool.AddLast(new BeamBone(0f, 0f, 0)); } LinkedListNode? last = _BonePool.Last; _BonePool.RemoveLast(); BeamBone value = last.Value; value.PosX = other.PosX; value.RotationAngle = other.RotationAngle; value.Position = other.Position; value.Velocity = other.Velocity; value.SubtileNum = other.SubtileNum; value.HomingRadius = other.HomingRadius; value.HomingAngularVelocity = other.HomingAngularVelocity; value.HomingDampenMotion = other.HomingDampenMotion; return last; } private static void ReturnFirst(LinkedList bones) { if (bones != null && bones.Count != 0) { LinkedListNode first = bones.First; bones.Remove(first); _BonePool.AddLast(first); } } private static void ReturnLast(LinkedList bones) { if (bones != null && bones.Count != 0) { LinkedListNode last = bones.Last; bones.Remove(last); _BonePool.AddLast(last); } } private static void ReturnAll(LinkedList bones) { if (bones != null) { while (bones.Count > 0) { LinkedListNode last = bones.Last; bones.RemoveLast(); _BonePool.AddLast(last); } } } [HarmonyPatch(typeof(BasicBeamController), "Start")] [HarmonyILManipulator] private static void StartPatch(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor cursor = new ILCursor(il); if (cursor.ReplaceNextIntConstructorAndAddFirst()) { cursor.ReplaceNextIntConstructorAndAddLast(); } } [HarmonyPatch(typeof(BasicBeamController), "SeparateBeam")] [HarmonyILManipulator] private static void SeparateBeamPatch(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); VariableDefinition val2 = val.ReplaceNextConstructionWithRental(il, "RentCopy"); if (val2 != null && val.TryGotoNext((MoveType)0, new Func[3] { (Instruction instr) => ILPatternMatchingExt.MatchLdloc(instr, 2), (Instruction instr) => ILPatternMatchingExt.MatchCallvirt(instr, (MethodBase)_AddFirstBone), (Instruction instr) => ILPatternMatchingExt.MatchPop(instr) })) { val.Remove(); val.Remove(); val.Remove(); val.Emit(OpCodes.Ldloc, val2); val.CallPrivate(typeof(BasicBeamPooler), "AddFirstNode"); } } [HarmonyPatch(typeof(BasicBeamController), "HandleBeamFrame")] [HarmonyILManipulator] private static void HandleBeamFramePatch(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (!val.ReplaceNextIntConstructorAndAddFirst() || !val.ReplaceNextRemoveLast()) { return; } VariableDefinition val2 = val.ReplaceNextConstructionWithRental(il, "RentInt"); if (val2 == null || !val.TryGotoNext((MoveType)0, new Func[2] { (Instruction instr) => ILPatternMatchingExt.MatchLdloc(instr, 23), (Instruction instr) => ILPatternMatchingExt.MatchCallvirt(instr, (MethodBase)_AddBeforeBone) })) { return; } val.Remove(); val.Remove(); val.Emit(OpCodes.Ldloc, val2); val.CallPrivate(typeof(BasicBeamPooler), "AddBeforeNode"); val.Emit(OpCodes.Ldloc, val2); if (val.ReplaceNextIntConstructorAndAddFirst() && val.ReplaceNextRemoveFirst() && val.ReplaceNextRemoveLast() && val.ReplaceNextClear() && val.ReplaceVecConstructorAndAddLast()) { VariableDefinition val3 = val.ReplaceNextConstructionWithRental(il, "RentVec"); if (val3 != null && val.TryGotoNext((MoveType)0, new Func[3] { (Instruction instr) => ILPatternMatchingExt.MatchLdloc(instr, 49), (Instruction instr) => ILPatternMatchingExt.MatchCallvirt(instr, (MethodBase)_AddLastBone), (Instruction instr) => ILPatternMatchingExt.MatchPop(instr) })) { val.Remove(); val.Remove(); val.Remove(); val.Emit(OpCodes.Ldloc, val3); val.CallPrivate(typeof(BasicBeamPooler), "AddLastNode"); val.ReplaceNextRemoveLast(); } } } [HarmonyPatch(typeof(BasicBeamController), "OnDestroy")] [HarmonyPrefix] private static void BasicBeamControllerOnDestroyPatch(BasicBeamController __instance) { if (__instance.m_bones != null) { ReturnAll(__instance.m_bones); } } private static bool ReplaceNextConstructor(this ILCursor cursor, MethodInfo oldAdd, string newAdd) { if (!cursor.TryGotoNext((MoveType)0, new Func[3] { (Instruction instr) => ILPatternMatchingExt.MatchNewobj(instr), (Instruction instr) => ILPatternMatchingExt.MatchCallvirt(instr, (MethodBase)oldAdd), (Instruction instr) => ILPatternMatchingExt.MatchPop(instr) })) { return false; } cursor.Remove(); cursor.Remove(); cursor.Remove(); cursor.CallPrivate(typeof(BasicBeamPooler), newAdd); return true; } private static bool ReplaceNextMethod(this ILCursor cursor, string oldMethod, string newMethod) { if (!cursor.TryGotoNext((MoveType)0, new Func[1] { (Instruction instr) => ILPatternMatchingExt.MatchCallvirt(instr, (MethodBase)_BoneListType.GetMethod(oldMethod)) })) { return false; } cursor.Remove(); cursor.CallPrivate(typeof(BasicBeamPooler), newMethod); return true; } private static VariableDefinition ReplaceNextConstructionWithRental(this ILCursor cursor, ILContext il, string rentalMethod) { //IL_0053: 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) if (!cursor.TryGotoNext((MoveType)0, new Func[1] { (Instruction instr) => ILPatternMatchingExt.MatchNewobj(instr) })) { return null; } cursor.Remove(); cursor.CallPrivate(typeof(BasicBeamPooler), rentalMethod); VariableDefinition val = il.DeclareLocal>(); cursor.Emit(OpCodes.Stloc, val); cursor.Emit(OpCodes.Ldloc, val); cursor.CallPrivate(typeof(BasicBeamPooler), "GetValue"); return val; } private static BeamBone GetValue(LinkedListNode node) { return node.Value; } private static void AddFirstNode(LinkedList list, LinkedListNode node) { list.AddFirst(node); } private static void AddLastNode(LinkedList list, LinkedListNode node) { list.AddLast(node); } private static void AddBeforeNode(LinkedList list, LinkedListNode prev, LinkedListNode node) { list.AddBefore(prev, node); } private static bool ReplaceNextRemoveFirst(this ILCursor cursor) { return cursor.ReplaceNextMethod("RemoveFirst", "ReturnFirst"); } private static bool ReplaceNextRemoveLast(this ILCursor cursor) { return cursor.ReplaceNextMethod("RemoveLast", "ReturnLast"); } private static bool ReplaceNextClear(this ILCursor cursor) { return cursor.ReplaceNextMethod("Clear", "ReturnAll"); } private static bool ReplaceNextIntConstructorAndAddFirst(this ILCursor cursor) { return cursor.ReplaceNextConstructor(_AddFirstBone, "RentIntAndAddFirst"); } private static bool ReplaceNextIntConstructorAndAddLast(this ILCursor cursor) { return cursor.ReplaceNextConstructor(_AddLastBone, "RentIntAndAddLast"); } private static bool ReplaceVecConstructorAndAddLast(this ILCursor cursor) { return cursor.ReplaceNextConstructor(_AddLastBone, "RentVecAndAddLast"); } } [HarmonyPatch] internal static class BeamSpriteOptimizations { private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_BEAMS) { return false; } return true; } [HarmonyPatch(typeof(BasicBeamController), "SetTiledSpriteGeom")] [HarmonyPrefix] private static bool BasicBeamControllerSetTiledSpriteGeomPatch(BasicBeamController __instance, Vector3[] pos, Vector2[] uv, int offset, out Vector3 boundsCenter, out Vector3 boundsExtents, tk2dSpriteDefinition spriteDef, Vector3 scale, Vector2 dimensions, Anchor anchor, float colliderOffsetZ, float colliderExtentZ) { //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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Invalid comparison between Unknown and I4 //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0188: 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_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Invalid comparison between Unknown and I4 //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Invalid comparison between Unknown and I4 //IL_0b4d: Unknown result type (might be due to invalid IL or missing references) //IL_0b52: Unknown result type (might be due to invalid IL or missing references) //IL_0b77: Unknown result type (might be due to invalid IL or missing references) //IL_0b7c: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Invalid comparison between Unknown and I4 //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Invalid comparison between Unknown and I4 //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Invalid comparison between Unknown and I4 //IL_042e: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_047c: Invalid comparison between Unknown and I4 //IL_0437: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_0450: Unknown result type (might be due to invalid IL or missing references) //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_0461: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_03f4: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_0726: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_07f6: Unknown result type (might be due to invalid IL or missing references) //IL_0803: Unknown result type (might be due to invalid IL or missing references) //IL_080a: Unknown result type (might be due to invalid IL or missing references) //IL_080f: Unknown result type (might be due to invalid IL or missing references) //IL_0819: Unknown result type (might be due to invalid IL or missing references) //IL_0826: Unknown result type (might be due to invalid IL or missing references) //IL_0833: Unknown result type (might be due to invalid IL or missing references) //IL_0838: Unknown result type (might be due to invalid IL or missing references) //IL_0733: Unknown result type (might be due to invalid IL or missing references) //IL_0748: Unknown result type (might be due to invalid IL or missing references) //IL_074d: Unknown result type (might be due to invalid IL or missing references) //IL_0752: Unknown result type (might be due to invalid IL or missing references) //IL_075c: Unknown result type (might be due to invalid IL or missing references) //IL_0765: Unknown result type (might be due to invalid IL or missing references) //IL_077f: Unknown result type (might be due to invalid IL or missing references) //IL_0784: Unknown result type (might be due to invalid IL or missing references) //IL_0789: Unknown result type (might be due to invalid IL or missing references) //IL_0793: Unknown result type (might be due to invalid IL or missing references) //IL_07a8: Unknown result type (might be due to invalid IL or missing references) //IL_07ad: Unknown result type (might be due to invalid IL or missing references) //IL_07b2: Unknown result type (might be due to invalid IL or missing references) //IL_07bc: Unknown result type (might be due to invalid IL or missing references) //IL_07c5: Unknown result type (might be due to invalid IL or missing references) //IL_07df: Unknown result type (might be due to invalid IL or missing references) //IL_07e4: Unknown result type (might be due to invalid IL or missing references) //IL_07e9: Unknown result type (might be due to invalid IL or missing references) //IL_0876: Unknown result type (might be due to invalid IL or missing references) //IL_087c: Invalid comparison between Unknown and I4 //IL_0843: Unknown result type (might be due to invalid IL or missing references) //IL_08d3: Unknown result type (might be due to invalid IL or missing references) //IL_08d5: Unknown result type (might be due to invalid IL or missing references) //IL_08df: Unknown result type (might be due to invalid IL or missing references) //IL_08e6: Unknown result type (might be due to invalid IL or missing references) //IL_08ed: Unknown result type (might be due to invalid IL or missing references) //IL_08f2: Unknown result type (might be due to invalid IL or missing references) //IL_08fc: Unknown result type (might be due to invalid IL or missing references) //IL_0903: Unknown result type (might be due to invalid IL or missing references) //IL_090a: Unknown result type (might be due to invalid IL or missing references) //IL_090f: Unknown result type (might be due to invalid IL or missing references) //IL_0919: Unknown result type (might be due to invalid IL or missing references) //IL_091b: Unknown result type (might be due to invalid IL or missing references) //IL_0881: Unknown result type (might be due to invalid IL or missing references) //IL_0883: Unknown result type (might be due to invalid IL or missing references) //IL_088d: Unknown result type (might be due to invalid IL or missing references) //IL_0894: Unknown result type (might be due to invalid IL or missing references) //IL_089b: Unknown result type (might be due to invalid IL or missing references) //IL_08a0: Unknown result type (might be due to invalid IL or missing references) //IL_08aa: Unknown result type (might be due to invalid IL or missing references) //IL_08b1: Unknown result type (might be due to invalid IL or missing references) //IL_08b8: Unknown result type (might be due to invalid IL or missing references) //IL_08bd: Unknown result type (might be due to invalid IL or missing references) //IL_08c7: Unknown result type (might be due to invalid IL or missing references) //IL_08c9: Unknown result type (might be due to invalid IL or missing references) //IL_0854: Unknown result type (might be due to invalid IL or missing references) //IL_085f: Unknown result type (might be due to invalid IL or missing references) //IL_0563: Unknown result type (might be due to invalid IL or missing references) //IL_0568: Unknown result type (might be due to invalid IL or missing references) //IL_056c: Unknown result type (might be due to invalid IL or missing references) //IL_0571: Unknown result type (might be due to invalid IL or missing references) //IL_0928: Unknown result type (might be due to invalid IL or missing references) //IL_05bc: Unknown result type (might be due to invalid IL or missing references) //IL_05c3: Unknown result type (might be due to invalid IL or missing references) //IL_05ca: Unknown result type (might be due to invalid IL or missing references) //IL_05d1: Unknown result type (might be due to invalid IL or missing references) //IL_05df: Unknown result type (might be due to invalid IL or missing references) //IL_05e6: Unknown result type (might be due to invalid IL or missing references) //IL_05ed: Unknown result type (might be due to invalid IL or missing references) //IL_05f4: Unknown result type (might be due to invalid IL or missing references) //IL_067b: Unknown result type (might be due to invalid IL or missing references) //IL_0688: Unknown result type (might be due to invalid IL or missing references) //IL_0692: Unknown result type (might be due to invalid IL or missing references) //IL_0697: Unknown result type (might be due to invalid IL or missing references) //IL_06a7: Unknown result type (might be due to invalid IL or missing references) //IL_06b4: Unknown result type (might be due to invalid IL or missing references) //IL_06be: Unknown result type (might be due to invalid IL or missing references) //IL_06c3: Unknown result type (might be due to invalid IL or missing references) //IL_06d3: Unknown result type (might be due to invalid IL or missing references) //IL_06e0: Unknown result type (might be due to invalid IL or missing references) //IL_06ea: Unknown result type (might be due to invalid IL or missing references) //IL_06ef: Unknown result type (might be due to invalid IL or missing references) //IL_06ff: Unknown result type (might be due to invalid IL or missing references) //IL_070c: Unknown result type (might be due to invalid IL or missing references) //IL_0716: Unknown result type (might be due to invalid IL or missing references) //IL_071b: Unknown result type (might be due to invalid IL or missing references) //IL_0588: Unknown result type (might be due to invalid IL or missing references) //IL_0595: Unknown result type (might be due to invalid IL or missing references) //IL_059a: Unknown result type (might be due to invalid IL or missing references) //IL_059f: Unknown result type (might be due to invalid IL or missing references) //IL_05a1: Unknown result type (might be due to invalid IL or missing references) //IL_05ae: Unknown result type (might be due to invalid IL or missing references) //IL_05b3: Unknown result type (might be due to invalid IL or missing references) //IL_05b8: Unknown result type (might be due to invalid IL or missing references) boundsCenter = Vector3.zero; boundsExtents = Vector3.zero; Vector2 val = Vector3Extensions.XY(((BraveBehaviour)__instance).transform.position); int num = Mathf.RoundToInt(spriteDef.untrimmedBoundsDataExtents.x / spriteDef.texelSize.x) / __instance.m_beamQuadPixelWidth; int num2 = Mathf.CeilToInt(dimensions.x / (float)__instance.m_beamQuadPixelWidth); int num3 = Mathf.CeilToInt((float)num2 / (float)num); if ((int)__instance.TileType == 2) { num2 = __instance.m_bones.Count - 1; _ = __instance.m_bones; num3 = 0; for (LinkedListNode linkedListNode = __instance.m_bones.First; linkedListNode != null; linkedListNode = linkedListNode.Next) { if (linkedListNode.Value.SubtileNum == 0) { num3++; } } if (__instance.m_bones.First.Value.SubtileNum != 0) { num3++; } if (__instance.m_bones.Last.Value.SubtileNum == 0) { num3--; } } Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(dimensions.x * spriteDef.texelSize.x * scale.x, dimensions.y * spriteDef.texelSize.y * scale.y); Vector2 val3 = Vector2.Scale(spriteDef.texelSize, Vector2.op_Implicit(scale)) * 0.1f; Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor((float)__instance.m_beamQuadPixelWidth * spriteDef.texelSize.x, spriteDef.untrimmedBoundsDataExtents.y, spriteDef.untrimmedBoundsDataExtents.z); val4 = Vector3.Scale(val4, scale); float num4 = 0f; Quaternion val5 = Quaternion.Euler(0f, 0f, Vector2Extensions.ToAngle(((BeamController)__instance).Direction)); LinkedListNode linkedListNode2 = __instance.m_bones.First; LinkedListNode linkedListNode3 = linkedListNode2?.Next; int num5 = offset; float num6 = 1f / (float)__instance.m_beamSpriteSubtileWidth; float x = scale.x; float num7 = scale.y * __instance.m_projectileScale; float z = scale.z; tk2dSpriteAnimationClip val6 = (__instance.UsesBeamStartAnimation ? ((BraveBehaviour)__instance).spriteAnimator.GetClipByName(__instance.CurrentBeamStartAnimation) : null); tk2dSpriteAnimationClip val7 = (__instance.UsesBeamEndAnimation ? ((BraveBehaviour)__instance).spriteAnimator.GetClipByName(__instance.CurrentBeamEndAnimation) : null); for (int i = 0; i < num3; i++) { int num8 = 0; int num9 = num - 1; if ((int)__instance.TileType == 1) { if (i == 0 && num2 % num != 0) { num8 = num - num2 % num; } } else if ((int)__instance.TileType == 0) { if (i == num3 - 1 && num2 % num != 0) { num9 = num2 % num - 1; } } else if ((int)__instance.TileType == 2) { if (i == 0) { num8 = linkedListNode2.Value.SubtileNum; } if (i == num3 - 1) { num9 = __instance.m_bones.Last.Previous.Value.SubtileNum; } } tk2dSpriteDefinition val8 = spriteDef; if (val6 != null && i == 0) { val8 = ((tk2dBaseSprite)__instance.m_beamSprite).Collection.spriteDefinitions[val6.frames[Mathf.Min(val6.frames.Length - 1, ((BraveBehaviour)__instance).spriteAnimator.CurrentFrame)].spriteId]; } if (val7 != null && i == num3 - 1) { val8 = ((tk2dBaseSprite)__instance.m_beamSprite).Collection.spriteDefinitions[val7.frames[Mathf.Min(val7.frames.Length - 1, ((BraveBehaviour)__instance).spriteAnimator.CurrentFrame)].spriteId]; } float num10 = 0f; if (i == 0) { if ((int)__instance.TileType == 1) { num10 = 1f - Mathf.Abs(val2.x % (val4.x * (float)num)) / (val4.x * (float)num); } else if ((int)__instance.TileType == 2) { num10 = __instance.m_uvOffset; } } for (int j = num8; j <= num9; j++) { BeamBone val9 = null; BeamBone val10 = null; if (linkedListNode2 != null) { val9 = linkedListNode2.Value; if (linkedListNode3 != null) { val10 = linkedListNode3.Value; } } float num11 = 1f; if ((int)__instance.TileType == 1) { if (i == 0 && j == 0 && (float)num2 * val4.x >= Mathf.Abs(val2.x) + val3.x) { num11 = Mathf.Abs(val2.x / val4.x) - (float)(num2 - 1); } } else if ((int)__instance.TileType == 0) { if (Mathf.Abs(num4 + val4.x) > Mathf.Abs(val2.x) + val3.x) { num11 = val2.x % val4.x / val4.x; } } else if ((int)__instance.TileType == 2) { if (i == 0 && linkedListNode2 == __instance.m_bones.First) { num11 = (val10.PosX - val9.PosX) / __instance.m_beamQuadUnitWidth; } else if (i == num3 - 1 && linkedListNode3.Next == null) { num11 = (val10.PosX - val9.PosX) / __instance.m_beamQuadUnitWidth; } } float num12 = 0f; if (__instance.RampHeightOffset != 0f && num4 < 5f) { num12 = z * (1f - num4 / 5f) * (0f - __instance.RampHeightOffset); } if (__instance.UsesBones && val10 != null) { float rotationAngle = val9.RotationAngle; float num13 = val10.RotationAngle; float num14 = BraveMathCollege.ClampAngle180(num13 - rotationAngle); if (num14 > 90f || num14 < -90f) { num13 = BraveMathCollege.ClampAngle360(num13 + 180f); } Vector2 val11 = val9.Position; Vector2 val12 = val10.Position; if (__instance.ProjectileAndBeamMotionModule != null) { bool inverted = ((BraveBehaviour)__instance).projectile.Inverted; val11 += __instance.ProjectileAndBeamMotionModule.GetBoneOffset(val9, (BeamController)(object)__instance, inverted); val12 += __instance.ProjectileAndBeamMotionModule.GetBoneOffset(val10, (BeamController)(object)__instance, inverted); } ((Vector2)(ref val11))..ctor(val11.x - val.x, val11.y - val.y); ((Vector2)(ref val12))..ctor(val12.x - val.x, val12.y - val.y); float num15 = rotationAngle * ((float)Math.PI / 180f); float num16 = Mathf.Sin(num15); float num17 = Mathf.Cos(num15); float num18 = num13 * ((float)Math.PI / 180f); float num19 = Mathf.Sin(num18); float num20 = Mathf.Cos(num18); float num21 = val8.position0.y * num7; float num22 = val8.position1.y * num7; float num23 = val8.position2.y * num7; float num24 = val8.position3.y * num7; pos[num5] = new Vector3((0f - num16) * num21 + val11.x, num17 * num21 + val11.y, num12); pos[num5 + 1] = new Vector3((0f - num19) * num22 + val12.x, num20 * num22 + val12.y, num12); pos[num5 + 2] = new Vector3((0f - num16) * num23 + val11.x, num17 * num23 + val11.y, num12); pos[num5 + 3] = new Vector3((0f - num19) * num24 + val12.x, num20 * num24 + val12.y, num12); } else if ((int)__instance.boneType == 0) { pos[num5] = val5 * new Vector3(num4, val8.position0.y * num7, num12); pos[num5 + 1] = val5 * new Vector3(num4 + x * num11 * val4.x, val8.position1.y * num7, num12); pos[num5 + 2] = val5 * new Vector3(num4, val8.position2.y * num7, num12); pos[num5 + 3] = val5 * new Vector3(num4 + x * num11 * val4.x, val8.position3.y * num7, num12); } Vector2 val13 = Vector2.Lerp(val8.uvs[0], val8.uvs[1], num10); Vector2 val14 = Vector2.Lerp(val8.uvs[2], val8.uvs[3], num10 + num11 / (float)num); if (__instance.FlipBeamSpriteLocal && ((BeamController)__instance).Direction.x < 0f) { float y = val13.y; val13.y = val14.y; val14.y = y; } if ((int)val8.flipped == 1) { uv[num5] = val13; uv[num5 + 1] = new Vector2(val13.x, val14.y); uv[num5 + 2] = new Vector2(val14.x, val13.y); uv[num5 + 3] = val14; } else { uv[num5] = val13; uv[num5 + 1] = new Vector2(val14.x, val13.y); uv[num5 + 2] = new Vector2(val13.x, val14.y); uv[num5 + 3] = val14; } num5 += 4; num4 += val4.x * num11; num10 += num11 * num6; linkedListNode2 = linkedListNode3; if (linkedListNode3 != null) { linkedListNode3 = linkedListNode3.Next; } } } float num25 = float.MaxValue; float num26 = float.MaxValue; float num27 = float.MaxValue; float num28 = float.MinValue; float num29 = float.MinValue; float num30 = float.MinValue; if (__instance.RampHeightOffset != 0f) { for (int k = 0; k < pos.Length; k++) { if (pos[k].x < num25) { num25 = pos[k].x; } if (pos[k].y < num26) { num26 = pos[k].y; } if (pos[k].z < num27) { num27 = pos[k].z; } if (pos[k].x > num28) { num28 = pos[k].x; } if (pos[k].y > num29) { num29 = pos[k].y; } if (pos[k].z > num30) { num30 = pos[k].z; } } } else { num27 = 0f; num30 = 0f; for (int l = 0; l < pos.Length; l++) { if (pos[l].x < num25) { num25 = pos[l].x; } if (pos[l].y < num26) { num26 = pos[l].y; } if (pos[l].x > num28) { num28 = pos[l].x; } if (pos[l].y > num29) { num29 = pos[l].y; } } } boundsExtents = new Vector3(0.5f * (num28 - num25), 0.5f * (num29 - num26), 0.5f * (num30 - num27)); boundsCenter = new Vector3(num25 + boundsExtents.x, num26 + boundsExtents.y, num27 + boundsExtents.z); return false; } } [HarmonyPatch] internal static class AmmoUICaching { private class QuickInvalidateData { private static readonly Dictionary> _CachedQIDs = new Dictionary>(); private static readonly Dictionary _QIDForSprite = new Dictionary(); public bool inUse; public GameObject spritePrefab; public GameObject spriteObject; public dfTiledSprite sprite; public dfRenderData preservedData; public int maxNumTiles; public int lastNumTiles; public Vector2 cachedTileScale; public bool cachedEnabled; public bool cachedBlackLineFix; public static QuickInvalidateData ForSprite(dfTiledSprite sprite) { return _QIDForSprite[sprite]; } public static void PreserveRenderData() { foreach (KeyValuePair item in _QIDForSprite) { dfTiledSprite key = item.Key; if (key != null && ((dfControl)key).renderData != null) { QuickInvalidateData value = item.Value; value.preservedData = ((dfControl)key).renderData; value.inUse = false; ((dfControl)key).renderData = null; } } } private static QuickInvalidateData RequestRaw(GameObject prefab) { if (!_CachedQIDs.TryGetValue(prefab, out var value)) { value = (_CachedQIDs[prefab] = new List()); } for (int num = value.Count - 1; num >= 0; num--) { if (!value[num].inUse) { value[num].inUse = true; return value[num]; } } GameObject val = Object.Instantiate(prefab); QuickInvalidateData quickInvalidateData = new QuickInvalidateData { inUse = true, spritePrefab = prefab, spriteObject = val, sprite = val.GetComponent(), preservedData = null, maxNumTiles = 0 }; _QIDForSprite[quickInvalidateData.sprite] = quickInvalidateData; value.Add(quickInvalidateData); return quickInvalidateData; } public static GameObject Request(GameObject prefab) { QuickInvalidateData quickInvalidateData = RequestRaw(prefab); if (Object.op_Implicit((Object)(object)quickInvalidateData.spriteObject)) { ((dfControl)quickInvalidateData.sprite).zindex = -1; ((dfControl)quickInvalidateData.sprite).IsVisible = true; quickInvalidateData.spriteObject.SetActive(true); return quickInvalidateData.spriteObject; } if (_QIDForSprite.ContainsKey(quickInvalidateData.sprite)) { _QIDForSprite.Remove(quickInvalidateData.sprite); } quickInvalidateData.spriteObject = Object.Instantiate(prefab); quickInvalidateData.sprite = quickInvalidateData.spriteObject.GetComponent(); if (quickInvalidateData.preservedData != null) { quickInvalidateData.maxNumTiles = quickInvalidateData.preservedData.Vertices.Count / 4; ((dfControl)quickInvalidateData.sprite).renderData = quickInvalidateData.preservedData; ((dfControl)quickInvalidateData.sprite).zindex = -1; ((dfControl)quickInvalidateData.sprite).IsVisible = true; quickInvalidateData.preservedData = null; } else { quickInvalidateData.maxNumTiles = 0; } _QIDForSprite[quickInvalidateData.sprite] = quickInvalidateData; return quickInvalidateData.spriteObject; } public static void ReturnSprite(dfTiledSprite sprite) { if (((dfControl)sprite).controls != null) { for (int num = ((dfControl)sprite).controls.Count - 1; num >= 0; num--) { dfControl val = ((dfControl)sprite).controls[num]; if (val != null) { Object.Destroy((Object)(object)((Component)val).gameObject); } } ((dfControl)sprite).controls.Clear(); } _QIDForSprite[sprite].inUse = false; ((Component)sprite).gameObject.SetActive(false); ((dfControl)sprite).parent.RemoveControl((dfControl)(object)sprite); } } private static bool Prepare(MethodBase original) { if (!GGVConfig.OPT_AMMO_DISPLAY) { return false; } return true; } [HarmonyPatch(typeof(GameUIAmmoController), "OnDestroy")] [HarmonyPrefix] private static void GameUIAmmoControllerOnDestroyPatch(GameUIAmmoController __instance) { QuickInvalidateData.PreserveRenderData(); } [HarmonyPatch(typeof(GameUIAmmoController), "UpdateAmmoUIForModule")] [HarmonyILManipulator] private static void GameUIAmmoControllerUpdateAmmoUIForModulePatchIL(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); ILLabel afterUIAmmoChangeLabel = null; if (val.TryGotoNext((MoveType)0, new Func[4] { (Instruction instr) => ILPatternMatchingExt.MatchLdarg(instr, 10), (Instruction instr) => ILPatternMatchingExt.MatchLdindRef(instr), (Instruction instr) => ILPatternMatchingExt.MatchCall(instr, "op_Inequality"), (Instruction instr) => ILPatternMatchingExt.MatchBrfalse(instr, ref afterUIAmmoChangeLabel) }) && val.TryGotoNext((MoveType)1, new Func[2] { (Instruction instr) => ILPatternMatchingExt.MatchLdarg(instr, 0), (Instruction instr) => ILPatternMatchingExt.MatchLdfld(instr, "m_additionalAmmoTypeDefinitions") })) { for (int num = 0; num <= 13; num++) { val.Emit(OpCodes.Ldarg, num); } val.CallPrivate(typeof(AmmoUICaching), "FastUpdateAmmoUIForModule"); val.Emit(OpCodes.Brfalse, (object)afterUIAmmoChangeLabel); } } [HarmonyPatch(typeof(GameUIAmmoController), "CleanupLists")] [HarmonyILManipulator] private static void GameUIAmmoControllerCleanupListsPatchIL(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); for (int i = 0; i < 4; i++) { if (!val.TryGotoNext((MoveType)0, new Func[2] { (Instruction instr) => ILPatternMatchingExt.MatchCallvirt(instr, "get_gameObject"), (Instruction instr) => ILPatternMatchingExt.MatchCall(instr, "Destroy") })) { break; } val.RemoveRange(2); val.CallPublic(typeof(QuickInvalidateData), "ReturnSprite"); } } [HarmonyPatch(typeof(dfControl), "Render")] [HarmonyILManipulator] private static void dfControlRenderPatchIL(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); ILLabel notInvalidatedLabel = null; if (val.TryGotoNext((MoveType)2, new Func[2] { (Instruction instr) => ILPatternMatchingExt.MatchLdfld(instr, "isControlInvalidated"), (Instruction instr) => ILPatternMatchingExt.MatchBrfalse(instr, ref notInvalidatedLabel) })) { val.Emit(OpCodes.Ldarg_0); val.CallPrivate(typeof(AmmoUICaching), "AttemptQuickInvalidate"); val.Emit(OpCodes.Brfalse, (object)notInvalidatedLabel); } } private static bool AttemptQuickInvalidate(dfControl control) { //IL_0036: 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_006b: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) dfTiledSprite val = (dfTiledSprite)(object)((control is dfTiledSprite) ? control : null); if (val == null || (Object)(object)((dfSprite)val).Atlas == (Object)null || ((dfSprite)val).SpriteInfo == (ItemInfo)null) { return true; } QuickInvalidateData quickInvalidateData = QuickInvalidateData.ForSprite(val); if (quickInvalidateData == null) { return true; } ((dfControl)val).pivot = (dfPivotPoint)0; if (quickInvalidateData.maxNumTiles == 0) { ((dfControl)val).renderData.Clear(); ((dfControl)val).renderData.Material = ((dfSprite)val).Atlas.Material; } if (quickInvalidateData.cachedTileScale != val.tileScale || quickInvalidateData.cachedEnabled != ((dfControl)val).isEnabled || quickInvalidateData.cachedBlackLineFix != val.EnableBlackLineFix) { quickInvalidateData.lastNumTiles = 0; quickInvalidateData.cachedTileScale = val.tileScale; quickInvalidateData.cachedEnabled = ((dfControl)val).isEnabled; quickInvalidateData.cachedBlackLineFix = val.EnableBlackLineFix; } dfList vertices = ((dfControl)val).renderData.Vertices; dfList colors = ((dfControl)val).renderData.Colors; Vector2 val2 = Vector2.Scale(((dfSprite)val).SpriteInfo.sizeInPixels, val.tileScale); Vector2 val3 = new Vector2(val.tileScroll.x % 1f, val.tileScroll.y % 1f); float num = (val.EnableBlackLineFix ? (-0.1f) : 0f); float num2 = val3.x * val2.x; if (num2 > 0f) { num2 = 0f - num2; } float num3 = num2 + val2.x; float num4 = val3.y * val2.y; if (num4 > 0f) { num4 = 0f - num4; } int num5 = (int)((((dfControl)val).size.y - num4) / val2.y); float num6 = ((dfControl)val).PixelsToUnits(); if (num5 > quickInvalidateData.maxNumTiles) { dfList uV = ((dfControl)val).renderData.UV; dfList triangles = ((dfControl)val).renderData.Triangles; vertices.EnsureCapacity(4 * num5); triangles.EnsureCapacity(6 * num5); uV.EnsureCapacity(4 * num5); colors.EnsureCapacity(4 * num5); Vector2[] array = val.buildQuadUV(); for (int num7 = num5 - quickInvalidateData.maxNumTiles; num7 > 0; num7--) { val.addQuadTriangles(triangles, vertices.Count); val.addQuadUV(uV, array); colors.Add(default(Color32)); colors.Add(default(Color32)); colors.Add(default(Color32)); colors.Add(default(Color32)); vertices.Add(default(Vector3)); vertices.Add(default(Vector3)); vertices.Add(default(Vector3)); vertices.Add(default(Vector3)); } } Vector3[] items = vertices.items; Color32[] items2 = colors.items; Color32 val4 = ((dfControl)val).ApplyOpacity(((dfControl)val).isEnabled ? ((dfControl)val).color : ((dfControl)val).disabledColor); int num8 = quickInvalidateData.lastNumTiles; float num9 = val2.y - num; for (float num10 = num4 + (float)num8 * val2.y; num10 < ((dfControl)val).size.y; num10 += val2.y) { int num11 = 4 * num8; num8++; items[num11].x = num2 * num6; items[num11 + 1].x = num3 * num6; items[num11 + 2].x = num3 * num6; items[num11 + 3].x = num2 * num6; items[num11].y = (0f - num10) * num6; items[num11 + 1].y = (0f - num10) * num6; items[num11 + 2].y = (0f - num10 - num9) * num6; items[num11 + 3].y = (0f - num10 - num9) * num6; items2[num11] = val4; items2[num11 + 1] = val4; items2[num11 + 2] = val4; items2[num11 + 3] = val4; } int num12 = 4 * quickInvalidateData.maxNumTiles; for (int i = 4 * num5; i < num12 && items2[i].a != 0; i++) { items2[i].a = 0; } if (num5 > quickInvalidateData.maxNumTiles) { quickInvalidateData.maxNumTiles = num5; } quickInvalidateData.lastNumTiles = num5; return false; } private static bool FastUpdateAmmoUIForModule(GameUIAmmoController self, ref dfTiledSprite currentAmmoFGSprite, ref dfTiledSprite currentAmmoBGSprite, List AddlModuleFGSprites, List AddlModuleBGSprites, dfSprite ModuleTopCap, dfSprite ModuleBottomCap, ProjectileModule module, Gun currentGun, ref AmmoType cachedAmmoTypeForModule, ref string cachedCustomAmmoTypeForModule, ref int cachedShotsInClip, bool didChangeGun, int numberRemaining) { //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Invalid comparison between Unknown and I4 //IL_0178: Unknown result type (might be due to invalid IL or missing references) GameActor owner = currentGun.m_owner; PlayerController val = (PlayerController)(object)((owner is PlayerController) ? owner : null); if (val == null) { return true; } int playerIDX = val.PlayerIDX; if (playerIDX != 0 && playerIDX != 1) { return true; } self.m_additionalAmmoTypeDefinitions.Clear(); if ((Object)(object)currentAmmoFGSprite != (Object)null) { QuickInvalidateData.ReturnSprite(currentAmmoFGSprite); } if ((Object)(object)currentAmmoBGSprite != (Object)null) { QuickInvalidateData.ReturnSprite(currentAmmoBGSprite); } for (int i = 0; i < AddlModuleBGSprites.Count; i++) { QuickInvalidateData.ReturnSprite(AddlModuleBGSprites[i]); QuickInvalidateData.ReturnSprite(AddlModuleFGSprites[i]); } AddlModuleBGSprites.Clear(); AddlModuleFGSprites.Clear(); GameUIAmmoType uIAmmoType = self.GetUIAmmoType(module.ammoType, module.customAmmoType); GameObject val2 = QuickInvalidateData.Request(((Component)uIAmmoType.ammoBarFG).gameObject); GameObject val3 = QuickInvalidateData.Request(((Component)uIAmmoType.ammoBarBG).gameObject); val2.transform.parent = ((Component)self.GunBoxSprite).transform.parent; val3.transform.parent = ((Component)self.GunBoxSprite).transform.parent; ((Object)val2).name = ((Object)uIAmmoType.ammoBarFG).name; ((Object)val3).name = ((Object)uIAmmoType.ammoBarBG).name; currentAmmoFGSprite = val2.GetComponent(); currentAmmoBGSprite = val3.GetComponent(); ((dfControl)self.m_panel).AddControl((dfControl)(object)currentAmmoFGSprite); ((dfControl)self.m_panel).AddControl((dfControl)(object)currentAmmoBGSprite); currentAmmoFGSprite.EnableBlackLineFix = (int)module.shootStyle == 2; currentAmmoBGSprite.EnableBlackLineFix = currentAmmoFGSprite.EnableBlackLineFix; if (module.usesOptionalFinalProjectile) { GameUIAmmoType uIAmmoType2 = self.GetUIAmmoType(module.finalAmmoType, module.finalCustomAmmoType); self.m_additionalAmmoTypeDefinitions.Add(uIAmmoType2); val2 = QuickInvalidateData.Request(((Component)uIAmmoType2.ammoBarFG).gameObject); val3 = QuickInvalidateData.Request(((Component)uIAmmoType2.ammoBarBG).gameObject); val2.transform.parent = ((Component)self.GunBoxSprite).transform.parent; val3.transform.parent = ((Component)self.GunBoxSprite).transform.parent; ((Object)val2).name = ((Object)uIAmmoType2.ammoBarFG).name; ((Object)val3).name = ((Object)uIAmmoType2.ammoBarBG).name; AddlModuleFGSprites.Add(val2.GetComponent()); AddlModuleBGSprites.Add(val3.GetComponent()); ((dfControl)self.m_panel).AddControl((dfControl)(object)AddlModuleFGSprites[0]); ((dfControl)self.m_panel).AddControl((dfControl)(object)AddlModuleBGSprites[0]); } return false; } } }