Esempio n. 1
0
        internal bool setComatoseKerbal(Part part, ProtoCrewMember crew, ProtoCrewMember.KerbalType type, bool start)
        {
            try
            {
                if (start)
                {
                    crew.UnregisterExperienceTraits(part);
                    DFGameEvents.onKerbalSetComatose.Fire(part, crew);
                }

                crew.type = type;

                if (!start)
                {
                    crew.RegisterExperienceTraits(part);
                    DFGameEvents.onKerbalUnSetComatose.Fire(part, crew);
                    ScreenMessages.PostScreenMessage(
                        crew.name + " has recovered from emergency thaw and resumed normal duties.", 5.0f,
                        ScreenMessageStyle.UPPER_CENTER);
                }
                else
                {
                    ScreenMessages.PostScreenMessage(crew.name + " has been emergency thawed and cannot perform duties for " + Instance.DFsettings.comatoseTime / 60 + " minutes.", 5.0f, ScreenMessageStyle.UPPER_CENTER);
                }

                return(true);
            }
            catch (Exception)
            {
                Utilities.Log("DeepFreeze Failed to set " + crew.name + " to status of " + type + " during emergency thaw processing.");
                return(false);
            }
        }
Esempio n. 2
0
        internal bool setComatoseKerbal(Part part, ProtoCrewMember crew, ProtoCrewMember.KerbalType type, bool start)
        {
            try
            {
                if (start)
                {
                    crew.UnregisterExperienceTraits(part);
                    DFGameEvents.onKerbalSetComatose.Fire(part, crew);
                }

                crew.type = type;

                if (!start)
                {
                    crew.RegisterExperienceTraits(part);
                    DFGameEvents.onKerbalUnSetComatose.Fire(part, crew);
                    ScreenMessages.PostScreenMessage(
                        Localizer.Format("#autoLOC_DF_00001", crew.name), 5.0f,
                        ScreenMessageStyle.UPPER_CENTER);
                }
                else
                {
                    ScreenMessages.PostScreenMessage(Localizer.Format("#autoLOC_DF_00002", crew.name, Instance.DFsettings.comatoseTime / 60), 5.0f, ScreenMessageStyle.UPPER_CENTER);
                }

                return(true);
            }
            catch (Exception)
            {
                Utilities.Log("DeepFreeze Failed to set " + crew.name + " to status of " + type + " during emergency thaw processing.");
                return(false);
            }
        }
 public static void AddCrew(this Part part, ProtoCrewMember crew)
 {
     part.protoModuleCrew.Add(crew);
     crew.RegisterExperienceTraits(part);
     if (!(part.internalModel != null) || !(part.internalModel.GetNextAvailableSeat() != null))
     {
         crew.seatIdx = -1;
         crew.seat    = null;
     }
     else
     {
         part.internalModel.SitKerbalAt(crew, part.internalModel.GetNextAvailableSeat());
     }
     if (part.vessel != null)
     {
         part.vessel.CrewListSetDirty();
     }
 }
        //Adds a just thawed kerbal to the vessel.
        private bool AddKerbal(ProtoCrewMember kerbal, int SeatIndx)
        {
            Utilities.Log_Debug("Start AddKerbal " + kerbal.name);
            try
            {
                try
                {
                    FrznCrewMbr tmpcrew = _StoredCrewList.Find(a => a.CrewName == kerbal.name);  // Find the thawed kerbal in the frozen kerbal list.
                    if (_StoredCrewList.Contains(tmpcrew))
                    {
                         Utilities.Log_Debug("Removing _StoredCrewList entry");
                        _StoredCrewList.Remove(tmpcrew);
                    }
                }
                catch (Exception ex)
                {
                     Utilities.Log("Unable to remove _StoredCrewList frozen crewmember " + kerbal.name);
                     Utilities.Log("Err: " + ex);
                    //ScreenMessages.PostScreenMessage("DeepFreezer mechanical failure", 5.0f, ScreenMessageStyle.UPPER_CENTER);
                    //return false;
                }

                // Update the saved frozen kerbals dictionary
                 Utilities.Log_Debug("Removing Frozen Crew to dictionary");
                try
                {
                    if (DeepFreeze.Instance.DFgameSettings.KnownFrozenKerbals.ContainsKey(kerbal.name))
                    {
                        DeepFreeze.Instance.DFgameSettings.KnownFrozenKerbals.Remove(kerbal.name);
                    }
                    if (DeepFreeze.Instance.DFsettings.debugging) DeepFreeze.Instance.DFgameSettings.DmpKnownFznKerbals();
                }
                catch (Exception ex)
                {
                     Utilities.Log("Unable to remove knownfrozenkerbals frozen crewmember " + kerbal.name);
                     Utilities.Log("Err: " + ex);
                    ScreenMessages.PostScreenMessage("DeepFreezer mechanical failure", 5.0f, ScreenMessageStyle.UPPER_CENTER);
                    return false;
                }
                if (partHasInternals && ExternalDoorActive)
                    Utilities.setHelmetshaders(kerbal.KerbalRef, true);
                // add the CrewMember to the part crewlist and register their traits.
                kerbal.RegisterExperienceTraits(part);
                if (!part.protoModuleCrew.Contains(kerbal))
                {
                    part.protoModuleCrew.Add(kerbal);
                }
                // Set our newly thawed Popsicle, er Kerbal, to Crew type and Assigned status.
                if (kerbal.type != ProtoCrewMember.KerbalType.Crew)
                {
                    kerbal.type = ProtoCrewMember.KerbalType.Crew;
                    kerbal.rosterStatus = ProtoCrewMember.RosterStatus.Assigned;
                }
                if (partHasInternals)
                {
                    if (kerbal.seat != part.internalModel.seats[SeatIndx])
                    {
                        kerbal.seat = part.internalModel.seats[SeatIndx];
                        kerbal.seatIdx = SeatIndx;
                    }
                    if (part.internalModel.seats[SeatIndx].crew != kerbal)
                    {
                        part.internalModel.seats[SeatIndx].crew = kerbal;
                    }
                    if (part.internalModel.seats[SeatIndx].kerbalRef != kerbal.KerbalRef)
                    {
                        part.internalModel.seats[SeatIndx].kerbalRef = kerbal.KerbalRef;
                        part.internalModel.seats[SeatIndx].taken = true;
                        setseatstaticoverlay(part.internalModel.seats[SeatIndx]);
                    }
                    seatTakenbyFrznKerbal[SeatIndx] = false;
                }
                /*if (kerbal.KerbalRef != null)
                {
                    if (kerbal.KerbalRef.InPart == null)
                    {
                        kerbal.KerbalRef.InPart = part;
                    }
                    //Add themto the GUIManager Portrait cams.
                    Portraits.RestorePortrait(kerbal.KerbalRef);
                }*/
                 Utilities.Log_Debug("End AddKerbal");
                return true;
            }
            catch (Exception ex)
            {
                Debug.Log("Add Kerbal " + kerbal.name + " for DeepFreeze failed");
                Debug.Log("Err: " + ex);
                return false;
            }
        }