public static string ParticipantOptionText(Pawn pawn, TournamentCategoryDef category) { string pawnName = pawn.Name.ToStringShort; if (CanParticipate(pawn, category)) { return($"{pawnName} ({"VanillaFactionsExpanded.PredictedPerformance".Translate()}: {TournamentEffectivenessString(TournamentEffectivenessFor(pawn, category))})"); } return($"{pawnName} ({"VanillaFactionsExpanded.CannotParticipate".Translate()})"); }
public static float TournamentEffectivenessFor(Pawn pawn, TournamentCategoryDef category) { if (category == TournamentCategoryDefOf.VFEM_Melee) { return(BaseMeleeEffectivenessFor(pawn)); } if (category == TournamentCategoryDefOf.VFEM_Jousting) { return(BaseJoustEffectivenessFor(pawn)); } if (category == TournamentCategoryDefOf.VFEM_Archery) { return(BaseArcheryEffectivenessFor(pawn)); } throw new NotImplementedException(); }
public static void GroupParticipants(List <Pawn> inPawnList, TournamentCategoryDef category, List <Pawn> outParticipants, List <Pawn> outNonParticipants) { for (int i = 0; i < inPawnList.Count(); i++) { var pawn = inPawnList[i]; if (CanParticipate(pawn, category)) { outParticipants.Add(pawn); } else { outNonParticipants.Add(pawn); } } outParticipants.SortByDescending(p => TournamentEffectivenessFor(p, category)); }
public static List <Pawn> GenerateCompetitors(int count, TournamentCategoryDef category, Faction faction, IEnumerable <Pawn> existingPawns = null) { var potentialCompetitors = existingPawns?.ToList() ?? null; var resultList = new List <Pawn>(); for (int i = 0; i < count; i++) { if (!potentialCompetitors.NullOrEmpty() && Rand.Chance(ExistingPawnSelectChance)) { var pawn = potentialCompetitors.RandomElement(); resultList.Add(pawn); potentialCompetitors.Remove(pawn); } else { resultList.Add(GenerateNewCompetitor(category, faction)); } } return(resultList); }
public static bool CanParticipate(Pawn pawn, TournamentCategoryDef category) { if (pawn.Downed || !pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { return(false); } if (category == TournamentCategoryDefOf.VFEM_Melee) { return(!StatDefOf.MeleeHitChance.Worker.IsDisabledFor(pawn)); } if (category == TournamentCategoryDefOf.VFEM_Jousting) { return(!StatDefOf.MeleeHitChance.Worker.IsDisabledFor(pawn) && !StatDefOf.TameAnimalChance.Worker.IsDisabledFor(pawn)); } if (category == TournamentCategoryDefOf.VFEM_Archery) { return(!StatDefOf.ShootingAccuracyPawn.Worker.IsDisabledFor(pawn)); } throw new NotImplementedException(); }
public static Pawn GenerateNewCompetitor(TournamentCategoryDef category, Faction faction) { return(PawnGenerator.GeneratePawn(new PawnGenerationRequest(faction.RandomPawnKind(), faction, forceGenerateNewPawn: true, validatorPreGear: p => CanParticipate(p, category)))); }