Unofficial CardLife revival project, pronounced like "celery"
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
3.1KB

  1. using System;
  2. using System.Diagnostics;
  3. using System.Linq;
  4. using System.Reflection;
  5. using System.Text;
  6. using CLre.API.Characters;
  7. using HarmonyLib;
  8. using Svelto.ECS;
  9. using UnityEngine;
  10. namespace CLre
  11. {
  12. public class CLre : IllusionPlugin.IEnhancedPlugin // the Illusion Plugin Architecture (IPA) will ignore classes that don't implement IPlugin
  13. {
  14. public override string Name { get; } = Assembly.GetExecutingAssembly().GetName().Name;
  15. public override string Version { get; } = Assembly.GetExecutingAssembly().GetName().Version.ToString();
  16. private Harmony harmonyInstance = null;
  17. // called when Cardlife shuts down
  18. public override void OnApplicationQuit()
  19. {
  20. harmonyInstance.UnpatchAll();
  21. }
  22. // called when Cardlife starts up
  23. public override void OnApplicationStart()
  24. {
  25. #if DEBUG
  26. FileLog.Reset();
  27. Harmony.DEBUG = true;
  28. Stopwatch startup = Stopwatch.StartNew();
  29. #endif
  30. // init all Harmony patches in project
  31. harmonyInstance = new Harmony(Name);
  32. harmonyInstance.PatchAll();
  33. // patches for bugs
  34. Fixes.InitLogSooner.Init();
  35. // misc
  36. LogIPAPlugins();
  37. Fixes.BugfixAttributeUtility.LogBugfixes();
  38. // Log info
  39. API.Utility.Logging.MetaLog($"{Name} init complete.");
  40. #if DEBUG
  41. API.App.Client.InitComplete += (_, __) =>
  42. {
  43. startup.Stop();
  44. API.Utility.Logging.MetaLog($"Startup took {startup.ElapsedMilliseconds}ms");
  45. API.Utility.Logging.Log(
  46. $"EAC has detected code mods? {EasyAntiCheat.Client.Hydra.Runtime.Integrity.Violated}" +
  47. (EasyAntiCheat.Client.Hydra.Runtime.Integrity.Violated
  48. ? EasyAntiCheat.Client.Hydra.Runtime.Integrity.ViolationMessage
  49. : ""));
  50. };
  51. API.App.Client.MenuReady += (_, __) => { API.Utility.Logging.MetaLog("Menu engine ready event fired!"); };
  52. API.App.Client.GameReady += (_, __) => { API.Utility.Logging.MetaLog("Game engine ready event fired!"); };
  53. API.App.Client.GameFrameworkReady += (_, __) => { API.Utility.Logging.MetaLog("Game framework ready event fired!"); };
  54. API.App.Client.GameFrameworkExit += (_, __) => { API.Utility.Logging.MetaLog("Game framework exit event fired!"); };
  55. Character c = Character.Local();
  56. c.Superuser = true;
  57. #endif
  58. }
  59. private static void LogIPAPlugins()
  60. {
  61. StringBuilder sb = new StringBuilder();
  62. sb.AppendFormat("Running on Unity {0}\n", Application.unityVersion);
  63. sb.AppendFormat("Running on CardLife {0} (aka {1})\n", API.App.Client.Version, Application.version);
  64. sb.AppendFormat("-----------------------------\n");
  65. sb.AppendFormat("Loading plugins from {0} and found {1}\n", System.IO.Path.Combine(Environment.CurrentDirectory, "Plugins"), IllusionInjector.PluginManager.Plugins.Count());
  66. sb.AppendFormat("-----------------------------\n");
  67. foreach (IllusionPlugin.IPlugin plugin in IllusionInjector.PluginManager.Plugins)
  68. {
  69. sb.AppendFormat(" {0}: {1}\n", plugin.Name, plugin.Version);
  70. }
  71. sb.AppendFormat("-----------------------------\n");
  72. API.Utility.Logging.Log(sb.ToString());
  73. }
  74. public override void OnGUI()
  75. {
  76. if (GUI.Button(new Rect(10, 10, 50, 50), "TEST"))
  77. {
  78. }
  79. }
  80. }
  81. }