Ejemplo n.º 1
0
        public float GetEfficiencyModifier(int planetID, string biomeName, HarvestTypes harvestType, string modifierName)
        {
            string         key            = planetID.ToString() + biomeName + harvestType.ToString();
            EfficiencyData efficiencyData = null;

            if (efficiencyDataMap.ContainsKey(key))
            {
                efficiencyData = efficiencyDataMap[key];
                if (efficiencyData.modifiers.ContainsKey(modifierName))
                {
                    return(efficiencyData.modifiers[modifierName]);
                }
                else
                {
                    return(1.0f);
                }
            }

            else
            {
                //Create a new entry.
                createNewEfficencyEntry(planetID, biomeName, harvestType);
            }

            return(1.0f);
        }
Ejemplo n.º 2
0
        public void ResetEfficiencyData(int planetID, string biomeName, HarvestTypes harvestType)
        {
            string         key            = planetID.ToString() + biomeName + harvestType.ToString();
            EfficiencyData efficiencyData = null;

            if (efficiencyDataMap.ContainsKey(key))
            {
                efficiencyData = efficiencyDataMap[key];
                efficiencyData.efficiencyModifier = 1.0f;
                efficiencyData.attemptsRemaining  = kMaxCoreSamples;
            }

            else
            {
                //Create a new entry.
                efficiencyData                    = new EfficiencyData();
                efficiencyData.planetID           = planetID;
                efficiencyData.biomeName          = biomeName;
                efficiencyData.harvestType        = harvestType;
                efficiencyData.efficiencyModifier = 1.0f;
                efficiencyData.attemptsRemaining  = kMaxCoreSamples;

                efficiencyDataMap.Add(efficiencyData.Key, efficiencyData);
            }
        }
        public void SetEfficiencyData(int planetID, string biomeName, HarvestTypes harvestType, string modifierName, float modifierValue)
        {
            string         key            = planetID.ToString() + biomeName + harvestType.ToString();
            EfficiencyData efficiencyData = null;

            //Create a new entry if needed.
            if (!efficiencyDataMap.ContainsKey(key))
            {
                createNewEfficencyEntry(planetID, biomeName, harvestType);
            }

            //If we already have the efficiency data then just update the value
            efficiencyData = efficiencyDataMap[key];
            if (efficiencyData.modifiers.ContainsKey(modifierName))
            {
                efficiencyData.modifiers[modifierName] = modifierValue;
            }
            else
            {
                efficiencyData.modifiers.Add(modifierName, modifierValue);
            }

            //Update interested parties
            if (onEfficiencyUpdate != null)
            {
                onEfficiencyUpdate(planetID, biomeName, harvestType, modifierName, modifierValue);
            }
        }
Ejemplo n.º 4
0
        public void SetCoreSamplesRemaining(int planetID, string biomeName, HarvestTypes harvestType, int attemptsRemaining)
        {
            string         key            = planetID.ToString() + biomeName + harvestType.ToString();
            EfficiencyData efficiencyData = null;

            if (efficiencyDataMap.ContainsKey(key))
            {
                efficiencyData = efficiencyDataMap[key];
                efficiencyData.attemptsRemaining = attemptsRemaining;
            }
        }
        public void ResetEfficiencyData(int planetID, string biomeName, HarvestTypes harvestType)
        {
            string         key            = planetID.ToString() + biomeName + harvestType.ToString();
            EfficiencyData efficiencyData = null;

            //Create a new entry if needed.
            if (!efficiencyDataMap.ContainsKey(key))
            {
                createNewEfficencyEntry(planetID, biomeName, harvestType);
            }

            efficiencyData = efficiencyDataMap[key];
            foreach (string modifierKey in efficiencyData.modifiers.Keys)
            {
                efficiencyData.modifiers[modifierKey] = 1.0f;
            }
            efficiencyData.attemptsRemaining = kMaxCoreSamples;
        }
        public int GetCoreSamplesRemaining(int planetID, string biomeName, HarvestTypes harvestType)
        {
            string         key            = planetID.ToString() + biomeName + harvestType.ToString();
            EfficiencyData efficiencyData = null;

            if (efficiencyDataMap.ContainsKey(key))
            {
                efficiencyData = efficiencyDataMap[key];
                return(efficiencyData.attemptsRemaining);
            }

            else
            {
                //Create a new entry.
                createNewEfficencyEntry(planetID, biomeName, harvestType);
            }

            return(kMaxCoreSamples);
        }
Ejemplo n.º 7
0
        public int GetCoreSamplesRemaining(int planetID, string biomeName, HarvestTypes harvestType)
        {
            string key = planetID.ToString() + biomeName + harvestType.ToString();
            EfficiencyData efficiencyData = null;

            if (efficiencyDataMap.ContainsKey(key))
            {
                efficiencyData = efficiencyDataMap[key];
                return efficiencyData.attemptsRemaining;
            }

            else
            {
                //Create a new entry.
                createNewEfficencyEntry(planetID, biomeName, harvestType);
            }

            return kMaxCoreSamples;
        }
