Exemplo n.º 1
0
        internal void transportKerbal_EVAToShip(Vessel evaKerbal)
        {
            //UnityEngine.Debug.Log("ImpulseDrive Transporter EVAToShip Button begin " + evaKerbal.name);
            kerbalEVA = (KerbalEVA)evaKerbal.rootPart.Modules["KerbalEVA"];
            playSound_transporter();

            //UnityEngine.Debug.Log("ImpulseDrive Transporter EVAToShip Button 1 " );
            //this.CurrentMotherShip.GoOffRails();
            foreach (Part part in this.CurrentMotherShip.Parts)
            {
                if (part.CrewCapacity > 0)
                {
                    //UnityEngine.Debug.Log("ImpulseDrive Transporter EVAToShip Button 1 ");

                    kerbalEVA.BoardPart(part);
                    //UnityEngine.Debug.Log("ImpulseDrive Transporter EVAToShip Button 1 ");

                    this.CurrentMotherShip.SpawnCrew();
                    //UnityEngine.Debug.Log("ImpulseDrive Transporter EVAToShip Button 1 ");

                    this.CurrentMotherShip.ResumeStaging();
                    //UnityEngine.Debug.Log("ImpulseDrive Transporter EVAToShip Button 1 ");

                    this.CurrentMotherShip.MakeActive();
                    //UnityEngine.Debug.Log("ImpulseDrive Transporter EVAToShip Button end " );
                    kerbalEVA = null;
                    return;
                }
            }
            float power = PT1.L2_usage;

            this.PowSys.draw(PT1.takerName, power);
        }
