Exemplo n.º 1
0
        public override ExperienceTrait ParseIdentifier(Token token)
        {
            // Try to parse more, as ExperienceTrait names can have spaces
            Match  m          = Regex.Match(expression, @"^((?>\s*[\w\d]+)+).*");
            string identifier = m.Groups[1].Value;

            expression = (expression.Length > identifier.Length ? expression.Substring(identifier.Length) : "");
            identifier = token.sval + identifier;

            if (identifier.Equals("null", StringComparison.CurrentCultureIgnoreCase))
            {
                return(null);
            }

            if (HighLogic.CurrentGame == null)
            {
                currentDataNode.SetDeterministic(currentKey, false);
                return(null);
            }

            for (int index = 0; index < GameDatabase.Instance.ExperienceConfigs.Categories.Count; ++index)
            {
                if (identifier == GameDatabase.Instance.ExperienceConfigs.Categories[index].Name)
                {
                    Type type = KerbalRoster.GetExperienceTraitType(identifier) ?? typeof(ExperienceTrait);
                    return(ExperienceTrait.Create(type, GameDatabase.Instance.ExperienceConfigs.Categories[index], null));
                }
            }

            LoggingUtil.LogError(this, StringBuilderCache.Format("Unknown experience trait '{0}'.", identifier));
            return(null);
        }
Exemplo n.º 2
0
        private void OnKerbalStatusChange(ProtoCrewMember pcm, ProtoCrewMember.RosterStatus oldStatus, ProtoCrewMember.RosterStatus newStatus)
        {
            if (oldStatus == ProtoCrewMember.RosterStatus.Assigned && newStatus == ProtoCrewMember.RosterStatus.Available)
            {
                FlightLog tmpLog = new FlightLog();
                foreach (FlightLog.Entry entry in pcm.careerLog.Entries.Union(pcm.flightLog.Entries))
                {
                    tmpLog.AddEntry(entry);
                }

                float xp  = KerbalRoster.CalculateExperience(pcm.careerLog);
                float xp2 = KerbalRoster.CalculateExperience(tmpLog);

                float amount = (xp2 - xp) * multiplier;

                if (currency == Currency.Funds)
                {
                    Funding.Instance.AddFunds(amount, TransactionReasons.Strategies);
                }
                else if (currency == Currency.Reputation)
                {
                    Reputation.Instance.AddReputation(amount, TransactionReasons.Strategies);
                }
                else if (currency == Currency.Science)
                {
                    ResearchAndDevelopment.Instance.AddScience(amount, TransactionReasons.Strategies);
                }

                CurrencyPopup.Instance.AddPopup(currency, amount, TransactionReasons.Strategies, Parent.Config.Title, false);
            }
        }
Exemplo n.º 3
0
        public override ExperienceTrait ConvertFrom <U>(U value)
        {
            LoggingUtil.LogDebug(this, StringBuilderCache.Format("ExperienceTraitParser.ConvertFrom<{0}>({1}", typeof(U), value));
            if (typeof(U) == typeof(string))
            {
                string sVal = (string)(object)value;

                if (HighLogic.CurrentGame == null)
                {
                    currentDataNode.SetDeterministic(currentKey, false);
                    return(null);
                }

                for (int index = 0; index < GameDatabase.Instance.ExperienceConfigs.Categories.Count; ++index)
                {
                    if (sVal == GameDatabase.Instance.ExperienceConfigs.Categories[index].Name)
                    {
                        Type type = KerbalRoster.GetExperienceTraitType(sVal) ?? typeof(ExperienceTrait);
                        return(ExperienceTrait.Create(type, GameDatabase.Instance.ExperienceConfigs.Categories[index], null));
                    }
                }

                throw new ArgumentException("'" + sVal + "' is not a valid experience trait.");
            }
            throw new DataStoreCastException(typeof(U), typeof(ExperienceTrait));
        }
