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.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("VLog")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("VLog")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ea8c92d4-b8f5-4404-af47-4c005f339474")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.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.4")]
public class VLogs : BaseUnityPlugin
{
private const string modGUID = "OreoM.VLog";
private const string modName = "VLog";
private const string modVersion = "2.1.4";
private bool isModded;
private string[] allowedVanillaMods = new string[15]
{
"chboo1.lethalcompany.hqfixes", "com.adibtw.loadstone", "com.fumiko.CullFactory", "com.github.tinyhoot.ShipLoot", "com.rune580.LethalCompanyInputUtils", "LCBetterSaves", "LightsOut", "mattymatty.TooManyItems", "MoreItems", "OreoM.VLog",
"quackandcheese.togglemute", "viviko.NoSellLimit", "Zaggy1024.PathfindingLagFix", "SlushyRH.LethalCompany.FreeMoons", "com.github.zehsteam.StreamOverlays"
};
private string[] allowedModdedMods = new string[21]
{
"atomic.terminalapi", "BCMECodeSecurityCheck", "Drinkable.BrutalCompanyMinus", "LethalNetworkAPI", "UnloadedHangar.BrutalCompanyMinusExtras", ".LCMaxSoundsFix", "AudioKnight.StarlancerAIFix", "bauyrsaq.SynthesisAssembly", "com.fumiko.CullFactory", "evaisa.lethallib",
"MaxWasUnavailable.LethalModDataLib", "imabatby.lethallevelloader", "CompanyCruiserFix", "DerelictMoonPlugin", "imabatby.lethaltoolbox", "JacobG5.JLL", "LethalNetworkAPI", "MoreItems", "ShowMoonPriceLLL", "ViewExtension",
"Yorimor.CustomStoryLogs"
};
private CustomLogger vlogger;
internal ManualLogSource vloglog;
private void Awake()
{
vloglog = Logger.CreateLogSource("OreoM.VLog");
vloglog.LogInfo((object)"VLog 2.1.4 has loaded.");
}
private void OnDestroy()
{
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Expected O, but got Unknown
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: 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)
{
vloglog.LogInfo((object)"Please make sure you're only using allowed mods.VLog detected the following mods: ");
foreach (PluginInfo value in Chainloader.PluginInfos.Values)
{
vloglog.LogInfo((object)$"{value.Metadata.GUID} - {value.Metadata.Name} {value.Metadata.Version}");
}
}
if (flag || isModded)
{
vloglog.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);
}
}
}