Esempio n. 1
0
        public void ScanCaravan(List <Pawn> pawns, int maxLinked)
        {
            linkedPawns.RemoveWhere(p => !pawns.Contains(p));

            for (int i = 0; i < pawns.Count; i++)
            {
                Pawn pawn = pawns[i];

                CompPawnLink link = pawn.GetComp <CompPawnLink>();
                if (link == null || network != link.Link.network || owner == pawn)
                {
                    continue;
                }

                if (linkedPawns.Add(pawn) && linkedPawns.Count > maxLinked)
                {
                    break;
                }
            }
        }
Esempio n. 2
0
        private static IEnumerable <Pawn> GetLinkedPawnsHelper(IEnumerable <Pawn> pawns, HashSet <Pawn> done)
        {
            foreach (Pawn pawn in pawns)
            {
                if (done.Contains(pawn))
                {
                    continue;
                }

                done.Add(pawn);

                yield return(pawn);

                CompPawnLink link = pawn.GetComp <CompPawnLink>();
                if (pawn.GetStatValue(link.Props.statRepeater) != 0f)
                {
                    foreach (Pawn p in GetLinkedPawnsHelper(link.Link.linkedPawns, done))
                    {
                        yield return(p);
                    }
                }
            }
        }