Exemplo n.º 1
0
        void ProcessResources(RMResourceSet resources, BuildResourceSet report_resources, BuildResourceSet required_resources = null)
        {
            var reslist = resources.resources.Keys.ToList();

            foreach (string res in reslist)
            {
                double amount = resources.ResourceAmount(res);
                var    recipe = ELRecipeDatabase.ResourceRecipe(res);

                if (recipe != null)
                {
                    double density = ELRecipeDatabase.ResourceDensity(res);
                    double mass    = amount * density;
                    recipe = recipe.Bake(mass);
                    foreach (var ingredient in recipe.ingredients)
                    {
                        var br     = new BuildResource(ingredient);
                        var resset = report_resources;
                        if (required_resources != null)
                        {
                            resset = required_resources;
                        }
                        resset.Add(br);
                    }
                }
                else
                {
                    var br = new BuildResource(res, amount);
                    report_resources.Add(br);
                }
            }
        }
Exemplo n.º 2
0
        void ProcessResource(RMResourceSet vr, string res, BuildResourceSet rd, bool xfer)
        {
            var amount = vr.ResourceAmount(res);
            var mass   = amount * ELRecipeDatabase.ResourceDensity(res);

            ProcessIngredient(new Ingredient(res, mass), rd, xfer);
        }
        public override void OnLoad(ConfigNode node)
        {
            var effKeys = node.GetValues("efficiency");

            if (effKeys.Length == 1)
            {
                double eff;
                double.TryParse(effKeys[0], out eff);
                efficiencyCurve = SinglePoint(eff);
            }
            else if (effKeys.Length > 1)
            {
                efficiencyCurve = MulitplePoints(effKeys);
            }
            else
            {
                ELConverter prefab = null;
                // loading in-flight?
                if (part.partInfo != null &&
                    part.partInfo.partPrefab != null)
                {
                    int        index  = part.Modules.IndexOf(this);
                    PartModule module = part.partInfo.partPrefab.Modules[index];
                    prefab = module as ELConverter;
                }
                if (prefab != null)
                {
                    efficiencyCurve = prefab.efficiencyCurve;
                }
                else
                {
                    efficiencyCurve = SinglePoint(1);
                }
            }
            converter_recipe = ELRecipeDatabase.ConverterRecipe(ConverterRecipe);
            for (int i = 0; i < efficiencyCurve.Length; i++)
            {
                Debug.LogFormat("efficiency: {0}", efficiencyCurve[i]);
            }
            if (converter_recipe == null)
            {
                Debug.LogFormat("[ELConverter] unknown recipe \"{0}\"",
                                ConverterRecipe);
            }
            else
            {
                Debug.LogFormat("[ELConverter] found recipe \"{0}\"",
                                ConverterRecipe);
                current_recipe = converter_recipe.Bake(0.5, current_recipe);
            }
            // two birds with one stone: make it clear that the config is
            // broken and ensure the stock converter doesn't mess with us
            RemoveConflictingNodes(node, "INPUT_RESOURCE");
            RemoveConflictingNodes(node, "OUTPUT_RESOURCE");
            RemoveConflictingNodes(node, "REQUIRED_RESOURCE");
            base.OnLoad(node);
        }
Exemplo n.º 4
0
 public void addPart(Part part)
 {
     if (ELSettings.KIS_Present)
     {
         KIS.KISWrapper.GetResources(part, container.resources);
     }
     ELRecipeDatabase.ProcessPart(part, hullResoures.resources);
     resources.AddPart(part);
     mass += part.mass;
 }
Exemplo n.º 5
0
 private double KerbalHours()
 {
     if (density > 0)
     {
         return(ELRecipeDatabase.ResourceRate(name) * density);
     }
     else
     {
         return(ELRecipeDatabase.ResourceRate(name) / 3600);
     }
 }
Exemplo n.º 6
0
        public void addPart(Part part)
        {
            double resMass = 0;

            if (ELSettings.KIS_Present)
            {
                // KIS container mass includes resources in contained parts
                resMass = KIS.KISWrapper.GetResources(part, container.resources);
            }
            ELRecipeDatabase.ProcessPart(part, hullResoures.resources, resMass);
            resources.AddPart(part);
            mass += part.mass - resMass;
        }
Exemplo n.º 7
0
        void ProcessIngredient(Ingredient ingredient, BuildResourceSet rd, bool xfer)
        {
            var    res    = ingredient.name;
            Recipe recipe = null;

            // If the resource is being transfered from a tank (rather than
            // coming from the part body itself), then a transfer recipe will
            // override a recycle recipe
            if (xfer)
            {
                recipe = ELRecipeDatabase.TransferRecipe(res);
            }
            if (recipe == null)
            {
                recipe = ELRecipeDatabase.RecycleRecipe(res);
            }

            if (recipe != null)
            {
                recipe = recipe.Bake(ingredient.ratio);
                foreach (var ing in recipe.ingredients)
                {
                    if (ing.isReal)
                    {
                        var br = new BuildResource(ing);
                        rd.Add(br);
                    }
                }
            }
            else
            {
                if (ELRecipeDatabase.ResourceRecipe(res) != null)
                {
                }
                else
                {
                    if (ingredient.isReal)
                    {
                        var br = new BuildResource(ingredient);
                        rd.Add(br);
                    }
                }
            }
        }
 void ExpandResourceRecipes(Recipe recipe)
 {
     for (int i = recipe.ingredients.Count; i-- > 0;)
     {
         Ingredient ingredient = recipe.ingredients[i];
         if (!ResourceDefined(ingredient.name))
         {
             var resRecipe = ELRecipeDatabase.ResourceRecipe(ingredient.name);
             if (resRecipe != null)
             {
                 resRecipe = resRecipe.Bake(ingredient.ratio);
                 resRecipe.ingredients[0].heat = ingredient.heat;
                 recipe.ingredients.RemoveAt(i);
                 for (int j = resRecipe.ingredients.Count; j-- > 0;)
                 {
                     recipe.AddIngredient(resRecipe.ingredients[j]);
                 }
             }
         }
     }
 }
Exemplo n.º 9
0
        void ProcessKerbal(ProtoCrewMember crew, BuildResourceSet rd)
        {
            string message = crew.name + " was mulched";

            ScreenMessages.PostScreenMessage(message, 30.0f, ScreenMessageStyle.UPPER_CENTER);

            var part_recipe = ELRecipeDatabase.KerbalRecipe();

            if (part_recipe == null)
            {
                return;
            }
            var kerbal_recipe = part_recipe.Bake(0.09375);             //FIXME

            for (int i = 0; i < kerbal_recipe.ingredients.Count; i++)
            {
                var ingredient = kerbal_recipe.ingredients[i];
                ProcessIngredient(ingredient, rd, false);
            }
            foreach (var br in rd.Values)
            {
                Debug.Log(String.Format("[EL RSM] ProcessKerbal: {0} {1} {2}", crew.name, br.name, br.amount));
            }
        }