List <Thing> ListPerishables(Pawn pawn) { var initialList = new List <Thing>(); foreach (Thing potential in pawn.Map.listerHaulables.ThingsPotentiallyNeedingHauling()) { float rotDays = RottableUtil.GetRotDays(potential); float detDays = GetDetDays(potential, pawn.Map); bool canDetOrRotSoon = !(detDays > DeteriorateDaysThresh && rotDays > GenDate.DaysPerYear); if (canDetOrRotSoon) { IntVec3 position = potential.Position; RoofDef roof = position.GetRoof(pawn.Map); bool canDetSoon = false || detDays <= DeteriorateDaysThresh; if (canDetSoon) { bool isRoofed = false || roof != null; if (!isRoofed) { initialList.Add(potential); } } else { bool canRotSoon = rotDays <= GenDate.DaysPerYear; if (canRotSoon) { initialList.Add(potential); } } } } var finalList = new List <Thing>(); foreach (Thing rotOrDetHaulable in initialList) { if (finalList.Contains(rotOrDetHaulable)) { continue; } bool stacksToOne = rotOrDetHaulable.def.stackLimit == 1; if (stacksToOne) { finalList.Add(rotOrDetHaulable); } else { //finalList.Add(rotOrDetHaulable); float detDays = GetDetDays(rotOrDetHaulable, pawn.Map); var minNumToHaul = (int)(rotOrDetHaulable.def.stackLimit * StackThreshPercent); bool stackBelowHaulThresh = rotOrDetHaulable.stackCount < minNumToHaul; if (stackBelowHaulThresh && detDays > DeteriorateDaysThresh) { var dupeList = new List <Thing>(); int numDupes = rotOrDetHaulable.stackCount; numDupes += DupeUtil.FindHowManyNearbyDupes(rotOrDetHaulable, GridRadiusToSearch, pawn, out dupeList); bool stillBelowHaulThresh = numDupes < minNumToHaul; if (!stillBelowHaulThresh) { finalList.Add(rotOrDetHaulable); finalList.AddRange(dupeList); } } else { finalList.Add(rotOrDetHaulable); } } } return(finalList); }
public override IEnumerable <Thing> PotentialWorkThingsGlobal(Pawn pawn) { var initiaList = pawn.Map.listerHaulables.ThingsPotentiallyNeedingHauling(); var topOfList = new List <Thing>(); var bottomOfList = new List <Thing>(); foreach (Thing t in initiaList) { if (t is Corpse) { continue; } if (topOfList.Contains(t)) { continue; } if (bottomOfList.Contains(t)) { continue; } if (t.def.stackLimit == 1) { continue; } var valueFullStack = t.def.BaseMarketValue * t.def.stackLimit; if (valueFullStack > ValueThresh) { topOfList.Add(t); continue; } var desiredNumToHaul = t.def.stackLimit * StackThreshPercent; if (t.stackCount < desiredNumToHaul) { var dupeList = new List <Thing>(); var numDupes = DupeUtil.FindHowManyNearbyDupes(t, GridRadiusToSearch, pawn, out dupeList); if (t.stackCount + numDupes >= desiredNumToHaul) { topOfList.Add(t); topOfList.AddRange(dupeList); continue; } dupeList.Clear(); numDupes = DupeUtil.FindDupesInLine(t, LineDupeLength, LineDupeWidth, pawn, out dupeList); if (t.stackCount + numDupes >= desiredNumToHaul) { topOfList.Add(t); topOfList.AddRange(dupeList); } else { bottomOfList.Add(t); bottomOfList.AddRange(dupeList); } } else { topOfList.Add(t); } } return(topOfList); //return pawn.Map.listerHaulables.ThingsPotentiallyNeedingHauling(); }