public static List <Pawn> GetTame(this PawnKindDef pawnKind, Map map, AgeAndSex ageSex) { #if DEBUG_LIFESTOCK_COUNTS List <Pawn> tame = GetAll(ageSex).Where(p => p.Faction == Faction.OfPlayer).ToList(); Log.Message("Tamecount " + ageSex + ": " + tame.Count); return(tame); #else return(pawnKind.GetAll(map, ageSex).Where(p => p.Faction == Faction.OfPlayer).ToList()); #endif }
public static List<Pawn> GetWild( this PawnKindDef pawnKind, Map map, AgeAndSex ageSex ) { #if DEBUG_LIFESTOCK_COUNTS foreach (Pawn p in GetAll( ageSex )) Log.Message(p.Faction?.GetCallLabel() ?? "NULL" ); List<Pawn> wild = GetAll( ageSex ).Where( p => p.Faction == null ).ToList(); Log.Message( "Wildcount " + ageSex + ": " + wild.Count ); return wild; #else return pawnKind.GetAll( map, ageSex ).Where( p => p.Faction == null ).ToList(); #endif }
public static IEnumerable <Pawn> GetAll(this PawnKindDef pawnKind, Map map, AgeAndSex ageSex) { var key = new Triplet <PawnKindDef, Map, AgeAndSex>(pawnKind, map, ageSex); if (AllSexedCache.TryGetValue(key, out var pawns)) { return(pawns); } Func <IEnumerable <Pawn> > getter = () => pawnKind.GetAll(map).Where(p => PawnIsOfAgeSex(p, ageSex)); // is of age and sex we want AllSexedCache.Add(key, getter); return(getter()); }
public static IEnumerable <Pawn> GetTame(this PawnKindDef pawnKind, Map map) { var key = new Pair <PawnKindDef, Map>(pawnKind, map); if (TameCache.TryGetValue(key, out var pawns)) { return(pawns); } Func <IEnumerable <Pawn> > getter = () => pawnKind.GetAll(map).Where(p => p.Faction == Faction.OfPlayer); TameCache.Add(key, getter); return(getter()); }
public static IEnumerable <Pawn> GetTame(this PawnKindDef pawnKind, Map map, AgeAndSex ageSex) { #if DEBUG_LIFESTOCK_COUNTS List <Pawn> tame = GetAll(ageSex).Where(p => p.Faction == Faction.OfPlayer).ToList(); Log.Message("Tamecount " + ageSex + ": " + tame.Count); return(tame); #else var key = new Triplet <PawnKindDef, Map, AgeAndSex>(pawnKind, map, ageSex); if (TameSexedCache.TryGetValue(key, out var pawns)) { return(pawns); } Func <IEnumerable <Pawn> > getter = () => pawnKind.GetAll(map, ageSex).Where(p => p.Faction == Faction.OfPlayer); TameSexedCache.Add(key, getter); return(getter()); #endif }
public static IEnumerable <Pawn> GetWild(this PawnKindDef pawnKind, Map map, AgeAndSex ageSex) { #if DEBUG_LIFESTOCK_COUNTS foreach (Pawn p in GetAll(ageSex)) { Log.Message(p.Faction?.GetCallLabel() ?? "NULL"); } List <Pawn> wild = GetAll(ageSex).Where(p => p.Faction == null).ToList(); Log.Message("Wildcount " + ageSex + ": " + wild.Count); return(wild); #else var key = new Triplet <PawnKindDef, Map, AgeAndSex>(pawnKind, map, ageSex); if (WildSexedCache.TryGetValue(key, out var pawns)) { return(pawns); } Func <IEnumerable <Pawn> > getter = () => pawnKind.GetAll(map, ageSex).Where(p => p.Faction == null); WildSexedCache.Add(key, getter); return(getter()); #endif }
public static IEnumerable <Pawn> GetAll(this PawnKindDef pawnKind, Map map, AgeAndSex ageSex) { return(pawnKind.GetAll(map).Where(p => PawnIsOfAgeSex(p, ageSex))); // is of age and sex we want }
public static List <Pawn> GetTame(this PawnKindDef pawnKind, Map map) { return(pawnKind.GetAll(map).Where(p => p.Faction == Faction.OfPlayer).ToList()); }
public static List <Pawn> GetWild(this PawnKindDef pawnKind, Map map) { return(pawnKind.GetAll(map).Where(p => p.Faction == null).ToList()); }