Exemplo n.º 1
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.º 2
0
        internal static void Display(int windowId)
        {
            // Reset Tooltip active flag...
            ToolTipActive = false;

            var rect = new Rect(371, 4, 16, 16);

            if (GUI.Button(rect, new GUIContent("", "Close Window")))
            {
                ToolTip = "";
                RMSettings.RestoreTempSettings();
                ShowWindow = false;
            }
            if (Event.current.type == EventType.Repaint && ShowToolTips)
            {
                ToolTip = RMToolTips.SetActiveToolTip(rect, GUI.tooltip, ref ToolTipActive, 10);
            }

            // Store settings in case we cancel later...
            //RMSettings.StoreTempSettings();

            GUILayout.BeginVertical();
            _scrollViewerPosition = GUILayout.BeginScrollView(_scrollViewerPosition, GUILayout.Height(280), GUILayout.Width(375));
            GUILayout.BeginVertical();

            DisplayOptions();

            DisplayHighlighting();

            DisplayToolTips();

            DisplayConfiguration();

            GUILayout.EndVertical();
            GUILayout.EndScrollView();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Save"))
            {
                //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 && RMSettings.PrevEnableAging == false)
                {
                    Utilities.LogMessage("RosterManagerWindowSettings.Display Save settings, aging has been enabled. Reset all birthdays.", "info", RMSettings.VerboseLogging);
                    var currentTime = Planetarium.GetUniversalTime();
                    foreach (var 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 && RMSettings.PrevEnableSalaries)
                {
                    Utilities.LogMessage("RosterManagerWindowSettings.Display Save settings, salaries have been turned off. Reset all salary related fields for all kerbals.", "info", RMSettings.VerboseLogging);
                    foreach (var 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 && RMSettings.PrevEnableSalaries == false)
                {
                    Utilities.LogMessage("RosterManagerWindowSettings.Display Save settings, salaries have been turned on. Reset all salary related fields for all kerbals.", "info", RMSettings.VerboseLogging);
                    var currentTime = Planetarium.GetUniversalTime();
                    foreach (var rmkerbal in RMLifeSpan.Instance.RMKerbals.AllrmKerbals)
                    {
                        rmkerbal.Value.Timelastsalary = currentTime;
                        rmkerbal.Value.TimeSalaryDue  = RMKerbal.SalaryNextDue(currentTime);
                    }
                }
                RMSettings.SaveSettings();
                ShowWindow = false;
            }
            if (GUILayout.Button("Cancel"))
            {
                // We've canclled, so restore original settings.
                RMSettings.RestoreTempSettings();
                ShowWindow = false;
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();

            GUI.DragWindow(new Rect(0, 0, Screen.width, 30));
            RMSettings.RepositionWindows("WindowSettings");
        }