// duplicated to make changes
 public bool TryDropSpawn(Thing thing, IntVec3 dropCell, ThingPlaceMode mode, out Thing resultingThing)
 {
     if (!dropCell.InBounds())
     {
         Log.Error(string.Concat(new object[]
         {
             "Dropped ",
             thing,
             " out of bounds at ",
             dropCell
         }));
         resultingThing = null;
         return false;
     }
     if (thing.def.destroyOnDrop)
     {
         thing.Destroy(DestroyMode.Vanish);
         resultingThing = null;
         return true;
     }
     if (thing.def.soundDrop != null)
     {
         thing.def.soundDrop.PlayOneShot(dropCell);
     }
     // call duplicated to make changes
     return TryPlaceThing(thing, dropCell, mode, out resultingThing);
 }
 // duplicated to make changes
 public bool TryPlaceThing(Thing thing, IntVec3 center, ThingPlaceMode mode, out Thing lastResultingThing)
 {
     if (thing.def.category == ThingCategory.Filth)
     {
         mode = ThingPlaceMode.Direct;
     }
     if (mode == ThingPlaceMode.Direct)
     {
         // call duplicated to make changes
         return TryPlaceDirect(thing, center, out lastResultingThing);
     }
     if (mode == ThingPlaceMode.Near)
     {
         lastResultingThing = null;
         while (true)
         {
             int stackCount = thing.stackCount;
             IntVec3 loc;
             // call duplicated cause vanilla is private
             if (!TryFindPlaceSpotNear(center, thing, out loc))
             {
                 break;
             }
             // call duplicated to make changes
             if (TryPlaceDirect(thing, loc, out lastResultingThing))
             {
                 return true;
             }
             if (thing.stackCount == stackCount)
             {
                 goto Block_6;
             }
         }
         return false;
         Block_6:
         Log.Error(string.Concat(new object[]
         {
             "Failed to place ",
             thing,
             " at ",
             center,
             " in mode ",
             mode,
             "."
         }));
         lastResultingThing = null;
         return false;
     }
     throw new InvalidOperationException();
 }
 // duplicated to make changes
 public bool TryDropCarriedThing(Pawn actor, IntVec3 dropLoc, ThingPlaceMode mode, out Thing resultingThing)
 {
     // call duplicated to make changes
     if (TryDrop(actor, actor.carrier.CarriedThing, dropLoc, mode, out resultingThing))
     {
         if (actor.Faction.HostileTo(Faction.OfColony))
         {
             resultingThing.SetForbidden(true, false);
         }
         return true;
     }
     return false;
 }
 // duplicated to make changes
 public bool TryDrop(Pawn actor, Thing thing, IntVec3 dropLoc, ThingPlaceMode mode, out Thing lastResultingThing)
 {
     if (!actor.carrier.container.Contains(thing))
     {
         Log.Error(string.Concat(new object[]
         {
             actor.carrier.container.owner,
             " container tried to drop  ",
             thing,
             " which it didn't contain."
         }));
         lastResultingThing = null;
         return false;
     }
     // call duplicated to make changes
     if (TryDropSpawn(thing, dropLoc, mode, out lastResultingThing))
     {
         actor.carrier.container.Remove(thing);
         return true;
     }
     return false;
 }
Exemple #5
0
        public static Toil DropTheCarriedInCell(TargetIndex StoreCellInd, ThingPlaceMode placeMode, TargetIndex CarrierInd)
        {
            Toil toil = new Toil();
            toil.initAction = () =>
            {
            Pawn actor = toil.actor;
            Job curJob = actor.jobs.curJob;
            Vehicle_Cart carrier = actor.jobs.curJob.GetTarget(CarrierInd).Thing as Vehicle_Cart;
            if (carrier.storage.Count <= 0)
                return;
            toil.actor.jobs.curJob.SetTarget(TargetIndex.A, carrier.storage.First());
            Thing dropThing = toil.actor.jobs.curJob.targetA.Thing;
            IntVec3 destLoc = actor.jobs.curJob.GetTarget(StoreCellInd).Cell;
            Thing dummy;

            if (destLoc.GetStorable() == null)
            {
                Find.DesignationManager.RemoveAllDesignationsOn(dropThing);
                carrier.storage.TryDrop(dropThing, destLoc, placeMode, out dummy);
            }

            //Check cell queue is adjacent
            List<TargetInfo> cells = curJob.GetTargetQueue(StoreCellInd);
            for (int i = 0; i < cells.Count && i < carrier.storage.Count; i++)
                if (destLoc.AdjacentTo8Way(cells[i].Cell) && cells[i].Cell.GetStorable() == null)
                {
                    Find.DesignationManager.RemoveAllDesignationsOn(carrier.storage[i]);
                    carrier.storage.TryDrop(carrier.storage[i], cells[i].Cell, ThingPlaceMode.Direct, out dummy);
                    cells.RemoveAt(i);
                    i--;
                }
            //Check item queue is valid storage for adjacent cell
            foreach (IntVec3 adjCell in GenAdj.CellsAdjacent8Way(destLoc))
                if (carrier.storage.Count > 0 && adjCell.GetStorable() == null && StoreUtility.IsValidStorageFor(adjCell, carrier.storage.First()))
                {
                    Find.DesignationManager.RemoveAllDesignationsOn(carrier.storage.First());
                    carrier.storage.TryDrop(carrier.storage.First(), adjCell, ThingPlaceMode.Direct, out dummy);
                }
            };
            toil.FailOnDespawned(CarrierInd);
            return toil;
        }
Exemple #6
0
        public static Toil DropTheCarriedInCell(TargetIndex StoreCellInd, ThingPlaceMode placeMode, Thing lastItem)
        {
            Toil toil = new Toil();
            toil.initAction = () =>
            {
            Pawn actor = toil.actor;
            Job curJob = actor.jobs.curJob;
            if (actor.inventory.container.Count <= 0)
                return;

            //Check dropThing is last item that should not be dropped
            Thing dropThing = null;
            if (lastItem != null)
                for (int i = 0; i + 1 < actor.inventory.container.Count; i++)
                    if (actor.inventory.container[i] == lastItem)
                        dropThing = actor.inventory.container[i + 1];
            else if (lastItem == null && actor.inventory.container.Count > 0)
                dropThing = actor.inventory.container.First();

            if (dropThing == null)
            {
                //Log.Error(toil.actor + "try drop null thing in " + actor.jobs.curJob.GetTarget(StoreCellInd).Cell);
                return;
            }
            IntVec3 destLoc = actor.jobs.curJob.GetTarget(StoreCellInd).Cell;
            Thing dummy;

            if (destLoc.GetStorable() == null)
            {
                Find.DesignationManager.RemoveAllDesignationsOn(dropThing);
                actor.inventory.container.TryDrop(dropThing, destLoc, placeMode, out dummy);
            }
            };
            return toil;
        }
Exemple #7
0
        public static Toil DropAllInCell(TargetIndex StoreCellInd, ThingPlaceMode placeMode)
        {
            Toil toil = new Toil();
            toil.initAction = () =>
            {
            Pawn actor = toil.actor;
            Job curJob = actor.jobs.curJob;
            IntVec3 destLoc = actor.jobs.curJob.GetTarget(StoreCellInd).Cell;

            actor.inventory.container.TryDropAll(destLoc, placeMode);
            };
            return toil;
        }