Ejemplo n.º 1
0
        public void ProcessDeadKerbal(ProtoCrewMember crewMember)
        {
            Kerbals.Remove(crewMember.name);
            if (LossAlreadyProcessed(crewMember))
            {
                return;
            }
            for (int i = 0; i < Kerbals.Count; i++)
            {
                CrewMember c = Kerbals.ElementAt(i).Value;
                if (Utilities.Instance.Randomise.NextDouble() < c.CrewReference().courage)
                {
                    continue;
                }
                string lostVessel = crewMember.name;
                if (CrewOnValidVessel(crewMember))
                {
                    lostVessel = crewMember.seat.vessel.vesselName;
                }
                c.AddUnhappiness("Loss of " + lostVessel);
                Debug.Log("[Bureaucracy]: Unhappiness event registered for " + crewMember.name + ": Dead Kerbal");
            }
            float penalty = Reputation.Instance.reputation * (SettingsClass.Instance.DeadKerbalPenalty / 100.0f);

            Reputation.Instance.AddReputation(-penalty, TransactionReasons.VesselLoss);
            Debug.Log("[Bureaucracy]: Dead Kerbal Penalty Applied");
        }
Ejemplo n.º 2
0
        private void TrainKerbal(CrewMember crewMember)
        {
            int   newLevel    = crewMember.CrewReference().experienceLevel + 1;
            float trainingFee = newLevel * SettingsClass.Instance.BaseTrainingFee;

            if (crewMember.CrewReference().inactive)
            {
                ScreenMessages.PostScreenMessage(crewMember.Name + " is already in training");
                return;
            }
            if (!Funding.CanAfford(trainingFee))
            {
                ScreenMessages.PostScreenMessage("Cannot afford training fee of $" + trainingFee);
                return;
            }
            Funding.Instance.AddFunds(-trainingFee, TransactionReasons.CrewRecruited);
            ScreenMessages.PostScreenMessage(crewMember.Name + " in training for " + newLevel + " months");
            crewMember.Train();
        }
Ejemplo n.º 3
0
 public override bool EventCanFire()
 {
     if (crewMember.CrewReference().rosterStatus != ProtoCrewMember.RosterStatus.Available)
     {
         return(false);
     }
     if (crewMember.WageModifier <= 1.0f && EventEffect < 0.0f)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 4
0
        public double GetWageCosts()
        {
            List <CrewMember> crew = CrewManager.Instance.Kerbals.Values.ToList();
            double            wage = 0;

            for (int i = 0; i < crew.Count; i++)
            {
                CrewMember c = crew.ElementAt(i);
                if (c.CrewReference().rosterStatus == ProtoCrewMember.RosterStatus.Dead || c.CrewReference().rosterStatus == ProtoCrewMember.RosterStatus.Missing)
                {
                    continue;
                }
                wage += c.Wage;
            }
            return(wage);
        }
Ejemplo n.º 5
0
        private string GenerateAstronautString(string kerbalName)
        {
            CrewMember c = CrewManager.Instance.Kerbals[kerbalName];

            //if for whatever reason we can't find the CrewMember just leave it at default
            if (c == null)
            {
                return("Available For Next Mission");
            }
            StringBuilder sb = new StringBuilder();

            // ReSharper disable once Unity.PerformanceCriticalCodeInvocation
            if (c.CrewReference().inactive)
            {
                sb.AppendLine("In Training | " + "Wage: " + c.Wage);
            }
            else
            {
                float morale = (1 - (float)c.UnhappinessEvents.Count / c.MaxStrikes) * 100;
                if (float.IsNaN(morale))
                {
                    morale = 100;
                }
                if (float.IsNegativeInfinity(morale))
                {
                    morale = 0;
                }
                sb.AppendLine("Morale: " + Math.Round(morale, 0) + "% | Wage: " + c.Wage);
            }

            if (SettingsClass.Instance.RetirementEnabled)
            {
                KeyValuePair <int, string> retirementDate = Utilities.Instance.ConvertUtToRealTime(c.retirementDate - Planetarium.GetUniversalTime());
                sb.AppendLine("Retires in " + retirementDate.Key + " " + retirementDate.Value);
            }

            return(sb.ToString());
        }