Exemplo n.º 4
0
        /// <summary>
        /// This method is called from the Main system to load all the kerbals we received
        /// when connecting to a server into the game
        /// </summary>
        public void LoadKerbalsIntoGame()
        {
            LunaLog.Log("[LMP]: Loading kerbals into game");
            while (KerbalQueue.Count > 0)
            {
                LoadKerbal(KerbalQueue.Dequeue());
            }

            //Server is new and don't have kerbals at all
            if (ServerKerbals.Count == 0)
            {
                var newRoster = KerbalRoster.GenerateInitialCrewRoster(HighLogic.CurrentGame.Mode);
                foreach (var pcm in newRoster.Crew)
                {
                    HighLogic.CurrentGame.CrewRoster.AddCrewMember(pcm);
                    MessageSender.SendKerbalIfDifferent(pcm);
                }
            }
            else
            {
                //Server has less than 20 kerbals so generate some
                var generateKerbals = ServerKerbals.Count < 20 ? 20 - ServerKerbals.Count : 0;
                if (generateKerbals > 0)
                {
                    LunaLog.Log($"[LMP]: Generating {generateKerbals} new kerbals");
                    for (var i = 0; i < generateKerbals; i++)
                    {
                        var protoKerbal = HighLogic.CurrentGame.CrewRoster.GetNewKerbal();
                        MessageSender.SendKerbalIfDifferent(protoKerbal);
                    }
                }
            }

            LunaLog.Log("[LMP]: Kerbals loaded");
        }
Exemplo n.º 5
0
            // Check for errors (e.g. cannot hire kerbals)
            static string CheckForErrors()
            {
                AstronautComplex complex = Resources.FindObjectsOfTypeAll <AstronautComplex>()?.FirstOrDefault();
                KerbalRoster     roster  = HighLogic.CurrentGame?.CrewRoster;

                if (complex == null || roster == null)
                {
                    return("");
                }

                int?active = roster?.GetActiveCrewCount();

                if (active < complex?.crewLimit())
                {
                    if (GameVariables.Instance?.GetRecruitHireCost((int)active) > Funding.Instance?.Funds)
                    {
                        return(TooltipErrors.OutOfFunds);
                    }
                }
                else
                {
                    return(TooltipErrors.AtCapacity);
                }

                return("");
            }
