示例#1
0
        /// <summary>
        /// Stuff
        /// </summary>
        private static bool CheckVessel(Vessel v)
        {
            bool answer = false;

            Debug.Log("Cheking Intersection for Vessel " + v.name);
            bool DontdetachConics = v.PatchedConicsAttached;


            //Debug Output
            string Output = "";

            Output = "Name:" + v.name + "; Of type:" + v.vesselType + "; doing: " + v.RevealSituationString() +
                     "; Unobserved for: " + v.DiscoveryInfo.unobservedLifetime + "sec; Orbiting:" + v.orbit.referenceBody.name;

            Debug.Log(Output);


            if (!v.PatchedConicsAttached)
            {
                Debug.Log("No PatchedConicSolver. Creating a New One. ");
                try {
                    //v.patchedConicSolver = new PatchedConicSolver ();
                    v.AttachPatchedConicsSolver();
                    v.patchedConicSolver.IncreasePatchLimit();
                    v.patchedConicSolver.Update();
                }
                catch (Exception ex)
                {
                    Debug.Log("Could not attach patchedConicSolver. Exception:" + ex);
                    //DontdetachConics = true;
                    //v.DetachPatchedConicsSolver ();
                }
            }

            answer = CheckOrbits(v.orbit);


            if (!DontdetachConics && v.PatchedConicsAttached && v.patchedConicSolver != null)
            {
                v.DetachPatchedConicsSolver();
            }
            return(answer);
        }
示例#2
0
        private void OnOrbitChange(Vessel ActiveVessel)
        {
            //if(ActiveVessel.id !=
            Debug.Log("Running  OnOrbitChange() / check for periapsis for  :" + ActiveVessel.GetName());
            if (!ActiveVessel.PatchedConicsAttached)
            {
                Debug.Log("No PatchedConicSolver. Creating a New One. ");
                try
                {
                    //v.patchedConicSolver = new PatchedConicSolver ();
                    ActiveVessel.AttachPatchedConicsSolver();
                    ActiveVessel.patchedConicSolver.IncreasePatchLimit();
                    ActiveVessel.patchedConicSolver.Update();
                } catch (Exception ex)
                {
                    Debug.Log("Could not attach patchedConicSolver. Exception:" + ex);
                    //DontdetachConics = true;
                    //v.DetachPatchedConicsSolver ();
                }
            }
            Orbit o = ActiveVessel.orbit;

            while (o.activePatch)
            {
                //@@@TODO: Make Altitude variable. 70k for now
                Debug.Log("Check Orbit");
                if (o.referenceBody.name == FlightGlobals.Bodies [1].bodyName)                  // Around Kerbin
                {
                    if (o.PeA >= 70000)
                    {
                        base.SetComplete();
                        return;
                    }
                    if (o.PeA < 70000)
                    {
                        base.SetIncomplete();
                        return;
                    }
                }
                o = o.nextPatch;
            }
        }
