Decompiled source of VLog v2.1.14

OreoM.VLog.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("OreoM.VLog")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.1.14.0")]
[assembly: AssemblyInformationalVersion("2.1.14")]
[assembly: AssemblyProduct("VLog")]
[assembly: AssemblyTitle("OreoM.VLog")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.1.14.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace VLog
{
	internal class CustomLogger : ILogListener, IDisposable, ILogHandler
	{
		private StreamWriter logWriter;

		private DateTime time = DateTime.Now;

		public CustomLogger()
		{
			string text = Application.persistentDataPath + "\\VLogs";
			string destFileName = text + "\\Player_" + time.ToString("yyyy-MM-dd_HH-mm-ss") + ".log";
			Directory.CreateDirectory(text);
			File.Copy(Application.persistentDataPath + "\\Player.log", destFileName);
			logWriter = new StreamWriter(text + "\\Player_" + time.ToString("yyyy-MM-dd_HH-mm-ss") + ".log", append: true)
			{
				AutoFlush = true
			};
		}

		public void LogEvent(object sender, LogEventArgs args)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			logWriter.WriteLine($"[{args.Level}] {args.Source.SourceName}: {args.Data}");
		}

		public void LogUnity(string log, string stackTrace, LogType type)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			logWriter.WriteLine($"{type}: {log}\n{stackTrace}");
		}

		public void LogFormat(LogType logType, Object context, string format, params object[] args)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			logWriter.WriteLine($"{logType}: {string.Format(format, args)}");
		}

		public void LogException(Exception exception, Object context)
		{
			logWriter.WriteLine($"Exception: {exception}");
		}

		public void Dispose()
		{
			logWriter?.Dispose();
		}
	}
	[BepInPlugin("OreoM.VLog", "VLog", "2.1.14")]
	public class VLog : BaseUnityPlugin
	{
		private bool isModded;

		private string[] allowedVanillaMods = new string[22]
		{
			"chboo1.lethalcompany.hqfixes", "com.adibtw.loadstone", "com.fumiko.CullFactory", "com.github.tinyhoot.ShipLoot", "com.rune580.LethalCompanyInputUtils", "LCBetterSaves", "LightsOut", "mattymatty.TooManyItems", "MoreItems", "OreoM.VLog",
			"OreoM.ShipLootCruiser", "LethalRebinding", "ArlenFreii.40Arachnophobia", "quackandcheese.togglemute", "viviko.NoSellLimit", "Zaggy1024.PathfindingLib", "Zaggy1024.PathfindingLagFix", "SlushyRH.LethalCompany.FreeMoons", "com.github.zehsteam.StreamOverlays", "com.github.zehsteam.SellMyScrap",
			"com.github.zehsteam.SellMyScrap.v40-v72", "lekakid.lcfontpatcher"
		};

		private string[] allowedModdedMods = new string[29]
		{
			"atomic.terminalapi", "BCMECodeSecurityCheck", "Drinkable.BrutalCompanyMinus", "LethalNetworkAPI", ".LCMaxSoundsFix", "AudioKnight.StarlancerAIFix", "bauyrsaq.SynthesisAssembly", "evaisa.lethallib", "MaxWasUnavailable.LethalModDataLib", "imabatby.lethallevelloader",
			"CompanyCruiserFix", "DerelictMoonPlugin", "imabatby.lethaltoolbox", "JacobG5.JLL", "JacobG5.JLLItemModule", "JacobG5.WesleyMoonScripts", "LethalNetworkAPI", "ShowMoonPriceLLL", "Tomatobird.BluranceTerrainFix", "ViewExtension",
			"Yorimor.CustomStoryLogs", "Chaos.LCCutscene", "com.github.WhiteSpike.MoonDaySpeedMultiplierPatcher", "dev.ladyalice.dungenplus", "dev.ladyalice.dungenplus.loadstonepatch", "JacobG5.ReverbTriggerFix", "JacobG5.WesleyMoons", "LethalPerformance", "MW.MagicWesleyInteriors"
		};

		public static VLog Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal CustomLogger vlogger { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Logger.LogInfo((object)"OreoM.VLog v2.1.14 has loaded!");
		}

		private void OnDestroy()
		{
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Expected O, but got Unknown
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Expected O, but got Unknown
			List<string> merged = new List<string>();
			isModded = false;
			bool flag = Chainloader.PluginInfos.Keys.All((string pluginGuid) => allowedVanillaMods.Contains(pluginGuid));
			if (!flag)
			{
				merged.AddRange(allowedVanillaMods);
				merged.AddRange(allowedModdedMods);
				isModded = Chainloader.PluginInfos.Keys.All((string pluginGuid) => merged.Contains(pluginGuid));
			}
			if (!flag && !isModded)
			{
				Logger.LogInfo((object)"Please make sure you're only using allowed mods.\nVLog detected the following mods: ");
				foreach (PluginInfo value in Chainloader.PluginInfos.Values)
				{
					Logger.LogInfo((object)$"{value.Metadata.GUID} - {value.Metadata.Name} {value.Metadata.Version}");
				}
			}
			if (flag || isModded)
			{
				try
				{
					Logger.LogInfo((object)("Mods verified!\n" + $"Modded: {isModded}"));
					vlogger = new CustomLogger();
					Application.logMessageReceived += new LogCallback(vlogger.LogUnity);
					Application.logMessageReceivedThreaded += new LogCallback(vlogger.LogUnity);
					Debug.unityLogger.logHandler = (ILogHandler)(object)vlogger;
					Logger.Listeners.Clear();
					Logger.Listeners.Add((ILogListener)(object)vlogger);
				}
				catch (Exception ex)
				{
					Debug.LogException(ex);
				}
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "OreoM.VLog";

		public const string PLUGIN_NAME = "VLog";

		public const string PLUGIN_VERSION = "2.1.14";
	}
}