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"); }
public void ProcessUnpaidKerbals(List <CrewMember> unpaidKerbals) { for (int i = 0; i < unpaidKerbals.Count; i++) { CrewMember c = Kerbals.ElementAt(i).Value; c.AddUnhappiness("not being paid"); Debug.Log("[Bureaucracy]: Adding new unpaid crew member " + c.Name); } }
private int GetBonusesToPay() { int bonusesToPay = 0; for (int i = 0; i < CrewManager.Instance.Kerbals.Count; i++) { CrewMember c = CrewManager.Instance.Kerbals.ElementAt(i).Value; bonusesToPay += c.GetBonus(false); } return(bonusesToPay); }
private CrewMember FindCrew() { if (CrewManager.Instance.Kerbals.Count == 0) { return(null); } int i = Utilities.Instance.Randomise.Next(0, CrewManager.Instance.Kerbals.Count); CrewMember c = CrewManager.Instance.Kerbals.ElementAt(i).Value; return(c); }
public void AddNewCrewMember(ProtoCrewMember crewMember) { CrewMember newCrew = new CrewMember(crewMember.name); Kerbals.Add(crewMember.name, newCrew); if (!SettingsClass.Instance.AstronautTraining) { return; } newCrew.Train(); Debug.Log("[Bureaucracy]: New Crewmember added: " + newCrew.Name); }
public WageEvent(ConfigNode eventNode) { CrewMember c = FindCrew(); if (c == null) { return; } crewMember = c; LoadConfig(eventNode); Body = Body.Replace("<crew>", c.Name); AcceptString = AcceptString.Replace("<crew>", c.Name); }
private void ProcessCrew() { Debug.Log("[Bureaucracy]: Processing Crew"); for (int i = 0; i < Kerbals.Count; i++) { CrewMember c = Kerbals.ElementAt(i).Value; c.MonthWithoutIncident(); } if (SettingsClass.Instance.RetirementEnabled) { ProcessRetirees(); } Debug.Log("[Bureaucracy]: Crew Processed"); }
public void ProcessUnhappyCrew() { Debug.Log("[Bureaucracy]: Processing Unhappy Crew"); UnhappyCrewOutcomes.Clear(); for (int i = 0; i < Kerbals.Count; i++) { CrewMember c = Kerbals.ElementAt(i).Value; if (!c.Unhappy) { continue; } string outcome = c.UnhappyOutcome(); Debug.Log("[Bureaucracy]: Unhappy Crewmember " + c.Name + " " + outcome); UnhappyCrewOutcomes.Add(c, outcome); } }
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); }
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(); }
public int Bonuses(double availableFunding, bool clearBonuses) { int bonus = 0; for (int i = 0; i < Kerbals.Count; i++) { CrewMember c = Kerbals.ElementAt(i).Value; int bonusToProcess = c.GetBonus(clearBonuses); if (clearBonuses && bonusToProcess > 0 && availableFunding < bonusToProcess) { c.AddUnhappiness("not being paid"); } else { bonus += bonusToProcess; } availableFunding -= bonus; } lastBonus = bonus; return(bonus); }
public void PayWageDebt(double debt) { debt = Math.Abs(debt); debt -= Funding.Instance.Funds; if (debt <= 0) { return; } List <CrewMember> unpaidKerbals = new List <CrewMember>(); for (int i = 0; i < CrewManager.Instance.Kerbals.Count; i++) { CrewMember c = CrewManager.Instance.Kerbals.ElementAt(i).Value; unpaidKerbals.Add(c); debt -= c.Wage; if (debt <= 0) { break; } } CrewManager.Instance.ProcessUnpaidKerbals(unpaidKerbals); }
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()); }
public CrewUnhappiness(string reason, CrewMember passingCrewMember) { Reason = reason; parentCrew = passingCrewMember; }