Ejemplo n.º 1
0
        private void FindAttachedThermalSource()
        {
            partDistance = 0;

            // first look if part contains an thermal source
            myAttachedReactor = part.FindModulesImplementing <IThermalSource>().FirstOrDefault();
            if (myAttachedReactor != null)
            {
                return;
            }

            // otherwise look for other non selfcontained thermal sources
            var source = ThermalSourceSearchResult.BreadthFirstSearchForThermalSource(part, (p) => p.IsThermalSource && p.ThermalEnergyEfficiency > 0, 3, 0, true);

            //var source = ThermalSourceSearchResult.BreadthFirstSearchForThermalSource(part, 3, 0, true);
            if (source == null)
            {
                return;
            }

            // verify cost is not higher than 1
            partDistance = (int)Math.Max(Math.Ceiling(source.Cost) - 1, 0);
            if (partDistance > 0)
            {
                return;
            }

            myAttachedReactor = source.Source;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Finds the nearest avialable thermalsource and update effective part mass
        /// </summary>
        public void FindAndAttachToThermalSource()
        {
            partDistance = 0;

            // disconnect
            if (attachedThermalSource != null)
            {
                if (chargedParticleMode)
                {
                    attachedThermalSource.ConnectedChargedParticleElectricGenerator = null;
                }
                else
                {
                    attachedThermalSource.ConnectedThermalElectricGenerator = null;
                }
            }

            // first look if part contains an thermal source
            attachedThermalSource = part.FindModulesImplementing <IThermalSource>().FirstOrDefault();
            if (attachedThermalSource != null)
            {
                return;
            }

            // otherwise look for other non selfcontained thermal sources
            var searchResult = ThermalSourceSearchResult.BreadthFirstSearchForThermalSource(part, (p) => p.IsThermalSource && p.ThermalEnergyEfficiency > 0, 3, 0, true);

            if (searchResult == null)
            {
                return;
            }

            // verify cost is not higher than 1
            partDistance = (int)Math.Max(Math.Ceiling(searchResult.Cost) - 1, 0);
            if (partDistance > 0)
            {
                return;
            }

            // update attached thermalsource
            attachedThermalSource = searchResult.Source;

            //connect with source
            if (chargedParticleMode)
            {
                attachedThermalSource.ConnectedChargedParticleElectricGenerator = this;
            }
            else
            {
                attachedThermalSource.ConnectedThermalElectricGenerator = this;
            }

            UpdateTargetMass();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Finds the nearest avialable thermalsource and update effective part mass
        /// </summary>
        public void FindAndAttachToThermalSource()
        {
            partDistance = 0;

            // first look if part contains an thermal source
            attachedThermalSource = part.FindModulesImplementing <IThermalSource>().FirstOrDefault();
            if (attachedThermalSource != null)
            {
                return;
            }

            // otherwise look for other non selfcontained thermal sources
            var searchResult = ThermalSourceSearchResult.BreadthFirstSearchForThermalSource(part, (p) => p.IsThermalSource && p.ThermalEnergyEfficiency > 0, 3, 0, true);

            if (searchResult == null)
            {
                return;
            }

            // verify cost is not higher than 1
            partDistance = (int)Math.Max(Math.Ceiling(searchResult.Cost) - 1, 0);
            if (partDistance > 0)
            {
                return;
            }

            // update attached thermalsource
            attachedThermalSource = searchResult.Source;

            // verify if mass calculation is active
            if (!calculatedMass)
            {
                return;
            }

            // update part mass
            effectiveMass = attachedThermalSource.RawMaximumPower > 0 && rawPowerToMassDivider > 0
                ? (massModifier * attachedThermalSource.ThermalProcessingModifier * attachedThermalSource.RawMaximumPower) / rawPowerToMassDivider
                : part.mass;
            part.mass = effectiveMass;
        }