Example #1
0
        /*
         * Copy constructor.
         */
        public OrbitGenerator(OrbitGenerator orig, Contract contract)
            : base()
        {
            foreach (OrbitData old in orig.orbits)
            {
                // Copy orbit data
                orbits.Add(new OrbitData(old, contract));
            }

            System.Random random = new System.Random(contract.MissionSeed);

            // Find/add the AlwaysTrue parameter
            AlwaysTrue alwaysTrue = AlwaysTrue.FetchOrAdd(contract);

            int i = 0;

            foreach (OrbitData obData in orbits)
            {
                // Do type specific handling
                if (obData.type == "RANDOM_ORBIT")
                {
                    obData.orbit = CelestialUtilities.GenerateOrbit(obData.orbitType, contract.MissionSeed + i++, obData.orbit.referenceBody, obData.difficulty);
                }

                // Create the wrapper to the SpecificOrbit parameter that will do the rendering work
                SpecificOrbitWrapper s = new SpecificOrbitWrapper(obData.orbitType, obData.orbit.inclination,
                                                                  obData.orbit.eccentricity, obData.orbit.semiMajorAxis, obData.orbit.LAN, obData.orbit.argumentOfPeriapsis,
                                                                  obData.orbit.meanAnomalyAtEpoch, obData.orbit.epoch, obData.orbit.referenceBody,
                                                                  obData.difficulty, 3.0);
                s.DisableOnStateChange = false;
                alwaysTrue.AddParameter(s);
                obData.index = alwaysTrue.ParameterCount - 1;
            }
        }
Example #2
0
        public void Draw()
        {
            // No contract
            if (contract == null)
            {
                return;
            }

            // Check contract state when displaying
            if (contract.ContractState == Contract.State.Active ||
                contract.ContractState == Contract.State.Offered && HighLogic.LoadedScene == GameScenes.TRACKSTATION)
            {
                // Update the map icons
                foreach (OrbitData obData in orbits)
                {
                    SpecificOrbitParameter s = AlwaysTrue.FetchOrAdd(contract).GetParameter(obData.index) as SpecificOrbitParameter;
                    s.updateMapIcons(CelestialUtilities.MapFocusBody() == obData.orbit.referenceBody);
                }
            }
        }
        public OrbitGenerator(OrbitGenerator orig, Contract contract)
            : base()
        {
            foreach (OrbitData old in orig.orbits)
            {
                for (int i = 0; i < old.count; i++)
                {
                    // Copy orbit data
                    orbits.Add(new OrbitData(old, contract));
                }
            }

            System.Random random = new System.Random(contract.MissionSeed);

            // Find/add the AlwaysTrue parameter
            AlwaysTrue alwaysTrue = AlwaysTrue.FetchOrAdd(contract);

            int index = 0;

            foreach (OrbitData obData in orbits)
            {
                // Do type specific handling
                if (obData.type == "RANDOM_ORBIT")
                {
                    if (!ValidateOrbitType(obData, null))
                    {
                    }

                    obData.orbit = OrbitUtilities.GenerateOrbit(contract.MissionSeed + index++, obData.targetBody, obData.orbitType,
                                                                obData.altitudeFactor, obData.inclinationFactor, obData.eccentricity);
                }
                else
                {
                    obData.orbit.referenceBody = obData.targetBody;
                }

                obData.SetupRenderer();
            }
        }
Example #4
0
 public SpecificOrbitWrapper GetOrbitParameter(int index)
 {
     return(AlwaysTrue.FetchOrAdd(contract).GetParameter(orbits[index].index) as SpecificOrbitWrapper);
 }