Ejemplo n.º 8
0
        public void SetEfficiencyData(int planetID, string biomeName, HarvestTypes harvestType, float efficiencyModifier)
        {
            string         key            = planetID.ToString() + biomeName + harvestType.ToString();
            EfficiencyData efficiencyData = null;

            //If we already have the efficiency data then just update the value
            if (efficiencyDataMap.ContainsKey(key))
            {
                efficiencyData = efficiencyDataMap[key];
                efficiencyData.efficiencyModifier = efficiencyModifier;
                return;
            }

            //Create a new entry.
            efficiencyData                    = new EfficiencyData();
            efficiencyData.planetID           = planetID;
            efficiencyData.biomeName          = biomeName;
            efficiencyData.harvestType        = harvestType;
            efficiencyData.efficiencyModifier = efficiencyModifier;
            efficiencyData.attemptsRemaining  = kMaxCoreSamples;

            efficiencyDataMap.Add(efficiencyData.Key, efficiencyData);
        }
Ejemplo n.º 9
0
        public void SetCoreSamplesRemaining(int planetID, string biomeName, HarvestTypes harvestType, int attemptsRemaining)
        {
            string key = planetID.ToString() + biomeName + harvestType.ToString();
            EfficiencyData efficiencyData = null;

            if (efficiencyDataMap.ContainsKey(key))
            {
                efficiencyData = efficiencyDataMap[key];
                efficiencyData.attemptsRemaining = attemptsRemaining;
            }
        }
Ejemplo n.º 10
0
        public float GetEfficiencyModifier(int planetID, string biomeName, HarvestTypes harvestType, string modifierName)
        {
            string key = planetID.ToString() + biomeName + harvestType.ToString();
            EfficiencyData efficiencyData = null;

            if (efficiencyDataMap.ContainsKey(key))
            {
                efficiencyData = efficiencyDataMap[key];
                if (efficiencyData.modifiers.ContainsKey(modifierName))
                    return efficiencyData.modifiers[modifierName];
                else
                    return 1.0f;
            }

            else
            {
                //Create a new entry.
                createNewEfficencyEntry(planetID, biomeName, harvestType);
            }

            return 1.0f;
        }
Ejemplo n.º 11
0
        public void SetEfficiencyData(int planetID, string biomeName, HarvestTypes harvestType, string modifierName, float modifierValue)
        {
            string key = planetID.ToString() + biomeName + harvestType.ToString();
            EfficiencyData efficiencyData = null;

            //If we already have the efficiency data then just update the value
            if (efficiencyDataMap.ContainsKey(key))
            {
                efficiencyData = efficiencyDataMap[key];
                if (efficiencyData.modifiers.ContainsKey(modifierName))
                    efficiencyData.modifiers[modifierName] = modifierValue;
                else
                    efficiencyData.modifiers.Add(modifierName, modifierValue);
                return;
            }

            //Create a new entry.
            createNewEfficencyEntry(planetID, biomeName, harvestType);
        }
Ejemplo n.º 12
0
        public void ResetEfficiencyData(int planetID, string biomeName, HarvestTypes harvestType)
        {
            string key = planetID.ToString() + biomeName + harvestType.ToString();
            EfficiencyData efficiencyData = null;

            if (efficiencyDataMap.ContainsKey(key))
            {
                efficiencyData = efficiencyDataMap[key];
                foreach (string modifierKey in efficiencyData.modifiers.Keys)
                    efficiencyData.modifiers[modifierKey] = 1.0f;
                efficiencyData.attemptsRemaining = kMaxCoreSamples;
            }

            else
            {
                //Create a new entry.
                createNewEfficencyEntry(planetID, biomeName, harvestType);
            }
        }
