Пример #1
0
        public static PawnFlyer MakeFlyer(ThingDef flyingDef, Pawn pawn, IntVec3 destCell)
        {
            PawnFlyer pawnFlyer = (PawnFlyer)ThingMaker.MakeThing(flyingDef);

            if (!pawnFlyer.ValidateFlyer())
            {
                return(null);
            }
            pawnFlyer.startVec        = pawn.TrueCenter();
            pawnFlyer.flightDistance  = pawn.Position.DistanceTo(destCell);
            pawnFlyer.pawnWasDrafted  = pawn.Drafted;
            pawnFlyer.pawnWasSelected = Find.Selector.IsSelected(pawn);
            if (pawnFlyer.pawnWasDrafted)
            {
                Find.Selector.ShelveSelected(pawn);
            }
            pawnFlyer.jobQueue = pawn.jobs.CaptureAndClearJobQueue();
            pawn.DeSpawn();
            if (!pawnFlyer.innerContainer.TryAdd(pawn))
            {
                Log.Error("Could not add " + pawn.ToStringSafe() + " to a flyer.");
                pawn.Destroy();
            }
            return(pawnFlyer);
        }
Пример #2
0
        protected override bool TryCastShot()
        {
            if (!ModLister.RoyaltyInstalled)
            {
                Log.ErrorOnce("Items with jump capability are a Royalty-specific game system. If you want to use this code please check ModLister.RoyaltyInstalled before calling it. See rules on the Ludeon forum for more info.", 550187797);
                return(false);
            }
            CompReloadable reloadableCompSource = base.ReloadableCompSource;
            Pawn           casterPawn           = CasterPawn;

            if (casterPawn == null || reloadableCompSource == null || !reloadableCompSource.CanBeUsed)
            {
                return(false);
            }
            IntVec3 cell = currentTarget.Cell;
            Map     map  = casterPawn.Map;

            reloadableCompSource.UsedOnce();
            PawnFlyer pawnFlyer = PawnFlyer.MakeFlyer(ThingDefOf.PawnJumper, casterPawn, cell);

            if (pawnFlyer != null)
            {
                GenSpawn.Spawn(pawnFlyer, cell, map);
                return(true);
            }
            return(false);
        }