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.

79 lines
2.4KB

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