Exemple #1
0
 public static void Prefix(Thing t, Pawn carrier, Map map, ref StoragePriority currentPriority,
                           ref IntVec3 foundCell)
 {
     if (t.stackCount > AdditionalStorageSettings.CalculateStackLimit(t))
     {
         currentPriority = StoragePriority.Unstored;
     }
 }
Exemple #2
0
        public static int CountToPickUpUntilOverEncumberedHooker(Pawn pawn, Thing thing)
        {
            int result = MassUtility.CountToPickUpUntilOverEncumbered(pawn, thing);
            int limit  = AdditionalStorageSettings.CalculateStackLimit(thing.Map, thing.Position);

            if (thing.stackCount <= limit)
            {
                return(result);
            }
            int num_can_pick = thing.stackCount - limit;

            if (result > num_can_pick)
            {
                result = num_can_pick;
            }
            return(result);
        }
        static void Postfix(ref Job __result, Pawn p, Thing t, IntVec3 storeCell, bool fitInStoreCell)
        {
            var temp = t.stackCount - AdditionalStorageSettings.CalculateStackLimit(t);

            if (temp > 0)
            {
                __result.count = temp;
                __result.haulOpportunisticDuplicates = false;
                Utilities.Debug($"clamp down hauling job count due to overlimit,job={__result},pawn={p},thing={t},count={__result.count}");
                return;
            }
            var slotGroup = p.Map.haulDestinationManager.SlotGroupAt(storeCell);

            if (slotGroup != null && AdditionalStorageSettings.TryGetLimit(slotGroup, out int limit))
            {
                limit = Mathf.Min(limit, t.def.stackLimit);
                int count     = 0;
                var statValue = p.GetStatValue(StatDefOf.CarryingCapacity, true);
                foreach (var cell in slotGroup.CellsList)
                {
                    if (StoreUtility.IsGoodStoreCell(cell, p.Map, t, p, p.Faction))
                    {
                        Thing thing2 = p.Map.thingGrid.ThingAt(cell, t.def);
                        count += thing2 != null?Mathf.Max(limit, -thing2.stackCount, 0) : limit;

                        if (count >= statValue)
                        {
                            count = (int)statValue;
                            break;
                        }
                    }
                }
                __result.count = limit;
                Utilities.Debug($"destination has a limit,recalculating job count,job={__result},pawn={p},thing={t},count={__result.count}");
            }
        }
 static void Postfix(Thing t, ref bool __result)
 {
     __result = !t.IsForbidden(Faction.OfPlayer) && t.GetSlotGroup() != null && t.stackCount != AdditionalStorageSettings.CalculateStackLimit(t);
 }