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.

78 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. // Log info
  37. API.Utility.Logging.MetaLog($"{Name} init complete.");
  38. #if DEBUG
  39. API.App.Client.InitComplete += (_, __) =>
  40. {
  41. startup.Stop();
  42. API.Utility.Logging.MetaLog($"Startup took {startup.ElapsedMilliseconds}ms");
  43. API.Utility.Logging.Log(
  44. $"EAC has detected code mods? {EasyAntiCheat.Client.Hydra.Runtime.Integrity.Violated}" +
  45. (EasyAntiCheat.Client.Hydra.Runtime.Integrity.Violated
  46. ? EasyAntiCheat.Client.Hydra.Runtime.Integrity.ViolationMessage
  47. : ""));
  48. };
  49. #endif
  50. }
  51. private static void LogIPAPlugins()
  52. {
  53. StringBuilder sb = new StringBuilder();
  54. sb.AppendFormat("Running on Unity {0}\n", Application.unityVersion);
  55. sb.AppendFormat("Running on CardLife {0} (aka {1})\n", API.App.Client.Version, Application.version);
  56. sb.AppendFormat("-----------------------------\n");
  57. sb.AppendFormat("Loading plugins from {0} and found {1}\n", System.IO.Path.Combine(Environment.CurrentDirectory, "Plugins"), IllusionInjector.PluginManager.Plugins.Count());
  58. sb.AppendFormat("-----------------------------\n");
  59. foreach (IllusionPlugin.IPlugin plugin in IllusionInjector.PluginManager.Plugins)
  60. {
  61. sb.AppendFormat(" {0}: {1}\n", plugin.Name, plugin.Version);
  62. }
  63. sb.AppendFormat("-----------------------------\n");
  64. API.Utility.Logging.Log(sb.ToString());
  65. }
  66. }
  67. }