예제 #1
0
        public static bool CustomDrawer_MatchingWeapons_active(Rect wholeRect, SettingHandle <ThingDefHashSetHandler> setting, WeaponListKind kind, Color background, string yesText = "Sidearms", string noText = "Not sidearms")
        {
            drawBackground(wholeRect, background);
            if (setting.Value == null)
            {
                setting.Value = new ThingDefHashSetHandler();
            }

            GUI.color = Color.white;

            Rect leftRect = new Rect(wholeRect);

            leftRect.width    = leftRect.width / 2;
            leftRect.height   = wholeRect.height - TextMargin + BottomMargin;
            leftRect.position = new Vector2(leftRect.position.x, leftRect.position.y);
            Rect rightRect = new Rect(wholeRect);

            rightRect.width    = rightRect.width / 2;
            leftRect.height    = wholeRect.height - TextMargin + BottomMargin;
            rightRect.position = new Vector2(rightRect.position.x + leftRect.width, rightRect.position.y);

            DrawLabel(yesText, leftRect, TextMargin);
            DrawLabel(noText, rightRect, TextMargin);

            leftRect.position  = new Vector2(leftRect.position.x, leftRect.position.y + TextMargin);
            rightRect.position = new Vector2(rightRect.position.x, rightRect.position.y + TextMargin);

            int iconsPerRow = (int)(leftRect.width / (IconGap + IconSize));

            IEnumerable <ThingDef> matchingSidearmsEnumerable;
            IEnumerable <ThingDef> allSidearmsEnumerable = GettersFilters.getValidWeaponsThingDefsOnly();

            switch (kind)
            {
            case WeaponListKind.Melee:
                matchingSidearmsEnumerable = allSidearmsEnumerable.Where(t => t.IsMeleeWeapon);
                break;

            case WeaponListKind.Ranged:
                matchingSidearmsEnumerable = allSidearmsEnumerable.Where(t => t.IsRangedWeapon);
                break;

            case WeaponListKind.Both:
            default:
                matchingSidearmsEnumerable = allSidearmsEnumerable;
                break;
            }


            List <ThingDef> matchingSidearms = matchingSidearmsEnumerable.ToList();
            List <ThingDef> allSidearms      = allSidearmsEnumerable.ToList();

            matchingSidearms = matchingSidearms.OrderBy(t => t.GetStatValueAbstract(StatDefOf.Mass)).ToList();

            List <ThingDef> selectedSidearms = setting.Value.InnerList.ToList();

            List <ThingDef> unselectedSidearms = new List <ThingDef>();

            for (int i = 0; i < matchingSidearms.Count; i++)
            {
                if (!selectedSidearms.Contains(matchingSidearms[i]))
                {
                    unselectedSidearms.Add(matchingSidearms[i]);
                }
            }

            bool change = false;

            int biggerRows = Math.Max((selectedSidearms.Count - 1) / iconsPerRow, (unselectedSidearms.Count - 1) / iconsPerRow) + 1;

            setting.CustomDrawerHeight = (biggerRows * IconSize) + ((biggerRows) * IconGap) + TextMargin;

            for (int i = 0; i < selectedSidearms.Count; i++)
            {
                int  collum     = (i % iconsPerRow);
                int  row        = (i / iconsPerRow);
                bool interacted = DrawIconForWeapon(selectedSidearms[i], leftRect, new Vector2(IconSize * collum + collum * IconGap, IconSize * row + row * IconGap), i);
                if (interacted)
                {
                    change = true;
                    setting.Value.InnerList.Remove(selectedSidearms[i]);
                }
            }

            for (int i = 0; i < unselectedSidearms.Count; i++)
            {
                int  collum     = (i % iconsPerRow);
                int  row        = (i / iconsPerRow);
                bool interacted = DrawIconForWeapon(unselectedSidearms[i], rightRect, new Vector2(IconSize * collum + collum * IconGap, IconSize * row + row * IconGap), i);
                if (interacted)
                {
                    change = true;
                    setting.Value.InnerList.Add(unselectedSidearms[i]);
                }
            }
            return(change);
        }
        public void ApplyBaseSettings()
        {
            ToolAutoSwitch         = true;
            OptimalMelee           = true;
            CQCAutoSwitch          = true;
            CQCTargetOnly          = false;
            RangedCombatAutoSwitch = true;

            RangedCombatAutoSwitchMaxWarmup = 0.75f;

            SpeedSelectionBiasMelee  = 1f;
            SpeedSelectionBiasRanged = 1.1f;

            SeparateModes   = false;
            LimitModeSingle = LimitModeSingleSidearm.None;
            LimitModeAmount = LimitModeAmountOfSidearms.None;

            LimitModeSingleMelee  = LimitModeSingleSidearm.None;
            LimitModeAmountMelee  = LimitModeAmountOfSidearms.None;
            LimitModeSingleRanged = LimitModeSingleSidearm.None;
            LimitModeAmountRanged = LimitModeAmountOfSidearms.None;
            LimitModeAmountTotal  = LimitModeAmountOfSidearms.None;

            #region LimitModeSingle
            LimitModeSingle_AbsoluteMass = 1.9f;
            LimitModeSingle_RelativeMass = 0.25f;
            LimitModeSingle_Selection    = GettersFilters.getValidWeaponsThingDefsOnly().Where(w => w.GetStatValueAbstract(StatDefOf.Mass) <= LimitModeSingle_AbsoluteMass).ToHashSet();
            #endregion
            #region LimitModeAmount
            LimitModeAmount_AbsoluteMass = 10f;
            LimitModeAmount_RelativeMass = 0.5f;
            LimitModeAmount_Slots        = 2;
            #endregion

            #region LimitModeSingleMelee
            LimitModeSingleMelee_AbsoluteMass = 1.9f;
            LimitModeSingleMelee_RelativeMass = 0.25f;
            LimitModeSingleMelee_Selection    = GettersFilters.filterForWeaponKind(GettersFilters.getValidWeaponsThingDefsOnly(), WeaponSearchType.Melee).Where(w => w.GetStatValueAbstract(StatDefOf.Mass) <= LimitModeSingleMelee_AbsoluteMass).ToHashSet();
            #endregion
            #region LimitModeAmountMelee
            LimitModeAmountMelee_AbsoluteMass = 10f;
            LimitModeAmountMelee_RelativeMass = 0.5f;
            LimitModeAmountMelee_Slots        = 2;
            #endregion

            #region LimitModeSingleRanged
            LimitModeSingleRanged_AbsoluteMass = 2.55f;
            LimitModeSingleRanged_RelativeMass = 0.25f;
            LimitModeSingleRanged_Selection    = GettersFilters.filterForWeaponKind(GettersFilters.getValidWeaponsThingDefsOnly(), WeaponSearchType.Ranged).Where(w => w.GetStatValueAbstract(StatDefOf.Mass) <= LimitModeSingleRanged_AbsoluteMass).ToHashSet();
            #endregion
            #region LimitModeAmountRanged
            LimitModeAmountRanged_AbsoluteMass = 10f;
            LimitModeAmountRanged_RelativeMass = 0.5f;
            LimitModeAmountRanged_Slots        = 2;
            #endregion

            #region LimitModeAmountTotal
            LimitModeAmountTotal_AbsoluteMass = 10f;
            LimitModeAmountTotal_RelativeMass = 0.5f;
            LimitModeAmountTotal_Slots        = 4;
            #endregion

            SidearmSpawnChance        = 0.5f;
            SidearmSpawnChanceDropoff = 0.25f;
            SidearmBudgetMultiplier   = 0.5f;
            SidearmBudgetDropoff      = 0.25f;

            ColonistDefaultWeaponMode = PrimaryWeaponMode.BySkill;
            NPCDefaultWeaponMode      = PrimaryWeaponMode.ByGenerated;

            FumbleMode           = FumbleModeOptionsEnum.InDistress;
            FumbleRecoveryChance = new SimpleCurve(defaultFumbleRecoveryChancePoints);
            ReEquipOutOfCombat   = true;
            ReEquipBest          = true;
            ReEquipInCombat      = true;

            PreserveInventoryInCaravans  = true;
            HideSidearmsInCaravanDialogs = true;
        }