Allow Bill_Production to include Storage_Building as SpecificStockpile target

Started by Kiame, September 04, 2018, 01:08:55 AM

Previous topic - Next topic

Kiame

Currently a Bill_Production's storeZone is a Zone_Stockpile. This prevents users from selecting items to be stored on shelves once created (base game). For my modding purposes this prevents users from selecting RimFridge, Change Dresser, Weapon Storage or Infinite Storage for their crafting bill destinations.

Thank you for your time


Below is the most relevant code:

RimWorld.Bill_Production

...
private Zone_Stockpile storeZone;
...


The code that sets this value when creating a production bill is:
RimWorld.Dialog_BillConfig.DoWindowContents

...
if (current == BillStoreModeDefOf.SpecificStockpile)
{
List<SlotGroup> allGroupsListInPriorityOrder = this.bill.billStack.billGiver.Map.haulDestinationManager.AllGroupsListInPriorityOrder;
int count = allGroupsListInPriorityOrder.Count;
for (int i = 0; i < count; i++)
{
SlotGroup group = allGroupsListInPriorityOrder[i];
Zone_Stockpile zone_Stockpile = group.parent as Zone_Stockpile;
if (zone_Stockpile != null)
{
if (!this.bill.recipe.WorkerCounter.CanPossiblyStoreInStockpile(this.bill, zone_Stockpile))
{
list.Add(new FloatMenuOption(string.Format("{0} ({1})", string.Format(current.LabelCap, group.parent.SlotYielderLabel()), "IncompatibleLower".Translate()), null, MenuOptionPriority.Default, null, null, 0f, null, null));
}
...


Up to the point of changing the type to Zone_Stockpile, all that's required is the object to inherit ISlotGroupParent and IHaulDestination which both Zone_Stockpile and Building_Storage inherit.

Ledaren