protected virtual bool ExpelCrewman()
        {
            List <ProtoCrewMember> crewChoices = new List <ProtoCrewMember>();

            foreach (var crewable in crewableParts)
            {
                crewChoices.AddRange(crewable.protoModuleCrew);
            }

            if (crewChoices.Count == 0)
            {
                return(false);
            }
            if (MapView.MapIsEnabled)
            {
                MapView.ExitMapView();
            }

            if ((CameraManager.Instance.currentCameraMode & (CameraManager.CameraMode.Internal | CameraManager.CameraMode.IVA)) != 0)
            {
                CameraManager.Instance.SetCameraFlight();
            }

            var luckyKerbal = crewChoices[UnityEngine.Random.Range(0, crewChoices.Count - 1)];

            return(FlightEVA.SpawnEVA(luckyKerbal.KerbalRef));
        }
Ejemplo n.º 2
0
        protected virtual bool ExpelCrewman()
        {
            List <ProtoCrewMember> crewChoices = new List <ProtoCrewMember>();

            //crewChoices.AddRange(crewableParts[i].protoModuleCrew);

            for (int i = crewableParts.Count - 1; i >= 0; i--)
            {
                for (int i1 = crewableParts[i].protoModuleCrew.Count - 1; i1 >= 0; i1--)
                {
                    if (crewableParts[i].protoModuleCrew[i1].type == ProtoCrewMember.KerbalType.Crew)
                    {
                        crewChoices.Add(crewableParts[i].protoModuleCrew[i1]);
                    }
                }
            }
            if (crewChoices.Count == 0)
            {
                return(false);
            }
            if (MapView.MapIsEnabled)
            {
                MapView.ExitMapView();
            }

            if ((CameraManager.Instance.currentCameraMode & (CameraManager.CameraMode.Internal | CameraManager.CameraMode.IVA)) != 0)
            {
                CameraManager.Instance.SetCameraFlight();
            }

            var luckyKerbal = crewChoices[UnityEngine.Random.Range(0, crewChoices.Count - 1)];

            return(FlightEVA.SpawnEVA(luckyKerbal.KerbalRef));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Ejects the Kerbal from the capsule
        /// </summary>
        private void GoEject()
        {
            print("Go eject...");
            InternalSeat commandSeat = part.internalModel.seats[0];

            if (commandSeat.taken == true)
            {
                activeKerbal = commandSeat.kerbalRef;
                commandSeat.DespawnCrew();
                FlightEVA.SpawnEVA(activeKerbal);

                bool test = FlightGlobals.ActiveVessel;

                currentKerbalEVA = FlightGlobals.ActiveVessel.GetComponent <KerbalEVA>();
                print("OK...");

                if (currentKerbalEVA.OnALadder)
                {
                    print("On ladder...");
                    currentKerbalEVA.OnVesselGoOffRails(FlightGlobals.ActiveVessel);
                }

                CameraManager.Instance.SetCameraFlight();
                activeKerbal = null;
            }
        }
Ejemplo n.º 4
0
        public static void GoEVA()
        {
            List <ProtoCrewMember> crew = FlightGlobals.ActiveVessel.GetVesselCrew();

            for (int i = 0; i < crew.Count; i++)
            {
                ProtoCrewMember pcm = crew[i];
                if (pcm != null && HighLogic.CurrentGame.Parameters.Flight.CanEVA)
                {
                    if (pcm.KerbalRef.eyeTransform == InternalCamera.Instance.transform.parent)
                    {
                        if (!(pcm.KerbalRef.state == Kerbal.States.ALIVE &&
                              !pcm.KerbalRef.InPart.packed &&
                              HighLogic.CurrentGame.Parameters.Flight.CanEVA &&
                              !pcm.KerbalRef.InPart.NoAutoEVA &&
                              !pcm.inactive &&
                              pcm.type != ProtoCrewMember.KerbalType.Tourist &&
                              (GameVariables.Instance.UnlockedEVA(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.AstronautComplex)) ||
                               (FlightGlobals.ActiveVessel.mainBody == Planetarium.fetch.Home && FlightGlobals.ActiveVessel.LandedOrSplashed))))
                        {
                            ScreenMessages.PostScreenMessage(GameVariables.Instance.GetEVALockedReason(FlightGlobals.ActiveVessel, pcm), 5);
                            return;
                        }
                        FlightEVA.SpawnEVA(pcm.KerbalRef);
                        CameraManager.Instance.SetCameraFlight();
                        pcm.KerbalRef.state = Kerbal.States.BAILED_OUT;
                        break;
                    }
                }
            }
        }
Ejemplo n.º 5
0
        private void CheckForLatching()
        {
            FindPotato();
            //If we're connected, then we should be latched.
            bool expectedLatch = _potato != null;

            if (expectedLatch != _isLatched)
            {
                _isLatched = expectedLatch;
                if (_isLatched)
                {
                    status            = "Connected";
                    part.CrewCapacity = 4;
                    LatchAnimation[latchAnimationName].speed = 1;
                    LatchAnimation.Play(latchAnimationName);
                }
                else
                {
                    status = "Not Connected";
                    foreach (var c in part.protoModuleCrew)
                    {
                        FlightEVA.SpawnEVA(c.KerbalRef);
                    }
                    part.CrewCapacity = part.protoModuleCrew.Count();
                    LatchAnimation[latchAnimationName].speed = -1;
                    LatchAnimation[latchAnimationName].time  = LatchAnimation[latchAnimationName].length;
                    LatchAnimation.Play(latchAnimationName);
                }
            }
        }
