Ви не можете вибрати більше 25 тем
Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
|
- using System;
- using IllusionPlugin;
- //using UnityEngine;
- using System.Reflection;
-
- using GamecraftModdingAPI.Commands;
- using GamecraftModdingAPI.Utility;
-
- namespace ExtraCommands
- {
- public class Plugin : IllusionPlugin.IEnhancedPlugin
- {
-
- public override string Name { get; } = "ExtraCommands";
-
- public override string Version { get; } = Assembly.GetExecutingAssembly().GetName().Version.ToString();
-
- public string HarmonyID { get; } = "org.git.exmods.extracommands.extracommands";
-
- public override void OnApplicationQuit()
- {
- GamecraftModdingAPI.Main.Shutdown();
- }
-
- public override void OnApplicationStart()
- {
- GamecraftModdingAPI.Main.Init();
- object[] empty = new object[] { };
- int engineCount = 0;
- foreach (Type t in Assembly.GetExecutingAssembly().GetTypes())
- {
- CustomCommandAttribute[] attributes = (CustomCommandAttribute[])t.GetCustomAttributes(typeof(CustomCommandAttribute), false);
- ICustomCommandEngine inst = null;
- foreach (CustomCommandAttribute attr in attributes)
- {
- if (attr != null && CustomCommandAttribute.IsCompatible(t))
- {
- if (inst == null)
- {
- // create instance by getting the constructor through reflection
- inst = (ICustomCommandEngine)t.GetConstructor(new Type[] { }).Invoke(empty);
- CommandManager.AddCommand(inst);
- engineCount++;
- }
- }
- }
- }
- Logging.MetaLog($"Added {engineCount} custom command engines");
- }
- }
- }
|