Exemplo n.º 2
0
        private void BoardAuto()
        {
            Debug.Log("[AirlockPlus|BoardingPass] INFO: " + vessel.vesselName + " auto boarding " + tgtAirlockPart.vessel.vesselName + " via " + tgtAirlockPart.partInfo.name);

            // check in case of full vessel first
            if (tgtAirlockPart.vessel.GetCrewCount() >= tgtAirlockPart.vessel.GetCrewCapacity())
            {
                Debug.Log("[AirlockPlus|BoardingPass] INFO: Auto boarding failed - vessel full");
                ScreenMessages.PostScreenMessage(scrmsgVesFull);

                // HACK: temporarily disable KerbalEVA for one update frame to prevent stock boarding from being registered alongside auto boarding
                // this prevents "spurious" stock "Cannot board a full module" message appearing alongside our auto boarding "Cannot board a full vessel"
                keva.enabled     = false;
                autoBoardingFull = true;

                return;
            }

            // find part to board
            Part dest = null;

            if (SpaceAvail(tgtAirlockPart))
            {
                // board the part itself if possible
                dest = tgtAirlockPart;
            }
            else
            {
                foreach (Part p in tgtAirlockPart.vessel.parts)
                {
                    if (SpaceAvail(p))
                    {
                        dest = p;
                        break;
                    }
                }
            }
            if (dest == null)
            {
                Debug.Log("[AirlockPlus|BoardingPass] ERROR: Auto boarding target vessel at " + tgtAirlockPart.vessel.GetCrewCount() + "/" + tgtAirlockPart.vessel.GetCrewCapacity() + "of capacity, but somehow unable to find a part with space?!");
                return;
            }

            keva.BoardPart(dest);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Addon work logic.
        /// </summary>
        public void Update()
        {
            if (FlightGlobals.ActiveVessel.isEVA)
            {
                string message = string.Empty;

                if (Input.GetKeyDown(BoardKey))
                {
                    // Prevent addon on map view, or when kerbal is busy,
                    // or when player is typing text in some text field.
                    if (MapView.MapIsEnabled || !this.CrewCanBoard(FlightGlobals.ActiveVessel.evaController))
                    {
                        return;
                    }

                    this.AllowMessages = true;
                    this.WantsBoard    = !this.WantsBoard;

                    if (this.WantsBoard)
                    {
                        this.KerbalName = FlightGlobals.ActiveVessel.vesselName;
                    }

                    message = this.GetStatusMessage();
                }

                KerbalEVA kerbal = FlightGlobals.ActiveVessel.evaController;

                if (this.WantsBoard && kerbal != null)
                {
                    Part airlockPart = this.GetKerbalAirlock(kerbal);

                    if (this.AirlockPart != airlockPart)
                    {
                        // Keep previous airlock to avoid multiple attemts to board it.
                        this.AirlockPart = airlockPart;

                        if (airlockPart != null && kerbal.vessel.state == Vessel.State.ACTIVE && !kerbal.vessel.packed)
                        {
                            if (airlockPart.protoModuleCrew.Count < airlockPart.CrewCapacity)
                            {
                                // There is enough place for the kerbal,
                                // boarding should be successful. We can reset addon fields.
                                this.AllowMessages = false;
                                this.AddonReset();
                            }

                            // Try board.
                            kerbal.BoardPart(airlockPart);
                            return;
                        }
                    }

                    // Try board nearest seat when no airlock.
                    if (airlockPart == null)
                    {
                        KerbalSeat seat = this.GetNearestSeat(kerbal,
                                                              Input.GetKeyDown(BoardKey) ? OriginalSeatDistance : SeatDistance);

                        if (seat != null)
                        {
                            this.AllowMessages = false;
                            seat.BoardSeat();

                            // Check whether boarding seat was successful.
                            if (((PartModule)seat).Events["BoardSeat"].active)
                            {
                                // Fail case.
                                this.AllowMessages = true;
                            }
                            else
                            {
                                // Success case.
                                this.AddonReset();
                            }
                        }
                    }
                }

                this.DisplayMessage(message);
            }
        }
Exemplo n.º 4
0
 private void BoardPart(Suffixed.Part.PartValue toboard)
 {
     CheckEvaController();
     kerbaleva.BoardPart(toboard.Part);
 }
Exemplo n.º 5
0
        /// <summary>
        /// Update is called once per frame.
        /// </summary>
        public void Update()
        {
            this.CheckVesselControl();

            if (FlightGlobals.ActiveVessel.isEVA)
            {
                string message = string.Empty;

                KerbalEVA kerbal = FlightGlobals.ActiveVessel.evaController;

                if (kerbal == null)
                {
                    return;
                }

                if (Input.GetKeyUp(this.BoardKey))
                {
                    // Prevent addon on map view, or when kerbal is busy,
                    // or when player is typing text in some text field.
                    if (!this.CanKerbalStartToWant(kerbal))
                    {
                        return;
                    }

                    this.AllowMessages = true;
                    this.WantsToBoard  = !this.WantsToBoard;

                    if (this.WantsToBoard)
                    {
                        this.KerbalName = FlightGlobals.ActiveVessel.vesselName;
                    }

                    message = this.GetStatusMessage(this.WantsToBoard ? WantsToBoardMessage : HesitatingMessage);
                }

                if (Input.GetKeyUp(this.GrabKey) && !kerbal.OnALadder)
                {
                    string pattern    = "[" + this.GrabKey.ToString() + "]:";
                    bool   canGrabNow = false;

                    ScreenMessages screenMessages = GameObject.FindObjectOfType <ScreenMessages>();
                    foreach (var activeMessage in screenMessages.ActiveMessages)
                    {
                        if (activeMessage.message.StartsWith(pattern, StringComparison.InvariantCultureIgnoreCase))
                        {
                            canGrabNow = true;
                            break;
                        }
                    }

                    if (!canGrabNow)
                    {
                        // Prevent addon on map view, or when kerbal is busy,
                        // or when player is typing text in some text field.
                        if (!this.CanKerbalStartToWant(kerbal))
                        {
                            return;
                        }

                        this.AllowMessages = true;
                        this.WantsToGrab   = !this.WantsToGrab;

                        if (this.WantsToGrab)
                        {
                            this.KerbalName = FlightGlobals.ActiveVessel.vesselName;
                        }

                        message = this.GetStatusMessage(this.WantsToGrab ? WantsToGrabMessage : HesitatingMessage);
                    }
                }

                if (this.WantsToBoard)
                {
                    Part airlockPart = this.GetKerbalAirlock(kerbal);

                    if (this.AirlockPart != airlockPart)
                    {
                        // Keep previous airlock to avoid multiple attemts to board it.
                        this.AirlockPart = airlockPart;

                        if (airlockPart != null && kerbal.vessel.state == Vessel.State.ACTIVE && !kerbal.vessel.packed)
                        {
                            if (airlockPart.protoModuleCrew.Count < airlockPart.CrewCapacity)
                            {
                                // There is enough place for the kerbal,
                                // boarding should be successful. We can reset addon fields.
                                this.AllowMessages = false;
                                this.AddonReset();
                            }

                            // Try board.
                            this.LockVesselControl();
                            kerbal.BoardPart(airlockPart);
                            return;
                        }
                    }

                    // Try board nearest seat when no airlock.
                    if (airlockPart == null)
                    {
                        KerbalSeat seat = this.GetNearestSeat(kerbal,
                                                              Input.GetKeyUp(this.BoardKey) ? OriginalSeatDistance : SeatDistance);

                        if (seat != null)
                        {
                            this.AllowMessages = false;
                            this.LockVesselControl();
                            seat.BoardSeat();

                            // Check whether boarding seat was successful.
                            if (((PartModule)seat).Events["BoardSeat"].active)
                            {
                                // Fail case.
                                this.AllowMessages = true;
                            }
                            else
                            {
                                // Success case.
                                this.AddonReset();
                                return;
                            }
                        }
                    }
                }

                if (this.WantsToGrab && !kerbal.OnALadder)
                {
                    ScreenMessages screenMessages = GameObject.FindObjectOfType <ScreenMessages>();
                    foreach (var activeMessage in screenMessages.ActiveMessages)
                    {
                        if (activeMessage.message.EndsWith("]: Grab", StringComparison.InvariantCultureIgnoreCase))
                        {
                            foreach (var stateEvent in kerbal.fsm.CurrentState.StateEvents)
                            {
                                if (stateEvent.name == "Ladder Grab Start")
                                {
                                    this.AllowMessages = false;
                                    this.WantsToGrab   = false;
                                    this.LockVesselControl();
                                    kerbal.fsm.RunEvent(stateEvent);
                                    break;
                                }
                            }

                            break;
                        }
                    }
                }

                this.DisplayMessage(message);
            }
        }