示例#1
0
        protected override bool TryCastShot()
        {
            bool result = false;
            CompAbilityUserMagic comp = this.CasterPawn.GetComp <CompAbilityUserMagic>();
            Pawn soulPawn             = comp.soulBondPawn;

            if (soulPawn != null && !soulPawn.Dead && !soulPawn.Destroyed)
            {
                Pawn p               = this.CasterPawn;
                bool drafted         = this.CasterPawn.Drafted;
                bool soulPawnSpawned = soulPawn.Spawned;
                Map  map             = this.CasterPawn.Map;
                Map  sMap            = soulPawn.Map;
                if (sMap == null)
                {
                    Hediff bondHediff = soulPawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("TM_SoulBondPhysicalHD"), false);
                    if (bondHediff != null)
                    {
                        HediffComp_SoulBondHost compS = bondHediff.TryGetComp <HediffComp_SoulBondHost>();
                        if (compS != null && compS.polyHost != null && !compS.polyHost.DestroyedOrNull() && !compS.polyHost.Dead)
                        {
                            soulPawn        = compS.polyHost;
                            soulPawnSpawned = true;
                        }
                    }

                    bondHediff = soulPawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("TM_SoulBondMentalHD"), false);
                    if (bondHediff != null)
                    {
                        HediffComp_SoulBondHost compS = bondHediff.TryGetComp <HediffComp_SoulBondHost>();
                        if (compS != null && compS.polyHost != null && !compS.polyHost.DestroyedOrNull() && !compS.polyHost.Dead)
                        {
                            soulPawn        = compS.polyHost;
                            soulPawnSpawned = true;
                        }
                    }
                    if (soulPawn.ParentHolder != null && soulPawn.ParentHolder is Caravan)
                    {
                        //Log.Message("caravan detected");
                        //p.DeSpawn();
                        Caravan van = soulPawn.ParentHolder as Caravan;
                        van.AddPawn(p, true);
                        Find.WorldPawns.PassToWorld(p);
                        p.Notify_PassedToWorld();
                        Messages.Message("" + p.LabelShort + " has shadow stepped to a caravan with " + soulPawn.LabelShort, MessageTypeDefOf.NeutralEvent);
                        goto fin;
                    }
                }
                IntVec3 casterCell = this.CasterPawn.Position;
                IntVec3 targetCell = soulPawn.Position;
                if (p.Spawned && soulPawnSpawned)
                {
                    try
                    {
                        p.DeSpawn();
                        GenSpawn.Spawn(p, targetCell, soulPawn.Map);
                        if (drafted)
                        {
                            p.drafter.Drafted = true;
                        }
                        CameraJumper.TryJumpAndSelect(p);
                    }
                    catch
                    {
                        Log.Message("Exception occured when trying to shadow step to soul bound pawn - recovered caster at original position");
                        GenSpawn.Spawn(p, casterCell, map);
                    }
                    this.Ability.PostAbilityAttempt();
                }
                else
                {
                    Messages.Message("TM_BondedPawnNotSpawned".Translate(
                                         soulPawn.LabelShort), MessageTypeDefOf.RejectInput);
                }
                result = true;
            }
            else
            {
                Log.Warning("No soul bond found to shadow call.");
            }

            //this.ability.TicksUntilCasting = (int)base.UseAbilityProps.SecondsToRecharge * 60;
            fin :;
            this.burstShotsLeft = 0;
            return(result);
        }
示例#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);
            }
        }