예제 #1
0
        public static void removeAllUnwantedVehicles()
        {
            for (ushort lineId = 1; lineId < Singleton <TransportManager> .instance.m_lines.m_size; lineId++)
            {
                if ((Singleton <TransportManager> .instance.m_lines.m_buffer[lineId].m_flags & TransportLine.Flags.Created) != TransportLine.Flags.None)
                {
                    if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
                    {
                        TLMUtils.doLog("removeAllUnwantedVehicles: line #{0}", lineId);
                    }
                    TransportLine tl     = Singleton <TransportManager> .instance.m_lines.m_buffer[lineId];
                    uint          prefix = 0;
                    if (TLMConfigWarehouse.getCurrentConfigInt(TLMConfigWarehouse.getConfigIndexForTransportInfo(tl.Info) | TLMConfigWarehouse.ConfigIndex.PREFIX) != (int)ModoNomenclatura.Nenhum)
                    {
                        prefix = tl.m_lineNumber / 1000u;
                    }
                    VehicleManager instance3 = Singleton <VehicleManager> .instance;
                    VehicleInfo    info      = instance3.m_vehicles.m_buffer[Singleton <TransportManager> .instance.m_lines.m_buffer[lineId].GetVehicle(0)].Info;
                    if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
                    {
                        TLMUtils.doLog("removeAllUnwantedVehicles: pre model list; type = {0}", info.GetAI());
                    }
                    var def = TransportSystemDefinition.from(info);
                    if (def == default(TransportSystemDefinition))
                    {
                        if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
                        {
                            TLMUtils.doLog("NULL TSysDef! {0}+{1}+{2}", info.GetAI().GetType(), info.m_class.m_subService, info.m_vehicleType);
                        }
                        continue;
                    }
                    var modelList = BasicTransportExtensionSingleton.instance(def).getAssetListForPrefix(prefix);
                    if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
                    {
                        TLMUtils.doLog("removeAllUnwantedVehicles: models found: {0}", modelList == null ? "?!?" : modelList.Count.ToString());
                    }
                    if (modelList.Count > 0)
                    {
                        Dictionary <ushort, VehicleInfo> vehiclesToRemove = new Dictionary <ushort, VehicleInfo>();
                        for (int i = 0; i < tl.CountVehicles(lineId); i++)
                        {
                            var vehicle = tl.GetVehicle(i);
                            if (vehicle != 0)
                            {
                                VehicleInfo info2 = instance3.m_vehicles.m_buffer[(int)vehicle].Info;
                                if (!modelList.Contains(info2.name))
                                {
                                    vehiclesToRemove[vehicle] = info2;
                                }
                            }
                        }

                        foreach (var item in vehiclesToRemove)
                        {
                            item.Value.m_vehicleAI.SetTransportLine(item.Key, ref instance3.m_vehicles.m_buffer[item.Key], 0);
                        }
                    }
                }
            }
        }
        private static int ticketPriceForPrefix(ushort vehicleID, ref Vehicle vehicleData)
        {
            var def = TransportSystemDefinition.from(vehicleData.Info.m_class.m_subService, vehicleData.Info.m_vehicleType);

            if (def == default(TransportSystemDefinition))
            {
                if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
                {
                    TLMUtils.doLog("NULL TSysDef! {0}+{1}+{2}", vehicleData.Info.GetAI().GetType(), vehicleData.Info.m_class.m_subService, vehicleData.Info.m_vehicleType);
                }
                return(100);
            }
            if (def.vehicleType == VehicleInfo.VehicleType.Ferry)
            {
                DistrictManager           instance        = Singleton <DistrictManager> .instance;
                byte                      district        = instance.GetDistrict(vehicleData.m_targetPos3);
                DistrictPolicies.Services servicePolicies = instance.m_districts.m_buffer[(int)district].m_servicePolicies;
                if ((servicePolicies & DistrictPolicies.Services.PreferFerries) != DistrictPolicies.Services.None)
                {
                    District[] expr_6E_cp_0 = instance.m_districts.m_buffer;
                    byte       expr_6E_cp_1 = district;
                    expr_6E_cp_0[(int)expr_6E_cp_1].m_servicePoliciesEffect = (expr_6E_cp_0[(int)expr_6E_cp_1].m_servicePoliciesEffect | DistrictPolicies.Services.PreferFerries);
                    return(0);
                }
            }
            if (vehicleData.m_transportLine == 0)
            {
                var value = (int)BasicTransportExtensionSingleton.instance(def).getDefaultTicketPrice();
                return(value);
            }
            else
            {
                var value = (int)(BasicTransportExtensionSingleton.instance(def).getTicketPrice((uint)vehicleData.m_transportLine));

                return(value);
            }
        }