using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AIGraph;
using AK;
using AssetShards;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Hook;
using ChainedPuzzles;
using CullingSystem;
using Decals;
using Enemies;
using FluffyUnderware.Curvy;
using GTFO.API;
using GameData;
using HarmonyLib;
using IRF;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppInterop.Runtime.Runtime;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using LevelGeneration;
using LowSpecGaming.Misc;
using LowSpecGaming.Patches;
using LowSpecGaming.Util;
using Microsoft.CodeAnalysis;
using ShaderValueAnimation;
using UnityEngine;
using UnityEngine.Rendering;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("LowSpecGaming")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LowSpecGaming")]
[assembly: AssemblyTitle("LowSpecGaming")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NativeIntegerAttribute : Attribute
{
public readonly bool[] TransformFlags;
public NativeIntegerAttribute()
{
TransformFlags = new bool[1] { true };
}
public NativeIntegerAttribute(bool[] P_0)
{
TransformFlags = P_0;
}
}
}
namespace LowSpecGaming
{
[BepInPlugin("Mushroom.LowSpecGaming", "LowSpecGaming", "0.2.8")]
public class EntryPoint : BasePlugin
{
public static ConfigEntry<DynamicResolution> dynamicResolution;
public static ConfigEntry<TreeDrawing> treeDrawing;
public static ConfigEntry<GameEnvironment> gameEnvironment;
public static ConfigEntry<BioScanBlink> BioScanUpdate;
public static ConfigEntry<HateSpitter> hateSpitter;
public static ConfigEntry<EnemyBehaviourCulling> enemyBehaviourCulling;
public static ConfigEntry<string> currentFolderPath;
public static ConfigEntry<bool> dumpTexture;
public static ConfigEntry<TextureSize> textureSize;
public static ConfigEntry<OneFlashLight> oneFlashLight;
public static ConfigEntry<Experimental> redundantComponents;
public static ConfigFile configFile;
public static EntryPoint e;
public override void Load()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
e = this;
Harmony val = new Harmony("Mushroom.LowSpecGaming");
((BasePlugin)this).Log.LogInfo((object)"Mushroom Low Spec Gaming is IN~!!");
GetTheSettings();
ClassInjector.RegisterTypeInIl2Cpp<LowSpecGaming>();
SightPatch.sightPaths = new Dictionary<string, string[]>();
SightPatch.GetSightFolders();
LogIt(Paths.BepInExRootPath);
val.PatchAll();
LevelAPI.OnBuildDone += C_CullingClusterPatch.GetAllClusters;
LevelAPI.OnLevelCleanup += C_CullingClusterPatch.CleanAllClusters;
}
public static void GetTheSettings()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
configFile = new ConfigFile(Path.Combine(Paths.ConfigPath, "mushroom.lowspecgaming.cfg"), true);
dynamicResolution = configFile.Bind<DynamicResolution>("Setup", "dynamicResolution", DynamicResolution.Stable, "Scales down your resolution whenever you move your camera, will improve this in the future");
treeDrawing = configFile.Bind<TreeDrawing>("Setup", "treeDrawing", TreeDrawing.Draw, "whether or not to draw IRF like trees and tentacles, this will break a lot of stuff during Kraken Fight");
gameEnvironment = configFile.Bind<GameEnvironment>("Setup", "gameEnvironment", GameEnvironment.Full, "Reduce fog distance, shadow distance, no more dust particles (requires restart to take effect)");
BioScanUpdate = configFile.Bind<BioScanBlink>("Setup", "BioScanUpdate", BioScanBlink.DontBlink, "Whether or not Bio Scans would blink, courtesy to McCad, this is his online code");
hateSpitter = configFile.Bind<HateSpitter>("Setup", "hateSpitter", HateSpitter.HATE, "If you hate spitters, make them low quality");
enemyBehaviourCulling = configFile.Bind<EnemyBehaviourCulling>("Setup", "enemyBehaviourCulling", EnemyBehaviourCulling.Full, "Reduce Enemy Update in order to save performance, will improve this feature in the future for better performance");
textureSize = configFile.Bind<TextureSize>("Setup", "textureSize", TextureSize.Full, "Texture size, for the potata army");
oneFlashLight = configFile.Bind<OneFlashLight>("Setup", "oneFlashLight", OneFlashLight.All, "All for vanilla, use One to load only 1 and also the best flashlight for all guns (DMR)");
redundantComponents = configFile.Bind<Experimental>("Setup", "redundantComponents", Experimental.TurnOn, "VERY EXPERIMENTAL, turn off some redundant compenents in game || You might gain 5fps");
currentFolderPath = configFile.Bind<string>("Setup", "currentFolderPath", "", "Manual Path to the current folder that has the plugin if it fails to load normally, This will be removed soon");
dumpTexture = configFile.Bind<bool>("Setup", "dumpTexture", false, "Dump and extract sight textures in order to load hi res textures even at low res texture settings");
}
public static void LogIt(object data)
{
((BasePlugin)e).Log.LogInfo(data);
}
public override bool Unload()
{
return ((BasePlugin)this).Unload();
}
public static void DecompressFolder(string compressedFilePath, string decompressedFolderPath)
{
ZipFile.ExtractToDirectory(compressedFilePath, decompressedFolderPath);
LogIt("Folder decompressed successfully.");
}
}
public enum BioScanBlink
{
Blink,
DontBlink
}
public enum GameEnvironment
{
Full,
Reduced
}
public enum TreeDrawing
{
Draw,
HalfDraw,
DontDraw
}
public enum DynamicResolution
{
Stable,
Dynamic
}
public enum HateSpitter
{
HATE,
LOVE
}
public enum EnemyBehaviourCulling
{
Full,
Reduced
}
public enum Experimental
{
TurnOn,
TurnOff
}
public enum TextureSize
{
Full,
Half,
Quater,
Eigth,
Low,
PentaLow,
VeryLow,
SuperLow,
UltraLow,
POTATA,
YouLiveLikeThis
}
public enum OneFlashLight
{
All,
One
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "Mushroom.LowSpecGaming";
public const string PLUGIN_NAME = "LowSpecGaming";
public const string PLUGIN_VERSION = "0.2.8";
public const string AUTHOR = "time1pm";
public const string BRANCH = "beta";
public const string INTERNAL_VERSION = "000599";
}
internal class LowSpecGaming : MonoBehaviour
{
public static List<Texture2D> lightTextures;
public static Texture2D text;
public void Start()
{
EntryPoint.GetTheSettings();
lightTextures = new List<Texture2D>();
LevelAPI.OnEnterLevel += HateTheGameFeel;
LevelAPI.OnEnterLevel += ClusterRenderingOff;
EntryPoint.LogIt("Applying settings in 12s");
((MonoBehaviour)this).Invoke("ApplySettings", 12f);
((MonoBehaviour)this).Invoke("GetFlashLights", 10f);
}
public void GetFlashLights()
{
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Expected O, but got Unknown
if (!EntryPoint.dumpTexture.Value)
{
return;
}
foreach (FlashlightSettingsDataBlock allBlock in GameDataBlockBase<FlashlightSettingsDataBlock>.GetAllBlocks())
{
lightTextures.Add(((Il2CppObjectBase)AssetShardManager.GetLoadedAsset(allBlock.cookie, false)).Cast<Texture2D>());
}
foreach (Texture2D lightTexture in lightTextures)
{
try
{
RenderTexture temporary = RenderTexture.GetTemporary(((Texture)lightTexture).width, ((Texture)lightTexture).height, 0, (RenderTextureFormat)7, (RenderTextureReadWrite)1);
RenderTexture active = RenderTexture.active;
Graphics.Blit((Texture)(object)lightTexture, temporary);
RenderTexture.active = active;
Texture2D val = new Texture2D(((Texture)lightTexture).width, ((Texture)lightTexture).height);
_ = RenderTexture.active;
RenderTexture.active = temporary;
val.ReadPixels(new Rect(0f, 0f, (float)((Texture)temporary).width, (float)((Texture)temporary).height), 0, 0);
val.Apply();
RenderTexture.ReleaseTemporary(temporary);
byte[] bytes = Il2CppArrayBase<byte>.op_Implicit((Il2CppArrayBase<byte>)(object)ImageConversion.EncodeToPNG(val));
string text = Paths.BepInExRootPath + "\\LowSpec\\";
if (!Directory.Exists(text))
{
Directory.CreateDirectory(text);
}
if (!Directory.Exists(text + "FlashLights\\"))
{
Directory.CreateDirectory(text + "FlashLights\\");
}
File.WriteAllBytes(text + "FlashLights\\" + ((Object)lightTexture).name + ".png", bytes);
}
catch
{
EntryPoint.LogIt("Skipping Texture");
}
}
}
public void ApplySettings()
{
int value = 10;
EntryPoint.LogIt("Apply Settings");
StartUpSettings.PotatoTexture(ref value);
}
private static void HateTheGameFeel()
{
if (EntryPoint.gameEnvironment.Value != 0)
{
((Behaviour)((Component)PreLitVolume.Current).gameObject.GetComponent<AmbientParticles>()).enabled = false;
PreLitVolume.Current.m_fogDistance = 45f;
PreLitVolume.Current.FogPostBlur = 1;
PreLitVolume.Current.FogShadowSamples = 0;
PreLitVolume.Current.IndirectBlurSamples = 0;
PreLitVolume.Current.IndirectDownsampling = 0;
QualitySettings.shadowDistance = 15f;
QualitySettings.softParticles = false;
}
}
public static void ClusterRenderingOff()
{
((Behaviour)ClusteredRendering.Current).enabled = false;
}
}
[HarmonyPatch]
internal class StartUpSettings
{
[HarmonyPostfix]
[HarmonyPatch(typeof(StartMainGame), "Start")]
public static void MakeItWork(StartMainGame __instance)
{
((Component)__instance).gameObject.AddComponent<LowSpecGaming>();
QualitySettings.masterTextureLimit = 0;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(CellSettingsApply), "ApplyTextureSize")]
public static bool PotatoTexture(ref int value)
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
EntryPoint.GetTheSettings();
ResolutionPatch.dynamic = EntryPoint.dynamicResolution.Value == DynamicResolution.Dynamic;
ResolutionPatch.markerLayer = ((Component)GameObject.Find("GUI").transform.GetChild(0).GetChild(0)).GetComponent<UI_Canvas>();
ResolutionPatch.canvasScale = CellSettingsManager.SettingsData.Video.Resolution.Value.y / 1080f;
SpitterPatch.hate = EntryPoint.hateSpitter.Value == HateSpitter.HATE;
BioScanPatch.update = EntryPoint.BioScanUpdate.Value == BioScanBlink.Blink;
IRFPatch.draw = EntryPoint.treeDrawing.Value == TreeDrawing.Draw;
RedundantMethods.draw = EntryPoint.treeDrawing.Value == TreeDrawing.DontDraw;
if (EntryPoint.dumpTexture.Value)
{
QualitySettings.masterTextureLimit = 0;
}
else
{
value = (int)EntryPoint.textureSize.Value;
if (QualitySettings.masterTextureLimit != value)
{
QualitySettings.masterTextureLimit = value;
}
}
return false;
}
}
}
namespace LowSpecGaming.Util
{
public static class C_Combine
{
public static List<Renderer> CombineMeshes(Renderer[] renderersToCombine)
{
return CombineMeshes(renderersToCombine.ToList());
}
public static List<Renderer> CombineMeshes(List<Renderer> renderersToCombine)
{
//IL_00b2: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Expected O, but got Unknown
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Expected O, but got Unknown
if (renderersToCombine.Count < 2)
{
return renderersToCombine;
}
Material val;
try
{
val = renderersToCombine[0].sharedMaterial;
foreach (Renderer item2 in renderersToCombine)
{
if ((Object)(object)item2.sharedMaterial != (Object)(object)val)
{
return renderersToCombine;
}
}
}
catch
{
val = renderersToCombine[0].material;
}
string name = ((Object)((Component)renderersToCombine[0]).gameObject).name;
List<CombineInstance> list = new List<CombineInstance>();
foreach (Renderer item3 in renderersToCombine)
{
MeshFilter component = ((Component)item3).GetComponent<MeshFilter>();
if ((Object)(object)component == (Object)null)
{
return renderersToCombine;
}
CombineInstance val2 = default(CombineInstance);
((CombineInstance)(ref val2)).mesh = component.sharedMesh;
((CombineInstance)(ref val2)).transform = ((Component)item3).transform.localToWorldMatrix;
CombineInstance item = val2;
list.Add(item);
item3.enabled = false;
item3.forceRenderingOff = true;
Object.Destroy((Object)(object)component);
}
GameObject val3 = new GameObject(name + "_Combined");
val3.isStatic = true;
C_CullingClusterPatch.CombinedGameObjects.Add(val3);
MeshFilter obj2 = val3.AddComponent<MeshFilter>();
MeshRenderer val4 = val3.AddComponent<MeshRenderer>();
Mesh val5 = new Mesh();
val5.CombineMeshes(Il2CppStructArray<CombineInstance>.op_Implicit(list.ToArray()), true, true);
obj2.mesh = val5;
((Renderer)val4).sharedMaterial = val;
((Renderer)val4).enabled = false;
((Renderer)val4).shadowCastingMode = (ShadowCastingMode)0;
((Renderer)val4).receiveShadows = false;
((Renderer)val4).lightProbeUsage = (LightProbeUsage)0;
((Renderer)val4).reflectionProbeUsage = (ReflectionProbeUsage)0;
return new List<Renderer> { (Renderer)(object)val4 };
}
}
}
namespace LowSpecGaming.Patches
{
public static class ClusterRestruct
{
public static Renderer[] Restruct(Renderer[] initialRenderers)
{
return Restruct(initialRenderers.ToList());
}
public static Renderer[] Restruct(List<Renderer> initialRenderers)
{
if (initialRenderers.Count < 1)
{
return initialRenderers.ToArray();
}
int count = initialRenderers.Count;
Dictionary<string, List<Renderer>> dictionary = new Dictionary<string, List<Renderer>>();
for (int i = 0; i < initialRenderers.Count; i++)
{
string name = ((Object)((Component)initialRenderers[i]).gameObject).name;
if (!dictionary.TryGetValue(name, out var _))
{
dictionary[name] = new List<Renderer>();
}
dictionary[name].Add(initialRenderers[i]);
}
List<Renderer> list = new List<Renderer>();
List<string> list2 = new List<string>();
foreach (string key in dictionary.Keys)
{
list2.Add(key);
}
foreach (string item in list2)
{
if (item.ToLower().Contains("lock"))
{
list.AddRange(dictionary[item]);
continue;
}
try
{
list.AddRange(C_Combine.CombineMeshes(dictionary[item]));
}
catch
{
list.AddRange(dictionary[item]);
}
}
C_CullingClusterPatch.initial_renderer += count;
C_CullingClusterPatch.after_renderer += list.Count;
EntryPoint.LogIt($"Cluster Renderer Count: {count} > {list.Count}");
return list.ToArray();
}
}
public static class C_CullingClusterPatch
{
public static List<GameObject> CombinedGameObjects = new List<GameObject>();
public static int initial_renderer = 0;
public static int after_renderer = 0;
public static void GetAllClusters()
{
foreach (LG_Area item in Object.FindObjectsOfType<LG_Area>())
{
C_Node cullNode = item.m_courseNode.m_cullNode;
if (cullNode == null || (Object)(object)item == (Object)null || item.m_courseNode == null)
{
continue;
}
EntryPoint.LogIt("Checking Renderers at " + ((Object)item).name + " Doors");
Enumerator<C_Portal> enumerator2 = cullNode.m_portals.GetEnumerator();
while (enumerator2.MoveNext())
{
C_CullBucket val = ((Il2CppObjectBase)enumerator2.Current).TryCast<C_CullBucket>();
Renderer[] array = ClusterRestruct.Restruct(Il2CppArrayBase<Renderer>.op_Implicit(val.Renderers.ToArray()));
val.Renderers.Clear();
Renderer[] array2 = array;
foreach (Renderer val2 in array2)
{
val.Renderers.Add(val2);
}
}
}
int num = 0;
int num2 = 0;
foreach (MeshRenderer item2 in Object.FindObjectsOfType<MeshRenderer>())
{
string text = ((Object)item2).name.ToLower();
string text2 = "";
if (text.Length > 7)
{
text2 = text.Substring(0, 6);
}
if (text.Contains("shadow") || text.Contains("cube"))
{
((Renderer)item2).forceRenderingOff = true;
((Renderer)item2).enabled = false;
num++;
}
if (text2 == "c_prop")
{
((Renderer)item2).forceRenderingOff = true;
((Renderer)item2).enabled = false;
num2++;
}
}
EntryPoint.LogIt($"Disable Shadows: {num} --- S_prop: {num2}");
EntryPoint.LogIt($"Total Initial Renderers: {initial_renderer} --- Total After Renderers: {after_renderer}");
}
public static void CleanAllClusters()
{
C_CullingManager.PointLights_WantsToShow.Clear();
C_CullingManager.SpotLights_WantsToShow.Clear();
initial_renderer = 0;
after_renderer = 0;
for (int i = 0; i < CombinedGameObjects.Count; i++)
{
Object.Destroy((Object)(object)CombinedGameObjects[i]);
}
GC.Collect();
}
public static void HideAllCombined()
{
for (int i = 0; i < CombinedGameObjects.Count; i++)
{
CombinedGameObjects[i].GetComponent<Renderer>().enabled = false;
CombinedGameObjects[i].SetActive(false);
}
}
public static void ShowAllCombined()
{
for (int i = 0; i < CombinedGameObjects.Count; i++)
{
CombinedGameObjects[i].GetComponent<Renderer>().enabled = true;
CombinedGameObjects[i].SetActive(true);
}
}
}
[HarmonyPatch]
internal class C_NodeGenerateCullersPatch
{
public static List<C_CullingCluster> clusters = new List<C_CullingCluster>();
[HarmonyPrefix]
[HarmonyPatch(typeof(C_NodeGenerateCullers), "Build")]
public static bool Build_Patch2(C_NodeGenerateCullers __instance, ref bool __result)
{
//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_0019: Expected I4, but got Unknown
//IL_027b: 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_0282: Unknown result type (might be due to invalid IL or missing references)
//IL_0299: Expected I4, but got Unknown
//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
//IL_02de: Unknown result type (might be due to invalid IL or missing references)
//IL_02e8: Expected O, but got Unknown
//IL_0309: Unknown result type (might be due to invalid IL or missing references)
//IL_0336: Unknown result type (might be due to invalid IL or missing references)
//IL_0340: Expected O, but got Unknown
//IL_0383: Unknown result type (might be due to invalid IL or missing references)
//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
//IL_03b1: Expected O, but got Unknown
//IL_00e8: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Expected I4, but got Unknown
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_01ec: Expected O, but got Unknown
State state = __instance.m_state;
switch ((int)state)
{
case 0:
__instance.m_cNode.SpatialPartitions = null;
__instance.m_clusterStep = 0;
__instance.m_clusterIDOffset = 0;
__instance.m_clusterMax = ((Il2CppArrayBase<Bounds>)(object)__instance.m_clusterinJob.m_clusterBounds).Length;
__instance.m_singleCullerStep = 0;
__instance.m_singleCullerMax = __instance.m_clusterinJob.m_clusterIJob.m_singleCullerClusters_Bounds.Count;
__instance.m_state = (State)1;
break;
case 1:
if (__instance.m_clusterStep < __instance.m_clusterMax)
{
int num = ((Il2CppArrayBase<int>)(object)__instance.m_clusterinJob.m_clusterIDCounts)[__instance.m_clusterStep];
int clusterIDOffset = __instance.m_clusterIDOffset;
int num2 = __instance.m_clusterIDOffset + num;
for (int j = clusterIDOffset; j < num2; j++)
{
__instance.m_renderer = ((C_CullBucket)__instance.m_cNode).Renderers[(int)((Il2CppArrayBase<ushort>)(object)__instance.m_clusterinJob.m_clusterIDs)[j]];
ShadowCastingMode shadowCastingMode = __instance.m_renderer.shadowCastingMode;
switch ((int)shadowCastingMode)
{
case 0:
__instance.m_renderers.Add(__instance.m_renderer);
break;
case 1:
__instance.m_renderers.Add(__instance.m_renderer);
__instance.m_shadowRenderers.Add(__instance.m_renderer);
break;
case 3:
__instance.m_renderer.enabled = typeof(SkinnedMeshRenderer) == ((object)__instance.m_renderer).GetType();
__instance.m_shadowRenderers.Add(__instance.m_renderer);
break;
default:
EntryPoint.LogIt("Error while generating CULLING CLUSTER");
break;
}
}
Renderer[] initialRenderers = Il2CppArrayBase<Renderer>.op_Implicit(__instance.m_renderers.ToArray());
initialRenderers = ClusterRestruct.Restruct(initialRenderers);
Renderer[] array = Il2CppArrayBase<Renderer>.op_Implicit(__instance.m_shadowRenderers.ToArray());
__instance.m_clusters.Add(new C_CullingCluster(((Il2CppArrayBase<Bounds>)(object)__instance.m_clusterinJob.m_clusterBounds)[__instance.m_clusterStep], Il2CppReferenceArray<Renderer>.op_Implicit(initialRenderers), Il2CppReferenceArray<Renderer>.op_Implicit(array)));
__instance.m_renderers.Clear();
__instance.m_shadowRenderers.Clear();
__instance.m_clusterIDOffset += num;
int singleCullerStep = __instance.m_clusterStep + 1;
__instance.m_clusterStep = singleCullerStep;
}
else
{
__instance.m_state = (State)2;
}
break;
case 2:
{
if (__instance.m_singleCullerStep < __instance.m_singleCullerMax)
{
__instance.m_renderer = ((C_CullBucket)__instance.m_cNode).Renderers[__instance.m_clusterinJob.m_clusterIJob.m_singleCullerClusters_refID[__instance.m_singleCullerStep]];
ShadowCastingMode shadowCastingMode = __instance.m_renderer.shadowCastingMode;
switch ((int)shadowCastingMode)
{
case 0:
__instance.m_clusters.Add(new C_CullingCluster(__instance.m_clusterinJob.m_clusterIJob.m_singleCullerClusters_Bounds[__instance.m_singleCullerStep], Il2CppReferenceArray<Renderer>.op_Implicit((Renderer[])(object)new Renderer[1] { __instance.m_renderer }), Il2CppReferenceArray<Renderer>.op_Implicit((Renderer[])(object)new Renderer[0])));
break;
case 1:
__instance.m_clusters.Add(new C_CullingCluster(__instance.m_clusterinJob.m_clusterIJob.m_singleCullerClusters_Bounds[__instance.m_singleCullerStep], Il2CppReferenceArray<Renderer>.op_Implicit((Renderer[])(object)new Renderer[1] { __instance.m_renderer }), Il2CppReferenceArray<Renderer>.op_Implicit((Renderer[])(object)new Renderer[1] { __instance.m_renderer })));
break;
case 3:
__instance.m_renderer.enabled = typeof(SkinnedMeshRenderer) == ((object)__instance.m_renderer).GetType();
__instance.m_clusters.Add(new C_CullingCluster(__instance.m_clusterinJob.m_clusterIJob.m_singleCullerClusters_Bounds[__instance.m_singleCullerStep], Il2CppReferenceArray<Renderer>.op_Implicit((Renderer[])(object)new Renderer[0]), Il2CppReferenceArray<Renderer>.op_Implicit((Renderer[])(object)new Renderer[1] { __instance.m_renderer })));
break;
}
int singleCullerStep = __instance.m_singleCullerStep + 1;
__instance.m_singleCullerStep = singleCullerStep;
break;
}
Enumerator<C_CullingCluster> enumerator = __instance.m_clusters.GetEnumerator();
while (enumerator.MoveNext())
{
C_Cullable val = ((Il2CppObjectBase)enumerator.Current).TryCast<C_Cullable>();
if (val != null)
{
__instance.m_cNode.m_staticCullables.Add(val);
}
}
((C_CullBucket)__instance.m_cNode).Renderers.Clear();
((C_CullBucket)__instance.m_cNode).SpecialRenderableObjects.Clear();
if (C_CullingManager.CullingEnabled)
{
((C_Cullable)__instance.m_cNode).Hide();
for (int i = 0; i < __instance.m_cNode.m_staticCullables.Count; i++)
{
__instance.m_cNode.m_staticCullables[i].IsShown = true;
__instance.m_cNode.m_staticCullables[i].Hide();
}
}
__result = true;
return false;
}
}
__result = false;
return false;
}
}
public static class Detour
{
public unsafe delegate void StaticVoidDelegate(Il2CppMethodInfo* methodInfo);
public unsafe delegate void InstanceVoidDelegate(IntPtr instance, Il2CppMethodInfo* methodInfo);
public static bool TryCreate<T>(DetourDescription description, T to, out T originalCall, out INativeDetour detourInstance) where T : Delegate
{
try
{
detourInstance = INativeDetour.CreateAndApply<T>((IntPtr)description.GetMethodPointer(), to, ref originalCall);
return detourInstance != null;
}
catch
{
}
originalCall = null;
detourInstance = null;
return false;
}
}
public struct DetourDescription
{
public Type Type;
public Type ReturnType;
public Type[] ArgTypes;
public string MethodName;
public bool IsGeneric;
public unsafe nint GetMethodPointer()
{
if (Type == null)
{
throw new MissingFieldException("Field Type is not set!");
}
if (ReturnType == null)
{
throw new MissingFieldException("Field ReturnType is not set! If you mean 'void' do typeof(void)");
}
if (string.IsNullOrEmpty(MethodName))
{
throw new MissingFieldException("Field MethodName is not set or valid!");
}
Il2CppType.From(Type, true);
IntPtr nativeClassPointer = Il2CppClassPointerStore.GetNativeClassPointer(Type);
Type val = Il2CppType.From(ReturnType, true);
Type[] array;
if (ArgTypes == null || ArgTypes.Length == 0)
{
array = Array.Empty<Type>();
}
else
{
int num = ArgTypes.Length;
array = (Type[])(object)new Type[num];
for (int i = 0; i < num; i++)
{
Type type = ArgTypes[i];
array[i] = Il2CppType.From(type, true);
}
}
string[] array2 = array.Select((Type t) => t.FullName).ToArray();
void** ptr = (void**)IL2CPP.GetIl2CppMethod(nativeClassPointer, IsGeneric, MethodName, val.FullName, array2).ToPointer();
if (ptr == null)
{
return (nint)ptr;
}
return (nint)(*ptr);
}
}
[Harmony]
[HarmonyPatch]
internal static class Detour_DrawMeshInstancedIndirect
{
private unsafe delegate void DrawDelegate(IntPtr mesh, int submeshIndex, IntPtr material, IntPtr bounds, IntPtr bufferWithArgs, int argsOffset, IntPtr properties, int castShadows, byte receiveShadows, int layer, IntPtr camera, int lightProbeUsage, IntPtr lightProbeProxyVolume, Il2CppMethodInfo* methodInfo);
public static IntPtr DrawMeshCamera = IntPtr.Zero;
private static DrawDelegate _Original;
private static INativeDetour _Detour;
public unsafe static void CreateDetour()
{
DetourDescription description = default(DetourDescription);
description.Type = typeof(Graphics);
description.MethodName = "DrawMeshInstancedIndirect";
description.ReturnType = typeof(void);
description.ArgTypes = new Type[1] { typeof(Camera) };
description.IsGeneric = false;
Detour.TryCreate<DrawDelegate>(description, Detour_Draw, out _Original, out _Detour);
}
private unsafe static void Detour_Draw(IntPtr mesh, int submeshIndex, IntPtr material, IntPtr bounds, IntPtr bufferWithArgs, int argsOffset, IntPtr properties, int castShadows, byte receiveShadows, int layer, IntPtr camera, int lightProbeUsage, IntPtr lightProbeProxyVolume, Il2CppMethodInfo* methodInfo)
{
_Original(mesh, submeshIndex, material, bounds, bufferWithArgs, argsOffset, properties, 0, 0, layer, DrawMeshCamera, lightProbeUsage, lightProbeProxyVolume, methodInfo);
}
}
[HarmonyPatch]
internal class EnemyPatch
{
[HarmonyPrefix]
[HarmonyPatch(typeof(EnemyUpdateManager), "Setup")]
public static bool EnemyCulling(EnemyUpdateManager __instance)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Expected O, but got Unknown
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Expected O, but got Unknown
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Expected O, but got Unknown
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Expected O, but got Unknown
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Expected O, but got Unknown
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Expected O, but got Unknown
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Expected O, but got Unknown
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Expected O, but got Unknown
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Expected O, but got Unknown
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Expected O, but got Unknown
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Expected O, but got Unknown
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Expected O, but got Unknown
//IL_0190: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Expected O, but got Unknown
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Expected O, but got Unknown
if (EntryPoint.enemyBehaviourCulling.Value == EnemyBehaviourCulling.Full)
{
return true;
}
ShaderValueAnimator.ManagerSetup();
__instance.m_nodeUpdates = new UpdateNodeGroup();
((SteppedUpdateGroup<AIG_CourseNode>)(object)__instance.m_nodeUpdates).Setup(1, (SteppedUpdateGroup)null);
__instance.m_locomotionUpdatesClose = new UpdateLocomotionGroup();
((SteppedUpdateGroup<EnemyLocomotion>)(object)__instance.m_locomotionUpdatesClose).Setup(18, (SteppedUpdateGroup)null);
__instance.m_locomotionUpdatesNear = new UpdateLocomotionGroup();
((SteppedUpdateGroup<EnemyLocomotion>)(object)__instance.m_locomotionUpdatesNear).Setup(9, (SteppedUpdateGroup)(object)__instance.m_locomotionUpdatesClose);
__instance.m_locomotionUpdatesFar = new UpdateLocomotionGroup();
((SteppedUpdateGroup<EnemyLocomotion>)(object)__instance.m_locomotionUpdatesFar).Setup(4, (SteppedUpdateGroup)(object)__instance.m_locomotionUpdatesNear);
__instance.m_fixedLocomotionUpdatesClose = new FixedUpdateLocomotionGroup();
((SteppedUpdateGroup<EnemyLocomotion>)(object)__instance.m_fixedLocomotionUpdatesClose).Setup(3, (SteppedUpdateGroup)null);
__instance.m_fixedLocomotionUpdatesNear = new FixedUpdateLocomotionGroup();
((SteppedUpdateGroup<EnemyLocomotion>)(object)__instance.m_fixedLocomotionUpdatesNear).Setup(2, (SteppedUpdateGroup)(object)__instance.m_fixedLocomotionUpdatesClose);
__instance.m_fixedLocomotionUpdatesFar = new FixedUpdateLocomotionGroup();
((SteppedUpdateGroup<EnemyLocomotion>)(object)__instance.m_fixedLocomotionUpdatesFar).Setup(1, (SteppedUpdateGroup)(object)__instance.m_fixedLocomotionUpdatesNear);
__instance.m_behaviourUpdatesClose = new UpdateBehaviourGroup();
((SteppedUpdateGroup<EnemyBehaviour>)(object)__instance.m_behaviourUpdatesClose).Setup(2, (SteppedUpdateGroup)null);
__instance.m_behaviourUpdatesNear = new UpdateBehaviourGroup();
((SteppedUpdateGroup<EnemyBehaviour>)(object)__instance.m_behaviourUpdatesNear).Setup(1, (SteppedUpdateGroup)(object)__instance.m_behaviourUpdatesClose);
__instance.m_behaviourUpdatesFar = new UpdateBehaviourGroup();
((SteppedUpdateGroup<EnemyBehaviour>)(object)__instance.m_behaviourUpdatesFar).Setup(1, (SteppedUpdateGroup)(object)__instance.m_behaviourUpdatesNear);
__instance.m_detectionUpdatesClose = new UpdateDetectionGroup();
((SteppedUpdateGroup<EnemyBehaviour>)(object)__instance.m_detectionUpdatesClose).Setup(10, (SteppedUpdateGroup)null);
__instance.m_detectionUpdatesNear = new UpdateDetectionGroup();
((SteppedUpdateGroup<EnemyBehaviour>)(object)__instance.m_detectionUpdatesNear).Setup(3, (SteppedUpdateGroup)(object)__instance.m_detectionUpdatesNear);
__instance.m_detectionUpdatesFar = new UpdateDetectionGroup();
((SteppedUpdateGroup<EnemyBehaviour>)(object)__instance.m_detectionUpdatesFar).Setup(1, (SteppedUpdateGroup)(object)__instance.m_detectionUpdatesFar);
__instance.m_networkUpdatesClose = new UpdateNetworkGroup();
((SteppedUpdateGroup<EnemyLocomotion>)(object)__instance.m_networkUpdatesClose).Setup(12, (SteppedUpdateGroup)null);
__instance.m_networkUpdatesNear = new UpdateNetworkGroup();
((SteppedUpdateGroup<EnemyLocomotion>)(object)__instance.m_networkUpdatesNear).Setup(3, (SteppedUpdateGroup)(object)__instance.m_networkUpdatesClose);
__instance.m_networkUpdatesFar = new UpdateNetworkGroup();
((SteppedUpdateGroup<EnemyLocomotion>)(object)__instance.m_networkUpdatesFar).Setup(1, (SteppedUpdateGroup)(object)__instance.m_networkUpdatesNear);
return false;
}
}
[Harmony]
[HarmonyPatch]
internal class EnemyUpdatePatch
{
[HarmonyPrefix]
[HarmonyPatch(typeof(EnemyUpdateManager), "GamestateUpdateFixed")]
public static bool EnemyUpdateManagerPatch2(EnemyUpdateManager __instance)
{
ShaderValueAnimator.ManagerUpdate();
((SteppedUpdateGroup<AIG_CourseNode>)(object)__instance.m_nodeUpdates).Update();
((SteppedUpdateGroup<EnemyLocomotion>)(object)__instance.m_locomotionUpdatesClose).Update();
((SteppedUpdateGroup<EnemyLocomotion>)(object)__instance.m_locomotionUpdatesNear).Update();
((SteppedUpdateGroup<EnemyLocomotion>)(object)__instance.m_locomotionUpdatesFar).Update();
((SteppedUpdateGroup<EnemyLocomotion>)(object)__instance.m_fixedLocomotionUpdatesClose).Update();
((SteppedUpdateGroup<EnemyLocomotion>)(object)__instance.m_fixedLocomotionUpdatesNear).Update();
((SteppedUpdateGroup<EnemyLocomotion>)(object)__instance.m_fixedLocomotionUpdatesFar).Update();
return false;
}
}
[HarmonyPatch]
internal class IRFPatch
{
public static bool draw;
[HarmonyPostfix]
[HarmonyPatch(typeof(InstancedRenderFeature), "OnEnable")]
public static void InstancedRenderFeaturePatch(InstancedRenderFeature __instance)
{
if (draw)
{
return;
}
try
{
if (!((Object)__instance.m_descriptor).name.ToLower().Contains("tentacle") && draw)
{
((Behaviour)__instance).enabled = false;
Object.Destroy((Object)(object)((Component)__instance).gameObject);
}
}
catch
{
}
}
}
public static class MathApprox
{
public static readonly int TableSize = 362;
public static readonly float[] SinTable = new float[TableSize];
public static readonly float[] CosTable = new float[TableSize];
public static void Init()
{
for (int i = 0; i < TableSize; i++)
{
float num = (float)Math.PI / 180f * (float)i;
SinTable[i] = Mathf.Sin(num);
CosTable[i] = Mathf.Cos(num);
}
}
public static float Sin(float angle)
{
if (angle < 0f)
{
angle += 360f;
}
return SinTable[Mathf.RoundToInt(angle)];
}
public static float SSin(float angle)
{
angle %= 360f;
if (angle < 0f)
{
angle += 360f;
}
return SinTable[Mathf.RoundToInt(angle)];
}
public static float Cos(float angle)
{
if (angle < 0f)
{
angle += 360f;
}
return CosTable[Mathf.RoundToInt(angle)];
}
public static float SCos(float angle)
{
angle %= 360f;
if (angle < 0f)
{
angle += 360f;
}
return CosTable[Mathf.RoundToInt(angle)];
}
}
[HarmonyPatch]
internal class MathPatch
{
[HarmonyPrefix]
[HarmonyPatch(typeof(MathUtil), "RotateVector2")]
public static bool RotateVector2Patch(ref Vector2 v, ref float angleDeg, ref Vector2 __result)
{
//IL_0038: 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)
float angle = 0.017453289f * angleDeg;
float num = MathApprox.Cos(angle);
float num2 = MathApprox.Sin(angle);
__result = new Vector2(v.x * num - v.y * num2, v.x * num2 + v.y * num);
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(SentryScannerPlane), "Update")]
public static bool SentryScannerPlaneUpdatePatch(SentryScannerPlane __instance)
{
__instance.m_fastDelta = Mathf.Lerp(__instance.m_fastDelta, __instance.FastScan ? 1f : 0f, Time.deltaTime * 4f);
__instance.m_material.SetFloat(SentryScannerPlane._HasTarget, __instance.m_fastDelta);
return false;
}
}
internal class PropagatePatch
{
public static IEnumerable<CodeInstruction> DisableTranspiler(IEnumerable<CodeInstruction> instructions)
{
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
list.Clear();
return list.AsEnumerable();
}
}
[HarmonyPatch]
internal class RedundantMethods
{
public static bool draw;
[HarmonyTranspiler]
[HarmonyPatch(typeof(EnemyUpdateManager), "GamestateUpdate")]
[HarmonyPatch(typeof(ClusteredRendering), "Update")]
[HarmonyPatch(typeof(CL_Light), "UpdateData")]
[HarmonyPatch(typeof(CP_Bioscan_Graphics), "Update")]
public static IEnumerable<CodeInstruction> DisableTranspiler(IEnumerable<CodeInstruction> instructions)
{
List<CodeInstruction> list = new List<CodeInstruction>();
list.Clear();
return list.AsEnumerable();
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(Graphics), "DrawMeshInstancedIndirect", new Type[]
{
typeof(Mesh),
typeof(int),
typeof(Material),
typeof(Bounds),
typeof(ComputeBuffer),
typeof(int),
typeof(MaterialPropertyBlock),
typeof(ShadowCastingMode),
typeof(bool),
typeof(int),
typeof(Camera),
typeof(LightProbeUsage),
typeof(LightProbeProxyVolume)
})]
public static IEnumerable<CodeInstruction> DisableTranspiler2(IEnumerable<CodeInstruction> instructions)
{
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
if (draw)
{
return list.AsEnumerable();
}
list.Clear();
return list.AsEnumerable();
}
}
[HarmonyPatch]
internal class ResolutionPatch
{
public static bool dynamic = false;
public static UI_Canvas markerLayer = null;
public static float canvasScale;
private static float scale = 0.8f;
private static float offset = 0.1f;
private static Rect screenRec = new Rect(0f, 0f, 1f, 1f);
[HarmonyPrefix]
[HarmonyPatch(typeof(LookCameraController), "MouseLookUpdate")]
public static void Mouse(ref float axisHor, ref float axisVer)
{
float num = Mathf.Abs(axisHor) + Mathf.Abs(axisVer);
if (num < 0.5f)
{
scale = 1f;
offset = 0f;
}
else if (num < 2f)
{
scale = 0.8f;
offset = 0.1f;
}
else
{
scale = 0.6f;
offset = 0.2f;
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(FPSCamera), "Update")]
public static void ScaleDown(FPSCamera __instance)
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
if (dynamic)
{
markerLayer.CanvasScale = canvasScale * scale;
((CameraController)__instance).m_camera.rect = new Rect(offset, offset, scale, scale);
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(FPSCamera), "OnPostRender")]
public static void ScaleUp(FPSCamera __instance)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
markerLayer.CanvasScale = canvasScale;
((CameraController)__instance).m_camera.rect = new Rect(0f, 0f, 1f, 1f);
}
[HarmonyPrefix]
[HarmonyPatch(typeof(FPSCamera), "Awake")]
public static void DrawDetour(FPSCamera __instance)
{
Detour_DrawMeshInstancedIndirect.DrawMeshCamera = ((Il2CppObjectBase)((CameraController)__instance).m_camera).Pointer;
}
}
[HarmonyPatch]
internal class SightPatch
{
public static byte[] flashLightData;
public static Dictionary<string, string[]> sightPaths;
public static Dictionary<string, string> flashlights;
public static Color newColor = new Color(10f, 0.5f, 0f);
private static string[] textNames = new string[4] { "_MainTex", "_ReticuleA", "_ReticuleB", "_ReticuleC" };
public static void GetSightFolders()
{
flashlights = new Dictionary<string, string>();
string[] array = null;
string path = Paths.BepInExRootPath + "\\LowSpec\\";
if (!Directory.Exists(path) || EntryPoint.dumpTexture.Value)
{
return;
}
EntryPoint.LogIt("Trying to find sights");
if (EntryPoint.currentFolderPath.Value.Equals("") || EntryPoint.currentFolderPath.Value == null)
{
EntryPoint.LogIt("Auto loaded and found sights");
}
else
{
EntryPoint.LogIt("Manually Loaded");
path = EntryPoint.currentFolderPath.Value;
}
array = Directory.GetDirectories(path);
if (array == null)
{
return;
}
try
{
string[] array2 = array;
foreach (string text in array2)
{
string key = text.Split("\\")[text.Split("\\").Count() - 1];
sightPaths[key] = Directory.GetFiles(text);
}
}
catch
{
EntryPoint.LogIt("NO GEAR SIGHT FOUND, MOVING ON");
}
try
{
string[] array2 = sightPaths["FlashLights"];
foreach (string text2 in array2)
{
string text3 = text2.Split("\\")[text2.Split("\\").Count() - 1];
string text4 = text3;
text3 = text4.Substring(0, text4.Length - 4);
flashlights[text3] = text2;
}
}
catch
{
EntryPoint.LogIt("NO FLASHLIGHT FOUND, MOVING ON");
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(GearMaterialFeeder), "ScanAndSetupParts")]
private static void MySight(GearMaterialFeeder __instance)
{
try
{
if (EntryPoint.dumpTexture.Value)
{
DumpTexture(__instance);
}
else
{
SetCustomTexture(__instance);
}
}
catch
{
EntryPoint.LogIt("Skipping texture for" + ((Object)((Component)((Component)__instance).transform.parent).gameObject).name + "..");
}
}
private static void DumpTexture(GearMaterialFeeder __instance)
{
for (int i = 0; i < ((Il2CppArrayBase<Renderer>)(object)__instance.m_allRenderers).Count; i++)
{
Renderer val = ((IEnumerable<Renderer>)__instance.m_allRenderers).ElementAt(i);
if (((Object)val.material.shader).name.ToLower().Contains("unlit"))
{
string[] array = new string[4] { "_MainTex", "_ReticuleA", "_ReticuleB", "_ReticuleC" };
foreach (string textName in array)
{
SaveTexture(((Object)((Component)((Component)__instance).transform.parent).gameObject).name, i, val.material, textName);
}
EntryPoint.LogIt(((Object)((Component)((Component)__instance).transform.parent).gameObject).name + " Dumped");
break;
}
}
}
private static void SaveTexture(string weaponName, int index, Material mat, string TextName)
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Expected O, but got Unknown
//IL_006a: 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_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_00ae: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = ((Il2CppObjectBase)mat.GetTexture(TextName)).Cast<Texture2D>();
RenderTexture temporary = RenderTexture.GetTemporary(((Texture)val).width, ((Texture)val).height, 0, (RenderTextureFormat)7, (RenderTextureReadWrite)1);
RenderTexture active = RenderTexture.active;
Graphics.Blit((Texture)(object)val, temporary);
RenderTexture.active = active;
Texture2D val2 = new Texture2D(((Texture)val).width, ((Texture)val).height);
_ = RenderTexture.active;
RenderTexture.active = temporary;
val2.ReadPixels(new Rect(0f, 0f, (float)((Texture)temporary).width, (float)((Texture)temporary).height), 0, 0);
val2.Apply();
if (TextName == "_MainTex")
{
for (int i = 0; i < ((Texture)val2).width; i++)
{
for (int j = 0; j < ((Texture)val2).height; j++)
{
Color val3 = val2.GetPixel(i, j) * newColor;
val2.SetPixel(i, j, val3);
}
}
val2.Apply();
}
RenderTexture.ReleaseTemporary(temporary);
byte[] bytes = Il2CppArrayBase<byte>.op_Implicit((Il2CppArrayBase<byte>)(object)ImageConversion.EncodeToPNG(val2));
string text = "";
text = ((index >= 10) ? (index + TextName) : ("0" + index + TextName));
string text2 = Paths.BepInExRootPath + "\\LowSpec\\";
if (!Directory.Exists(text2))
{
Directory.CreateDirectory(text2);
}
if (!Directory.Exists(text2 + weaponName))
{
Directory.CreateDirectory(text2 + weaponName);
}
File.WriteAllBytes(text2 + weaponName + "\\" + text + ".png", bytes);
}
private static void SetVanillaTexture(GearMaterialFeeder __instance)
{
for (int i = 0; i < ((Il2CppArrayBase<Renderer>)(object)__instance.m_allRenderers).Count; i++)
{
Renderer val = ((IEnumerable<Renderer>)__instance.m_allRenderers).ElementAt(i);
if (!((Object)val.material.shader).name.ToLower().Contains("unlit"))
{
continue;
}
Material material = val.material;
string[] array = textNames;
foreach (string text in array)
{
try
{
material.SetTexture(text, (Texture)(object)LoadEmbeddedTexture(((Object)((Component)((Component)__instance).transform.parent).gameObject).name, text));
material.SetFloat("_SightDirt", 0f);
}
catch
{
EntryPoint.LogIt("Skipping texture " + text + " for " + ((Object)((Component)((Component)__instance).transform.parent).gameObject).name);
}
}
break;
}
}
private static void SetCustomTexture(GearMaterialFeeder __instance)
{
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Expected O, but got Unknown
if (!sightPaths.TryGetValue(((Object)((Component)((Component)__instance).transform.parent).gameObject).name, out string[] value))
{
SetVanillaTexture(__instance);
return;
}
Material val = null;
val = ((IEnumerable<Renderer>)__instance.m_allRenderers).ElementAt(int.Parse(Path.GetFileNameWithoutExtension(value[0]).Substring(0, 2))).material;
if (!((Object)(object)val == (Object)null))
{
string[] array = value;
foreach (string path in array)
{
Texture2D val2 = new Texture2D(1024, 1024, (TextureFormat)4, false);
ImageConversion.LoadImage(val2, Il2CppStructArray<byte>.op_Implicit(File.ReadAllBytes(path)));
val2.Apply();
Material obj = val;
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(path);
obj.SetTexture(fileNameWithoutExtension.Substring(2, fileNameWithoutExtension.Length - 2), (Texture)(object)val2);
val.SetFloat("_SightDirt", 0f);
}
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(CL_ShadowGenerator), "SetCookie")]
private static void MyFlashLight(ref Texture2D cookie)
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Expected O, but got Unknown
if (!((Object)cookie).name.Contains("FlashlightRegular"))
{
return;
}
try
{
if (EntryPoint.oneFlashLight.Value == OneFlashLight.All)
{
if (flashlights.TryGetValue(((Object)cookie).name, out string value))
{
Texture2D val = new Texture2D(512, 512, (TextureFormat)4, false);
ImageConversion.LoadImage(val, Il2CppStructArray<byte>.op_Implicit(File.ReadAllBytes(value)));
cookie = val;
}
else
{
cookie = TryLoadEmbeddedTexture("LowSpecGaming.Resources.FlashLights." + ((Object)cookie).name + ".png");
}
}
else
{
cookie = TryLoadEmbeddedTexture("LowSpecGaming.Resources.FlashLights.FlashlightRegularCookie_01.png");
}
}
catch
{
}
}
public static Texture2D LoadEmbeddedTexture(string gearName, string texName)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
Texture2D val = new Texture2D(512, 512, (TextureFormat)4, false);
ImageConversion.LoadImage(val, Il2CppStructArray<byte>.op_Implicit(GetEmbededResources(gearName, texName)));
val.Apply();
return val;
}
public static Texture2D TryLoadEmbeddedTexture(string resourceName)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
Texture2D val = new Texture2D(512, 512, (TextureFormat)4, false);
ImageConversion.LoadImage(val, Il2CppStructArray<byte>.op_Implicit(TryGetEmbededResources(resourceName)));
val.Apply();
return val;
}
private static byte[] GetEmbededResources(string gearName, string texName)
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
gearName = gearName.Replace(" ", "_");
string text = $"LowSpecGaming.Resources.{gearName}.{texName}.png";
using Stream stream = executingAssembly.GetManifestResourceStream(text);
if (stream == null)
{
throw new FileNotFoundException("Resource not found", text);
}
using MemoryStream memoryStream = new MemoryStream();
stream.CopyTo(memoryStream);
return memoryStream.ToArray();
}
private static byte[] TryGetEmbededResources(string resourceName)
{
using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);
if (stream == null)
{
throw new FileNotFoundException("Resource not found", resourceName);
}
using MemoryStream memoryStream = new MemoryStream();
stream.CopyTo(memoryStream);
return memoryStream.ToArray();
}
private static void ListResourcesInAssembly()
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
if ((object)executingAssembly == null)
{
return;
}
string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
if (manifestResourceNames.Length != 0)
{
EntryPoint.LogIt("Resources in " + executingAssembly.FullName);
string[] array = manifestResourceNames;
for (int i = 0; i < array.Length; i++)
{
EntryPoint.LogIt(array[i]);
}
EntryPoint.LogIt("");
}
}
}
}
namespace LowSpecGaming.Misc
{
[HarmonyPatch]
internal static class BioScanPatch
{
public static bool update;
[HarmonyPrefix]
[HarmonyPatch(typeof(CP_Holopath_Spline), "Reveal")]
private static void Holopath_Spline_Reveal(CP_Holopath_Spline __instance)
{
__instance.CurvySpline.UseThreading = true;
__instance.CurvySpline.UpdateIn = (CurvyUpdateMethod)(-1);
__instance.CurvyExtrusion.Optimize = true;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(CP_Bioscan_Graphics), "Setup")]
private static void Bioscan_Graphics_Setup(CP_Bioscan_Graphics __instance)
{
//IL_0016: 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_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: 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_0080: Unknown result type (might be due to invalid IL or missing references)
if (!__instance.m_colorsByMode.ContainsKey((eChainedPuzzleGraphicsColorMode)4))
{
__instance.m_colorsByMode.Add((eChainedPuzzleGraphicsColorMode)4, __instance.m_currentCol);
}
if (!__instance.m_colorsByMode.ContainsKey((eChainedPuzzleGraphicsColorMode)6))
{
__instance.m_colorsByMode.Add((eChainedPuzzleGraphicsColorMode)6, __instance.m_colorsByMode[(eChainedPuzzleGraphicsColorMode)4]);
}
if (!__instance.m_colorsByMode.ContainsKey((eChainedPuzzleGraphicsColorMode)5))
{
__instance.m_colorsByMode.Add((eChainedPuzzleGraphicsColorMode)5, __instance.m_colorsByMode[(eChainedPuzzleGraphicsColorMode)4] * new Color(1.1f, 1.1f, 1.1f, 1.1f));
}
Dictionary<eChainedPuzzleGraphicsColorMode, Color> colorsByMode = __instance.m_colorsByMode;
colorsByMode[(eChainedPuzzleGraphicsColorMode)5] = colorsByMode[(eChainedPuzzleGraphicsColorMode)5] * new Color(1.1f, 1.1f, 1.1f, 1.1f);
}
}
[HarmonyPatch]
internal static class SpitterPatch
{
public static bool hate = true;
[HarmonyPostfix]
[HarmonyPatch(typeof(InfectionSpitter), "Awake")]
public static void ShutUpSpitter(InfectionSpitter __instance)
{
if (hate)
{
Material material = __instance.m_renderer.material;
material.GetTexture(1).mipMapBias = 10f;
material.GetTexture("_MetallicGlossMap").mipMapBias = 10f;
material.GetTexture("_SSSMap").mipMapBias = 10f;
material.GetTexture("_MainTex_B").mipMapBias = 10f;
Object.Destroy((Object)(object)((Component)__instance).gameObject.GetComponentInChildren<Decal>());
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(InfectionSpitter), "StopPurring")]
public static void StopPurring(InfectionSpitter __instance)
{
__instance.m_purrLoopPlaying = true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(InfectionSpitter), "TryPlaySound")]
public static bool StopPurringSeriously(ref uint id)
{
if (id == EVENTS.INFECTION_SPITTER_PURR_LOOP)
{
return false;
}
return true;
}
}
[HarmonyPatch]
internal class WeaponPatch
{
[HarmonyPrefix]
[HarmonyPatch(typeof(ShellCasing), "Awake")]
private static bool MyMags(ShellCasing __instance)
{
((Component)__instance).gameObject.active = false;
Object.Destroy((Object)(object)((Component)((Component)__instance).transform.GetChild(0)).gameObject);
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(DisableAfterDelay), "Awake")]
private static void MyBullets(DisableAfterDelay __instance)
{
__instance.delay = 0f;
}
}
}