Exemple #1
0
        public static float GetCareerModifier(SimGameDifficulty simGameDifficulty)
        {
            float ret = 0.0f;

            foreach (SimGameDifficulty.DifficultySetting difficultySetting in simGameDifficulty.GetSettings())
            {
                if (difficultySetting.Enabled)
                {
                    int idx = simGameDifficulty.GetCurSettingIndex(difficultySetting.ID);
                    ret += difficultySetting.Options[idx].CareerScoreModifier;
                }
            }

            PersistentMapClient.Logger.Log($"Unclamped Career Modifier is: {ret}");
            ret = Mathf.Clamp(ret, 0.01f, 1.5f);
            PersistentMapClient.Logger.Log($"Clamped Career Modifier is: {ret}");
            return(ret);
        }
        static void Postfix(SimGameDifficultySettingsModule __instance, SimGameDifficulty ___cachedDiff, string ___ironManModeId, string ___autoEquipMechsId, string ___mechPartsReqId, string ___skipPrologueId, string ___randomMechId, string ___argoUpgradeCostId, SGDSToggle ___ironManModeToggle, SGDSDropdown ___mechPartsReqDropdown, GameObject ___disabledOverlay, List <SGDSDropdown> ___activeDropdowns, List <SGDSToggle> ___activeToggles, List <SGDSDropdown> ___cachedDropdowns, List <SGDSToggle> ___cachedToggles, SGDSToggle ___togglePrefab, SGDSDropdown ___dropdownPrefab)
        {
            var existingStartOnlyVars = new List <string>()
            {
                ___ironManModeId,
                ___autoEquipMechsId,
                ___mechPartsReqId,
                ___skipPrologueId,
                ___randomMechId,
                ___argoUpgradeCostId
            };

            ___cachedDiff = UnityGameInstance.BattleTechGame.DifficultySettings;
            var settings = ___cachedDiff.GetSettings();

            settings.Sort(delegate(SimGameDifficulty.DifficultySetting a, SimGameDifficulty.DifficultySetting b)
            {
                if (a.UIOrder != b.UIOrder)
                {
                    return(a.UIOrder.CompareTo(b.UIOrder));
                }
                return(a.Name.CompareTo(b.Name));
            });

            foreach (var setting in settings)
            {
                if (setting.Visible)
                {
                    int curSettingIndex = ___cachedDiff.GetCurSettingIndex(setting.ID);

                    if (setting.StartOnly && existingStartOnlyVars.All(x => x != setting.ID))
                    {
                        if (!setting.Toggle)
                        {
                            var sourceSettingDropDownGO = ___mechPartsReqDropdown.gameObject;

                            GameObject newDropDownObject = UnityEngine.Object.Instantiate <GameObject>(sourceSettingDropDownGO, sourceSettingDropDownGO.transform.parent);

                            SGDSDropdown newDropDown = newDropDownObject.GetOrAddComponent <SGDSDropdown>();

                            var dropdown     = Traverse.Create(newDropDown).Field("dropdown").GetValue <HBS_Dropdown>();
                            var dropdownrect = dropdown.gameObject.GetComponent <RectTransform>();
                            dropdownrect.sizeDelta = new Vector2(170, 40);

                            var dropdownLabel = Traverse.Create(dropdown).Field("m_CaptionText")
                                                .GetValue <LocalizableText>();
                            dropdownLabel.enableWordWrapping = false;

                            if (!ModState.instantiatedDropdowns.Contains(newDropDown))
                            {
                                ___activeDropdowns.Add(newDropDown);
                                newDropDown.Initialize(__instance, setting, curSettingIndex);
                                newDropDown.gameObject.SetActive(true);
                                ModState.instantiatedDropdowns.Add(newDropDown);
                            }
                        }
                        else if (setting.Toggle)
                        {
                            var        sourceDiffToggleGO = ___ironManModeToggle.gameObject;
                            GameObject sourceDiffToggle   = UnityEngine.Object.Instantiate <GameObject>(sourceDiffToggleGO, sourceDiffToggleGO.transform.parent);
                            SGDSToggle newToggle          = sourceDiffToggle.GetOrAddComponent <SGDSToggle>();

                            if (!ModState.instantiatedToggles.Contains(newToggle))
                            {
                                ___activeToggles.Add(newToggle);
                                newToggle.Initialize(__instance, setting, curSettingIndex);
                                newToggle.gameObject.SetActive(true);
                                ModState.instantiatedToggles.Add(newToggle);
                            }
                        }
                    }
                }
            }

            var newDisabledOverlay =
                UnityEngine.Object.Instantiate <GameObject>(___disabledOverlay, ___disabledOverlay.transform.parent);

            ___disabledOverlay.SetActive(false);
            newDisabledOverlay.SetActive(!__instance.CanModifyStartSettings);
            __instance.UpdateDifficultyScoreBar();
            ModState.HaveDiffSettingsInitiated = true;
        }