Example #1
0
        public void Scan(List <Pawn> pawns, int range, int maxLinked)
        {
            rangeCache = range * range;
            IntVec3 parentPosition = owner.Position;

            linkedPawns.RemoveWhere(p => !p.Spawned || parentPosition.DistanceToSquared(p.Position) > rangeCache);

            if (linkedPawns.Count >= maxLinked)
            {
                return;
            }

            for (int i = 0; i < pawns.Count; i++)
            {
                Pawn            pawn = pawns[i];
                PawnLinkNetwork link = pawn.GetComp <CompPawnLink>()?.Link;

                if (link == null || network != link.network || owner == pawn)
                {
                    continue;
                }

                int maxRange = Math.Max(rangeCache, link.rangeCache);

                if (parentPosition.DistanceToSquared(pawn.Position) <= maxRange)
                {
                    if (linkedPawns.Add(pawn) && linkedPawns.Count >= maxLinked)
                    {
                        break;
                    }
                }
            }
        }
Example #2
0
        public override void Initialize(CompProperties props)
        {
            base.Initialize(props);
            link = new PawnLinkNetwork(parent as Pawn, Props.networkDef);

            if (Props.part != null)
            {
                affectedPart = Owner.RaceProps.body.GetPartsWithDef(Props.part).First();
            }
        }