public List <Designation> DesignationsOfOn(DesignationDef def, AgeAndSex ageSex) { return(_designations.Where(des => des.def == def && des.target.HasThing && des.target.Thing is Pawn && ((Pawn)des.target.Thing).PawnIsOfAgeSex(ageSex)) .ToList()); }
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()); }
private void DoCountField(Rect rect, AgeAndSex ageSex) { if (_newCounts == null || _newCounts[ageSex] == null) { _newCounts = _selectedCurrent?.Trigger?.CountTargets.ToDictionary(k => k.Key, v => v.Value.ToString()); } if (!_newCounts[ageSex].IsInt()) { GUI.color = Color.red; } else { _selectedCurrent.Trigger.CountTargets[ageSex] = int.Parse(_newCounts[ageSex]); } _newCounts[ageSex] = Widgets.TextField(rect.ContractedBy(1f), _newCounts[ageSex]); GUI.color = Color.white; }
public static bool PawnIsOfAgeSex( this Pawn p, AgeAndSex ageSex ) { // we're making the assumption here that anything with a lifestage index of 2 or greater is adult - so 3 lifestages. // this works for vanilla and all modded animals that I know off. switch ( ageSex ) { case AgeAndSex.AdultFemale: return p.gender == Gender.Female && p.ageTracker.CurLifeStageIndex >= 2; case AgeAndSex.AdultMale: return p.gender == Gender.Male && p.ageTracker.CurLifeStageIndex >= 2; case AgeAndSex.JuvenileFemale: return p.gender == Gender.Female && p.ageTracker.CurLifeStageIndex < 2; case AgeAndSex.JuvenileMale: default: return p.gender == Gender.Male && p.ageTracker.CurLifeStageIndex < 2; } }
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 }
private bool TryRemoveDesignation(AgeAndSex ageSex, DesignationDef def) { // get current designations List <Designation> currentDesignations = DesignationsOfOn(def, ageSex); // if none, return false if (currentDesignations.Count == 0) { return(false); } // else, remove one from the game as well as our managed list. (delete last - this should be the youngest/oldest). var designation = currentDesignations.Last(); _designations.Remove(designation); designation.Delete(); return(true); }
public static bool PawnIsOfAgeSex(this Pawn p, AgeAndSex ageSex) { // we're making the assumption here that anything with a lifestage index of 2 or greater is adult - so 3 lifestages. // this works for vanilla and all modded animals that I know off. switch (ageSex) { case AgeAndSex.AdultFemale: return(p.gender == Gender.Female && p.ageTracker.CurLifeStageIndex >= 2); case AgeAndSex.AdultMale: return(p.gender == Gender.Male && p.ageTracker.CurLifeStageIndex >= 2); case AgeAndSex.JuvenileFemale: return(p.gender == Gender.Female && p.ageTracker.CurLifeStageIndex < 2); case AgeAndSex.JuvenileMale: default: return(p.gender == Gender.Male && p.ageTracker.CurLifeStageIndex < 2); } }
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 bool Juvenile(this AgeAndSex ageSex) { return(ageSex == AgeAndSex.JuvenileFemale || ageSex == AgeAndSex.JuvenileMale); }
public static IEnumerable<Pawn> GetAll( this PawnKindDef pawnKind, AgeAndSex ageSex ) { return pawnKind.GetAll().Where( p => PawnIsOfAgeSex( p, ageSex ) ); // is of age and sex we want }
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 }
private List <Designation> DesignationsOfOn( DesignationDef def, AgeAndSex ageSex) => _self.DesignationsOfOn(def, ageSex);
private bool TryRemoveDesignation(AgeAndSex ageSex, DesignationDef def) => (bool)_tryRemoveDesignationMethod.Invoke(_self, new object[] { ageSex, def });
public static List<Pawn> GetWild( this PawnKindDef pawnKind, 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( ageSex ).Where( p => p.Faction == null ).ToList(); #endif }
public static List<Pawn> GetTame( this PawnKindDef pawnKind, AgeAndSex ageSex ) { #if DEBUG_LIFESTOCK_COUNTS List<Pawn> tame = GetAll( ageSex ).Where( p => p.Faction == Faction.OfColony ).ToList(); Log.Message( "Tamecount " + ageSex + ": " + tame.Count ); return tame; #else return pawnKind.GetAll( ageSex ).Where( p => p.Faction == Faction.OfColony ).ToList(); #endif }