Ejemplo n.º 1
0
        public void SetAsFollower()
        {
            SetOff();
            isFollowing = true;
            this.vessel.ActionGroups.groups[3] = true;             //enable rcs
            this.vessel.ActionGroups.groups[4] = false;            //disable sas

            foreach (Vessel v in FlightGlobals.Vessels)
            {
                if (!v.packed)
                {
                    Debug.Log("Checking if leader: " + v.vesselName);
                    foreach (BurnTogether pp in v.FindPartModulesImplementing <BurnTogether>())
                    {
                        //Debug.Log ("Found BurnTogether module");
                        if (pp.isLeader)
                        {
                            leader    = pp;
                            hasLeader = true;
                            //Debug.Log ("Found Leader.");
                            if (vessel == FlightGlobals.ActiveVessel)
                            {
                                ScreenMessages.PostScreenMessage("Following " + leader.vessel.vesselName, 5, ScreenMessageStyle.UPPER_CENTER);
                            }
                            statusGui = "Following " + leader.vessel.vesselName;
                            if (indicatorStates.Length > 0)
                            {
                                foreach (AnimationState anim in indicatorStates)
                                {
                                    anim.normalizedTime = 1;
                                }
                            }

                            if (!pp.followers.Contains(this))
                            {
                                pp.followers.Add(this);
                            }

                            //copy rotation
                            vessel.OnFlyByWire += new FlightInputCallback(FollowLeader);

                            //RCS kill relative v code
                            this.vessel.OnFlyByWire += new FlightInputCallback(RCSKillVelocity);

                            break;
                        }
                    }
                }
            }


            if (!hasLeader)           //if leader not found
            {
                Debug.Log("Could not find leader.");
                ScreenMessages.PostScreenMessage("Could not find a leader.", 5, ScreenMessageStyle.UPPER_CENTER);
                SetOff();
            }
        }
Ejemplo n.º 2
0
        public void SetOff()
        {
            if (indicatorStates.Length > 0)
            {
                foreach (AnimationState anim in indicatorStates)
                {
                    anim.normalizedTime = 0;
                }
            }
            if (isFollowing)
            {
                vessel.OnFlyByWire      -= new FlightInputCallback(FollowLeader);
                this.vessel.OnFlyByWire -= new FlightInputCallback(RCSKillVelocity);
                if (roverMode)
                {
                    this.vessel.OnFlyByWire -= new FlightInputCallback(RoverControl);
                    roverMode = false;
                }
                if (atmosphericMode)
                {
                    Debug.Log("atmosphericMode disabled");
                    atmosphericMode = false;
                }

                //reset sas
                vessel.Autopilot.SAS.DisconnectFlyByWire();

                this.vessel.ActionGroups.groups[4] = true;
            }
            if (isLeader)
            {
                ScreenMessages.PostScreenMessage("Releasing Followers", 5, ScreenMessageStyle.UPPER_CENTER);

                this.vessel.OnFlyByWire -= new FlightInputCallback(LimitLeaderThrottle);


                foreach (BurnTogether fBt in followers)
                {
                    if (fBt && fBt.isFollowing)
                    {
                        fBt.SetOff();
                        ScreenMessages.PostScreenMessage("Releasing Follower: " + fBt.vessel.vesselName);
                    }
                }

                followers.Clear();
            }
            //Events["ToggleAGM"].active = false;
            mimicAG     = false;
            isLeader    = false;
            isFollowing = false;
            hasLeader   = false;
            leader      = null;
            statusGui   = "Off";
            //throttleLimitFactor = 1;
        }
Ejemplo n.º 3
0
        public void SetOff()
        {
            if(indicatorStates.Length > 0)
            {
                foreach(AnimationState anim in indicatorStates)
                {
                    anim.normalizedTime = 0;
                }
            }
            if(isFollowing)
            {

                vessel.OnFlyByWire -= new FlightInputCallback(FollowLeader);
                this.vessel.OnFlyByWire -= new FlightInputCallback(RCSKillVelocity);
                if(roverMode)
                {
                    this.vessel.OnFlyByWire -= new FlightInputCallback(RoverControl);
                    roverMode = false;
                }
                if(atmosphericMode)
                {
                    Debug.Log ("atmosphericMode disabled");
                    atmosphericMode = false;
                }

                //reset sas
                vessel.Autopilot.SAS.DisconnectFlyByWire();

                this.vessel.ActionGroups.groups[4] = true;
            }
            if(isLeader)
            {
                ScreenMessages.PostScreenMessage("Releasing Followers", 5, ScreenMessageStyle.UPPER_CENTER);

                this.vessel.OnFlyByWire -= new FlightInputCallback(LimitLeaderThrottle);

                foreach(BurnTogether fBt in followers)
                {
                    if(fBt && fBt.isFollowing)
                    {
                        fBt.SetOff();
                        ScreenMessages.PostScreenMessage("Releasing Follower: "+fBt.vessel.vesselName);
                    }
                }

                followers.Clear();
            }
            //Events["ToggleAGM"].active = false;
            mimicAG = false;
            isLeader = false;
            isFollowing = false;
            hasLeader = false;
            leader = null;
            statusGui = "Off";
            //throttleLimitFactor = 1;
        }
Ejemplo n.º 4
0
        public void SetAsFollower()
        {
            SetOff ();
            isFollowing = true;
            this.vessel.ActionGroups.groups[3] = true; //enable rcs
            this.vessel.ActionGroups.groups[4] = false; //disable sas

            foreach(Vessel v in FlightGlobals.Vessels)
            {
                if(!v.packed)
                {
                    Debug.Log ("Checking if leader: "+v.vesselName);
                    foreach(BurnTogether pp in v.FindPartModulesImplementing<BurnTogether>())
                    {
                        //Debug.Log ("Found BurnTogether module");
                        if(pp.isLeader)
                        {
                            leader = pp;
                            hasLeader = true;
                            //Debug.Log ("Found Leader.");
                            if(vessel == FlightGlobals.ActiveVessel)
                            {
                                ScreenMessages.PostScreenMessage("Following "+leader.vessel.vesselName, 5, ScreenMessageStyle.UPPER_CENTER);
                            }
                            statusGui = "Following "+leader.vessel.vesselName;
                            if(indicatorStates.Length > 0)
                            {
                                foreach(AnimationState anim in indicatorStates)
                                {
                                    anim.normalizedTime = 1;
                                }
                            }

                            if(!pp.followers.Contains(this))
                            {
                                pp.followers.Add(this);
                            }

                            //copy rotation
                            vessel.OnFlyByWire += new FlightInputCallback(FollowLeader);

                            //RCS kill relative v code
                            this.vessel.OnFlyByWire += new FlightInputCallback(RCSKillVelocity);

                            break;
                        }
                    }
                }
            }

            if(!hasLeader)//if leader not found
            {
                Debug.Log ("Could not find leader.");
                ScreenMessages.PostScreenMessage("Could not find a leader.", 5, ScreenMessageStyle.UPPER_CENTER);
                SetOff ();
            }
        }