|
- using System;
- using System.Diagnostics;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using CLre.API.Characters;
- using HarmonyLib;
- using Svelto.ECS;
- using UnityEngine;
-
- namespace CLre
- {
- public class CLre : IllusionPlugin.IEnhancedPlugin // the Illusion Plugin Architecture (IPA) will ignore classes that don't implement IPlugin
- {
- public override string Name { get; } = Assembly.GetExecutingAssembly().GetName().Name;
-
- public override string Version { get; } = Assembly.GetExecutingAssembly().GetName().Version.ToString();
-
- private Harmony harmonyInstance = null;
- // called when Cardlife shuts down
- public override void OnApplicationQuit()
- {
- harmonyInstance.UnpatchAll();
- }
-
- // called when Cardlife starts up
- public override void OnApplicationStart()
- {
- #if DEBUG
- FileLog.Reset();
- Harmony.DEBUG = true;
- Stopwatch startup = Stopwatch.StartNew();
- #endif
- // init all Harmony patches in project
- harmonyInstance = new Harmony(Name);
- harmonyInstance.PatchAll();
-
- // patches for bugs
- Fixes.InitLogSooner.Init();
-
- // misc
- LogIPAPlugins();
- Fixes.BugfixAttributeUtility.LogBugfixes();
-
- // Log info
- API.Utility.Logging.MetaLog($"{Name} init complete.");
-
- #if DEBUG
- API.App.Client.InitComplete += (_, __) =>
- {
- startup.Stop();
- API.Utility.Logging.MetaLog($"Startup took {startup.ElapsedMilliseconds}ms");
- API.Utility.Logging.Log(
- $"EAC has detected code mods? {EasyAntiCheat.Client.Hydra.Runtime.Integrity.Violated}" +
- (EasyAntiCheat.Client.Hydra.Runtime.Integrity.Violated
- ? EasyAntiCheat.Client.Hydra.Runtime.Integrity.ViolationMessage
- : ""));
- };
-
- API.App.Client.MenuReady += (_, __) => { API.Utility.Logging.MetaLog("Menu engine ready event fired!"); };
- API.App.Client.GameReady += (_, __) => { API.Utility.Logging.MetaLog("Game engine ready event fired!"); };
- API.App.Client.GameFrameworkReady += (_, __) => { API.Utility.Logging.MetaLog("Game framework ready event fired!"); };
- API.App.Client.GameFrameworkExit += (_, __) => { API.Utility.Logging.MetaLog("Game framework exit event fired!"); };
-
- Character c = Character.Local();
- c.Superuser = true;
- #endif
- }
-
- private static void LogIPAPlugins()
- {
- StringBuilder sb = new StringBuilder();
- sb.AppendFormat("Running on Unity {0}\n", Application.unityVersion);
- sb.AppendFormat("Running on CardLife {0} (aka {1})\n", API.App.Client.Version, Application.version);
- sb.AppendFormat("-----------------------------\n");
- sb.AppendFormat("Loading plugins from {0} and found {1}\n", System.IO.Path.Combine(Environment.CurrentDirectory, "Plugins"), IllusionInjector.PluginManager.Plugins.Count());
- sb.AppendFormat("-----------------------------\n");
- foreach (IllusionPlugin.IPlugin plugin in IllusionInjector.PluginManager.Plugins)
- {
-
- sb.AppendFormat(" {0}: {1}\n", plugin.Name, plugin.Version);
- }
- sb.AppendFormat("-----------------------------\n");
- API.Utility.Logging.Log(sb.ToString());
- }
- }
- }
|