示例#3
0
        public void Draw()
        {
            mScrollPosition = GUILayout.BeginScrollView(mScrollPosition, AbstractWindow.Frame);
            {
                Color      pushColor = GUI.contentColor;
                TextAnchor pushAlign = GUI.skin.button.alignment;
                GUI.skin.button.alignment = TextAnchor.MiddleLeft;

                var TSWList = UnityEngine.Object.FindObjectsOfType <KSP.UI.Screens.TrackingStationWidget>();

                foreach (VesselSatellite sat in RTCore.Instance.Satellites)
                {
                    if ((sat.parentVessel != null && !MapViewFiltering.CheckAgainstFilter(sat.parentVessel)) || FlightGlobals.ActiveVessel == sat.parentVessel)
                    {
                        continue;
                    }

                    String text = sat.Name.Truncate(25);
                    RTUtil.StateButton(text, mSelection == sat.parentVessel ? 1 : 0, 1, s =>
                    {
                        mSelection = (s > 0) ? sat.parentVessel : null;
                        if (mSelection != null)
                        {
                            if (HighLogic.LoadedScene == GameScenes.TRACKSTATION)
                            {
                                foreach (var tsw in TSWList)
                                {
                                    if (tsw.vessel == sat.parentVessel)
                                    {
                                        tsw.toggle.isOn = true;
                                    }
                                }
                            }
                            else
                            {
                                Vessel vessel = sat.parentVessel;
                                ScaledMovement scaledMovement   = new GameObject().AddComponent <ScaledMovement>();
                                scaledMovement.tgtRef           = vessel.transform;
                                scaledMovement.name             = sat.Name;
                                scaledMovement.transform.parent = ScaledSpace.Instance.transform;
                                scaledMovement.vessel           = vessel;
                                scaledMovement.type             = MapObject.ObjectType.Vessel;

                                var success = PlanetariumCamera.fetch.SetTarget(PlanetariumCamera.fetch.AddTarget(scaledMovement));
                                PlanetariumCamera.fetch.targets.Remove(scaledMovement);
                                this.resetTarget();

                                if (mLastVessel != vessel)
                                {
                                    if (mLastVessel)
                                    {
                                        mLastVessel.DetachPatchedConicsSolver();
                                        mLastVessel.orbitRenderer.isFocused = false;
                                    }

                                    vessel.AttachPatchedConicsSolver();
                                    vessel.orbitRenderer.isFocused = true;
                                    vessel.orbitRenderer.drawIcons = OrbitRenderer.DrawIcons.OBJ;
                                    mLastVessel = vessel;
                                }
                            }
                        }
                        else
                        {
                            if (HighLogic.LoadedScene != GameScenes.TRACKSTATION)
                            {
                                // go back to the active vessel
                                PlanetariumCamera.fetch.SetTarget(this.resetTarget());
                            }
                        }
                    });
                }
                GUI.skin.button.alignment = pushAlign;
                GUI.contentColor          = pushColor;
            }
            GUILayout.EndScrollView();
        }
        private void OnOrbitChange(Vessel ActiveVessel)
        {
            //if(ActiveVessel.id !=
            Debug.Log("Running  OnOrbitChange() / check for periapsis for  :" +  ActiveVessel.GetName() );
            if (!ActiveVessel.PatchedConicsAttached)
            {
                Debug.Log ("No PatchedConicSolver. Creating a New One. ");
                try
                {
                    //v.patchedConicSolver = new PatchedConicSolver ();
                    ActiveVessel.AttachPatchedConicsSolver ();
                    ActiveVessel.patchedConicSolver.IncreasePatchLimit ();
                    ActiveVessel.patchedConicSolver.Update ();
                } catch (Exception ex)
                {
                    Debug.Log ("Could not attach patchedConicSolver. Exception:" + ex);
                    //DontdetachConics = true;
                    //v.DetachPatchedConicsSolver ();
                }
            }
            Orbit o = ActiveVessel.orbit;
            while(o.activePatch)
            {
            //@@@TODO: Make Altitude variable. 70k for now
                Debug.Log("Check Orbit" );
                if (o.referenceBody.name == FlightGlobals.Bodies [1].bodyName)  // Around Kerbin
                {
                    if(o.PeA >= 70000 )
                    {
                        base.SetComplete();
                        return;
                    }
                    if(o.PeA < 70000 )
                    {
                        base.SetIncomplete();
                        return;
                    }

                }
                o = o.nextPatch;

            }
        }