Exemplo n.º 6
0
        public void OnKerbalAdded(ProtoCrewMember kerbal)
        {
            List <string> originalNames = new List <string> {
                "Jebediah Kerman",
                "Bill Kerman",
                "Bob Kerman",
                "Valentina Kerman"
            };

            if (preserveOriginals)
            {
                if (originalNames.Contains(kerbal.name))
                {
                    return;
                }
            }
            else             // see if any of the originals are still around
            {
                foreach (var originalKerbalName in originalNames)
                {
                    if (HighLogic.CurrentGame.CrewRoster[originalKerbalName] != null)
                    {
                        var origKerbal = HighLogic.CurrentGame.CrewRoster[originalKerbalName];
                        var origTrait  = origKerbal.trait;
                        RerollKerbal(origKerbal);
                        KerbalRoster.SetExperienceTrait(origKerbal, origTrait);
                    }
                }
            }

            RerollKerbal(kerbal);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Scans all trackable kerbals and adds them to the list
        /// </summary>
        public void RegisterKerbals()
        {
            Core.Log("Registering kerbals...");
            KerbalRoster kerbalRoster = HighLogic.fetch.currentGame.CrewRoster;

            Core.Log("" + kerbalRoster.Count + " kerbals in CrewRoster: " + kerbalRoster.Crew.Count() + " crew, " + kerbalRoster.Tourist.Count() + " tourists.", Core.LogLevel.Important);
            foreach (KerbalHealthStatus khs in Values)
            {
                if (!Core.IsKerbalTrackable(khs.PCM) && !khs.HasCondition("Frozen"))
                {
                    Remove(khs.Name);
                }
            }
            List <ProtoCrewMember> list = kerbalRoster.Crew.Concat(kerbalRoster.Tourist).ToList();

            Core.Log(list.Count + " total kerbals in the roster.");
            foreach (ProtoCrewMember pcm in list)
            {
                if (Core.IsKerbalTrackable(pcm))
                {
                    Add(pcm.name, KerbalHealthStatus.GetMaxHP(pcm));
                }
            }
            Core.Log("KerbalHealthList updated: " + Count + " kerbals found.", Core.LogLevel.Important);
        }
        public void removekerbals(List <ProtoCrewMember> crewMembers)
        {
            KerbalRoster roster = HighLogic.CurrentGame.CrewRoster;

            //Remove all of the vessel's registered crew members.
            foreach (ProtoCrewMember crewMember in crewMembers)
            {
                if (kerbals.Contains(crewMember.name) && roster[crewMember.name] != null)
                {
                    roster.Remove(crewMember.name);
                    kerbals.Remove(crewMember.name);
                }
            }

            //Also clean up the list
            List <string> doomed = new List <string>();

            foreach (string kerbalName in kerbals)
            {
                if (roster[kerbalName] == null)
                {
                    doomed.Add(kerbalName);
                }
            }
            foreach (string doomedKerbal in doomed)
            {
                kerbals.Remove(doomedKerbal);
            }
        }
Exemplo n.º 9
0
Arquivo: Main.cs Projeto: WopsS/L.O.G
        public void StartGame()
        {
            string     SaveDirectory = Path.Combine(KSPUtil.ApplicationRootPath, Path.Combine("saves", "L.O.G"));
            ConfigNode Node          = ConfigNode.Load(Path.Combine(SaveDirectory, "persistent.sfs"));

            HighLogic.CurrentGame             = new Game(Node);
            HighLogic.CurrentGame.Mode        = Game.Modes.SANDBOX;
            HighLogic.CurrentGame.Title       = "L.O.G.";
            HighLogic.CurrentGame.Description = "L.O.G. - Multiplayer";
            HighLogic.CurrentGame.startScene  = GameScenes.SPACECENTER;
            HighLogic.CurrentGame.CrewRoster  = KerbalRoster.GenerateInitialCrewRoster(Game.Modes.SANDBOX);
            Planetarium.SetUniversalTime(0.0);

            if (HighLogic.CurrentGame.Mode != Game.Modes.SANDBOX)
            {
                HighLogic.CurrentGame.Parameters.Difficulty.AllowStockVessels = true;
            }

            HighLogic.CurrentGame.additionalSystems = new ConfigNode();
            HighLogic.CurrentGame.additionalSystems.AddNode("MESSAGESYSTEM");

            HighLogic.CurrentGame.flightState = new FlightState();
            HighLogic.CurrentGame.CrewRoster.ValidateAssignments(HighLogic.CurrentGame);

            HighLogic.SaveFolder = "L.O.G";
            GamePersistence.SaveGame(HighLogic.CurrentGame, "persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE);
            HighLogic.CurrentGame.Start();

            this.m_playerModel.GameStarted = true;
        }
Exemplo n.º 10
0
        protected virtual string applyAstronautRetires()
        {
            string       message = string.Empty;
            KerbalRoster roster  = HighLogic.CurrentGame.CrewRoster;

            ProtoCrewMember[] crewRoster = roster.Crew.ToArray();
            ProtoCrewMember   astronaut  = null;
            int randomIndex = 0;

            //Keep looking until we find an available astronaut that isn't a vet.
            for (int index = 0; index < crewRoster.Length; index++)
            {
                randomIndex = UnityEngine.Random.Range(0, crewRoster.Length - 1);
                astronaut   = crewRoster[randomIndex];

                if (astronaut.rosterStatus == ProtoCrewMember.RosterStatus.Available && !astronaut.veteran)
                {
                    //Remove astronaut from roster
                    roster.Remove(astronaut.name);

                    //Inform player
                    message = astronaut.name + Localizer.Format(BARISScenario.StatusRetiredMsg);
                    break;
                }
            }

            return(message);
        }
Exemplo n.º 11
0
        protected void processAllAvailableEvent()
        {
            KerbalRoster roster = HighLogic.CurrentGame.CrewRoster;
            int          count  = roster.Count;

            for (int index = 0; index < count; index++)
            {
                if (roster[index].rosterStatus != ProtoCrewMember.RosterStatus.Available)
                {
                    continue;
                }

                //Make sure all preconditions are valid before applying outcomes.
                if (PreconditionsValid(roster[index]))
                {
                    ApplyOutcomes(roster[index]);
                }
            }

            //Finally, show player message
            if (!string.IsNullOrEmpty(playerMessage))
            {
                ScreenMessages.PostScreenMessage(playerMessage, 5.0f, ScreenMessageStyle.UPPER_LEFT);
            }
        }
Exemplo n.º 12
0
        protected void processRandomAvailableEvent()
        {
            KerbalRoster           roster         = HighLogic.CurrentGame.CrewRoster;
            int                    count          = roster.Count;
            List <ProtoCrewMember> availableCrews = new List <ProtoCrewMember>();

            for (int index = 0; index < count; index++)
            {
                if (roster[index].rosterStatus == ProtoCrewMember.RosterStatus.Available)
                {
                    availableCrews.Add(roster[index]);
                }
            }
            if (availableCrews.Count == 0)
            {
                return;
            }

            //Now select one at random
            int randomIndex = UnityEngine.Random.Range(0, availableCrews.Count - 1);

            //Make sure all preconditions are valid before applying outcomes.
            if (PreconditionsValid(roster[randomIndex]))
            {
                ApplyOutcomes(roster[randomIndex]);

                //Finally, show player message
                if (!string.IsNullOrEmpty(playerMessage))
                {
                    string message = playerMessage;
                    message = message.Replace("<<KerbalName>>", roster[randomIndex].name);
                    ScreenMessages.PostScreenMessage(message, 5.0f, ScreenMessageStyle.UPPER_LEFT);
                }
            }
        }
Exemplo n.º 13
0
        private static void ReContract(RMKerbal disputekerbal)
        {
            if (!Funding.CanAfford((float)disputekerbal.Salary + (float)disputekerbal.OwedSalary))
            {
                return;
            }

            Funding.Instance.AddFunds(-(disputekerbal.Salary + disputekerbal.OwedSalary), TransactionReasons.CrewRecruited);
            disputekerbal.Timelastsalary                 = Planetarium.GetUniversalTime();
            disputekerbal.SalaryContractDispute          = false;
            disputekerbal.SalaryContractDisputeProcessed = true;
            disputekerbal.SalaryContractDisputePeriods   = 0;
            disputekerbal.PayriseRequired                = 0d;
            disputekerbal.OwedSalary = 0d;
            //If they are a tourist (dispute) and not dead (DeepFreeze frozen/comatose) set them back to crew
            if (disputekerbal.Type != ProtoCrewMember.KerbalType.Tourist ||
                disputekerbal.Status == ProtoCrewMember.RosterStatus.Dead)
            {
                return;
            }

            disputekerbal.Type         = ProtoCrewMember.KerbalType.Crew;
            disputekerbal.Kerbal.type  = ProtoCrewMember.KerbalType.Crew;
            disputekerbal.Trait        = disputekerbal.RealTrait;
            disputekerbal.Kerbal.trait = disputekerbal.RealTrait;
            KerbalRoster.SetExperienceTrait(disputekerbal.Kerbal, disputekerbal.Kerbal.trait);
            RMKerbal.RegisterExperienceTrait(disputekerbal);
        }
Exemplo n.º 14
0
        protected void removeTourists()
        {
            WBIKerbalStayParam stayParam;
            KerbalRoster       roster = HighLogic.CurrentGame.CrewRoster;

            foreach (ContractParameter parameter in AllParameters)
            {
                if (parameter is WBIKerbalStayParam)
                {
                    stayParam = (WBIKerbalStayParam)parameter;
                    if (roster[stayParam.kerbalName] != null)
                    {
                        //Remove them if they haven't flown yet.
                        if (roster[stayParam.kerbalName].rosterStatus == ProtoCrewMember.RosterStatus.Available)
                        {
                            roster.Remove(stayParam.kerbalName);
                        }

                        //Remove them when they recover
                        else
                        {
                            WBIContractScenario.Instance.registerKerbal(stayParam.kerbalName);
                        }
                    }
                }
            }
        }
Exemplo n.º 15
0
        protected override void OnLoad(ConfigNode node)
        {
            base.OnLoad(node);
            count          = Convert.ToInt32(node.GetValue("count"));
            passengerNames = ConfigNodeUtil.ParseValue <List <string> >(node, "potentialPassenger", new List <string>());

            // Backwards compatibility
            if (node.HasValue("passengersLoaded"))
            {
                List <ProtoCrewMember> allPassengers = ConfigNodeUtil.ParseValue <List <ProtoCrewMember> >(node, "passenger", new List <ProtoCrewMember>());
                bool passengersLoaded = ConfigNodeUtil.ParseValue <bool>(node, "passengersLoaded");

                foreach (ProtoCrewMember crew in allPassengers)
                {
                    KerbalRoster.SetExperienceTrait(crew, "Engineer");
                    passengers[crew] = passengersLoaded;
                }
            }
            else
            {
                foreach (ConfigNode child in node.GetNodes("PASSENGER_DATA"))
                {
                    ProtoCrewMember crew   = ConfigNodeUtil.ParseValue <ProtoCrewMember>(child, "passenger");
                    bool            loaded = ConfigNodeUtil.ParseValue <bool>(child, "loaded");

                    KerbalRoster.SetExperienceTrait(crew, "Engineer");
                    passengers[crew] = loaded;
                }
            }
        }
Exemplo n.º 16
0
 /// <summary>
 /// Gets all the kerbals for the given roster.
 /// </summary>
 /// <param name="p">Contract parameter</param>
 /// <returns>Enumerator of descendents</returns>
 public static IEnumerable <ProtoCrewMember> AllKerbals(this KerbalRoster roster)
 {
     for (int i = 0; i < roster.Count; i++)
     {
         yield return(roster[i]);
     }
 }
Exemplo n.º 17
0
        private protected void KloneKerbal()
        {
            Logging.DLog(logMsg: "Kloning: KloneKerbal");
            DebitCurrencies();
            ProtoCrewMember kerbal = HighLogic.CurrentGame.CrewRoster.GetNewKerbal();

            kerbal.suit  = (ProtoCrewMember.KerbalSuit)HighLogic.CurrentGame.Parameters.CustomParams <Settings2>().birthdaySuit;
            kerbal.trait = Localizer.Format("#MOAR-004");

            if (HighLogic.CurrentGame.Parameters.CustomParams <Settings2>().kloneCivilians)
            {
                KerbalRoster.SetExperienceTrait(kerbal, Localizer.Format("#MOAR-004"));
            }
            ;
            part.AddCrewmember(kerbal);

            if (kerbal.seat != null)
            {
                kerbal.seat.SpawnCrew();
            }

            kerbal.rosterStatus = ProtoCrewMember.RosterStatus.Assigned;

            //Logging.Msg("Kloning Success!  " + kerbal.name + "(Lv " + kerbal.experienceLevel.ToString() + " " + kerbal.experienceTrait.Title + ") has joined your space program");
            Logging.Msg(Localizer.Format("#MOAR-KloneBay-04", kerbal.name, kerbal.experienceLevel.ToString(), kerbal.experienceTrait.Title), true);

            if (HighLogic.CurrentGame.Parameters.CustomParams <Settings2>().soundOn)
            {
                SuccessSound();
            }
        }
Exemplo n.º 18
0
 public void SyncKerbal()
 {
     if (RMSettings.EnableKerbalRename)
     {
         Kerbal.name = Name;
     }
     if (RMSettings.EnableKerbalRename && RMSettings.RenameWithProfession)
     {
         KerbalRoster.SetExperienceTrait(Kerbal);
     }
     if (Title != Kerbal.experienceTrait.Title)
     {
         while (Kerbal.experienceTrait.Title != Title)
         {
             Kerbal.name = Name += char.ConvertFromUtf32(1);
             KerbalRoster.SetExperienceTrait(Kerbal);
         }
     }
     Kerbal.gender          = Gender;
     Kerbal.stupidity       = Stupidity;
     Kerbal.courage         = Courage;
     Kerbal.isBadass        = Badass;
     Kerbal.experienceLevel = Skill;
     Kerbal.experience      = Experience;
 }
Exemplo n.º 19
0
        protected void retrainKerbals()
        {
            ProtoCrewMember trainee;

            foreach (string kerbalName in newProfessions.Keys)
            {
                trainee = trainees[kerbalName];

                //If the kerbal is currently a tourist, then unregister the kerbal from any tourism contracts.
                if (trainee.trait == "Tourist")
                {
                    WBIContractScenario.Instance.unregisterKerbal(kerbalName);
                }

                //Set the new trait
                KerbalPortraitGallery.Instance.UnregisterActiveCrew(trainee.KerbalRef);
                KerbalRoster.SetExperienceTrait(trainee, newProfessions[kerbalName]);
                KerbalPortraitGallery.Instance.RegisterActiveCrew(trainee.KerbalRef);
                KerbalPortraitGallery.Instance.UpdatePortrait(trainee.KerbalRef);

                //Reset experience
                if (resetExperience)
                {
                    KerbalRoster.SetExperienceLevel(trainee, 0);
                }
            }
        }
Exemplo n.º 20
0
        public void birthOfNewCivilans(double date, CivPopRepository repo)
        {
            List <CivPopKerbal> childs = new List <CivPopKerbal>();

            IEnumerable <CivPopKerbal> females = repo.GetRoster()
                                                 .Where(kerbal => kerbal.GetExpectingBirthAt() > 0)
                                                 .Where(kerbal => !kerbal.IsDead())
                                                 .Where(kerbal => kerbal.GetExpectingBirthAt() < date)
            ;

            foreach (CivPopKerbal female in females)
            {
                female.SetExpectingBirthAt(-1);
                if (female.GetVesselId() != null)
                {
                    CivPopVessel vessel = repo.GetVessel(female.GetVesselId());
                    if (vessel.GetCapacity() > repo.GetLivingRosterForVessel(vessel.GetId()).Count())
                    {
                        CivPopKerbal child = builder.build(date);
                        child.SetBirthdate(date);
                        child.SetVesselId(female.GetVesselId());

                        ProtoCrewMember pcm = new ProtoCrewMember(ProtoCrewMember.KerbalType.Crew, child.GetName());
                        KerbalRoster.SetExperienceTrait(pcm, "Civilian");//Set the Kerbal as the specified role (kerbalTraitName)
                        var plist = vessel.KSPVessel.parts.FindAll(p => p.CrewCapacity > p.protoModuleCrew.Count);

                        // There may be a better way, but this will look for space in the same part as the female giving birth
                        Part part = null;
                        foreach (var p in plist)
                        {
                            var crew = p.protoModuleCrew.Find(c => c.name == female.GetName());
                            if (crew != null)
                            {
                                part = p;
                                SimpleLogger.fetch.Info("Crew member: " + female.GetName() + ", found on part: " + p.partInfo.title);
                                break;
                            }
                        }
                        // If part is null, no room in same part, so just find a part with room
                        if (part == null)
                        {
                            part = vessel.KSPVessel.parts.Find(p => p.CrewCapacity > p.protoModuleCrew.Count);
                        }
                        if (part != null)
                        {
                            part.AddCrewmember(pcm);
                            vessel.KSPVessel.SpawnCrew();
                            SimpleLogger.fetch.Info("Child added to childs, name: " + child.GetName());
                        }
                        childs.Add(child);
                    }
                }
            }

            foreach (CivPopKerbal child in childs)
            {
                repo.Add(child);
            }
        }
Exemplo n.º 21
0
        public void OnContractAccepted(Contract contract)
        {
            //Only if we're restricting classes
            if (KolonyACOptions.KolonistRescueEnabled)
            {
                return;
            }

            ConfigNode contractData = new ConfigNode("CONTRACT");

            contract.Save(contractData);
            int type = contractData.HasValue("recoveryType") ? int.Parse(contractData.GetValue("recoveryType")) : 0;

            if (type != 1 && type != 3)
            {
                return;
            }

            string kerbalName = contractData.GetValue("kerbalName");

            if (!string.IsNullOrEmpty(kerbalName))
            {
                if (HighLogic.CurrentGame.CrewRoster.Exists(kerbalName))
                {
                    HighLogic.CurrentGame.CrewRoster.Remove(kerbalName);
                }

                string newTrait = getRandomTrait();
                var    newKerb  = HighLogic.CurrentGame.CrewRoster.GetNewKerbal(ProtoCrewMember.KerbalType.Crew);
                newKerb.ChangeName(kerbalName);
                if (KolonyACOptions.VeteranRescueEnabled)
                {
                    var KLevel  = rnd.Next(6);
                    var acLevel = 5;
                    if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER)
                    {
                        acLevel = (int)ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.AstronautComplex);
                    }
                    var xp = HighLogic.CurrentGame.Parameters.CustomParams <GameParameters.AdvancedParams>().KerbalExperienceEnabled(HighLogic.CurrentGame.Mode);

                    if (KLevel > 0)
                    {
                        var logName       = "RecruitementLevel" + KLevel;
                        var homeworldName = FlightGlobals.Bodies.Where(cb => cb.isHomeWorld).FirstOrDefault().name;
                        newKerb.flightLog.AddEntry(logName, homeworldName);
                        newKerb.ArchiveFlightLog();
                        newKerb.experience      = CustomAstronautComplexUI.GetExperienceNeededFor(KLevel);
                        newKerb.experienceLevel = KLevel;
                    }
                    if (acLevel == 5 || !xp)
                    {
                        newKerb.experience      = 9999;
                        newKerb.experienceLevel = 5;
                    }
                }
                KerbalRoster.SetExperienceTrait(newKerb, newTrait);
                newKerb.rosterStatus = ProtoCrewMember.RosterStatus.Assigned;
            }
        }
