public void AddHaulDestination(IHaulDestination haulDestination)
        {
            if (allHaulDestinationsInOrder.Contains(haulDestination))
            {
                Log.Error("Double-added haul destination " + haulDestination.ToStringSafe());
                return;
            }
            allHaulDestinationsInOrder.Add(haulDestination);
            allHaulDestinationsInOrder.InsertionSort(CompareHaulDestinationPrioritiesDescending);
            ISlotGroupParent slotGroupParent = haulDestination as ISlotGroupParent;

            if (slotGroupParent == null)
            {
                return;
            }
            SlotGroup slotGroup = slotGroupParent.GetSlotGroup();

            if (slotGroup == null)
            {
                Log.Error("ISlotGroupParent gave null slot group: " + slotGroupParent.ToStringSafe());
                return;
            }
            allGroupsInOrder.Add(slotGroup);
            allGroupsInOrder.InsertionSort(CompareSlotGroupPrioritiesDescending);
            List <IntVec3> cellsList = slotGroup.CellsList;

            for (int i = 0; i < cellsList.Count; i++)
            {
                SetCellFor(cellsList[i], slotGroup);
            }
            map.listerHaulables.Notify_SlotGroupChanged(slotGroup);
            map.listerMergeables.Notify_SlotGroupChanged(slotGroup);
        }
        public void RemoveHaulDestination(IHaulDestination haulDestination)
        {
            if (!allHaulDestinationsInOrder.Contains(haulDestination))
            {
                Log.Error("Removing haul destination that isn't registered " + haulDestination.ToStringSafe());
                return;
            }
            allHaulDestinationsInOrder.Remove(haulDestination);
            ISlotGroupParent slotGroupParent = haulDestination as ISlotGroupParent;

            if (slotGroupParent == null)
            {
                return;
            }
            SlotGroup slotGroup = slotGroupParent.GetSlotGroup();

            if (slotGroup == null)
            {
                Log.Error("ISlotGroupParent gave null slot group: " + slotGroupParent.ToStringSafe());
                return;
            }
            allGroupsInOrder.Remove(slotGroup);
            List <IntVec3> cellsList = slotGroup.CellsList;

            for (int i = 0; i < cellsList.Count; i++)
            {
                IntVec3 intVec = cellsList[i];
                groupGrid[intVec.x, intVec.y, intVec.z] = null;
            }
            map.listerHaulables.Notify_SlotGroupChanged(slotGroup);
            map.listerMergeables.Notify_SlotGroupChanged(slotGroup);
        }
        public void AddHaulDestination(IHaulDestination haulDestination)
        {
            if (this.allHaulDestinationsInOrder.Contains(haulDestination))
            {
                Log.Error("Double-added haul destination " + haulDestination.ToStringSafe <IHaulDestination>(), false);
                return;
            }
            this.allHaulDestinationsInOrder.Add(haulDestination);
            this.allHaulDestinationsInOrder.InsertionSort(new Comparison <IHaulDestination>(HaulDestinationManager.CompareHaulDestinationPrioritiesDescending));
            ISlotGroupParent slotGroupParent = haulDestination as ISlotGroupParent;

            if (slotGroupParent != null)
            {
                SlotGroup slotGroup = slotGroupParent.GetSlotGroup();
                if (slotGroup == null)
                {
                    Log.Error("ISlotGroupParent gave null slot group: " + slotGroupParent.ToStringSafe <ISlotGroupParent>(), false);
                }
                else
                {
                    this.allGroupsInOrder.Add(slotGroup);
                    this.allGroupsInOrder.InsertionSort(new Comparison <SlotGroup>(HaulDestinationManager.CompareSlotGroupPrioritiesDescending));
                    List <IntVec3> cellsList = slotGroup.CellsList;
                    for (int i = 0; i < cellsList.Count; i++)
                    {
                        this.SetCellFor(cellsList[i], slotGroup);
                    }
                    this.map.listerHaulables.Notify_SlotGroupChanged(slotGroup);
                    this.map.listerMergeables.Notify_SlotGroupChanged(slotGroup);
                }
            }
        }