示例#5
0
        //////////////////////////////
        /// Debug functions
        /// ///////////////////////////

        /// <summary>
        ///
        /// </summary>
        /// <param name="o">O.</param>
        private static void Print_Vessel_info(Vessel v)
        {
            Debug.Log("Vessel Info \n");
            bool AttachedConicsAtStart = v.PatchedConicsAttached;

            string Output = "";

            Output = "Name:" + v.name + "; Of type:" + v.vesselType + "; doing: " + v.RevealSituationString() +
                     "; Unobserved for: " + v.DiscoveryInfo.unobservedLifetime + "sec; Orbiting:" + v.orbit.referenceBody.name;

            Debug.Log(Output);



            //Dump All info
            Output = "Vessel Dump \n";

            //Variables
            //Output += "\n acceleration:" + v.acceleration;
            Output += "\n altitude:" + v.altitude;
            //Output += "\n angularMomentum:" + v.angularMomentum;
            //Output += "\n angularVelocity:" + v.angularVelocity;
            //Output += "\n atmDensity:" + v.atmDensity;
            //Output += "\n CoM:" + v.CoM;
            Output += "\n ctrlState:" + v.ctrlState;
            //Output += "\n currentStage:" + v.currentStage;
            //Output += "\n geeForce:" + v.geeForce;
            //Output += "\n geeForce_immediate:" + v.geeForce_immediate;
            //Output += "\n heightFromSurface:" + v.heightFromSurface;
            //Output += "\n heightFromTerrain:" + v.heightFromTerrain;
            //Output += "\n horizontalSrfSpeed:" + v.horizontalSrfSpeed;
            Output += "\n id:" + v.id;
            //Output += "\n isEVA:" + v.isEVA;
            //Output += "\n Landed:" + v.Landed;
            //Output += "\n LandedAt:" + v.landedAt;
            Output += "\n Latitude:" + v.latitude;
            Output += "\n LaunchTime:" + v.launchTime;
            Output += "\n loaded:" + v.loaded;
            //Output += "\n LocalCoM:" + v.localCoM;
            //Output += "\n missionTime:" + v.missionTime;
            //Output += "\n MOI:" + v.MOI;
            //Output += "\n obt_speed:" + v.obt_speed;
            //Output += "\n obt_velocity:" + v.obt_velocity;
//			Output += "\n A:" + v.OnFlyByWire;
            Output += "\n orbitDriver:" + v.orbitDriver;
            Output += "\n orbitTargeter:" + v.orbitTargeter;
            Output += "\n packed:" + v.packed;
            //Output += "\n parts:" + v.parts;
            Output += "\n patchedConicRenderer:" + v.patchedConicRenderer;
            Output += "\n patchedConicSolver:" + v.patchedConicSolver;
            //Output += "\n perturbation:" + v.perturbation;
            //Output += "\n pqsAltitude:" + v.pqsAltitude;
            Output += "\n protoVessel:" + v.protoVessel;
            //Output += "\n rb_velocity:" + v.rb_velocity;
            //Output += "\n referenceTransformId:" + v.referenceTransformId;
            //Output += "\n rootPart:" + v.rootPart;
            Output += "\n situation:" + v.situation;
            //Output += "\n specificAcceleration:" + v.specificAcceleration;
            //Output += "\n Splashed:" + v.Splashed;
            //Output += "\n srf_velocity:" + v.srf_velocity;
            //Output += "\n srfRelRotation:" + v.srfRelRotation;
            Output += "\n state:" + v.state;
            //Output += "\n staticPressurekPa:" + v.staticPressurekPa;
            //Output += "\n terrainAltitude:" + v.terrainAltitude;
            //Output += "\n terrainNormal:" + v.terrainNormal;
            //Output += "\n upAxis:" + v.upAxis;
            Output += "\n verticalSpeed:" + v.verticalSpeed;
            Output += "\n vesselName:" + v.vesselName;
            Output += "\n vesselType:" + v.vesselType;

            //Properties (get/set)
            //Output += "\n ActionGroups:" + v.ActionGroups;
            Output += "\n DiscoveryInfo:" + v.DiscoveryInfo.ToString();             //@@@TODO: add Function

            Output += "\n HoldPhysics:" + v.HoldPhysics;
            Output += "\n isActiveVessel:" + v.isActiveVessel;
            Output += "\n isCommandable:" + v.isCommandable;
            Output += "\n IsControllable:" + v.IsControllable;
            Output += "\n isPersistent:" + v.isPersistent;
            Output += "\n LandedOrSplashed:" + v.LandedOrSplashed;
            Output += "\n orbit:" + v.orbit;

            //functions
            Output += "\n PatchedConicsAttached:" + v.PatchedConicsAttached;

//			Debug.Log(v.GetComponents<Component> ());


            //tests
            if (v.PatchedConicsAttached)
            {
                ///@@@TODO: Add another funtion for PatchConic Solver Dump
                Output += "\n maxTotalPatches:" + v.patchedConicSolver.maxTotalPatches;
            }
            Debug.Log(Output);
            Print_Discovery_info(v.DiscoveryInfo);
            Print_Orbit_info(v.orbit);


            if (!v.PatchedConicsAttached)
            {
                Debug.Log("No PatchedConicSolver. Creating a New One. ");
                //v.patchedConicSolver = new PatchedConicSolver ();
                try {
                    v.AttachPatchedConicsSolver();
                    v.patchedConicSolver.Update();
                    v.patchedConicSolver.IncreasePatchLimit();
                    v.patchedConicSolver.Update();
                    v.patchedConicSolver.IncreasePatchLimit();
                    v.patchedConicSolver.Update();
                    v.patchedConicSolver.IncreasePatchLimit();
                    v.patchedConicSolver.Update();
                    Print_Orbit_info(v.orbit);
                }
                catch (Exception ex)
                {
                    Debug.Log("Could not attach patchedConicSolver. Exception:" + ex);
                    AttachedConicsAtStart = true;
                    //v.DetachPatchedConicsSolver ();
                }
            }

            if (!AttachedConicsAtStart)
            {
                v.DetachPatchedConicsSolver();
            }
        }