Exemplo n.º 22
0
 public void GenerateKerbal()
 {
     _pcm        = HighLogic.CurrentGame.CrewRoster.GetNewKerbal(kerbalType);
     _pcm.gender = gender;
     _pcm.ChangeName(name);
     _pcm.trait = experienceTrait;
     KerbalRoster.SetExperienceTrait(_pcm, experienceTrait);
 }
Exemplo n.º 23
0
        protected int getActiveDutyAstronauts()
        {
            int          astronautCount = 0;
            KerbalRoster roster         = HighLogic.CurrentGame.CrewRoster;

            astronautCount += roster.GetAssignedCrewCount() + roster.GetAvailableCrewCount();

            return(astronautCount);
        }
Exemplo n.º 24
0
        /// <summary>
        /// Creates the new crew member of trait kerbalTraitName.  It must be of type Crew because they seem to be the only
        /// type of Kerbal that can keep a trait.
        /// </summary>
        /// <returns>The new crew member.</returns>
        /// <param name="kerbalTraitName">Kerbal trait name.</param>
        ProtoCrewMember createNewCrewMember(string kerbalTraitName)
        {
            KerbalRoster    roster    = HighLogic.CurrentGame.CrewRoster;
            ProtoCrewMember newKerbal = roster.GetNewKerbal(ProtoCrewMember.KerbalType.Crew);

            KerbalRoster.SetExperienceTrait(newKerbal, kerbalTraitName); //Set the Kerbal as the specified role (kerbalTraitName)
            Debug.Log(debuggingClass.modName + "Created " + newKerbal.name + ", a " + newKerbal.trait);
            return(newKerbal);                                           //returns newly-generated Kerbal
        }
