Пример #1
0
        public static PawnThrown MakeThrown(ThingDef thrownDef, Pawn pawn, IntVec3 destCell, DamageInfo?newDamageInfo = null)
        {
            PawnThrown pawnthrown = (PawnThrown)ThingMaker.MakeThing(thrownDef, null);

            if (!pawnthrown.ValidateThrower())
            {
                return(null);
            }
            pawnthrown.impactDamage    = newDamageInfo;
            pawnthrown.startVec        = pawn.TrueCenter();
            pawnthrown.throwDistance   = pawn.Position.DistanceTo(destCell);
            pawnthrown.pawnWasDrafted  = pawn.Drafted;
            pawnthrown.pawnWasSelected = Find.Selector.IsSelected(pawn);
            if (pawnthrown.pawnWasDrafted)
            {
                Find.Selector.ShelveSelected(pawn);
            }
            pawnthrown.jobQueue = pawn.jobs.CaptureAndClearJobQueue();
            pawn.DeSpawn(DestroyMode.Vanish);
            if (!pawnthrown.innerContainer.TryAdd(pawn, true))
            {
                Log.Error("Could not add " + pawn.ToStringSafe <Pawn>() + " to a thrower.", false);
                pawn.Destroy(DestroyMode.Vanish);
            }
            return(pawnthrown);
        }
Пример #2
0
 private void CheckDestination()
 {
     if (!PawnThrown.ValidJumpTarget(base.Map, base.Position))
     {
         int num = GenRadial.NumCellsInRadius(3.9f);
         for (int i = 0; i < num; i++)
         {
             IntVec3 intVec = base.Position + GenRadial.RadialPattern[i];
             if (PawnThrown.ValidJumpTarget(base.Map, intVec))
             {
                 base.Position = intVec;
                 return;
             }
         }
     }
 }