using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AIGraph;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using GTFO.API;
using GTFO.API.Utilities;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppSystem;
using LevelGeneration;
using LevelGeneration.Core;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("STFU")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+a5c817df18c4a86f594375edc77d30c780a39c31")]
[assembly: AssemblyProduct("STFU")]
[assembly: AssemblyTitle("STFU")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace STFU
{
internal static class Configuration
{
private static readonly ConfigFile Config;
private static readonly ConfigEntry<bool> Config_SuppressAllMCP3Logs;
private static readonly ConfigEntry<bool> Config_SuppressCGWSLogs;
private static readonly ConfigEntry<bool> Config_LogGeoVolumeResults;
private static readonly ConfigEntry<bool> Config_LogBoxColliderResults;
private static readonly ConfigEntry<bool> Config_ShowAffectedBoxColliderNames;
public static bool SuppressAllMCP3Logs => Config_SuppressAllMCP3Logs.Value;
public static bool SuppressAllCGWSLogs => Config_SuppressCGWSLogs.Value;
public static bool LogGeoVolumeResults => Config_LogGeoVolumeResults.Value;
public static bool LogBoxColliderResults => Config_LogBoxColliderResults.Value;
public static bool ShowAffectedBoxColliderNames => Config_ShowAffectedBoxColliderNames.Value;
static Configuration()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
Config = new ConfigFile(Path.Combine(Paths.ConfigPath, "STFU.cfg"), true);
string text = "General Settings";
Config_SuppressAllMCP3Logs = Config.Bind<bool>(text, "Suppress All MyCoolPlugin3 Logs", false, "If enabled, don't allow any logs from MCP3. Otherwise, only print unique logs.");
Config_SuppressCGWSLogs = Config.Bind<bool>(text, "Suppress ConfigurableGlobalWaveSettings Logs", true, "If enabled, don't allow any logs of EnemyType Heats and selected EnemyTypes from CGWS.");
Config_LogGeoVolumeResults = Config.Bind<bool>(text, "Show Post-LG GeomorphVolume Results", true, "Show the total amount of \"borken cells\" error logs.");
Config_LogBoxColliderResults = Config.Bind<bool>(text, "Show Post-LG BoxCollider Results", true, "Show the total amount of BoxColliders warning logs with a negative size or scale.");
Config_ShowAffectedBoxColliderNames = Config.Bind<bool>(text, "Show Affected BoxCollider Names", false, "List the specific BoxColliders that have a negative size or scale.");
}
internal static void Init()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
LiveEditListener val = LiveEdit.CreateListener(Paths.ConfigPath, "STFU.cfg", false);
val.FileChanged += new LiveEditEventHandler(OnFileChanged);
}
private static void OnFileChanged(LiveEditEventArgs e)
{
STFULogger.LogWarning("Config file changed: " + e.FullPath);
Config.Reload();
}
}
[BepInPlugin("Amor.STFU", "STFU", "1.3.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
internal class EntryPoint : BasePlugin
{
public override void Load()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
Configuration.Init();
new Harmony("Amor.STFU").PatchAll();
RuntimeHelpers.RunClassConstructor(typeof(STFUConsoleDiskLogListener).TypeHandle);
STFULogger.LogInfo("STFU is done loading!");
}
}
internal sealed class STFUConsoleDiskLogListener : ILogListener, IDisposable
{
public static readonly List<BoxCollider> AffectedBoxColliders;
public const string NegativeScaleSize = "BoxColliders does not support negative scale or size.";
private readonly ILogListener _inner;
public LogLevel LogLevelFilter => _inner.LogLevelFilter;
static STFUConsoleDiskLogListener()
{
AffectedBoxColliders = new List<BoxCollider>();
STFULogger.LogWarning("Replacing BepInEx.Logging.Listeners...");
foreach (ILogListener item in Logger.Listeners.ToList())
{
Logger.Listeners.Remove(item);
Logger.Listeners.Add((ILogListener)(object)new STFUConsoleDiskLogListener(item));
}
LevelAPI.OnBuildDone += OnBuildDone;
LevelAPI.OnEnterLevel += OnEnterLevel;
LevelAPI.OnLevelCleanup += OnLevelCleanup;
}
public STFUConsoleDiskLogListener(ILogListener inner)
{
_inner = inner;
}
public void LogEvent(object sender, LogEventArgs eventArgs)
{
if (!(((eventArgs != null) ? eventArgs.Data : null) is string text) || !text.StartsWith("BoxColliders does not support negative scale or size.", StringComparison.Ordinal))
{
_inner.LogEvent(sender, eventArgs);
}
}
public void Dispose()
{
((IDisposable)_inner).Dispose();
}
private static void OnBuildDone()
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: 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_0059: 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_0073: 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)
foreach (BoxCollider item in Object.FindObjectsOfType<BoxCollider>())
{
if (!((Object)(object)item == (Object)null))
{
Vector3 lossyScale = ((Component)item).transform.lossyScale;
Vector3 size = item.size;
if (lossyScale.x < 0f || lossyScale.y < 0f || lossyScale.z < 0f || size.x < 0f || size.y < 0f || size.z < 0f)
{
STFULogger.LogAs((LogLevel)4, "BoxColliders does not support negative scale or size.", suppressLog: true);
AffectedBoxColliders.Add(item);
}
}
}
}
private static void OnEnterLevel()
{
if (!Configuration.LogBoxColliderResults || !AffectedBoxColliders.Any())
{
return;
}
STFULogger.LogWarning($"Found {AffectedBoxColliders.Count} BoxColliders with negative size or scale");
if (Configuration.ShowAffectedBoxColliderNames)
{
STFULogger.LogDebug(AffectedBoxColliders.Select((BoxCollider box) => ((Object)box).name).Aggregate((string a, string b) => a + ", " + b));
}
}
private static void OnLevelCleanup()
{
AffectedBoxColliders.Clear();
}
}
internal static class STFULogger
{
private static readonly ManualLogSource MLS;
public static ConcurrentDictionary<string, int> UniqueLogMap { get; internal set; }
static STFULogger()
{
UniqueLogMap = new ConcurrentDictionary<string, int>();
MLS = Logger.CreateLogSource("STFU");
LevelAPI.OnBuildStart += Clear;
LevelAPI.OnLevelCleanup += Clear;
}
private static void Clear()
{
UniqueLogMap.Clear();
}
public static void LogInfo(string str)
{
MLS.Log((LogLevel)8, (object)str);
}
public static void LogWarning(string str)
{
MLS.Log((LogLevel)4, (object)str);
}
public static void LogError(string str)
{
MLS.Log((LogLevel)2, (object)str);
}
public static void LogDebug(string str)
{
MLS.Log((LogLevel)32, (object)str);
}
public static void LogAs(LogLevel logLevel, string str, bool suppressLog = false)
{
//IL_0015: 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)
UniqueLogMap.AddOrUpdate(str, delegate
{
//IL_0020: 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_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Invalid comparison between Unknown and I4
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Invalid comparison between Unknown and I4
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Invalid comparison between Unknown and I4
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Invalid comparison between Unknown and I4
if (!string.IsNullOrEmpty(str) && !suppressLog)
{
LogLevel val = logLevel;
LogLevel val2 = val;
if ((int)val2 <= 4)
{
if ((int)val2 != 2)
{
if ((int)val2 != 4)
{
goto IL_007d;
}
LogWarning(str);
}
else
{
LogError(str);
}
}
else if ((int)val2 != 8)
{
if ((int)val2 != 32)
{
goto IL_007d;
}
LogDebug(str);
}
else
{
LogInfo(str);
}
}
goto IL_0096;
IL_0096:
return 1;
IL_007d:
LogError("<null> " + str);
goto IL_0096;
}, (string key, int cnt) => ++cnt);
}
public static int GetLogCount(string str)
{
int value;
return UniqueLogMap.TryGetValue(str, out value) ? value : 0;
}
}
}
namespace STFU.Patches
{
[HarmonyPatch(typeof(CellSoundEmitter), "OnParticleCollision")]
internal static class Patch_ParticleCollision
{
[HarmonyPrefix]
private static bool Cancel_Null_ps_Param(CellSoundEmitter __instance)
{
if ((Object)(object)__instance.m_particleSystem == (Object)null)
{
return false;
}
return true;
}
}
[HarmonyPatch]
internal static class Patch_TryGetGeomorphVolume
{
public const string DimensionIsBorken = "ERROR: Dimension X is borken";
public const string NoCellInGrid = "ERROR: Couldn't find cell in grid";
public const string BorkenCell = "ERROR: Borken cell";
public static bool IsNotInLevel { get; private set; }
static Patch_TryGetGeomorphVolume()
{
IsNotInLevel = true;
LevelAPI.OnEnterLevel += OnEnterLevel;
LevelAPI.OnLevelCleanup += OnLevelCleanup;
}
private static void OnEnterLevel()
{
string[] array = new string[3] { "ERROR: Dimension X is borken", "ERROR: Couldn't find cell in grid", "ERROR: Borken cell" };
foreach (string text in array)
{
if (Configuration.LogGeoVolumeResults && STFULogger.UniqueLogMap.TryGetValue(text, out var value))
{
STFULogger.LogWarning($"\"{text}\" message was logged {value} time(s)");
}
}
IsNotInLevel = false;
}
private static void OnLevelCleanup()
{
IsNotInLevel = true;
}
[HarmonyTargetMethod]
private static MethodBase TargetMethod()
{
return AccessTools.Method(typeof(AIG_GeomorphNodeVolume), "TryGetGeomorphVolume", (Type[])null, (Type[])null);
}
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Transpile_GeomorphVolume(IEnumerable<CodeInstruction> instructions)
{
MethodInfo helper = AccessTools.Method(typeof(Patch_TryGetGeomorphVolume), "TryGetGeomorphVolumeSilent", new Type[4]
{
typeof(int),
typeof(eDimensionIndex),
typeof(Vector3),
typeof(AIG_GeomorphNodeVolume).MakeByRefType()
}, (Type[])null);
yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null);
yield return new CodeInstruction(OpCodes.Ldarg_1, (object)null);
yield return new CodeInstruction(OpCodes.Ldarg_2, (object)null);
yield return new CodeInstruction(OpCodes.Ldarg_3, (object)null);
yield return new CodeInstruction(OpCodes.Call, (object)helper);
yield return new CodeInstruction(OpCodes.Ret, (object)null);
}
public static bool TryGetGeomorphVolumeSilent(int floorNR, eDimensionIndex dimensionIndex, Vector3 pos, out AIG_GeomorphNodeVolume resultingGeoVolume)
{
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: 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_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_0109: 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_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
resultingGeoVolume = null;
LG_Floor currentFloor = Builder.CurrentFloor;
if ((Object)(object)currentFloor == (Object)null)
{
Debug.LogError(Object.op_Implicit($"TryGetGeomorphVolume: No floor found! Dim: {dimensionIndex}. Doing this too early?"));
return false;
}
Dimension val = default(Dimension);
if (!currentFloor.GetDimension(dimensionIndex, ref val))
{
Debug.LogError(Object.op_Implicit($"TryGetGeomorphVolume: Tried to get dimension with index ({dimensionIndex}) but failed."));
return false;
}
if (val.Grid == null || !TryGetCell(val.Grid, pos, out LG_Cell cell))
{
LogErrorAs("ERROR: Dimension X is borken", val.DimensionIndex, val.Grid, pos, null);
if (val.Grid != null)
{
LogErrorAs("ERROR: Couldn't find cell in grid", val.DimensionIndex, val.Grid, pos, null);
}
return false;
}
LG_Tile grouping = ((CellBase<LG_Tile, LG_Cell>)(object)cell).m_grouping;
if ((Object)(object)((grouping != null) ? grouping.m_geoRoot : null) == (Object)null)
{
LogErrorAs("ERROR: Borken cell", val.DimensionIndex, val.Grid, pos, cell);
return false;
}
resultingGeoVolume = ((Il2CppObjectBase)((CellBase<LG_Tile, LG_Cell>)(object)cell).m_grouping.m_geoRoot.m_nodeVolume).TryCast<AIG_GeomorphNodeVolume>();
return (Object)(object)resultingGeoVolume != (Object)null;
}
private static bool TryGetCell(LG_Grid grid, Vector3 pos, [MaybeNullWhen(false)] out LG_Cell cell)
{
//IL_0001: 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)
//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_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
pos -= ((CellGridBase<LG_Grid, LG_Tile, LG_Cell>)(object)grid).m_gridPosition;
int num = Mathf.RoundToInt((pos.x - ((CellGridBase<LG_Grid, LG_Tile, LG_Cell>)(object)grid).m_cellDimHalf) / ((CellGridBase<LG_Grid, LG_Tile, LG_Cell>)(object)grid).m_cellDim);
int num2 = Mathf.RoundToInt((pos.z - ((CellGridBase<LG_Grid, LG_Tile, LG_Cell>)(object)grid).m_cellDimHalf) / ((CellGridBase<LG_Grid, LG_Tile, LG_Cell>)(object)grid).m_cellDim);
if (num < 0 || num2 < 0 || num >= ((CellGridBase<LG_Grid, LG_Tile, LG_Cell>)(object)grid).m_sizeX || num2 >= ((CellGridBase<LG_Grid, LG_Tile, LG_Cell>)(object)grid).m_sizeZ)
{
cell = null;
return false;
}
cell = ((CellGridBase<LG_Grid, LG_Tile, LG_Cell>)(object)grid).GetCell(num, num2);
return true;
}
public static void LogErrorAs(string simpleStr, eDimensionIndex dim, LG_Grid? grid, Vector3 pos, LG_Cell? cell)
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: 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_011f: 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)
if (IsNotInLevel)
{
STFULogger.LogAs((LogLevel)2, simpleStr, IsNotInLevel);
return;
}
string text;
switch (simpleStr)
{
case "ERROR: Dimension X is borken":
text = $"ERROR : Dimension {dim} is borken. grid: {grid}, cell: {cell}, DimIndexLookup: {dim}";
break;
case "ERROR: Couldn't find cell in grid":
text = $"ERROR COULDN'T FIND CELL IN GRID : {dim}, gridPos: {((CellGridBase<LG_Grid, LG_Tile, LG_Cell>)(object)grid)?.m_gridPosition}, cellPos: {pos}";
break;
case "ERROR: Borken cell":
{
DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(82, 5);
defaultInterpolatedStringHandler.AppendLiteral("ERROR : Borken cell (pos(");
defaultInterpolatedStringHandler.AppendFormatted<Vector3>(pos);
defaultInterpolatedStringHandler.AppendLiteral(") | cellpos(x:");
defaultInterpolatedStringHandler.AppendFormatted(((CellBase<LG_Tile, LG_Cell>)(object)cell)?.x);
defaultInterpolatedStringHandler.AppendLiteral(", z:");
defaultInterpolatedStringHandler.AppendFormatted(((CellBase<LG_Tile, LG_Cell>)(object)cell)?.z);
defaultInterpolatedStringHandler.AppendLiteral(")) grouping or root. grouping: ");
object obj;
if (cell == null)
{
obj = null;
}
else
{
LG_Tile grouping = ((CellBase<LG_Tile, LG_Cell>)(object)cell).m_grouping;
obj = ((grouping != null) ? ((Object)grouping).ToString() : null);
}
if (obj == null)
{
obj = "<null>";
}
defaultInterpolatedStringHandler.AppendFormatted((string?)obj);
defaultInterpolatedStringHandler.AppendLiteral(" | dim: ");
defaultInterpolatedStringHandler.AppendFormatted<eDimensionIndex>(dim);
text = defaultInterpolatedStringHandler.ToStringAndClear();
break;
}
default:
text = simpleStr;
break;
}
Debug.LogError(Object.op_Implicit(text));
}
}
}
namespace STFU.Dependencies
{
[HarmonyPatch]
internal static class CGWS_Wrapper
{
public const string PLUGIN_GUID = "com.Untilted.ConfigurableGlobalWaveSettings";
private static readonly Type? SPtype;
public const string SPmethod = "LogNextType";
public static bool IsLoaded { get; private set; }
static CGWS_Wrapper()
{
IsLoaded = false;
if (((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("com.Untilted.ConfigurableGlobalWaveSettings", out var value))
{
try
{
Assembly assembly = ((value == null) ? null : value.Instance?.GetType()?.Assembly) ?? throw new Exception("CGWS Assembly is missing!");
Type[] typesFromAssembly = AccessTools.GetTypesFromAssembly(assembly);
SPtype = typesFromAssembly.First((Type t) => t.Name == "SettingsPatches");
IsLoaded = SPtype != null;
}
catch (Exception value2)
{
STFULogger.LogError($"Exception thrown while reading data from ConfigurableGlobalWaveSettings:\n{value2}");
IsLoaded = false;
}
}
STFULogger.LogDebug($"ConfigurableGlobalWaveSettings is loaded: {IsLoaded}");
}
[HarmonyPrepare]
private static bool PreparePatch()
{
return IsLoaded;
}
[HarmonyTargetMethod]
private static MethodBase GetTargetMethod()
{
STFULogger.LogDebug("Found CGWS patch method: LogNextType");
return AccessTools.Method(SPtype, "LogNextType", (Type[])null, (Type[])null);
}
[HarmonyPrefix]
private static bool Pre_LogNextType()
{
return !Configuration.SuppressAllCGWSLogs;
}
}
[HarmonyPatch]
internal static class MCP3_Wrapper
{
public const string PLUGIN_GUID = "com.MyName.MyGTFOPlugin";
private static readonly Type? Ltype;
private static readonly string[] Lmethods;
public static bool IsLoaded { get; private set; }
static MCP3_Wrapper()
{
IsLoaded = false;
Lmethods = new string[3] { "Info", "Debug", "Error" };
if (((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("com.MyName.MyGTFOPlugin", out var value))
{
try
{
Assembly assembly = ((value == null) ? null : value.Instance?.GetType()?.Assembly) ?? throw new Exception("MCP3 Assembly is missing!");
Type[] typesFromAssembly = AccessTools.GetTypesFromAssembly(assembly);
Ltype = typesFromAssembly.First((Type t) => t.Name == "L");
IsLoaded = Ltype != null;
}
catch (Exception value2)
{
STFULogger.LogError($"Exception thrown while reading data from MyCoolPLugin3:\n{value2}");
IsLoaded = false;
}
}
STFULogger.LogDebug($"MyCoolPlugin3 is loaded: {IsLoaded}");
}
[HarmonyPrepare]
private static bool PrepPatches()
{
return IsLoaded;
}
[HarmonyTargetMethods]
private static IEnumerable<MethodBase> GetTargetMethods()
{
string[] lmethods = Lmethods;
foreach (string name in lmethods)
{
yield return AccessTools.Method(Ltype, name, (Type[])null, (Type[])null);
STFULogger.LogAs(MapLogLevel(name), "Found MCP3 patch method: " + name);
}
}
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Transpile_Lspam(IEnumerable<CodeInstruction> instructions, MethodBase __originalMethod)
{
yield return new CodeInstruction(OpCodes.Ldstr, (object)__originalMethod.Name);
yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null);
yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MCP3_Wrapper), "Intercept", new Type[2]
{
typeof(string),
typeof(object)
}, (Type[])null));
yield return new CodeInstruction(OpCodes.Ret, (object)null);
}
public static void Intercept(string method, object data)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
STFULogger.LogAs(MapLogLevel(method), (data as string) ?? string.Empty, Configuration.SuppressAllMCP3Logs);
}
private static LogLevel MapLogLevel(string str)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: 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_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
return (LogLevel)(str switch
{
"Info" => 8,
"Debug" => 32,
"Error" => 2,
_ => 4,
});
}
}
}