Exemplo n.º 25
0
 /// <summary>
 /// Static initializer to hack the kerbal experience/flight log system to add our entries.
 /// </summary>
 static NewKerbalExperience()
 {
     Debug.Log("Strategia: Setting up Kerbal Experience");
     KerbalRoster.AddExperienceType(SPECIAL_XP + "1", "Special training", 0.0f, 2.0f);
     KerbalRoster.AddExperienceType(SPECIAL_XP + "2", "Special training", 0.0f, 8.0f);
     KerbalRoster.AddExperienceType(SPECIAL_XP + "3", "Special training", 0.0f, 16.0f);
     KerbalRoster.AddExperienceType(SPECIAL_XP + "4", "Special training", 0.0f, 32.0f);
     KerbalRoster.AddExperienceType(SPECIAL_XP + "5", "Special training", 0.0f, 64.0f);
 }
        /// <summary>
        /// Static initializer to add our entries into the experience/flight log system.
        /// It's done on the factory to guarantee it's always run, otherwise uninstalling a
        /// contract pack could have the side effect of wiping some XP from a saved game.
        /// </summary>
        static AwardExperienceFactory()
        {
            LoggingUtil.LogVerbose(typeof(AwardExperienceFactory), "Doing setup of Kerbal Experience extras");

            for (int i = 3; i <= 64; i++)
            {
                KerbalRoster.AddExperienceType(AwardExperience.SPECIAL_XP + i, "#cc.experienceType", 0.0f, (float)i);
            }
        }
