public static void GenerateGearFor(Pawn pawn, PawnGenerationRequest request) { float modifiedChance = SimpleSidearms.SidearmSpawnChance; float modifiedBudgetMultiplier = SimpleSidearms.SidearmBudgetMultiplier.Value; bool more = true; int sanityLimiter = 0; while (more && modifiedChance > 0 && modifiedBudgetMultiplier > 0 && sanityLimiter < 10) { more = PawnSidearmsGenerator.TryGenerateSidearmFor(pawn, modifiedChance, modifiedBudgetMultiplier, request); modifiedChance -= SimpleSidearms.SidearmSpawnChanceDropoff.Value; modifiedBudgetMultiplier -= SimpleSidearms.SidearmBudgetDropoff.Value; sanityLimiter++; } }
public static void GenerateGearFor(Pawn pawn, PawnGenerationRequest request) { try { //Log.Message("generating sidearms for " + pawn.Label); float modifiedChance = Settings.SidearmSpawnChance; float modifiedBudgetMultiplier = Settings.SidearmBudgetMultiplier; bool more = true; int sanityLimiter = 0; while (more && modifiedChance > 0 && modifiedBudgetMultiplier > 0 && sanityLimiter < 10) { sanityLimiter++; //Log.Message("generating sidearm number " + sanityLimiter + " chance: "+modifiedChance+" budgetMult:"+modifiedBudgetMultiplier); more = PawnSidearmsGenerator.TryGenerateSidearmFor(pawn, modifiedChance, modifiedBudgetMultiplier, request); modifiedChance -= Settings.SidearmSpawnChanceDropoff; modifiedBudgetMultiplier -= Settings.SidearmBudgetDropoff; } } catch (Exception e) { Log.Error("Exception during pawn gear generation intercept. Cancelling intercept. Exception: " + e.ToString()); } }
internal static bool CustomDrawer_MatchingWeapons_active(Rect wholeRect, SettingHandle <StringHashSetHandler> setting, WeaponListKind kind, Color background, string yesText = "Sidearms", string noText = "Not sidearms", bool excludeNeolithic = false) { drawBackground(wholeRect, background); if (setting.Value == null) { setting.Value = new StringHashSetHandler(); } 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)); HashSet <string> selection = setting.Value.InnerList; List <ThingStuffPair> matchingSidearms; List <ThingStuffPair> allSidearms = GettersFilters.filterForType(PawnSidearmsGenerator.getWeaponsList(), WeaponSearchType.Both, false); switch (kind) { case WeaponListKind.Melee: matchingSidearms = GettersFilters.filterForType(allSidearms, WeaponSearchType.Melee, false); break; case WeaponListKind.Ranged: matchingSidearms = GettersFilters.filterForType(allSidearms, WeaponSearchType.Ranged, false); break; case WeaponListKind.Both: default: matchingSidearms = allSidearms; break; } if (excludeNeolithic) { GettersFilters.excludeNeolithic(matchingSidearms); } matchingSidearms.Sort(new MassComparer()); List <string> selectionAsList = selection.ToList(); ThingDef[] selectionThingDefs = new ThingDef[selectionAsList.Count]; for (int i = 0; i < allSidearms.Count; i++) { for (int j = 0; j < selectionThingDefs.Length; j++) { if (selectionAsList[j].Equals(allSidearms[i].thing.defName)) { selectionThingDefs[j] = allSidearms[i].thing; } } } List <ThingStuffPair> unselectedSidearms = new List <ThingStuffPair>(); for (int i = 0; i < matchingSidearms.Count; i++) { if (!selection.Contains(matchingSidearms[i].thing.defName)) { unselectedSidearms.Add(matchingSidearms[i]); } } bool change = false; int biggerRows = Math.Max((selection.Count - 1) / iconsPerRow, (unselectedSidearms.Count - 1) / iconsPerRow) + 1; setting.CustomDrawerHeight = (biggerRows * IconSize) + ((biggerRows) * IconGap) + TextMargin; for (int i = 0; i < selectionAsList.Count; i++) { if (selectionThingDefs[i] == null) { continue; } int collum = (i % iconsPerRow); int row = (i / iconsPerRow); bool interacted = DrawIconForWeapon(selectionThingDefs[i], leftRect, new Vector2(IconSize * collum + collum * IconGap, IconSize * row + row * IconGap), i); if (interacted) { change = true; selection.Remove(selectionAsList[i]); } } for (int i = 0; i < unselectedSidearms.Count; i++) { int collum = (i % iconsPerRow); int row = (i / iconsPerRow); bool interacted = DrawIconForWeapon(unselectedSidearms[i].thing, rightRect, new Vector2(IconSize * collum + collum * IconGap, IconSize * row + row * IconGap), i); if (interacted) { change = true; selection.Add(unselectedSidearms[i].thing.defName); } } if (change) { setting.Value.InnerList = selection; } return(change); }
private static bool CustomDrawer_MatchingWeapons_passive(Rect wholeRect, SettingHandle <WeaponListKind> setting, float weightLimit, string label, Color background) { drawBackground(wholeRect, background); Rect offsetRect = new Rect(wholeRect); offsetRect.height = wholeRect.height - TextMargin + BottomMargin; offsetRect.position = new Vector2(offsetRect.position.x, offsetRect.position.y); DrawLabel(label, offsetRect, TextMargin); offsetRect.position = new Vector2(offsetRect.position.x, offsetRect.position.y + TextMargin); List <ThingStuffPair> matchingSidearms; switch (setting.Value) { case WeaponListKind.Melee: matchingSidearms = GettersFilters.filterForType(PawnSidearmsGenerator.getWeaponsList(), WeaponSearchType.Melee, false); break; case WeaponListKind.Ranged: matchingSidearms = GettersFilters.filterForType(PawnSidearmsGenerator.getWeaponsList(), WeaponSearchType.Ranged, false); break; case WeaponListKind.Both: default: matchingSidearms = GettersFilters.filterForType(PawnSidearmsGenerator.getWeaponsList(), WeaponSearchType.Both, false); break; } matchingSidearms.Sort(new MassComparer()); List <ThingStuffPair> matchingSidearmsUnderLimit = new List <ThingStuffPair>(); for (int i = 0; i < matchingSidearms.Count; i++) { float mass = matchingSidearms[i].thing.GetStatValueAbstract(StatDefOf.Mass); if (mass > weightLimit) { break; } else { matchingSidearmsUnderLimit.Add(matchingSidearms[i]); } } int iconsPerRow = (int)(offsetRect.width / (IconGap + IconSize)); int biggerRows = ((matchingSidearmsUnderLimit.Count - 1) / iconsPerRow) + 1; setting.CustomDrawerHeight = (biggerRows * IconSize) + ((biggerRows) * IconGap) + TextMargin; for (int i = 0; i < matchingSidearmsUnderLimit.Count; i++) { int collum = (i % iconsPerRow); int row = (i / iconsPerRow); bool interacted = DrawIconForWeapon(matchingSidearmsUnderLimit[i].thing, offsetRect, new Vector2(IconSize * collum + collum * IconGap, IconSize * row + row * IconGap), i); if (interacted) { //nothing, since this is the passive list } } return(false); }
private static void Reset() { PawnSidearmsGenerator.Reset(); }
private static void GenerateGearFor(Pawn pawn, PawnGenerationRequest request) { PawnSidearmsGenerator.TryGenerateSidearmsFor(pawn); }
private static void Reset() { //Log.Message("reset intercept"); PawnSidearmsGenerator.Reset(); }