/// <summary> /// Check if a plugin is loaded and has at least the minimum version. /// If the plugin is missing or older than minimumVersion, user is shown an error message on screen and false is returned. /// Warning: Run only from Start, not from constructor or Awake because some plugins might not be loaded yet! /// </summary> /// <param name="origin">Your plugin</param> /// <param name="guid">Guid of the plugin your plugin is dependant on</param> /// <param name="minimumVersion">Minimum version of the required plugin</param> /// <param name="level">Level of the issue - <code>Error</code> if plugin can't work, <code>Warning</code> if there might be issues, or <code>None</code> to not show any message.</param> /// <returns>True if plugin exists and it's version equals or is newer than minimumVersion, otherwise false</returns> public static bool CheckRequiredPlugin(BaseUnityPlugin origin, string guid, Version minimumVersion, LogLevel level = LogLevel.Error) { var target = BepInEx.Bootstrap.Chainloader.Plugins .Select(MetadataHelper.GetMetadata) .FirstOrDefault(x => x.GUID == guid); if (target == null) { if (level != LogLevel.None) { KoikatuAPI.Log(LogLevel.Message | level, $"{level.ToString().ToUpper()}: Plugin \"{guid}\" required by \"{MetadataHelper.GetMetadata(origin).GUID}\" was not found!"); } return(false); } if (minimumVersion > target.Version) { if (level != LogLevel.None) { KoikatuAPI.Log(LogLevel.Message | level, $"{level.ToString().ToUpper()}: Plugin \"{guid}\" required by \"{MetadataHelper.GetMetadata(origin).GUID}\" is outdated! At least v{minimumVersion} is needed!"); } return(false); } return(true); }
/// <summary> /// Don't use manually /// </summary> public KoikatuAPI() { Instance = this; Log(LogLevel.Debug, $"Game version {GetGameVersion()} running under {System.Threading.Thread.CurrentThread.CurrentCulture.Name} culture"); Log(LogLevel.Debug, $"Processor: {SystemInfo.processorType} ({SystemInfo.processorCount} cores @ {SystemInfo.processorFrequency}MHz); RAM: {SystemInfo.systemMemorySize}MB; OS: {SystemInfo.operatingSystem}"); SceneManager.sceneLoaded += (scene, mode) => Log(LogLevel.Debug, $"SceneManager.sceneLoaded - {scene.name} in {mode} mode"); SceneManager.sceneUnloaded += scene => Log(LogLevel.Debug, $"SceneManager.sceneUnloaded - {scene.name}"); SceneManager.activeSceneChanged += (prev, next) => Log(LogLevel.Debug, $"SceneManager.activeSceneChanged - from {prev.name} to {next.name}"); }
private void Start() { if (KoikatuAPI.GetCurrentGameMode() == GameMode.Studio) { return; } _logger = Logger; MakerCardSave.RegisterNewCardSavePathModifier(null, FilenameModifier); _nickname = Config.Bind("", "Nickname", DefaultNickname, "Your nickname that will be saved to your cards and used in the card filenames."); CharacterApi.RegisterExtraBehaviour <CardAuthorDataController>(GUID); MakerAPI.RegisterCustomSubCategories += MakerAPI_RegisterCustomSubCategories; MakerAPI.ReloadCustomInterface += MakerApiOnReloadCustomInterface; MakerAPI.MakerExiting += MakerAPI_MakerExiting; }
/// <summary> /// Check if a plugin that is not compatible with your plugin is loaded. /// If the plugin is loaded, user is shown a warning message on screen and true is returned. /// Warning: Run only from Start, not from constructor or Awake because some plugins might not be loaded yet! /// </summary> /// <param name="origin">Your plugin</param> /// <param name="guid">Guid of the plugin your plugin is incompatible with</param> /// <param name="level">Level of the issue - <code>Error</code> if plugin can't work, <code>Warning</code> if there might be issues, or <code>None</code> to not show any message.</param> /// <returns>True if plugin exists, otherwise false</returns> public static bool CheckIncompatiblePlugin(BaseUnityPlugin origin, string guid, LogLevel level = LogLevel.Warning) { var target = BepInEx.Bootstrap.Chainloader.Plugins .Select(MetadataHelper.GetMetadata) .FirstOrDefault(x => x.GUID == guid); if (target != null) { if (level != LogLevel.None) { KoikatuAPI.Log(LogLevel.Message | level, $"{level.ToString().ToUpper()}: Plugin \"{guid}\" is incompatible with \"{MetadataHelper.GetMetadata(origin).GUID}\"!"); } return(true); } return(false); }