Exemplo n.º 27
0
        protected string applyStatusChange()
        {
            KerbalRoster roster  = HighLogic.CurrentGame.CrewRoster;
            string       message = string.Empty;

            ProtoCrewMember[] crewRoster = roster.Crew.ToArray();
            ProtoCrewMember   astronaut  = null;
            int randomIndex = 0;

            //Keep looking until we find an available astronaut that isn't a vet.
            for (int index = 0; index < crewRoster.Length; index++)
            {
                randomIndex = UnityEngine.Random.Range(0, crewRoster.Length - 1);
                astronaut   = crewRoster[randomIndex];

                switch (statusType)
                {
                //Do nothing
                default:
                    return(Localizer.Format("Unrecognized BARISStatusType."));

                case BARISStatusTypes.badS:
                    if (!astronaut.isBadass)
                    {
                        astronaut.isBadass = true;

                        //Inform player
                        return(astronaut.name + Localizer.Format(BARISScenario.StatusBadassMsg));
                    }
                    break;

                case BARISStatusTypes.missing:
//                        CrewAssignmentDialog.Instance.RefreshCrewLists() See Crew R&R mod
                    if (astronaut.rosterStatus == ProtoCrewMember.RosterStatus.Available && !astronaut.veteran)
                    {
                        astronaut.rosterStatus = ProtoCrewMember.RosterStatus.Missing;
                        astronaut.StartRespawnPeriod();

                        //Inform player
                        return(astronaut.name + Localizer.Format(BARISScenario.StatusMissingMsg));
                    }
                    break;

                case BARISStatusTypes.dead:
                    if (astronaut.rosterStatus == ProtoCrewMember.RosterStatus.Available && !astronaut.veteran)
                    {
                        astronaut.rosterStatus = ProtoCrewMember.RosterStatus.Dead;

                        //Inform player
                        return(astronaut.name + Localizer.Format(BARISScenario.StatusDeadMsg));
                    }
                    break;
                }
            }

            return(message);
        }
