Ejemplo n.º 1
0
        public void TryMakePack()
        {
            //TryMakePackUsingJoinPack();

            if (pawnsInPack < maxPawnsInPack)
            {
                List <Pawn> freeHumanlikesOfFaction = pawn.Map.mapPawns.FreeHumanlikesOfFaction(pawn.Faction).ToList();
                //Log.Message("FreeColonists count = " + freeHumanlikesOfFaction.Count());
                for (int i = 0; i < freeHumanlikesOfFaction.Count; i++)
                {
                    Pawn pawn2 = freeHumanlikesOfFaction[i];

                    if (pawn2 == pawn || !pawn2.Awake() || pawn2.IsSlave() || pawn.HavePackRelation(pawn2))
                    {
                        continue;
                    }

                    if (AvaliUtility.BothPawnsReproductiveOrNotReproductive(pawn, pawn2))                     // kits form packs with kits and adults form packs with adults
                    {
                        if (pawnPosInQueue == 0 || (pawn.relations.OpinionOf(pawn2) >= pawnOpinionNeeded && pawn2.relations.OpinionOf(pawn) >= pawnOpinionNeeded))
                        {
                            if (TotalPawnsInPack(pawn2) < maxPawnsInPack)                             // check if pawn2 has atleast 1 vacant slot in pack
                            {
                                if (debug)
                                {
                                    Log.Message(pawn + " try make pack relation with " + pawn2);
                                }
                                pawn.TryAddDirectRelation(pawn2, PawnRelationDefOf.Packmate);
                                if (pawn2.def == ThingDefOf.Avali)
                                {
                                    pawn2.TryAddDirectRelation(pawn, PawnRelationDefOf.Packmate);
                                }

                                pawnsInPack++;

                                if (debug)
                                {
                                    Log.Message(pawn + " packSize = " + pawnsInPack);
                                }
                                if (pawnsInPack >= maxPawnsInPack)
                                {
                                    return;
                                }
                            }

                            /*
                             * if (TotalPawnsInPack(pawn2) < maxPawnsInPack) // check if pawn2 has atleast 1 valant slot in pack
                             * {
                             *      if (debug) Log.Message(pawn + " try make pack relation with " + pawn2);
                             *      GetPawnSkillCount(pawn2); // compare pawn and pawn2 total skill count
                             * }
                             */
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void MakeStartingPack()
        {
            //Log.Message("DaysPassed = " + GenDate.DaysPassedFloat);
            if (pawn.IsColonist && GenDate.DaysPassedFloat > 0.1f)
            {
                makeStartingPack = false;
            }
            if (pawn.IsPrisoner)
            {
                makeStartingPack = false;
            }
            if (pawn.story.traits.HasTrait(RimWorld.TraitDefOf.Psychopath))
            {
                makeStartingPack = false;
            }

            if (makeStartingPack == false)
            {
                return;
            }

            for (int i = 0; i < relatedPawns.Count; i++)
            {
                Pawn pawn2 = relatedPawns[i];
                if (pawn.HavePackRelation(pawn2))
                {
                    makeStartingPack = false;
                    return;
                }
            }

            List <Pawn> freeHumanlikesOfFaction = pawn.Map.mapPawns.FreeHumanlikesOfFaction(pawn.Faction).ToList();

            //Log.Message("FreeColonists count = " + freeHumanlikesOfFaction.Count);

            pawnPosInQueue = 0;
            for (int i = 0; i < freeHumanlikesOfFaction.Count; i++)
            {
                Pawn pawn2 = freeHumanlikesOfFaction[i];

                if (pawn2 == pawn ||
                    pawn2.def != ThingDefOf.Avali ||
                    pawn2.IsSlave() ||
                    pawn2.story.traits.HasTrait(RimWorld.TraitDefOf.Psychopath) ||
                    pawn2.HavePackRelation(pawn))
                {
                    continue;
                }

                if (AvaliUtility.BothPawnsReproductiveOrNotReproductive(pawn, pawn2))
                {
                    if (pawn.thingIDNumber > pawn2.thingIDNumber)
                    {
                        pawnPosInQueue += 1;
                    }
                }
            }

            if (debug)
            {
                Log.Message(pawn + " ID: " + pawn.thingIDNumber + "; pawnPosInQueue = " + pawnPosInQueue);
            }
            makeStartingPack = false;
        }