public void ModRegistryReady(IModRegistry registry)
        {
            if (registry.IsLoaded("tZed.SimpleSprinkler"))
            {
                this.simpleSprinklersAPI = registry.GetApi <ISimpleSprinklersAPI>("tZed.SimpleSprinkler");
            }

            if (registry.IsLoaded("Speeder.BetterSprinklers"))
            {
                this.betterSprinklersAPI = registry.GetApi <IBetterSprinklersAPI>("Speeder.BetterSprinklers");
            }
        }
 /// <summary>Called when the mod registry is ready.</summary>
 /// <param name="registry">The mod registry.</param>
 public void ModRegistryReady(IModRegistry registry)
 {
     if (registry.IsLoaded("stokastic.PrismaticTools"))
     {
         this.prismaticToolsAPI = registry.GetApi<IPrismaticToolsAPI>("stokastic.PrismaticTools");
     }
 }
Exemple #3
0
        /// <inheritdoc cref="IModRegistry.GetApi{T}"/>
        /// <param name="modRegistry">The mod registry to extend.</param>
        /// <param name="uniqueId">The mod's unique ID.</param>
        /// <param name="label">A human-readable name for the mod.</param>
        /// <param name="minVersion">The minimum supported version of the API.</param>
        /// <param name="monitor">The monitor with which to log errors.</param>
        public static TInterface GetApi <TInterface>(this IModRegistry modRegistry, string uniqueId, string label, string minVersion, IMonitor monitor) where TInterface : class
        {
            // fetch info
            IManifest manifest = modRegistry.Get(uniqueId)?.Manifest;

            if (manifest == null)
            {
                return(null);
            }

            // check version
            if (manifest.Version.IsOlderThan(minVersion))
            {
                monitor.Log($"Detected {label} {manifest.Version}, but need {minVersion} or later. Disabled integration with this mod.", LogLevel.Warn);
                return(null);
            }

            // fetch API
            TInterface api = modRegistry.GetApi <TInterface>(uniqueId);

            if (api == null)
            {
                monitor.Log($"Detected {label}, but couldn't fetch its API. Disabled integration with this mod.", LogLevel.Warn);
                return(null);
            }

            return(api);
        }
        /// <summary>
        /// Set up compatibility with other external mods.
        /// </summary>
        private void AddModCompatibility()
        {
            // Setup compatibility for the mod [Rush Orders].

            isPlayerUsingRushedOrders = false;

            // Check if the player uses the mod [Rush Orders].
            bool isLoaded = modRegistry.IsLoaded(MOD_RUSH_ORDERS_MOD_ID);

            if (!isLoaded)
            {
                return;
            }

            // The API we consume is only available starting with Rush Orders 1.1.4.
            IModInfo mod = modRegistry.Get(MOD_RUSH_ORDERS_MOD_ID);

            if (mod.Manifest.Version.IsOlderThan("1.1.4"))
            {
                monitor.Log($"You are running an unsupported version of the mod [{mod.Manifest.Name}]! " +
                            $"Please use at least [{mod.Manifest.Name} 1.1.4] for compatibility!", LogLevel.Info);
                return;
            }

            rushOrdersApi = modRegistry.GetApi <IRushOrdersApi>(MOD_RUSH_ORDERS_MOD_ID);
            if (rushOrdersApi == null)
            {
                monitor.Log($"Could not add compatibility for the mod [{mod.Manifest.Name}]! " +
                            $"A newer version of the mod [ToolUpgradeDeliveryService] might be needed.", LogLevel.Error);
                return;
            }

            rushOrdersApi.ToolRushed += OnPlacedRushOrder;
            isPlayerUsingRushedOrders = true;
        }
        /*********
        ** Public methods
        *********/
        /// <summary>Get a mod API if it's installed and valid.</summary>
        /// <param name="label">A human-readable name for the mod.</param>
        /// <param name="modId">The mod's unique ID.</param>
        /// <param name="minVersion">The minimum version of the mod that's supported.</param>
        /// <param name="modRegistry">An API for fetching metadata about loaded mods.</param>
        /// <param name="monitor">Encapsulates monitoring and logging.</param>
        /// <returns>Returns the mod's API interface if valid, else null.</returns>
        public static TInterface GetValidatedApi <TInterface>(string label, string modId, string minVersion, IModRegistry modRegistry, IMonitor monitor)
            where TInterface : class
        {
            // check mod installed
            IManifest mod = modRegistry.Get(modId)?.Manifest;

            if (mod == null)
            {
                return(null);
            }

            // check mod version
            if (mod.Version.IsOlderThan(minVersion))
            {
                monitor.Log($"Detected {label} {mod.Version}, but need {minVersion} or later. Disabled integration with that mod.", LogLevel.Warn);
                return(null);
            }

            // get API
            var api = modRegistry.GetApi <TInterface>(modId);

            if (api == null)
            {
                monitor.Log($"Detected {label}, but couldn't fetch its API. Disabled integration with that mod.", LogLevel.Warn);
                return(null);
            }

            return(api);
        }
Exemple #6
0
        public CustomKissingModProxy(IModRegistry registry, IMonitor monitor)
        {
            IModInfo modInfo = registry.Get("Digus.CustomKissingMod");

            if (modInfo != null && modInfo.Manifest.Version.IsOlderThan(MINIMUM_VERSION))
            {
                monitor.Log($"Couldn't work correctly with Custom Kissing Mod version {modInfo.Manifest.Version} (requires >= {MINIMUM_VERSION}). Don't worry, this issue doesn't affect stability, but update is recommended :)", LogLevel.Warn);
            }

            this.api = registry.GetApi <ICustomKissingModApi>("Digus.CustomKissingMod");
        }
Exemple #7
0
        /// <inheritdoc/>
        public void AddColorOption(IManifest mod, Func <Color> getValue, Action <Color> setValue, Func <string> name,
                                   Func <string> tooltip = null, bool showAlpha = true,
                                   uint colorPickerStyle = 0, string fieldId    = null)
        {
            var gmcm = modRegistry.GetApi <GMCMAPI>("spacechase0.GenericModConfigMenu");

            if (gmcm == null)
            {
                return;
            }
            ColorPickerOption option = new ColorPickerOption(fixedHeight, getValue, setValue, showAlpha, (ColorPickerStyle)colorPickerStyle);

            gmcm.AddComplexOption(
                mod: mod,
                name: name,
                tooltip: tooltip,
                draw: option.Draw,
                height: option.Height,
                beforeMenuOpened: option.Reset,
                beforeSave: option.SaveChanges,
                afterReset: option.Reset,
                fieldId: fieldId);
        }
Exemple #8
0
 /// <summary>Get the mod API for Generic Mod Config Menu, if it's loaded and compatible.</summary>
 /// <param name="modRegistry">The mod registry to extend.</param>
 /// <param name="monitor">The monitor with which to log errors.</param>
 /// <returns>Returns the API instance if available, else <c>null</c>.</returns>
 public static IGenericModConfigMenuApi GetGenericModConfigMenuApi(this IModRegistry modRegistry, IMonitor monitor)
 {
     return(modRegistry.GetApi <IGenericModConfigMenuApi>("spacechase0.GenericModConfigMenu", "Generic Mod Config Menu", "1.8.0", monitor));
 }
 public CustomKissingModProxy(IModRegistry registry)
 {
     this.api = registry.GetApi <ICustomKissingModApi>("Digus.CustomKissingMod");
 }