示例#6
0
        //////////////////////////////
        /// Debug functions
        /// ///////////////////////////	
        /// <summary>
        /// 
        /// </summary>
        /// <param name="o">O.</param>
        private static void Print_Vessel_info(Vessel v)
        {
            Debug.Log("Vessel Info \n");
            bool AttachedConicsAtStart = v.PatchedConicsAttached;

            string Output = "";

            Output = "Name:" + v.name + "; Of type:" +  v.vesselType +  "; doing: " + v.RevealSituationString () +
                "; Unobserved for: " + v.DiscoveryInfo.unobservedLifetime + "sec; Orbiting:" + v.orbit.referenceBody.name ;

            Debug.Log(Output);

            //Dump All info
            Output = "Vessel Dump \n";

            //Variables
            //Output += "\n acceleration:" + v.acceleration;
            Output += "\n altitude:" + v.altitude;
            //Output += "\n angularMomentum:" + v.angularMomentum;
            //Output += "\n angularVelocity:" + v.angularVelocity;
            //Output += "\n atmDensity:" + v.atmDensity;
            //Output += "\n CoM:" + v.CoM;
            Output += "\n ctrlState:" + v.ctrlState;
            //Output += "\n currentStage:" + v.currentStage;
            //Output += "\n geeForce:" + v.geeForce;
            //Output += "\n geeForce_immediate:" + v.geeForce_immediate;
            //Output += "\n heightFromSurface:" + v.heightFromSurface;
            //Output += "\n heightFromTerrain:" + v.heightFromTerrain;
            //Output += "\n horizontalSrfSpeed:" + v.horizontalSrfSpeed;
            Output += "\n id:" + v.id;
            //Output += "\n isEVA:" + v.isEVA;
            //Output += "\n Landed:" + v.Landed;
            //Output += "\n LandedAt:" + v.landedAt;
            Output += "\n Latitude:" + v.latitude;
            Output += "\n LaunchTime:" + v.launchTime;
            Output += "\n loaded:" + v.loaded;
            //Output += "\n LocalCoM:" + v.localCoM;
            //Output += "\n missionTime:" + v.missionTime;
            //Output += "\n MOI:" + v.MOI;
            //Output += "\n obt_speed:" + v.obt_speed;
            //Output += "\n obt_velocity:" + v.obt_velocity;
            //			Output += "\n A:" + v.OnFlyByWire;
            Output += "\n orbitDriver:" + v.orbitDriver;
            Output += "\n orbitTargeter:" + v.orbitTargeter;
            Output += "\n packed:" + v.packed;
            //Output += "\n parts:" + v.parts;
            Output += "\n patchedConicRenderer:" + v.patchedConicRenderer;
            Output += "\n patchedConicSolver:" + v.patchedConicSolver;
            //Output += "\n perturbation:" + v.perturbation;
            //Output += "\n pqsAltitude:" + v.pqsAltitude;
            Output += "\n protoVessel:" + v.protoVessel;
            //Output += "\n rb_velocity:" + v.rb_velocity;
            //Output += "\n referenceTransformId:" + v.referenceTransformId;
            //Output += "\n rootPart:" + v.rootPart;
            Output += "\n situation:" + v.situation;
            //Output += "\n specificAcceleration:" + v.specificAcceleration;
            //Output += "\n Splashed:" + v.Splashed;
            //Output += "\n srf_velocity:" + v.srf_velocity;
            //Output += "\n srfRelRotation:" + v.srfRelRotation;
            Output += "\n state:" + v.state;
            //Output += "\n staticPressurekPa:" + v.staticPressurekPa;
            //Output += "\n terrainAltitude:" + v.terrainAltitude;
            //Output += "\n terrainNormal:" + v.terrainNormal;
            //Output += "\n upAxis:" + v.upAxis;
            Output += "\n verticalSpeed:" + v.verticalSpeed;
            Output += "\n vesselName:" + v.vesselName;
            Output += "\n vesselType:" + v.vesselType;

            //Properties (get/set)
            //Output += "\n ActionGroups:" + v.ActionGroups;
            Output += "\n DiscoveryInfo:" + v.DiscoveryInfo.ToString(); //@@@TODO: add Function

            Output += "\n HoldPhysics:" + v.HoldPhysics;
            Output += "\n isActiveVessel:" + v.isActiveVessel;
            Output += "\n isCommandable:" + v.isCommandable;
            Output += "\n IsControllable:" + v.IsControllable;
            Output += "\n isPersistent:" + v.isPersistent;
            Output += "\n LandedOrSplashed:" + v.LandedOrSplashed;
            Output += "\n orbit:" + v.orbit;

            //functions
            Output += "\n PatchedConicsAttached:" + v.PatchedConicsAttached;

            //			Debug.Log(v.GetComponents<Component> ());

            //tests
            if(v.PatchedConicsAttached){
                ///@@@TODO: Add another funtion for PatchConic Solver Dump
                Output += "\n maxTotalPatches:" + v.patchedConicSolver.maxTotalPatches;
            }
            Debug.Log(Output);
            Print_Discovery_info (v.DiscoveryInfo);
            Print_Orbit_info (v.orbit);

            if (!v.PatchedConicsAttached) {
                Debug.Log("No PatchedConicSolver. Creating a New One. ");
                //v.patchedConicSolver = new PatchedConicSolver ();
                try {
                    v.AttachPatchedConicsSolver ();
                    v.patchedConicSolver.Update ();
                    v.patchedConicSolver.IncreasePatchLimit ();
                    v.patchedConicSolver.Update ();
                    v.patchedConicSolver.IncreasePatchLimit ();
                    v.patchedConicSolver.Update ();
                    v.patchedConicSolver.IncreasePatchLimit ();
                    v.patchedConicSolver.Update ();
                    Print_Orbit_info (v.orbit);
                }
                catch(Exception ex)
                {
                    Debug.Log("Could not attach patchedConicSolver. Exception:" + ex);
                    AttachedConicsAtStart = true;
                    //v.DetachPatchedConicsSolver ();
                }
            }

            if (!AttachedConicsAtStart) {
                v.DetachPatchedConicsSolver ();
            }
        }
