예제 #1
0
        private static List <IDecorationItem> RegisterDecorationItems()
        {
            List <IDecorationItem> result = new List <IDecorationItem>();

            Logger.Log("Registering items...");

            // Get the list of modified existing items
            var existingItems = from t in Assembly.GetExecutingAssembly().GetTypes()
                                where t.IsClass && t.Namespace == "DecorationsMod.ExistingItems"
                                select t;

            // Register modified existing items
            foreach (Type existingItemType in existingItems)
            {
                // Get item
                DecorationItem existingItem = (DecorationItem)(Activator.CreateInstance(existingItemType));
                // Register item
                existingItem.RegisterItem();
                // Unlock item at game start
                KnownTechPatcher.unlockedAtStart.Add(existingItem.TechType);
                // Store item in the list
                result.Add(existingItem);
            }

            // Get the list of new items
            var newItems = from t in Assembly.GetExecutingAssembly().GetTypes()
                           where t.IsClass && t.Namespace == "DecorationsMod.NewItems"
                           select t;

            // Register new items
            foreach (Type newItemType in newItems)
            {
                DecorationItem newItem = (DecorationItem)(Activator.CreateInstance(newItemType));

                // If current item is not a nutrient block continue, otherwise if that is a nutrient block
                // we continue only if nutrient blocks are enabled in Config.txt file.
                if (newItem.TechType != TechType.NutrientBlock || (newItem.TechType == TechType.NutrientBlock && ConfigSwitcher.EnableNutrientBlock))
                {
                    // If decoration items from habitat builder are enabled, add everything.
                    // Otherwise add only items that are not from habitat builder.
                    if (ConfigSwitcher.EnableSpecialItems || (!ConfigSwitcher.EnableSpecialItems && !newItem.IsHabitatBuilder))
                    {
                        newItem.RegisterItem();
                        result.Add(newItem);
                    }
                }
            }

            // Get the list of new land flora
            var newFlora = from t in Assembly.GetExecutingAssembly().GetTypes()
                           where t.IsClass && t.Namespace == "DecorationsMod.Flora"
                           select t;

            // Register new land flora
            foreach (Type newItemType in newFlora)
            {
                DecorationItem newItem = (DecorationItem)(Activator.CreateInstance(newItemType));

                newItem.RegisterItem();
                result.Add(newItem);
            }

            // Get the list of new water flora
            var newWaterFlora = from t in Assembly.GetExecutingAssembly().GetTypes()
                                where t.IsClass && t.Namespace == "DecorationsMod.FloraAquatic"
                                select t;

            // Register new water flora
            foreach (Type newItemType in newWaterFlora)
            {
                DecorationItem newItem = (DecorationItem)(Activator.CreateInstance(newItemType));

                newItem.RegisterItem();
                result.Add(newItem);
            }

            // Register existing air seeds recipes
            if (ConfigSwitcher.EnableRegularAirSeeds)
            {
                RegisterRecipeForTechType(TechType.BulboTreePiece, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.PurpleVegetable, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.HangingFruit, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.MelonSeed, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.FernPalmSeed, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.OrangePetalsPlantSeed, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.PurpleVasePlantSeed, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.OrangeMushroomSpore, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.PinkMushroomSpore, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.PurpleRattleSpore, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.PinkFlowerSeed, ConfigSwitcher.FloraRecipiesResource);
            }

            // Register existing water seeds recipes
            if (ConfigSwitcher.EnableRegularWaterSeeds)
            {
                RegisterRecipeForTechType(TechType.GabeSFeatherSeed, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.RedGreenTentacleSeed, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.SeaCrownSeed, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.ShellGrassSeed, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.PurpleBranchesSeed, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.RedRollPlantSeed, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.RedBushSeed, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.PurpleStalkSeed, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.SpottedLeavesPlantSeed, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.AcidMushroomSpore, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.WhiteMushroomSpore, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.JellyPlantSeed, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.SmallFanSeed, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.PurpleFanSeed, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.PurpleTentacleSeed, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.BluePalmSeed, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.EyesPlantSeed, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.MembrainTreeSeed, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.RedConePlantSeed, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.RedBasketPlantSeed, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.SnakeMushroomSpore, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.SpikePlantSeed, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.CreepvinePiece, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.CreepvineSeedCluster, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.BloodOil, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.PurpleBrainCoralPiece, ConfigSwitcher.FloraRecipiesResource);
                RegisterRecipeForTechType(TechType.KooshChunk, ConfigSwitcher.FloraRecipiesResource);
            }

            // Register lamp tooltip
            LanguagePatcher.customLines.Add("ToggleLamp", LanguageHelper.GetFriendlyWord("LampTooltip"));
            // Register seamoth doll tooltip
            LanguagePatcher.customLines.Add("SwitchSeamothModel", LanguageHelper.GetFriendlyWord("SwitchSeamothModel"));
            // Register exosuit doll tooltip
            LanguagePatcher.customLines.Add("SwitchExosuitModel", LanguageHelper.GetFriendlyWord("SwitchExosuitModel"));
            // Register cargo boxes tooltip
            LanguagePatcher.customLines.Add("AdjustCargoBoxSize", LanguageHelper.GetFriendlyWord("AdjustCargoBoxSize"));
            // Register forklift tooltip
            LanguagePatcher.customLines.Add("AdjustForkliftSize", LanguageHelper.GetFriendlyWord("AdjustForkliftSize"));
            // Register cove tree tooltip
            LanguagePatcher.customLines.Add("DisplayCoveTreeEggs", LanguageHelper.GetFriendlyWord("DisplayCoveTreeEggs"));

            return(result);
        }