Exemplo n.º 28
0
 public StaticLoader()
 {
     Debug.Log("InitStaticData");
     for (int level = 1; level <= 5; level++)
     {
         var expValue = GetExperienceNeededFor(level);
         KerbalRoster.AddExperienceType(RecruitLevel + level, "Recruited at level " + level + " on", 0.0f, expValue);
     }
 }
Exemplo n.º 29
0
        private void Awake()
        {
            _areaRect = new Rect(-500f, -500f, 200f, 200f);
            KMale     = new GUIContent("Male", AssetBase.GetTexture("kerbalicon_recruit"));
            KFemale   = new GUIContent("Female", AssetBase.GetTexture("kerbalicon_recruit_female"));
            KGRandom  = new GUIContent("Random", "When this option is selected the kerbal might be male or female");
            basecolor = GUI.color;
            roster    = HighLogic.CurrentGame.CrewRoster;
            kerExp    = HighLogic.CurrentGame.Parameters.CustomParams <GameParameters.AdvancedParams>().KerbalExperienceEnabled(HighLogic.CurrentGame.Mode);

            _kolonists = new List <Kolonist>
            {
                new Kolonist {
                    Name = "Pilot", isBase = true, Effects = "Autopilot, VesselControl, RepBoost, Logistics, Explorer"
                },
                new Kolonist {
                    Name = "Scientist", isBase = true, Effects = "Science, Experiment, Botany, Agronomy, Medical, ScienceBoost"
                },
                new Kolonist {
                    Name = "Engineer", isBase = true, Effects = "Repair, Converter, Drill, Geology, FundsBoost"
                },
                new Kolonist {
                    Name = "Kolonist", isBase = false, Effects = "RepBoost, FundsBoost, ScienceBoost"
                },
                new Kolonist {
                    Name = "Miner", isBase = false, Effects = "Drill, FundsBoost"
                },
                new Kolonist {
                    Name = "Technician", isBase = false, Effects = "Converter, FundsBoost"
                },
                new Kolonist {
                    Name = "Mechanic", isBase = false, Effects = "Repair, FundsBoost"
                },
                new Kolonist {
                    Name = "Biologist", isBase = false, Effects = "Biology, ScienceBoost"
                },
                new Kolonist {
                    Name = "Geologist", isBase = false, Effects = "Geology, FundsBoost"
                },
                new Kolonist {
                    Name = "Farmer", isBase = false, Effects = "Agronomy, ScienceBoost, RepBoost"
                },
                new Kolonist {
                    Name = "Medic", isBase = false, Effects = "Medical, ScienceBoost, RepBoost"
                },
                new Kolonist {
                    Name = "Quartermaster", isBase = false, Effects = "Logistics, RepBoost"
                },
                new Kolonist {
                    Name = "Scout", isBase = false, Effects = "Explorer"
                }
            };
            KGendArray = new GUIContent[3] {
                KGRandom, KMale, KFemale
            };
        }
Exemplo n.º 30
0
        /// <summary>
        /// Runs when the EVA is killed.
        /// </summary>
        /// <param name="report"></param>

        public void OnCrewKilled(EventReport report)
        {
            OrXchaseDebug.DebugLog("OnCrewKilled()");
            KerbalRoster boboo = new KerbalRoster(Game.Modes.SANDBOX);

            print(boboo[report.sender].name);
            //MonoBehaviour.print(report.origin);
            //MonoBehaviour.print(report.origin.vessel);
            Unload(report.origin.vessel, true);
        }