コード例 #1
0
        //Track our vessel's orbit
        protected override void OnUpdate()
        {
            if (this.Root.ContractState != Contract.State.Active)
            {
                return;
            }

            if (HighLogic.LoadedSceneIsEditor)
            {
                return;
            }

            if (root == null)
            {
                this.SetIncomplete();
                return;
            }

            for (int i = 0; i < root.VesselCount; i++)
            {
                Vessel v = root.GetVessel(i);

                if (v == null)
                {
                    continue;
                }

                if (type == 0)
                {
                    if (v.orbit.eccentricity > orbitalParameter && v.situation == Vessel.Situations.ORBITING)
                    {
                        this.SetComplete();
                        return;
                    }
                }
                else if (type == 1)
                {
                    if (Math.Abs(v.orbit.inclination) > orbitalParameter && Math.Abs(v.orbit.inclination) < (180 - orbitalParameter) && v.situation == Vessel.Situations.ORBITING)
                    {
                        this.SetComplete();
                        return;
                    }
                }
            }

            this.SetIncomplete();
        }
コード例 #2
0
        protected override void OnUpdate()
        {
            if (this.Root.ContractState != Contract.State.Active)
            {
                return;
            }

            if (HighLogic.LoadedSceneIsEditor)
            {
                return;
            }

            if (!orbitTested)
            {
                setupOrbit(HighLogic.LoadedScene == GameScenes.SPACECENTER);
                orbitLoaded = testOrbit(HighLogic.LoadedScene == GameScenes.SPACECENTER);
                orbitTested = true;
            }

            if (!orbitLoaded)
            {
                return;
            }

            if (HighLogic.LoadedScene != GameScenes.SPACECENTER)
            {
                if (orbitRenderer == null)
                {
                    return;
                }

                if (orbitRenderer.driver == null)
                {
                    return;
                }

                if (orbitRenderer.driver.orbit == null)
                {
                    return;
                }
            }
            else
            {
                if (KSCOrbit == null)
                {
                    return;
                }
            }

            if (root == null)
            {
                this.SetIncomplete();
                return;
            }

            for (int i = 0; i < root.VesselCount; i++)
            {
                Vessel v = root.GetVessel(i);

                if (v == null)
                {
                    continue;
                }

                if (VesselUtilities.VesselAtOrbit(HighLogic.LoadedScene == GameScenes.SPACECENTER ? KSCOrbit : orbitRenderer.driver.orbit, deviationWindow, v))
                {
                    this.SetComplete();
                    return;
                }
            }

            this.SetIncomplete();
        }