private void KillCrewMember(ProtoCrewMember crewMember, string causeOfDeath, Vessel vessel)
        {
            TimeWarp.SetRate(0, false);
            if (CameraManager.Instance.currentCameraMode == CameraManager.CameraMode.IVA)
            {
                CameraManager.Instance.SetCameraFlight();
            }

            string vesselName = (!vessel.isEVA) ? vessel.vesselName + " - " : "";
            ScreenMessages.PostScreenMessage(vesselName + crewMember.name + " died of " + causeOfDeath + "!", 15.0f, ScreenMessageStyle.UPPER_CENTER);
            this.Log(vessel.vesselName + " - " + crewMember.name + " died of " + causeOfDeath + "!");

            if (!vessel.isEVA)
            {
                Part part = vessel.Parts.Find(p => p.protoModuleCrew.Contains(crewMember));
                if (part != null)
                {
                    part.RemoveCrewmember(crewMember);
                    crewMember.Die();

                    if (gameSettings.AllowCrewRespawn)
                    {
                        crewMember.StartRespawnPeriod(gameSettings.RespawnDelay);
                    }
                }
            }
            else
            {
                vessel.rootPart.Die();

                if (gameSettings.AllowCrewRespawn)
                {
                    crewMember.StartRespawnPeriod(gameSettings.RespawnDelay);
                }
            }

            gameSettings.knownCrew.Remove(crewMember.name);
        }
 /// <summary>
 /// Kill a kerbal and erase them from the ship.
 /// </summary>
 /// <param name="unluckyBastard">The unlucky bastard.</param>
 internal static void KillKerbal(ProtoCrewMember unluckyBastard)
 {
     unluckyBastard.Die();
     unluckyBastard.seat.part.RemoveCrewmember(unluckyBastard);
     //Yes, this is ugly. No, I don't know how to get it to -actually- kill a Kerbal instead of just listing it as "killed".
     //Without doing this, the kerbal can still EVA, etc.
 }
        public void KillCrewmember(ProtoCrewMember pcm, Vessel vessel)
        {

            //This code adapted from TAC Life Support, written by taraniselsu under the (CC BY-NC-SA 3.0) license. Source available here: https://github.com/taraniselsu/TacLifeSupport/blob/master/Source/LifeSupportController.cs
            TimeWarp.SetRate(0, true);
            if (CameraManager.Instance.currentCameraMode == CameraManager.CameraMode.IVA)
            {
                CameraManager.Instance.SetCameraFlight();
            }

            Debug.Log("Terminus LS: " + pcm.name + " has died due to lack of life support at UT:"+Planetarium.GetUniversalTime()+"!");
            ScreenMessages.PostScreenMessage(pcm.name + " has died due to lack of life support!", 4.0f, ScreenMessageStyle.UPPER_CENTER);

            if (!vessel.isEVA)
            {
                Part part = vessel.Parts.Find(p => p.protoModuleCrew.Contains(pcm));
                if (part != null)
                {
                    part.RemoveCrewmember(pcm);
                    pcm.Die();

                    if (HighLogic.CurrentGame.Parameters.Difficulty.MissingCrewsRespawn)
                    {
                        pcm.StartRespawnPeriod();
                    }
                }
            }
            else
            {
                vessel.rootPart.Die();

                if (HighLogic.CurrentGame.Parameters.Difficulty.MissingCrewsRespawn)
                {
                    pcm.StartRespawnPeriod();
                }
            }

            //remove from the tracked and loaded lists
            KerbalInfo ki = GetInfoForPCM(pcm, false);
            TrackedKerbals.Remove(ki);
            LoadedKerbals.Remove(ki);
        }
        private void KillCrewMember(ProtoCrewMember crewMember, string causeOfDeath, Vessel vessel)
        {
            TimeWarp.SetRate(0, false);
            if (CameraManager.Instance.currentCameraMode == CameraManager.CameraMode.IVA)
            {
                CameraManager.Instance.SetCameraFlight();
            }

            ScreenMessages.PostScreenMessage(vessel.vesselName + " - " + crewMember.name + " died of " + causeOfDeath + "!", 30.0f, ScreenMessageStyle.UPPER_CENTER);
            Debug.Log("TAC Life Support (LifeSupportController) [" + this.GetInstanceID().ToString("X") + "][" + Time.time + "]: " + vessel.vesselName + " - " + crewMember.name + " died of " + causeOfDeath + "!");

            if (!vessel.isEVA)
            {
                Part part = vessel.Parts.Find(p => p.protoModuleCrew.Contains(crewMember));
                if (part != null)
                {
                    part.RemoveCrewmember(crewMember);
                    crewMember.Die();

                    if (settings.AllowCrewRespawn)
                    {
                        crewMember.StartRespawnPeriod(settings.RespawnDelay);
                    }
                }
            }
            else
            {
                vessel.rootPart.Die();

                if (settings.AllowCrewRespawn)
                {
                    crewMember.StartRespawnPeriod(settings.RespawnDelay);
                }
            }
        }
Beispiel #5
0
        // kill a kerbal
        // note: you can't kill a kerbal while iterating over vessel crew list, do it outside the loop
        public static void Kill(Vessel v, ProtoCrewMember c)
        {
            // if on pod
            if (!v.isEVA)
            {
                // if vessel is loaded
                if (v.loaded)
                {
                    // find part
                    Part part = null;
                    foreach (Part p in v.parts)
                    {
                        if (p.protoModuleCrew.Find(k => k.name == c.name) != null)
                        {
                            part = p; break;
                        }
                    }

                    // remove kerbal from part
                    part.RemoveCrewmember(c);

                    // and from vessel
                    v.RemoveCrew(c);

                    // then kill it
                    c.Die();
                }
                // if vessel is not loaded
                else
                {
                    // find proto part
                    ProtoPartSnapshot part = null;
                    foreach (ProtoPartSnapshot p in v.protoVessel.protoPartSnapshots)
                    {
                        if (p.HasCrew(c.name))
                        {
                            part = p; break;
                        }
                    }

                    // remove from part
                    part.RemoveCrew(c.name);

                    // and from vessel
                    v.protoVessel.RemoveCrew(c);

                    // flag as dead
                    c.rosterStatus = ProtoCrewMember.RosterStatus.Dead;
                }

                // forget kerbal data
                DB.KillKerbal(c.name, true);
            }
            // else it must be an eva death
            else
            {
                // flag as eva death
                DB.Kerbal(c.name).eva_dead = true;

                // rename vessel
                v.vesselName = c.name + "'s body";
            }

            // remove reputation
            if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER)
            {
                Reputation.Instance.AddReputation(-Settings.KerbalDeathReputationPenalty, TransactionReasons.Any);
            }
        }