using System.Reflection; using IllusionPlugin; using GamecraftModdingAPI.Utility; using Leadercraft.Server; namespace Leadercraft { public class LeadercraftPlugin : IPlugin // the Illusion Plugin Architecture (IPA) will ignore classes that don't implement IPlugin' { public static float LoopDelay = 0.1f; public string Name { get; } = Assembly.GetExecutingAssembly().GetName().Name; // mod name public string Version { get; } = Assembly.GetExecutingAssembly().GetName().Version.ToString(); // mod & assembly version internal static LeadercraftApi Api = null; private static string tokenUrl = #if DEBUG "http://192.168.122.229:1337/token"; #else "https://leadercraft.exmods.org/token"; #endif private static string criteriaUrl = #if DEBUG "http://192.168.122.229:7048/criteria"; #else "https://board.exmods.org/criteria"; #endif public static void BuildApi() { if (Api == null) { if (!Tools.IsSteamAvailable) { Logging.MetaDebugLog("Steam is unavailable :("); return; } Api = new LeadercraftApi(Tools.UserId, tokenUrl, criteriaUrl); GamecraftModdingAPI.Utility.Logging.MetaDebugLog("Leadercraft API initialized"); } } // called when Gamecraft shuts down public void OnApplicationQuit() { // Shutdown this mod GamecraftModdingAPI.Utility.Logging.LogDebug($"{Name} has shutdown"); // Shutdown the Gamecraft modding API last GamecraftModdingAPI.Main.Shutdown(); } // called when Gamecraft starts up public void OnApplicationStart() { // Initialize the Gamecraft modding API first GamecraftModdingAPI.Main.Init(); // check out the modding API docs here: https://mod.exmods.org/ // Initialize this mod GamecraftModdingAPI.Utility.GameEngineManager.AddGameEngine(new Scoring.LeadercraftSimEventHandler()); GamecraftModdingAPI.Utility.GameEngineManager.AddGameEngine(new Scoring.LeadercraftGameEventHandler()); GamecraftModdingAPI.Events.EventManager.AddEventHandler(new Scoring.GameLoop()); GamecraftModdingAPI.Utility.Logging.LogDebug($"{Name} has started up"); // Debug mode Debug(); } // unused methods public void OnFixedUpdate() { } // called once per physics update public void OnLevelWasInitialized(int level) { }// called after a level is initialized public void OnLevelWasLoaded(int level) { } // called after a level is loaded public void OnUpdate() { } // called once per rendered frame (frame update) public static void Debug() { tokenUrl = "http://192.168.122.229:1337/token"; criteriaUrl = "http://192.168.122.229:7048/criteria"; } } }