AvailableCart() public static method

public static AvailableCart ( Vehicle_Cart cart, Pawn pawn ) : bool
cart Vehicle_Cart
pawn Pawn
return bool
        public override Job JobOnThing(Pawn pawn, Thing t)
        {
            Vehicle_Cart cart = t as Vehicle_Cart;

            if (cart == null)
            {
                return((Job)null);
            }
            if (cart.IsForbidden(pawn.Faction) || !ReservationUtility.CanReserveAndReach(pawn, cart, PathEndMode.ClosestTouch, DangerUtility.NormalMaxDanger(pawn)))
            {
                return((Job)null);
            }
            if (FireUtility.IsBurning(cart))
            {
                JobFailReason.Is(ToolsForHaulUtility.BurningLowerTrans);
                return((Job)null);
            }
            if (ListerHaulables.ThingsPotentiallyNeedingHauling().Count == 0 && cart.storage.Count == 0)
            {
                JobFailReason.Is(ToolsForHaulUtility.NoHaulable);
                return((Job)null);
            }
            if (Find.SlotGroupManager.AllGroupsListInPriorityOrder.Count == 0)
            {
                JobFailReason.Is(ToolsForHaulUtility.NoEmptyPlaceLowerTrans);
                return((Job)null);
            }
            if (ToolsForHaulUtility.AvailableAnimalCart(cart) || ToolsForHaulUtility.AvailableCart(cart, pawn))
            {
                return(ToolsForHaulUtility.HaulWithTools(pawn, cart));
            }
            JobFailReason.Is(ToolsForHaulUtility.NoAvailableCart);
            return((Job)null);
        }
示例#2
0
 public static void DebugWriteHaulingPawn(Pawn pawn)
 {
     Trace.AppendLine(pawn.LabelCap + " Report: Cart " + ToolsForHaulUtility.Cart().Count + " Job: " + ((pawn.CurJob != null) ? pawn.CurJob.def.defName : "No Job")
                      + " Backpack: " + ((ToolsForHaulUtility.TryGetBackpack(pawn) != null) ? "True" : "False")
                      + " lastGivenWorkType: " + pawn.mindState.lastGivenWorkType);
     foreach (Pawn other in Find.ListerPawns.FreeColonistsSpawned)
     {
         //Vanilla haul or Haul with backpack
         if (other.CurJob != null && (other.CurJob.def == JobDefOf.HaulToCell || other.CurJob.def == DefDatabase <JobDef> .GetNamed("HaulWithBackpack")))
         {
             Trace.AppendLine(other.LabelCap + " Job: " + other.CurJob.def.defName
                              + " Backpack: " + ((ToolsForHaulUtility.TryGetBackpack(other) != null) ? "True" : "False")
                              + " lastGivenWorkType: " + other.mindState.lastGivenWorkType);
         }
     }
     foreach (Vehicle_Cart cart in ToolsForHaulUtility.Cart())
     {
         string driver = ((cart.mountableComp.IsMounted) ? cart.mountableComp.Driver.LabelCap : "No Driver");
         string state  = "";
         if (cart.IsForbidden(pawn.Faction))
         {
             state = string.Concat(state, "Forbidden ");
         }
         if (pawn.CanReserveAndReach(cart, PathEndMode.Touch, Danger.Some))
         {
             state = string.Concat(state, "CanReserveAndReach ");
         }
         if (ToolsForHaulUtility.AvailableCart(cart, pawn))
         {
             state = string.Concat(state, "AvailableCart ");
         }
         if (ToolsForHaulUtility.AvailableAnimalCart(cart))
         {
             state = string.Concat(state, "AvailableAnimalCart ");
         }
         Pawn reserver = Find.Reservations.FirstReserverOf(cart, Faction.OfColony);
         if (reserver != null)
         {
             state = string.Concat(state, reserver.LabelCap, " Job: ", reserver.CurJob.def.defName);
         }
         Trace.AppendLine(cart.LabelCap + "- " + driver + ": " + state);
     }
     Trace.LogMessage();
 }