private void OnKerbalHired(ProtoCrewMember crew, int num)
        {
            var currentTime = Planetarium.GetUniversalTime();
            var rmkerbal    = RMLifeSpan.Instance.RMKerbals.AllrmKerbals.FirstOrDefault(a => a.Key == crew.name);

            rmkerbal.Value.Timelastsalary = currentTime;
            rmkerbal.Value.TimeSalaryDue  = RMKerbal.SalaryNextDue(currentTime);
            Utilities.LogMessage("RosterManagerLifeSpanAddon.onKerbalHired " + crew.name + " has been hired to the crew roster.", "info", RMSettings.VerboseLogging);
        }
 private void CheckSalary(ProtoCrewMember crew, KeyValuePair <string, RMKerbal> kerbal, double currentTime)
 {
     if (currentTime >= kerbal.Value.TimeSalaryDue) // Salary Due??
     {
         //Set time next salary due
         kerbal.Value.TimeSalaryDue = RMKerbal.SalaryNextDue(currentTime);
         //Pay Salary
         if (HighLogic.CurrentGame.Mode != Game.Modes.CAREER)
         {
             return;
         }
         //Check if contractdispute is active and if it is process that
         if (kerbal.Value.SalaryContractDispute && kerbal.Value.SalaryContractDisputeProcessed)
         {
             //If they are a Tourist they are on strike. We don't process dispute.
             if (kerbal.Value.Type == ProtoCrewMember.KerbalType.Tourist)
             {
                 return;
             }
             ProcessContractDispute(crew, kerbal, currentTime, false, true);
         }
         else //No contract dispute so process normal salary.
         {
             if (Funding.CanAfford((float)kerbal.Value.Salary))
             {
                 Funding.Instance.AddFunds(-kerbal.Value.Salary, TransactionReasons.CrewRecruited);
                 kerbal.Value.Timelastsalary = currentTime;
                 RmUtils.LogMessage($"RosterManagerLifeSpanAddon.CheckSalary paid {crew.name} salary.", "info", RMSettings.VerboseLogging);
                 ScreenMessages.PostScreenMessage(
                     $"{crew.name} {Localizer.Format("#autoLOC_RM_1102")} {kerbal.Value.Salary}", 5.0f, ScreenMessageStyle.UPPER_CENTER); // #autoLOC_RM_1102 = Paid {0} salary of {1}
             }
             else //Unable to pay, start a contract dispute.
             {
                 if (!kerbal.Value.SalaryContractDispute && kerbal.Value.SalaryContractDisputeProcessed)
                 {
                     ProcessContractDispute(crew, kerbal, currentTime, true, true);
                 }
             }
         }
     }
 }
Esempio n. 3
0
        internal static void SaveSettings()
        {
            //If EnableAging has been turned ON when it was previously OFF, we reset age processing, otherwise they could all die instantly.
            if (RMLifeSpan.Instance.RMGameSettings.EnableAging && PrevEnableAging == false)
            {
                RmUtils.LogMessage("RosterManagerWindowSettings.Display Save settings, aging has been enabled. Reset all birthdays.", "info", RMSettings.VerboseLogging);
                double currentTime = Planetarium.GetUniversalTime();
                foreach (KeyValuePair <string, RMKerbal> rmkerbal in RMLifeSpan.Instance.RMKerbals.AllrmKerbals)
                {
                    rmkerbal.Value.TimelastBirthday = currentTime;
                    rmkerbal.Value.TimeNextBirthday = RMKerbal.BirthdayNextDue(currentTime);
                }
            }
            //If EnableSalaries has been turned OFF when it was previously ON, reset any kerbals from tourist back to active.
            if (!RMLifeSpan.Instance.RMGameSettings.EnableSalaries && PrevEnableSalaries)
            {
                RmUtils.LogMessage("RosterManagerWindowSettings.Display Save settings, salaries have been turned off. Reset all salary related fields for all kerbals.", "info", RMSettings.VerboseLogging);
                foreach (KeyValuePair <string, RMKerbal> rmkerbal in RMLifeSpan.Instance.RMKerbals.AllrmKerbals)
                {
                    if (rmkerbal.Value.Type == ProtoCrewMember.KerbalType.Tourist && rmkerbal.Value.Kerbal.rosterStatus != ProtoCrewMember.RosterStatus.Dead)
                    {
                        rmkerbal.Value.Type         = ProtoCrewMember.KerbalType.Crew;
                        rmkerbal.Value.Kerbal.type  = ProtoCrewMember.KerbalType.Crew;
                        rmkerbal.Value.Trait        = rmkerbal.Value.RealTrait;
                        rmkerbal.Value.Kerbal.trait = rmkerbal.Value.RealTrait;
                        KerbalRoster.SetExperienceTrait(rmkerbal.Value.Kerbal, rmkerbal.Value.Trait);
                        RMKerbal.RegisterExperienceTrait(rmkerbal.Value);
                    }
                    rmkerbal.Value.SalaryContractDispute          = false;
                    rmkerbal.Value.SalaryContractDisputePeriods   = 0;
                    rmkerbal.Value.SalaryContractDisputeProcessed = true;
                }
            }
            //If EnableSalaries has been turned ON when it was previously OFF, reset all kerbals salary time to now.
            if (RMLifeSpan.Instance.RMGameSettings.EnableSalaries && PrevEnableSalaries == false)
            {
                RmUtils.LogMessage("RosterManagerWindowSettings.Display Save settings, salaries have been turned on. Reset all salary related fields for all kerbals.", "info", RMSettings.VerboseLogging);
                double currentTime = Planetarium.GetUniversalTime();
                foreach (KeyValuePair <string, RMKerbal> rmkerbal in RMLifeSpan.Instance.RMKerbals.AllrmKerbals)
                {
                    rmkerbal.Value.Timelastsalary = currentTime;
                    rmkerbal.Value.TimeSalaryDue  = RMKerbal.SalaryNextDue(currentTime);
                }
            }
            if (Settings == null)
            {
                Settings = LoadSettingsFile();
            }

            ConfigNode windowsNode  = Settings.HasNode("RM_Windows") ? Settings.GetNode("RM_Windows") : Settings.AddNode("RM_Windows");
            ConfigNode settingsNode = Settings.HasNode("RM_Settings") ? Settings.GetNode("RM_Settings") : Settings.AddNode("RM_Settings");
            ConfigNode hiddenNode   = Settings.HasNode("RM_Hidden") ? Settings.GetNode("RM_Hidden") : Settings.AddNode("RM_Hidden");

            // Write window positions
            WriteRectangle(windowsNode, "DebuggerPosition", WindowDebugger.Position);
            WriteRectangle(windowsNode, "SettingsPosition", WindowSettings.Position);
            WriteRectangle(windowsNode, "RosterPosition", WindowRoster.Position);
            WriteRectangle(windowsNode, "ContractDisputePosition", WindowContracts.Position);

            //Write settings...
            // Realism Settings
            WriteValue(settingsNode, "LockSettings", LockSettings);

            // ToolTip Settings
            WriteValue(settingsNode, "ShowToolTips", ShowToolTips);
            WriteValue(settingsNode, "SettingsToolTips", WindowSettings.ShowToolTips);
            WriteValue(settingsNode, "RosterToolTips", WindowRoster.ShowToolTips);
            WriteValue(settingsNode, "DebuggerToolTips", WindowDebugger.ShowToolTips);
            WriteValue(settingsNode, "ContractDisputeToolTips", WindowContracts.ShowToolTips);

            // Config Settings
            WriteValue(settingsNode, "ShowDebugger", WindowDebugger.ShowWindow);
            WriteValue(settingsNode, "EnableBlizzyToolbar", EnableBlizzyToolbar);
            WriteValue(settingsNode, "VerboseLogging", VerboseLogging);
            WriteValue(settingsNode, "AutoDebug", AutoDebug);
            WriteValue(settingsNode, "DebugLogPath", DebugLogPath);
            WriteValue(settingsNode, "ErrorLogLength", ErrorLogLength);
            WriteValue(settingsNode, "SaveLogOnExit", SaveLogOnExit);
            WriteValue(settingsNode, "EnableKerbalRename", EnableKerbalRename);

            // Hidden Settings
            WriteValue(hiddenNode, "LifeInfoUpdatePeriod", LifeInfoUpdatePeriod);

            if (!Directory.Exists(SettingsPath))
            {
                Directory.CreateDirectory(SettingsPath);
            }
            Settings.Save(SettingsFile);
        }