示例#1
0
        public void Patch()
        {
            if (this.IsPatched)
            {
                return;
            }

            this.TechType = TechTypeHandler.AddTechType(this.ClassID, this.FriendlyName, this.Description, this.UnlocksAtStart);

            if (!this.UnlocksAtStart)
            {
                KnownTechHandler.SetAnalysisTechEntry(this.RequiredForUnlock, new TechType[] { this.TechType });
            }

            if (this.Sprite == null)
            {
                this.Sprite = ImageUtils.LoadSpriteFromFile(IOUtilities.Combine(ExecutingFolder, this.PluginFolder, this.IconFileName));
            }

            SpriteHandler.RegisterSprite(this.TechType, this.Sprite);

            CraftDataHandler.SetTechData(this.TechType, GetBlueprintRecipe());

            CraftDataHandler.AddToGroup(TechGroup.Resources, TechCategory.Electronics, this.TechType);

            CraftDataHandler.SetEquipmentType(this.TechType, this.ChargerType);

            CraftTreeHandler.AddCraftingNode(CraftTree.Type.Fabricator, this.TechType, this.StepsToFabricatorTab);

            PrefabHandler.RegisterPrefab(this);

            AddToList();

            this.IsPatched = true;
        }
示例#2
0
        /// <summary>
        /// Determines thee <see cref="UnityEngine.Sprite"/> to be used for this spawnable's icon.<para/>
        /// Default behavior will look for a PNG file named <see cref="IconFileName"/> inside <see cref="AssetsFolder"/>.
        /// </summary>
        /// <returns>Returns the <see cref="UnityEngine.Sprite"/> that will be used in the <see cref="SpriteHandler.RegisterSprite(TechType, UnityEngine.Sprite)"/> call.</returns>
        protected virtual UnityEngine.Sprite GetItemSprite()
        {
            // This is for backwards compatibility with mods that were using the "ModName/Assets" format
            string path = this.AssetsFolder != modFolderLocation
                ? IOUtilities.Combine(".", "QMods", this.AssetsFolder.Trim('/'), this.IconFileName)
                : Path.Combine(this.AssetsFolder, this.IconFileName);

            if (File.Exists(path))
            {
                return(ImageUtils.LoadSpriteFromFile(path));
            }

            Logger.Warn($"Sprite for '{this.PrefabFileName}'{Environment.NewLine}Did not find an image file at '{path}'");
            return(SpriteManager.defaultSprite);
        }