public override void Apply(LocalTargetInfo target, LocalTargetInfo dest)
        {
            IEnumerable <Thing> enumerable = FindClosestChunks(target);
            Map map = parent.pawn.Map;

            foreach (Thing item in enumerable)
            {
                if (FindFreeCell(target.Cell, map, out var result))
                {
                    AbilityUtility.DoClamor(item.Position, Props.clamorRadius, parent.pawn, Props.clamorType);
                    AbilityUtility.DoClamor(result, Props.clamorRadius, parent.pawn, Props.clamorType);
                    parent.AddEffecterToMaintain(EffecterDefOf.Skip_Entry.Spawn(item.Position, map, 0.72f), item.Position, 60);
                    parent.AddEffecterToMaintain(EffecterDefOf.Skip_ExitNoDelay.Spawn(result, map, 0.72f), result, 60);
                    MoteMaker.ThrowDustPuffThick(result.ToVector3(), map, Rand.Range(1.5f, 3f), DustColor);
                    item.Position = result;
                }
            }
            SoundDefOf.Psycast_Skip_Pulse.PlayOneShot(new TargetInfo(target.Cell, map));
            base.Apply(target, dest);
        }
Example #2
0
        public override void Apply(GlobalTargetInfo target)
        {
            Caravan     caravan    = parent.pawn.GetCaravan();
            Map         targetMap  = (target.WorldObject as MapParent)?.Map;
            IntVec3     targetCell = IntVec3.Invalid;
            List <Pawn> list       = PawnsToSkip().ToList();

            if (parent.pawn.Spawned)
            {
                foreach (Pawn item in list)
                {
                    parent.AddEffecterToMaintain(EffecterDefOf.Skip_Entry.Spawn(item, item.Map), item.Position, 60);
                }
                SoundDefOf.Psycast_Skip_Pulse.PlayOneShot(new TargetInfo(target.Cell, parent.pawn.Map));
            }
            if (ShouldEnterMap(target))
            {
                Pawn pawn = AlliedPawnOnMap(targetMap);
                if (pawn != null)
                {
                    targetCell = pawn.Position;
                }
                else
                {
                    targetCell = parent.pawn.Position;
                }
            }
            if (targetCell.IsValid)
            {
                foreach (Pawn item2 in list)
                {
                    if (item2.Spawned)
                    {
                        item2.teleporting = true;
                        item2.ExitMap(allowedToJoinOrCreateCaravan: false, Rot4.Invalid);
                        AbilityUtility.DoClamor(item2.Position, Props.clamorRadius, parent.pawn, Props.clamorType);
                        item2.teleporting = false;
                    }
                    CellFinder.TryFindRandomSpawnCellForPawnNear_NewTmp(targetCell, targetMap, out var result, 4, (IntVec3 cell) => cell != targetCell && cell.GetRoom(targetMap) == targetCell.GetRoom(targetMap));
                    GenSpawn.Spawn(item2, result, targetMap);
                    if (item2.drafter != null && item2.IsColonistPlayerControlled)
                    {
                        item2.drafter.Drafted = true;
                    }
                    item2.stances.stunner.StunFor_NewTmp(Props.stunTicks.RandomInRange, parent.pawn, addBattleLog: false);
                    item2.Notify_Teleported();
                    if (item2.IsPrisoner)
                    {
                        item2.guest.WaitInsteadOfEscapingForDefaultTicks();
                    }
                    parent.AddEffecterToMaintain(EffecterDefOf.Skip_ExitNoDelay.Spawn(item2, item2.Map), item2.Position, 60);
                    SoundDefOf.Psycast_Skip_Exit.PlayOneShot(new TargetInfo(result, item2.Map));
                    if ((item2.IsColonist || item2.RaceProps.packAnimal) && item2.Map.IsPlayerHome)
                    {
                        item2.inventory.UnloadEverything = true;
                    }
                }
                caravan?.Destroy();
                return;
            }
            Caravan caravan2 = target.WorldObject as Caravan;

            if (caravan2 != null && caravan2.Faction == parent.pawn.Faction)
            {
                if (caravan != null)
                {
                    caravan.pawns.TryTransferAllToContainer(caravan2.pawns);
                    caravan2.Notify_Merged(new List <Caravan>
                    {
                        caravan
                    });
                    caravan.Destroy();
                    return;
                }
                foreach (Pawn item3 in list)
                {
                    caravan2.AddPawn(item3, addCarriedPawnToWorldPawnsIfAny: true);
                    item3.ExitMap(allowedToJoinOrCreateCaravan: false, Rot4.Invalid);
                    AbilityUtility.DoClamor(item3.Position, Props.clamorRadius, parent.pawn, Props.clamorType);
                }
                return;
            }
            if (caravan != null)
            {
                caravan.Tile = target.Tile;
                caravan.pather.StopDead();
                return;
            }
            CaravanMaker.MakeCaravan(list, parent.pawn.Faction, target.Tile, addToWorldPawnsIfNotAlready: false);
            foreach (Pawn item4 in list)
            {
                item4.ExitMap(allowedToJoinOrCreateCaravan: false, Rot4.Invalid);
            }
        }