Example #1
0
 public override bool AllowVerbCast(IntVec3 root, TargetInfo targ)
 {
     if (this.wearer.equipment.Primary != null)
     {
         if (this.wearer.equipment.Primary.def.IsMeleeWeapon)
         {
             return(true);
         }
         if (this.wearer.equipment.Primary.def.defName.Equals("Gun_Pistol"))
         {
             return(true);
         }
         if (this.wearer.equipment.Primary.def.defName.Equals("Gun_PDW"))
         {
             return(true);
         }
         if (this.wearer.equipment.Primary.def.defName.Equals("Gun_HeavySMG"))
         {
             return(true);
         }
         if (this.wearer.equipment.Primary.def.weaponTags.Contains("MedievalShields_ValidSidearm"))
         {
             return(true);
         }
     }
     return(root.AdjacentTo8Way(targ.Cell));
 }
 public override bool AllowVerbCast(IntVec3 root, TargetInfo targ)
 {
     if (this.wearer.equipment.Primary != null)
     {
         if (this.wearer.equipment.Primary.def.IsMeleeWeapon)
         {
             return true;
         }
         if (this.wearer.equipment.Primary.def.defName.Equals("Gun_Pistol"))
         {
             return true;
         }
         if (this.wearer.equipment.Primary.def.defName.Equals("Gun_PDW"))
         {
             return true;
         }
         if (this.wearer.equipment.Primary.def.defName.Equals("Gun_HeavySMG"))
         {
             return true;
         }
         if (this.wearer.equipment.Primary.def.weaponTags.Contains("MedievalShields_ValidSidearm"))
         {
             return true;
         }
     }
     return root.AdjacentTo8Way(targ.Cell);
 }
        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;

                SlotGroup slotGroup = Find.SlotGroupManager.SlotGroupAt(destLoc);
                //    if (destLoc.GetStorable() == null)
                if (slotGroup != null && slotGroup.Settings.AllowedToAccept(dropThing))
                {
                    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 && adjCell.IsValidStorageFor(carrier.storage.First()))
                    {
                        Find.DesignationManager.RemoveAllDesignationsOn(carrier.storage.First());
                        carrier.storage.TryDrop(carrier.storage.First(), adjCell, ThingPlaceMode.Direct, out dummy);
                    }
                }
            };
            toil.FailOnDestroyedOrNull(CarrierInd);
            return(toil);
        }
Example #4
0
        public static Toil DropTheCarriedInCell(TargetIndex StoreCellInd, ThingPlaceMode placeMode)
        {
            Toil toil = new Toil();

            toil.initAction = () =>
            {
                Pawn actor  = toil.actor;
                Job  curJob = actor.jobs.curJob;
                if (actor.inventory.container.Count <= 0)
                {
                    return;
                }
                toil.actor.jobs.curJob.SetTarget(TargetIndex.A, actor.inventory.container.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);
                    actor.inventory.container.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 < actor.inventory.container.Count; i++)
                {
                    if (destLoc.AdjacentTo8Way(cells[i].Cell) && cells[i].Cell.GetStorable() == null)
                    {
                        Find.DesignationManager.RemoveAllDesignationsOn(actor.inventory.container[i]);
                        actor.inventory.container.TryDrop(actor.inventory.container[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 (actor.inventory.container.Count > 0 && adjCell.GetStorable() == null && StoreUtility.IsValidStorageFor(adjCell, actor.inventory.container.First()))
                    {
                        Find.DesignationManager.RemoveAllDesignationsOn(actor.inventory.container.First());
                        actor.inventory.container.TryDrop(actor.inventory.container.First(), adjCell, ThingPlaceMode.Direct, out dummy);
                    }
                }
            };
            return(toil);
        }
Example #5
0
 public new void PawnRotatorTick()
 {
     if (pawn.Destroyed)
     {
         return;
     }
     if (pawn.pather.Moving)
     {
         if (pawn.pather.curPath == null || pawn.pather.curPath.NodesLeftCount < 1)
         {
             return;
         }
         FaceAdjacentCell(this, pawn.pather.nextCell);
     }
     else
     {
         Stance_Busy stance_Busy = pawn.stances.curStance as Stance_Busy;
         if (stance_Busy != null && stance_Busy.focusTarg.IsValid)
         {
             if (stance_Busy.focusTarg.HasThing)
             {
                 Face(stance_Busy.focusTarg.Thing.DrawPos);
             }
             else
             {
                 FaceCell(stance_Busy.focusTarg.Cell);
             }
             return;
         }
         if (pawn.jobs.curJob != null)
         {
             LocalTargetInfo target = pawn.CurJob.GetTarget(pawn.jobs.curDriver.rotateToFace);
             if (target.HasThing)
             {
                 bool     flag     = false;
                 IntVec3  c        = default(IntVec3);
                 CellRect cellRect = target.Thing.OccupiedRect();
                 for (int i = cellRect.minZ; i <= cellRect.maxZ; i++)
                 {
                     for (int j = cellRect.minX; j <= cellRect.maxX; j++)
                     {
                         if (pawn.Position == new IntVec3(j, 0, i))
                         {
                             Face(target.Thing.DrawPos);
                             return;
                         }
                     }
                 }
                 for (int k = cellRect.minZ; k <= cellRect.maxZ; k++)
                 {
                     for (int l = cellRect.minX; l <= cellRect.maxX; l++)
                     {
                         IntVec3 intVec = new IntVec3(l, 0, k);
                         if (intVec.AdjacentToCardinal(pawn.Position))
                         {
                             FaceAdjacentCell(this, intVec);
                             return;
                         }
                         if (intVec.AdjacentTo8Way(pawn.Position))
                         {
                             flag = true;
                             c    = intVec;
                         }
                     }
                 }
                 if (flag)
                 {
                     if (DebugViewSettings.drawPawnRotatorTarget)
                     {
                         pawn.Map.debugDrawer.FlashCell(pawn.Position, 0.6f, "jbthing");
                         GenDraw.DrawLineBetween(pawn.Position.ToVector3Shifted(), c.ToVector3Shifted());
                     }
                     FaceAdjacentCell(this, c);
                     return;
                 }
             }
             else if (pawn.Position.AdjacentTo8Way(target.Cell))
             {
                 if (DebugViewSettings.drawPawnRotatorTarget)
                 {
                     pawn.Map.debugDrawer.FlashCell(pawn.Position, 0.2f, "jbloc");
                     GenDraw.DrawLineBetween(pawn.Position.ToVector3Shifted(), target.Cell.ToVector3Shifted());
                 }
                 FaceAdjacentCell(this, target.Cell);
                 return;
             }
         }
     }
 }
Example #6
0
 // allows to attack only adjacent cells (melee targets)
 public override bool AllowVerbCast(IntVec3 root, TargetInfo targ)
 {
     if (targ.HasThing && targ.Thing.def.size != IntVec2.One)
     {
         return root.AdjacentTo8WayOrInside(targ.Thing);
     }
     return root.AdjacentTo8Way(targ.Cell);
 }