예제 #1
0
        private static Neuron_NegPos[] CreateNeurons(ShipPartDNA dna, ItemOptions itemOptions, Point3D[] brainChemicalPositions)
        {
            // Figure out how many to make
            GetNeuronVolume(out double radius, out double volume, dna, itemOptions);

            int count = Convert.ToInt32(Math.Round(itemOptions.Brain_NeuronDensity * volume));

            if (count == 0)
            {
                count = 1;
            }

            // Figure out the positions
            Vector3D[] positions = NeuralUtility.GetNeuronPositions_Spherical_Cluster(dna.Neurons, brainChemicalPositions, 3d, count, radius, itemOptions.Brain_NeuronMinClusterDistPercent);

            return(positions.
                   Select(o => new Neuron_NegPos(o.ToPoint())).
                   ToArray());
        }
예제 #2
0
        private static Neuron_Fade[] CreateBrainChemicals(ShipPartDNA dna, ItemOptions itemOptions)
        {
            const double K_UP        = 50d;
            const double K_DOWN      = 750d;
            const double VALUECUTOFF = .75d;

            // Figure out how many to make
            double radius, volume;

            GetNeuronVolume(out radius, out volume, dna, itemOptions);

            int count = Convert.ToInt32(Math.Round(itemOptions.Brain_ChemicalDensity * volume));

            if (count == 0)
            {
                return(new Neuron_Fade[0]);
            }

            // The brain chemicals are stored in dna.AltNeurons
            Point3D[] brainChemPositions = null;
            if (dna.AltNeurons != null && dna.AltNeurons.Length > 0)
            {
                if (dna.AltNeurons.Length != 1)
                {
                    throw new ApplicationException("dna.AltNeurons.Length should be exactly 1 (" + dna.AltNeurons.Length.ToString() + ")");
                }

                brainChemPositions = dna.AltNeurons[0];
            }

            // Figure out the positions
            //NOTE: Only let them go to half radius.  Cluster% then needs to be doubled (doubling it again so that the brain chemicals don't get
            //too close together)
            Vector3D[] positions = NeuralUtility.GetNeuronPositions_Spherical_Cluster(brainChemPositions, count, radius * .5d, itemOptions.Brain_NeuronMinClusterDistPercent * 4d);

            // Exit Function
            return(positions.Select(o => new Neuron_Fade(o.ToPoint(), K_UP, K_DOWN, VALUECUTOFF)).ToArray());
        }