using System; using UnityEngine; using GamecraftModdingAPI.Utility; namespace GamecraftModdingAPI.App { /// <summary> /// The Gamecraft application that is running this code right now. /// </summary> public class Client { // extensible engine protected static AppEngine appEngine = new AppEngine(); /// <summary> /// An event that fires whenever the main menu is loaded. /// </summary> public static event EventHandler<MenuEventArgs> EnterMenu { add => appEngine.EnterMenu += value; remove => appEngine.EnterMenu -= value; } /// <summary> /// An event that fire whenever the main menu is exited. /// </summary> public static event EventHandler<MenuEventArgs> ExitMenu { add => appEngine.ExitMenu += value; remove => appEngine.ExitMenu -= value; } /// <summary> /// Gamecraft build version string. /// Usually this is in the form YYYY.mm.DD.HH.MM.SS /// </summary> /// <value>The version.</value> public string Version { get => Application.version; } /// <summary> /// Unity version string. /// </summary> /// <value>The unity version.</value> public string UnityVersion { get => Application.unityVersion; } /// <summary> /// Game saves currently visible in the menu. /// These take a second to completely populate after the EnterMenu event fires. /// </summary> /// <value>My games.</value> public Game[] MyGames { get { if (!appEngine.IsInMenu) return new Game[0]; return appEngine.GetMyGames(); } } /// <summary> /// Whether Gamecraft is in the Main Menu /// </summary> /// <value><c>true</c> if in menu; <c>false</c> when loading or in a game.</value> public bool InMenu { get => appEngine.IsInMenu; } internal static void Init() { MenuEngineManager.AddMenuEngine(appEngine); } } }