Example #1
0
        /// <summary>
        /// Called when the mod is enabled.
        /// </summary>
        public void OnEnabled()
        {
            this.Log                  = new Logger(this.GetType().Assembly);
            this.PluginInfo           = PluginUtils.GetPluginInfo(this);
            UserModBase <T> .Instance = (T)(object)this; // Make the compiler shut up about non-existing conversions

            this.isValid = this.CheckValidity();
            if (!this.isValid)
            {
                return;
            }

            this.CheckIncompatibility();
            this.OnModInitializing();
        }
Example #2
0
        private bool CheckValidity()
        {
            var pluginInfo = PluginUtils.GetPluginInfo(this);

            if (this.WorkshopId > 0 && pluginInfo.PublishedFileID != PublishedFileId.invalid && pluginInfo.PublishedFileID.AsUInt64 != this.WorkshopId)
            {
                // The mod is not published officially
                this.Log.Error("YOU ARE CURRENTLY USING AN UNAUTHORIZED PUBLICATION OF THE MOD '{0}' WITH WORKSHOP ID {1}.\r\n" +
                               "Please use the original version that can be found at http://steamcommunity.com/sharedfiles/filedetails/?id={2}.\r\n\r\n" +
                               "This version will not be loaded. Don't forget to report this version on the original workshop item page as it's most likely stolen (it has happened before).",
                               this.Name.ToUpper(), pluginInfo.PublishedFileID.AsUInt64, this.WorkshopId);
                return(false);
            }
            return(true);
        }
Example #3
0
        /// <summary>
        /// Gets the assembly folder of the calling mod. This is where the DLL and every other static file are located.
        /// </summary>
        /// <param name="modInstance">The mod instance.</param>
        /// <returns>The assembly folder.</returns>
        public static string GetAssemblyFolder(IUserMod modInstance)
        {
            var pluginInfo = PluginUtils.GetPluginInfo(modInstance);

            return(pluginInfo != null ? pluginInfo.ModPath : null);
        }