示例#7
0
        /// <summary>
        /// Stuff
        /// </summary>
        private static bool CheckVessel(Vessel v)
        {
            bool answer = false;
            Debug.Log("Cheking Intersection for Vessel " + v.name );
            bool DontdetachConics = v.PatchedConicsAttached;

            //Debug Output
            string Output = "";

            Output = "Name:" + v.name + "; Of type:" +  v.vesselType +  "; doing: " + v.RevealSituationString () +
                "; Unobserved for: " + v.DiscoveryInfo.unobservedLifetime + "sec; Orbiting:" + v.orbit.referenceBody.name ;

            Debug.Log(Output);

            if (!v.PatchedConicsAttached) {
                Debug.Log("No PatchedConicSolver. Creating a New One. ");
                try {
                    //v.patchedConicSolver = new PatchedConicSolver ();
                    v.AttachPatchedConicsSolver();
                    v.patchedConicSolver.IncreasePatchLimit ();
                    v.patchedConicSolver.Update ();
                }
                catch(Exception ex)
                {
                    Debug.Log("Could not attach patchedConicSolver. Exception:" + ex);
                    //DontdetachConics = true;
                    //v.DetachPatchedConicsSolver ();
                }
            }

            answer = CheckOrbits (v.orbit);

            if (!DontdetachConics && v.PatchedConicsAttached && v.patchedConicSolver != null) {
                v.DetachPatchedConicsSolver ();
            }
            return answer;
        }