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());
 }
Ejemplo n.º 2
0
        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
        }
Ejemplo n.º 3
0
        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
        }
Ejemplo n.º 4
0
        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());
        }
Ejemplo n.º 5
0
        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;
        }
Ejemplo n.º 6
0
        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;
            }
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 9
0
        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);
            }
        }
Ejemplo n.º 10
0
        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
        }
Ejemplo n.º 11
0
 public static bool Juvenile(this AgeAndSex ageSex)
 {
     return(ageSex == AgeAndSex.JuvenileFemale || ageSex == AgeAndSex.JuvenileMale);
 }
Ejemplo n.º 12
0
 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
 }
Ejemplo n.º 13
0
 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
 }
Ejemplo n.º 14
0
 private List <Designation> DesignationsOfOn(
     DesignationDef def,
     AgeAndSex ageSex) => _self.DesignationsOfOn(def, ageSex);
Ejemplo n.º 15
0
 private bool TryRemoveDesignation(AgeAndSex ageSex, DesignationDef def) =>
 (bool)_tryRemoveDesignationMethod.Invoke(_self, new object[] { ageSex, def });
Ejemplo n.º 16
0
 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
 }
Ejemplo n.º 17
0
 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
 }