예제 #2
0
        /// <summary>Returns a list containing all new items added by this mod.</summary>
        private static List <IDecorationItem> RegisterNewItems()
        {
            List <IDecorationItem> result = new List <IDecorationItem>();

            Logger.Log("INFO: Registering items...");

            // Get the list of modified existing items
            var existingItems = from t in Assembly.GetExecutingAssembly().GetTypes()
                                where t.IsClass && t.Namespace == "DecorationsMod.ExistingItems"
                                select t;

            // Register modified existing items
            foreach (Type existingItemType in existingItems)
            {
#if DEBUG_ITEMS_REGISTRATION
                Logger.Log("INFO: Trying to create item type=[{0}]", existingItemType.Name);
#endif
                // Get item
                DecorationItem existingItem = (DecorationItem)(Activator.CreateInstance(existingItemType));
                if (existingItem.GameObject != null)
                {
                    // Register item
                    existingItem.RegisterItem();
                    // Unlock item at game start
                    SMLHelper.V2.Handlers.KnownTechHandler.UnlockOnStart(existingItem.TechType);
                    // Store item in the list
                    result.Add(existingItem);
                }
#if DEBUG_ITEMS_REGISTRATION
                else
                {
                    Logger.Log("WARNING: Unable to create existing item type=[{0}]!", existingItemType.Name);
                }
#endif
            }

            // Get the list of new items
            var newItems = from t in Assembly.GetExecutingAssembly().GetTypes()
                           where t.IsClass && t.Namespace == "DecorationsMod.NewItems"
                           select t;

            // Register new items
            foreach (Type newItemType in newItems)
            {
#if DEBUG_ITEMS_REGISTRATION
                Logger.Log("INFO: Trying to create new item type=[{0}]", newItemType.Name);
#endif
                DecorationItem newItem = (DecorationItem)(Activator.CreateInstance(newItemType));
                if (newItem.GameObject != null)
                {
                    // Check if item has been enabled in Config options
                    if ((ConfigSwitcher.EnableNutrientBlock || newItem.TechType != TechType.NutrientBlock) && (ConfigSwitcher.EnableSofas || (newItem.ClassID != "SofaStr1" && newItem.ClassID != "SofaStr2" && newItem.ClassID != "SofaStr3" && newItem.ClassID != "SofaCorner2")))
                    {
                        if (!newItem.IsHabitatBuilder ||
                            (ConfigSwitcher.EnableNewItems && ConfigSwitcher.HabitatBuilderItems.Contains(newItem.ClassID) &&
                             (ConfigSwitcher.EnableDecorativeElectronics || (newItem.ClassID != "DecorativeTechBox" && newItem.ClassID != "DecorativeControlTerminal" && newItem.ClassID != "WorkDeskScreen1" && newItem.ClassID != "WorkDeskScreen2")) &&
                             (ConfigSwitcher.EnableCustomBaseParts || newItem.ClassID != "OutdoorLadder")))
                        {
                            newItem.RegisterItem();
                            result.Add(newItem);
                        }
#if DEBUG_ITEMS_REGISTRATION
                        else
                        {
                            Logger.Log("INFO: Skipping registration for item type=[{0}]", newItemType.Name);
                        }
#endif
                    }
                }
#if DEBUG_ITEMS_REGISTRATION
                else
                {
                    Logger.Log("WARNING: Unable to create new item type=[{0}]!", newItemType.Name);
                }
#endif
            }

            // Register new flora
            if (ConfigSwitcher.EnableNewFlora)
            {
                // Get the list of new air flora
                var newFlora = from t in Assembly.GetExecutingAssembly().GetTypes()
                               where t.IsClass && t.Namespace == "DecorationsMod.Flora"
                               select t;
                // Register new air flora
                foreach (Type newItemType in newFlora)
                {
#if DEBUG_ITEMS_REGISTRATION
                    Logger.Log("INFO: Trying to create flora item type=[{0}]", newItemType.Name);
#endif
                    DecorationItem newItem = (DecorationItem)(Activator.CreateInstance(newItemType));
                    if (newItem.GameObject != null)
                    {
                        newItem.RegisterItem();
                        result.Add(newItem);
                    }
#if DEBUG_ITEMS_REGISTRATION
                    else
                    {
                        Logger.Log("WARNING: Unable create flora item type=[{0}]!", newItemType.Name);
                    }
#endif
                }

                // Get the list of new water flora
                var newWaterFlora = from t in Assembly.GetExecutingAssembly().GetTypes()
                                    where t.IsClass && t.Namespace == "DecorationsMod.FloraAquatic"
                                    select t;
                // Register new water flora
                foreach (Type newItemType in newWaterFlora)
                {
#if DEBUG_ITEMS_REGISTRATION
                    Logger.Log("INFO: Trying to create water flora item type=[{0}]", newItemType.Name);
#endif
                    DecorationItem newItem = (DecorationItem)(Activator.CreateInstance(newItemType));
                    if (newItem.GameObject != null)
                    {
                        newItem.RegisterItem();
                        result.Add(newItem);
                    }
#if DEBUG_ITEMS_REGISTRATION
                    else
                    {
                        Logger.Log("WARNING: Unable to create water flora item type=[{0}]!", newItemType.Name);
                    }
#endif
                }

                // Register existing air seeds recipes
                if (ConfigSwitcher.EnableRegularAirSeeds)
                {
                    List <TechType> processedSeeds = new List <TechType>();
                    foreach (KeyValuePair <TechType, TechType> airPlant in Fabricator_Flora.AirPlants)
                    {
                        if (!processedSeeds.Contains(airPlant.Value))
                        {
                            RegisterRecipeForTechType(airPlant.Value, ConfigSwitcher.FloraRecipiesResource, ConfigSwitcher.FloraRecipiesResourceAmount);
                            processedSeeds.Add(airPlant.Value);
                        }
                        if (ConfigSwitcher.AddAirSeedsWhenDiscovered)
                        {
                            SMLHelper.V2.Handlers.KnownTechHandler.SetAnalysisTechEntry(airPlant.Key, new TechType[] { airPlant.Value });
                        }
                        else
                        {
                            SMLHelper.V2.Handlers.KnownTechHandler.UnlockOnStart(airPlant.Value);
                        }
                    }
                }

                // Register existing water seeds recipes
                if (ConfigSwitcher.EnableRegularWaterSeeds)
                {
                    List <TechType> processedSeeds = new List <TechType>();
                    foreach (KeyValuePair <TechType, TechType> waterPlant in Fabricator_Flora.WaterPlants)
                    {
                        if (!processedSeeds.Contains(waterPlant.Value))
                        {
                            RegisterRecipeForTechType(waterPlant.Value, ConfigSwitcher.FloraRecipiesResource, ConfigSwitcher.FloraRecipiesResourceAmount);
                            processedSeeds.Add(waterPlant.Value);
                        }
                        if (ConfigSwitcher.AddWaterSeedsWhenDiscovered)
                        {
                            SMLHelper.V2.Handlers.KnownTechHandler.SetAnalysisTechEntry(waterPlant.Key, new TechType[] { waterPlant.Value });
                        }
                        else
                        {
                            SMLHelper.V2.Handlers.KnownTechHandler.UnlockOnStart(waterPlant.Value);
                        }
                    }
                }
            }

            return(result);
        }