|
- using System;
- using IllusionPlugin;
- //using UnityEngine;
- using System.Reflection;
-
- using GamecraftModdingAPI.Commands;
- using GamecraftModdingAPI.Utility;
-
- namespace ExtraCommands
- {
- public class Plugin : IllusionPlugin.IEnhancedPlugin
- {
- public string[] Filter { get; } = new string[] { "RobocraftX", "Gamecraft", "GamecraftPreview" };
-
- public string Name { get; } = "ExtraCommands";
-
- public string Version { get; } = Assembly.GetExecutingAssembly().GetName().Version.ToString();
-
- public string HarmonyID { get; } = "org.git.exmods.extracommands.extracommands";
-
- public void OnApplicationQuit()
- {
- GamecraftModdingAPI.Main.Shutdown();
- }
-
- public 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");
- }
-
- public void OnFixedUpdate()
- {
- //throw new NotImplementedException();
- }
-
- public void OnLateUpdate()
- {
- //throw new NotImplementedException();
- }
-
- public void OnLevelWasInitialized(int level)
- {
- //throw new NotImplementedException();
- }
-
- public void OnLevelWasLoaded(int level)
- {
- //throw new NotImplementedException();
- }
-
- public void OnUpdate()
- {
- //throw new NotImplementedException();
- }
- }
- }
|