Ejemplo n.º 6
0
 private void GoEva()
 {
     if (activeKerbal != null)
     {
         FlightEVA.SpawnEVA(activeKerbal);
         CameraManager.Instance.SetCameraFlight();
         activeKerbal = null;
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Toss a random kerbal out the airlock
        /// </summary>
        /// <returns></returns>
        protected virtual bool ExpelCrewman()
        {
            // You might think HighLogic.CurrentGame.CrewRoster.GetNextAvailableCrewMember
            // is a logical function to use.  Actually it's possible for it to
            // generate a crew member out of thin air and put it outside, so nope
            //
            // luckily we can specify a particular onboard Kerbal.  We'll do so by
            // finding the possibilities and then picking one totally at
            // pseudorandom

            List <ProtoCrewMember> crewChoices = new List <ProtoCrewMember>();

            foreach (var crewable in crewableParts)
            {
                crewChoices.AddRange(crewable.protoModuleCrew);
            }

            if (crewChoices.Count == 0)
            {
                Log.Error("{0}.Deploy - No crew choices available.  Check logic", GetType().Name);
                return(false);
            }
            else
            {
                // 1.4b bugfix for the 1.4a buxfix:
                //  if the player is in map view, SetCameraFlight won't shut it
                // down for us. Whoops
                if (MapView.MapIsEnabled)
                {
                    MapView.ExitMapView();
                }

                // 1.4a bugfix:
                //   if the player is in IVA view when we spawn eva, it looks
                // like KSP doesn't switch cameras automatically
                if ((CameraManager.Instance.currentCameraMode & (CameraManager.CameraMode.Internal | CameraManager.CameraMode.IVA)) != 0)
                {
                    Log.Normal("Detected IVA or internal cam; switching to flight cam");
                    CameraManager.Instance.SetCameraFlight();
                }


                Log.Debug("Choices of kerbal:");
                foreach (var crew in crewChoices)
                {
                    Log.Debug(" - {0}", crew.name);
                }

                // select a kerbal target...
                var luckyKerbal = crewChoices[UnityEngine.Random.Range(0, crewChoices.Count - 1)];
                Log.Debug("{0} is the lucky Kerbal.  Out the airlock with him!", luckyKerbal.name);

                // out he goes!
                return(FlightEVA.SpawnEVA(luckyKerbal.KerbalRef));
            }
        }
Ejemplo n.º 8
0
        private void OnUpdateIVA(KerbalInfo kerbal)
        {
            _Camera.Update(kerbal);

            Debug.Log("G");
            if (Input.GetKeyDown(BeKerbal.Settings.IVA_GoToEVAKeyCode))
            {
                CameraManager.Instance.SetCameraFlight();
                FlightEVA.SpawnEVA(kerbal.Kerbal);
            }
            Debug.Log("H");
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Begins the EVA for the active kerbal. Based on Mihara's Internal Module code for EVA.
        /// https://github.com/Mihara/RasterPropMonitor/blob/master/RasterPropMonitor/Auxiliary%20modules/JSIInternalEVAHatch.cs
        /// </summary>
        private void GoEva()
        {
            InternalSeat commandSeat = part.internalModel.seats[0];

            if (commandSeat.taken == true)
            {
                activeKerbal = commandSeat.kerbalRef;
                commandSeat.DespawnCrew();
                FlightEVA.SpawnEVA(activeKerbal);
                CameraManager.Instance.SetCameraFlight();
                activeKerbal = null;
            }
        }
        // EVA Menu
        private void CrewEVA(int index, TextMenu.Item ti)
        {
            var   vesselCrew  = vessel.GetVesselCrew();
            float acLevel     = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.AstronautComplex);
            bool  evaUnlocked = GameVariables.Instance.UnlockedEVA(acLevel);
            bool  evaPossible = GameVariables.Instance.EVAIsPossible(evaUnlocked, vessel);

            if (evaPossible && ti.id < vesselCrew.Count && vesselCrew[ti.id] != null && HighLogic.CurrentGame.Parameters.Flight.CanEVA)
            {
                FlightEVA.SpawnEVA(vesselCrew[ti.id].KerbalRef);
                CameraManager.Instance.SetCameraFlight();
            }
        }
Ejemplo n.º 11
0
 private void DumpCrew()
 {
     if (part.protoModuleCrew.Any())
     {
         try
         {
             var c = part.protoModuleCrew.First();
             FlightEVA.SpawnEVA(c.KerbalRef);
         }
         catch (Exception)
         {
             print("[ART] problem removing crewmember");
         }
     }
 }
Ejemplo n.º 12
0
 void GoEVA(Vessel vessel)
 {
     if (CheckEVAUnlocked(vessel))
     {
         if (!vessel.isEVA && !vessel.packed)
         {
             if (vessel.GetCrewCount() > 0)
             {
                 Kerbal _first;
                 if (VesselHasCrewAlive(vessel, out _first))
                 {
                     Kerbal _kerbal = (isIVA() ? CheckIVAKerbal(vessel) : _first);
                     FlightEVA.SpawnEVA(_kerbal);
                     CameraManager.Instance.SetCameraFlight();
                     Log(string.Format("GoEVA {0}({1}) experienceTrait: {2}", _kerbal.crewMemberName, _kerbal.protoCrewMember.seatIdx, _kerbal.protoCrewMember.experienceTrait.Title), "QIVA");
                 }
                 else
                 {
                     ScreenMessages.PostScreenMessage("[QuickIVA] This vessel has no crew alive.", 5, ScreenMessageStyle.UPPER_CENTER);
                 }
             }
             else
             {
                 ScreenMessages.PostScreenMessage("[QuickIVA] This vessel has no crew.", 5, ScreenMessageStyle.UPPER_CENTER);
             }
         }
         else
         {
             ScreenMessages.PostScreenMessage("[QuickIVA] You can't EVA an EVA.", 5, ScreenMessageStyle.UPPER_CENTER);
         }
     }
     else
     {
         ScreenMessages.PostScreenMessage("[QuickIVA] EVA is locked: " + GameVariables.Instance.GetEVALockedReason(vessel, vessel.GetVesselCrew()[0]), 5, ScreenMessageStyle.UPPER_CENTER);
     }
 }
        // PRIVATE METHODS //

        private IEnumerator GoEVADelayed(Kerbal kerbal)
        {
            yield return(new WaitForFixedUpdate());

            FlightEVA.SpawnEVA(kerbal);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// This method controls how the window actually looks when the HUD window is displayed.
        /// </summary>
        public void PopulationManagementGUI(int windowId)
        {
            string activeVesselName   = FlightGlobals.ActiveVessel.vesselName;
            string activeVesselStatus = FlightGlobals.ActiveVessel.situation.ToString();
            string activeSoI          = FlightGlobals.currentMainBody.name;

            if (activeVesselName != null)
            {
                activeVesselName = FlightGlobals.ActiveVessel.vesselName;
            }
            else
            {
                activeVesselName = "[Could not find name]";
            }
            int numCivilians = 0;
            List <ProtoCrewMember> listCivilians = new List <ProtoCrewMember>();

            foreach (ProtoCrewMember crewMember in FlightGlobals.ActiveVessel.GetVesselCrew())
            {
                if (crewMember.trait == debuggingClass.civilianTrait)
                {
                    listCivilians.Add(crewMember);
                    numCivilians++;
                }
            }

            //begin GUI
            GUILayout.BeginVertical();

            //row for ship information
            GUILayout.BeginHorizontal();
            {
                GUILayout.Label("Vessel Name:  " + activeVesselName);
                GUILayout.Label("Status:  " + activeVesselStatus);
                GUILayout.Label("SoI:  " + activeSoI);
            }
            GUILayout.EndHorizontal();

            //row for civilian information
            GUILayout.BeginHorizontal();
            {
                GUILayout.BeginVertical();
                if (GUILayout.Button("Show Civilian Info"))
                {
                    showPopInfo = !showPopInfo;
                    Debug.Log(debuggingClass.modName + "Civilian Info button pressed. New value:  " + showPopInfo);
                }
                if (showPopInfo)
                {
                    if (listCivilians.FirstOrDefault() != null)
                    {
                        foreach (ProtoCrewMember crewMember in listCivilians)
                        {
                            GUILayout.BeginHorizontal();
                            {
                                GUILayout.Label(crewMember.trait);
                                GUILayout.Label(crewMember.name);
                                if (GUILayout.Button("EVA"))
                                {
                                    Debug.Log(debuggingClass.modName + "User pressed button to initiate EVA of " + crewMember.name);
                                    FlightEVA.SpawnEVA(crewMember.KerbalRef);
                                }

                                /*if(GUILayout.Button("Transfer")){
                                 * Debug.Log (debuggingClass.modName + "User pressed button to initiated transfer of " + crewMember.name);
                                 * CrewTransfer.Create(crewMember.seat.part,crewMember);
                                 * }Transfer disabled for now; need to figure out how to use highlighting from ShipManifest mod...*/
                            }
                            GUILayout.EndHorizontal();
                        }
                    }
                }
                GUILayout.EndVertical();
                GUILayout.Label("Civilians:  " + numCivilians);
                GUILayout.Label("Crew Capacity:  " + FlightGlobals.ActiveVessel.GetCrewCount() + "/" + FlightGlobals.ActiveVessel.GetCrewCapacity());
            }
            GUILayout.EndHorizontal();

            //row for close button
            GUILayout.BeginHorizontal();
            {
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Close this Window", GUILayout.Width(200f)))
                {
                    Debug.Log(debuggingClass.modName + "Closing CivPopGUI window");
                    OnToggleFalse();
                }
                GUILayout.FlexibleSpace();
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            GUI.DragWindow();
        }