public static bool Prefix(TransferManager.TransferReason material, ref TransferManager.TransferOffer offer)
        {
            Logger.LogMaterial($"TransferManager::AddIncomingOffer: {Utils.ToString(ref offer, material)}!", material);

            // Inactive outside connections should not be adding offers ...
            if (OutsideConnectionInfo.IsInvalidIncomingOutsideConnection(offer.Building))
            {
                Logger.LogMaterial($"TransferManager::AddIncomingOffer: Disallowing outside connection B{offer.Building} because of missing cargo buildings!", material);
                return(false);
            }

            if (!(TransferManagerInfo.IsDistrictOffer(material) || TransferManagerInfo.IsSupplyChainOffer(material)))
            {
                // Fix for certain assets that have sub buildings that should not be making offers ...
                if (offer.Building != 0 && BuildingManager.instance.m_buildings.m_buffer[offer.Building].m_parentBuilding != 0)
                {
                    if (material == TransferManager.TransferReason.ParkMaintenance)
                    {
                        Logger.LogMaterial($"TransferManager::AddIncomingOffer: Filtering out subBuilding {Utils.ToString(ref offer, material)}!", material);
                        return(false);
                    }
                }

                return(true);
            }

            if (material == TransferManager.TransferReason.Taxi && offer.Citizen != 0)
            {
                var instance       = CitizenManager.instance.m_citizens.m_buffer[offer.Citizen].m_instance;
                var targetBuilding = CitizenManager.instance.m_instances.m_buffer[instance].m_targetBuilding;
                var targetPosition = BuildingManager.instance.m_buildings.m_buffer[targetBuilding].m_position;

                if (!TaxiMod.CanUseTaxis(offer.Position, targetPosition))
                {
                    Logger.LogMaterial($"TransferManager::AddIncomingOffer: Filtering out {Utils.ToString(ref offer, material)}!", material);
                    var instanceId = CitizenManager.instance.m_citizens.m_buffer[offer.Citizen].m_instance;
                    CitizenManager.instance.m_instances.m_buffer[instanceId].m_flags      &= ~CitizenInstance.Flags.WaitingTaxi;
                    CitizenManager.instance.m_instances.m_buffer[instanceId].m_flags      |= CitizenInstance.Flags.BoredOfWaiting;
                    CitizenManager.instance.m_instances.m_buffer[instanceId].m_flags      |= CitizenInstance.Flags.CannotUseTaxi;
                    CitizenManager.instance.m_instances.m_buffer[instanceId].m_waitCounter = byte.MaxValue;
                    return(false);
                }
            }

            TransferManagerAddOffer.ModifyOffer(material, ref offer);
            return(true);
        }
        public static bool Prefix(ref TransferManager.TransferReason material, ref TransferManager.TransferOffer offer)
        {
            Logger.LogMaterial($"TransferManager::AddOutgoingOffer: {Utils.ToString(ref offer, material)}!", material);

            // Inactive outside connections should not be adding offers ...
            if (OutsideConnectionInfo.IsInvalidOutgoingOutsideConnection(offer.Building))
            {
                Logger.LogMaterial($"TransferManager::AddOutgoingOffer: Disallowing outside connection B{offer.Building} because of missing cargo buildings!", material);
                return(false);
            }

            // Change these offers ... a bug in the base game.  Citizens should not offer health care services.
            if ((material == TransferManager.TransferReason.ElderCare || material == TransferManager.TransferReason.ChildCare) && offer.Citizen != 0)
            {
                offer.Active = true;
                TransferManager.instance.AddIncomingOffer(material, offer);
                return(false);
            }

            // Too many requests for helicopters ...
            if (material == TransferManager.TransferReason.Sick2)
            {
                if (Singleton <SimulationManager> .instance.m_randomizer.Int32(10U) != 0)
                {
                    material = TransferManager.TransferReason.Sick;
                }
            }

            if (!(TransferManagerInfo.IsDistrictOffer(material) || TransferManagerInfo.IsSupplyChainOffer(material)))
            {
                // Fix for certain assets that have sub buildings that should not be making offers ...
                if (offer.Building != 0 && BuildingManager.instance.m_buildings.m_buffer[offer.Building].m_parentBuilding != 0)
                {
                    if (material == TransferManager.TransferReason.ParkMaintenance)
                    {
                        Logger.LogMaterial($"TransferManager::AddOutgoingOffer: Filtering out subBuilding {Utils.ToString(ref offer, material)}!", material);
                        return(false);
                    }
                }

                return(true);
            }

            TransferManagerAddOffer.ModifyOffer(material, ref offer);
            return(true);
        }
        /// <summary>
        /// Matches all offers of the given material, if supported.  Returns true if this method did attempt to match
        /// offers.
        /// </summary>
        /// <param name="material"></param>
        /// <returns></returns>
        public static bool MatchOffers(TransferManager.TransferReason material)
        {
            try
            {
                if (material == TransferManager.TransferReason.None)
                {
                    return(true);
                }

                if (Settings.enableIndustriesControl == false && TransferManagerInfo.IsSupplyChainOffer(material))
                {
                    return(false);
                }

                // Park/Road maintenance, taxis, etc. are switched around ...
                if (material == TransferManager.TransferReason.ChildCare ||
                    material == TransferManager.TransferReason.ElderCare ||
                    material == TransferManager.TransferReason.ParkMaintenance ||
                    material == TransferManager.TransferReason.RoadMaintenance ||
                    material == TransferManager.TransferReason.Taxi)
                {
                    MatchOffersClosest(
                        material,
                        requestCount: m_incomingCount, requestOffers: m_incomingOffers,
                        requestPriorityMax: 7, requestPriorityMin: 1,
                        responseCount: m_outgoingCount, responseOffers: m_outgoingOffers,
                        responsePriorityMax: 7, responsePriorityMin: 1,
                        matchFilter: IsValidDistrictOffer);

                    Clear(material);
                    return(true);
                }
                else if (material == TransferManager.TransferReason.Fish)
                {
                    MatchOffersClosest(
                        material,
                        requestCount: m_incomingCount, requestOffers: m_incomingOffers,
                        requestPriorityMax: 7, requestPriorityMin: 1,
                        responseCount: m_outgoingCount, responseOffers: m_outgoingOffers,
                        responsePriorityMax: 7, responsePriorityMin: 1,
                        matchFilter: IsValidSupplyChainOffer);

                    MatchOffersClosest(
                        material,
                        requestCount: m_incomingCount, requestOffers: m_incomingOffers,
                        requestPriorityMax: 0, requestPriorityMin: 0,
                        responseCount: m_outgoingCount, responseOffers: m_outgoingOffers,
                        responsePriorityMax: 7, responsePriorityMin: 1,
                        matchFilter: IsValidLowPriorityOffer);

                    Clear(material);
                    return(true);
                }
                else if (TransferManagerInfo.IsDistrictOffer(material))
                {
                    MatchOffersClosest(
                        material,
                        requestCount: m_outgoingCount, requestOffers: m_outgoingOffers,
                        requestPriorityMax: 7, requestPriorityMin: 1,
                        responseCount: m_incomingCount, responseOffers: m_incomingOffers,
                        responsePriorityMax: 7, responsePriorityMin: 1,
                        matchFilter: IsValidDistrictOffer);

                    Clear(material);
                    return(true);
                }
                else if (TransferManagerInfo.IsSupplyChainOffer(material))
                {
                    // First try to match using supply chain rules.
                    MatchOffersClosest(
                        material,
                        requestCount: m_incomingCount, requestOffers: m_incomingOffers,
                        requestPriorityMax: 7, requestPriorityMin: 1,
                        responseCount: m_outgoingCount, responseOffers: m_outgoingOffers,
                        responsePriorityMax: 7, responsePriorityMin: 1,
                        matchFilter: IsValidSupplyChainOffer);

                    MatchOffersClosest(
                        material,
                        requestCount: m_incomingCount, requestOffers: m_incomingOffers,
                        requestPriorityMax: 7, requestPriorityMin: 1,
                        responseCount: m_outgoingCount, responseOffers: m_outgoingOffers,
                        responsePriorityMax: 7, responsePriorityMin: 0,
                        matchFilter: IsValidLowPriorityOffer);

                    // Now finally try and match to outside offers, as well as match using extra supply.
                    MatchOffersClosest(
                        material,
                        requestCount: m_incomingCount, requestOffers: m_incomingOffers,
                        requestPriorityMax: 0, requestPriorityMin: 0,
                        responseCount: m_outgoingCount, responseOffers: m_outgoingOffers,
                        responsePriorityMax: 7, responsePriorityMin: 0,
                        matchFilter: IsValidLowPriorityOffer);

                    Clear(material);
                    return(true);
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                Clear(material);
                return(true);
            }

            // Did not handle the material.
            return(false);
        }