Ejemplo n.º 13
0
        protected virtual void prepareOutputsByLocale(HarvestTypes harvestType)
        {
            Log("prepareOutputsByLocale called for harvestType: " + harvestType.ToString());
            ResourceRatio          outputSource;
            PartResourceDefinition outputDef = null;
            float totalAbundance             = 0f;
            float abundance   = 0f;
            float outputMass  = 0f;
            float outputUnits = 0f;
            IEnumerable <ResourceCache.AbundanceSummary> abundanceCache;

            if (harvestType == HarvestTypes.Planetary)
            {
                if (!ResourceMap.Instance.IsPlanetScanned(this.part.vessel.mainBody.flightGlobalsIndex) && !ResourceMap.Instance.IsBiomeUnlocked(this.part.vessel.mainBody.flightGlobalsIndex, currentBiome))
                {
                    return;
                }
                abundanceCache = Utils.GetAbundances(this.part.vessel, harvestType);
            }
            else
            {
                abundanceCache = Utils.GetAbundances(this.part.vessel, harvestType);
            }

            foreach (ResourceCache.AbundanceSummary summary in abundanceCache)
            {
                Log("checking " + summary.ResourceName);
                outputDef = ResourceHelper.DefinitionForResource(summary.ResourceName);
                if (outputDef == null)
                {
                    continue;
                }

                abundance = ResourceMap.Instance.GetAbundance(new AbundanceRequest()
                {
                    Altitude     = this.vessel.altitude,
                    BodyId       = FlightGlobals.currentMainBody.flightGlobalsIndex,
                    CheckForLock = true,
                    Latitude     = this.vessel.latitude,
                    Longitude    = this.vessel.longitude,
                    ResourceType = harvestType,
                    ResourceName = summary.ResourceName
                });

                outputMass = abundance * yieldMass;
                if (outputDef.density > 0)
                {
                    outputUnits = outputMass / outputDef.density;
                }
                else
                {
                    outputUnits = outputMass;
                }
                Log("abundance: " + abundance);
                Log("outputUnits: " + outputUnits);

                //If the resource is an input resource then add its output mass to the byproductMass.
                if (inputSources.Contains(summary.ResourceName))
                {
                    Log(summary.ResourceName + " added to byproductMass");
                    byproductMass += outputMass;
                }

                //If the resource is on our ignore list, then add the output mass to the byproductMass.
                else if (!string.IsNullOrEmpty(ignoreResources) && ignoreResources.Contains(summary.ResourceName))
                {
                    Log(summary.ResourceName + " ignored and added to byproductMass");
                    byproductMass += outputMass;
                }

                //Legit!
                else if (abundance > 0.0001f)
                {
                    totalAbundance += abundance;
                    Log(summary.ResourceName + " abundance: " + abundance + " Ratio: " + outputUnits);
                    outputSource = new ResourceRatio {
                        ResourceName = summary.ResourceName, Ratio = outputUnits, FlowMode = ResourceFlowMode.ALL_VESSEL_BALANCE, DumpExcess = true
                    };
                    outputList.Add(outputSource);
                }
            }

            //Leftovers
            if (!string.IsNullOrEmpty(byproduct))
            {
                byproductMass += (1.0f - totalAbundance) * yieldMass;
                outputUnits    = byproductMass / byproductDef.density;
                outputSource   = new ResourceRatio {
                    ResourceName = byproduct, Ratio = outputUnits, FlowMode = ResourceFlowMode.ALL_VESSEL_BALANCE, DumpExcess = true
                };
                outputList.Add(outputSource);
                Log("added " + byproduct + " to output list");
            }

            Log("totalAbundance: " + totalAbundance);
            Log("Byproduct Units: " + outputUnits);
            Log("output resources added: " + outputList.Count);
        }
Ejemplo n.º 14
0
        public void ResetEfficiencyData(int planetID, string biomeName, HarvestTypes harvestType)
        {
            string key = planetID.ToString() + biomeName + harvestType.ToString();
            EfficiencyData efficiencyData = null;

            if (efficiencyDataMap.ContainsKey(key))
            {
                efficiencyData = efficiencyDataMap[key];
                efficiencyData.efficiencyModifier = 1.0f;
                efficiencyData.attemptsRemaining = kMaxCoreSamples;
            }

            else
            {
                //Create a new entry.
                efficiencyData = new EfficiencyData();
                efficiencyData.planetID = planetID;
                efficiencyData.biomeName = biomeName;
                efficiencyData.harvestType = harvestType;
                efficiencyData.efficiencyModifier = 1.0f;
                efficiencyData.attemptsRemaining = kMaxCoreSamples;

                efficiencyDataMap.Add(efficiencyData.Key, efficiencyData);
            }
        }
Ejemplo n.º 15
0
        public void SetEfficiencyData(int planetID, string biomeName, HarvestTypes harvestType, float efficiencyModifier)
        {
            string key = planetID.ToString() + biomeName + harvestType.ToString();
            EfficiencyData efficiencyData = null;

            //If we already have the efficiency data then just update the value
            if (efficiencyDataMap.ContainsKey(key))
            {
                efficiencyData = efficiencyDataMap[key];
                efficiencyData.efficiencyModifier = efficiencyModifier;
                return;
            }

            //Create a new entry.
            efficiencyData = new EfficiencyData();
            efficiencyData.planetID = planetID;
            efficiencyData.biomeName = biomeName;
            efficiencyData.harvestType = harvestType;
            efficiencyData.efficiencyModifier = efficiencyModifier;
            efficiencyData.attemptsRemaining = kMaxCoreSamples;

            efficiencyDataMap.Add(efficiencyData.Key, efficiencyData);
        }