예제 #1
0
        public static Blueprint ProcessFactoryPart(AvailablePart part)
        {
            var resources = new Dictionary <string, WorkshopResource>();

            if (PartRecipes.ContainsKey(part.name))
            {
                var recipe = FactoryRecipes[part.name];
                foreach (var workshopResource in recipe.Prepare(part.partPrefab.mass))
                {
                    if (resources.ContainsKey(workshopResource.Name))
                    {
                        resources[workshopResource.Name].Merge(workshopResource);
                    }
                    else
                    {
                        resources[workshopResource.Name] = workshopResource;
                    }
                }
            }
            else
            {
                WorkshopUtils.LogError($"No FactoryRecipeFound for {part.title}");
                return(null);
            }
            var blueprint = new Blueprint();

            blueprint.AddRange(resources.Values);
            blueprint.Funds = Mathf.Max(part.cost - (float)blueprint.ResourceCosts(), 0);
            return(blueprint);
        }
예제 #2
0
        public static List <ModuleKISInventory> GetInventories(Part part)
        {
            var inventories = new List <ModuleKISInventory>();

            foreach (PartModule module in part.Modules)
            {
                if (module.moduleName == "ModuleKISInventory")
                {
                    if (module is KIS.ModuleKISInventory)
                    {
                        inventories.Add(new ModuleKISInventory(module));
                    }
                    else
                    {
                        WorkshopUtils.LogError(module.name + " is not KIS.ModuleKISInventory, but " + module.ClassName + " instead. Skipping");
                    }
                }
            }

            return(inventories);
        }
예제 #3
0
        public static Blueprint ProcessFactoryPart(AvailablePart part)
        {
            double complexity = 1;
            var    resources  = new Dictionary <string, WorkshopResource>();

            if (PartRecipes.ContainsKey(part.name))
            {
                if (HighLogic.CurrentGame.Parameters.CustomParams <Workshop_Settings>().useComplexity)
                {
                    complexity += PartRecipes[part.name].Complexity;
                }
                var recipe = FactoryRecipes[part.name];
                foreach (var workshopResource in recipe.Prepare(part.partPrefab.mass))
                {
                    if (resources.ContainsKey(workshopResource.Name))
                    {
                        resources[workshopResource.Name].Merge(workshopResource);
                    }
                    else
                    {
                        resources[workshopResource.Name] = workshopResource;
                    }
                }
            }
            else
            {
                WorkshopUtils.LogError(string.Format("No FactoryRecipeFound for {0}", part.title));
                return(null);
            }
            var blueprint = new Blueprint();

            blueprint.AddRange(resources.Values);
            blueprint.Complexity = complexity;
            blueprint.Funds      = Mathf.Max(part.cost - (float)blueprint.ResourceCosts(), 0);
            return(blueprint);
        }