GamecraftScripting/GamecraftScripting/Plugin.cs

62 lines
1.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using IllusionPlugin;
using UnityEngine;
using GamecraftModdingAPI;
using GamecraftModdingAPI.Commands;
using HarmonyLib;
namespace GamecraftScripting
{
class Plugin : IEnhancedPlugin
{
public string[] Filter { get; } = new string[] { "Gamecraft" };
public string Name { get; } = Assembly.GetExecutingAssembly().GetName().Name;
public string Version { get; } = Assembly.GetExecutingAssembly().GetName().Version.ToString();
private Harmony harmony = null;
public void OnApplicationQuit()
{
var currentAssembly = Assembly.GetExecutingAssembly();
harmony.UnpatchAll(currentAssembly.GetName().Name);
harmony = null;
Main.Shutdown();
}
public void OnApplicationStart()
{
Main.Init();
var currentAssembly = Assembly.GetExecutingAssembly();
harmony = new Harmony(currentAssembly.GetName().Name);
harmony.PatchAll(currentAssembly);
// register development commands
#if DEBUG
#endif
// debugging commands
CommandManager.AddCommand(new Commands.DebugCommandEngine());
// functional commands
CommandManager.AddCommand(new Commands.PythonRunnerCommandEngine());
CommandManager.AddCommand(new Commands.ExecuteCommandEngine());
CommandManager.AddCommand(new Commands.SerializationCommandEngine());
}
public void OnFixedUpdate() { }
public void OnLateUpdate() { }
public void OnLevelWasInitialized(int level) { }
public void OnLevelWasLoaded(int level) { }
public void OnUpdate() { }
}
}