Exemplo n.º 1
0
 public static bool IsSharedStopTransport(this TransportInfo.TransportType transportType)
 {
     return(transportType == TransportInfo.TransportType.Bus ||
            transportType == TransportInfo.TransportType.Tram ||
            transportType == TransportInfo.TransportType.TouristBus ||
            transportType == TransportInfo.TransportType.Trolleybus);
 }
        public void SetPrefab(VehicleInfo prefab)
        {
            if ((UnityEngine.Object)prefab == (UnityEngine.Object)null)
            {
                return;
            }
            PrefabAI ai = prefab.GetAI();

            if ((UnityEngine.Object)ai == (UnityEngine.Object)null)
            {
                return;
            }
            FieldInfo field = ai.GetType().GetField("m_transportInfo");

            if (field == null)
            {
                return;
            }
            TransportInfo.TransportType transportType = (field.GetValue((object)ai) as TransportInfo).m_transportType;
            if (this._firstShow)
            {
                this.FirstShowInit(transportType, prefab);
            }
            else
            {
                this.SetTransportType(transportType, prefab);
            }
        }
Exemplo n.º 3
0
        private static ItemClass.SubService GetSubService(TransportInfo.TransportType transportType)
        {
            switch (transportType)
            {
            case TransportInfo.TransportType.Bus:
                return(ItemClass.SubService.PublicTransportBus);

            case TransportInfo.TransportType.Metro:
                return(ItemClass.SubService.PublicTransportMetro);

            case TransportInfo.TransportType.Train:
                return(ItemClass.SubService.PublicTransportTrain);

            case TransportInfo.TransportType.Ship:
                return(ItemClass.SubService.PublicTransportShip);

            case TransportInfo.TransportType.Airplane:
                return(ItemClass.SubService.PublicTransportPlane);

            case TransportInfo.TransportType.Taxi:
                return(ItemClass.SubService.PublicTransportTaxi);

            case TransportInfo.TransportType.Tram:
                return(ItemClass.SubService.PublicTransportTram);

            default:
                return(ItemClass.SubService.None);
            }
        }
 public static bool IsValidTransport(this TransportInfo.TransportType transportType)
 {
     return(transportType == TransportInfo.TransportType.Trolleybus ||
            transportType == TransportInfo.TransportType.Bus ||
            transportType == TransportInfo.TransportType.TouristBus ||
            transportType == TransportInfo.TransportType.Tram);
 }
        private static string GetLocaleID(TransportInfo.TransportType transportType)
        {
            switch (transportType)
            {
            case TransportInfo.TransportType.Bus:
                return("INFO_PUBLICTRANSPORT_BUS");

            case TransportInfo.TransportType.Metro:
                return("INFO_PUBLICTRANSPORT_METRO");

            case TransportInfo.TransportType.Train:
                return("INFO_PUBLICTRANSPORT_TRAIN");

            case TransportInfo.TransportType.Ship:
                return("INFO_PUBLICTRANSPORT_SHIP");

            case TransportInfo.TransportType.Airplane:
                return("INFO_PUBLICTRANSPORT_PLANE");

            case TransportInfo.TransportType.Taxi:
                return("INFO_PUBLICTRANSPORT_TAXI");

            case TransportInfo.TransportType.Tram:
                return("INFO_PUBLICTRANSPORT_TRAM");

            case TransportInfo.TransportType.CableCar:
                return("INFO_PUBLICTRANSPORT_CABLECAR");

            case TransportInfo.TransportType.Monorail:
                return("INFO_PUBLICTRANSPORT_MONORAIL");

            default:
                return(string.Empty);
            }
        }
        private void FirstShowInit(TransportInfo.TransportType type, VehicleInfo info = null)
        {
            this._firstShow = false;
            TransportManager instance = Singleton <TransportManager> .instance;
            bool             flag1    = instance.TransportTypeLoaded(TransportInfo.TransportType.Taxi);
            bool             flag2    = instance.TransportTypeLoaded(TransportInfo.TransportType.Tram);

            if (OptionsWrapper <Settings> .Options.VehicleEditorPosition == 0)
            {
                float x = this._publicTransportInfoViewPanel.component.absolutePosition.x;
                if (flag1 & flag2)
                {
                    this.relativePosition = new Vector3(x, 486f);
                }
                else if (flag1 | flag2)
                {
                    this.relativePosition = new Vector3(x, 445f);
                }
                else
                {
                    this.relativePosition = new Vector3(x, 404f);
                }
            }
            else
            {
                this.relativePosition = this._publicTransportInfoViewPanel.component.absolutePosition + new Vector3(this._publicTransportInfoViewPanel.component.size.x + 1f, 0.0f);
            }
            this.SetTransportType(type, info);
        }
Exemplo n.º 7
0
        private static ItemClassTriplet[] GetItemClasses(TransportInfo.TransportType transportType)
        {
            switch (transportType)
            {
            case TransportInfo.TransportType.Bus:
                return(new[]
                {
                    new ItemClassTriplet(ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportBus, ItemClass.Level.Level1),
                    new ItemClassTriplet(ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportBus, ItemClass.Level.Level2),
                    new ItemClassTriplet(ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportTours, ItemClass.Level.Level3)
                });

            case TransportInfo.TransportType.EvacuationBus:
                return(new[] { new ItemClassTriplet(ItemClass.Service.Disaster, ItemClass.SubService.None, ItemClass.Level.Level4) });

            case TransportInfo.TransportType.Metro:
                return(new[] { new ItemClassTriplet(ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportMetro, ItemClass.Level.Level1) });

            case TransportInfo.TransportType.Train:
                return(new[] { new ItemClassTriplet(ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportTrain, ItemClass.Level.Level1) });

            case TransportInfo.TransportType.Ship:
                return(new[]
                {
                    new ItemClassTriplet(ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportShip, ItemClass.Level.Level1),
                    new ItemClassTriplet(ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportShip, ItemClass.Level.Level2)
                });

            case TransportInfo.TransportType.Airplane:
                return(new[]
                {
                    new ItemClassTriplet(ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportPlane, ItemClass.Level.Level1),
                    new ItemClassTriplet(ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportPlane, ItemClass.Level.Level2)
                });

            case TransportInfo.TransportType.Taxi:
                return(new[] { new ItemClassTriplet(ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportTaxi, ItemClass.Level.Level1) });

            case TransportInfo.TransportType.Tram:
                return(new[] { new ItemClassTriplet(ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportTram, ItemClass.Level.Level1) });

            case TransportInfo.TransportType.Monorail:
                return(new[] { new ItemClassTriplet(ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportMonorail, ItemClass.Level.Level1) });

            case TransportInfo.TransportType.CableCar:
                return(new[] { new ItemClassTriplet(ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportCableCar, ItemClass.Level.Level1) });

            case TransportInfo.TransportType.Helicopter:
                return(new[] { new ItemClassTriplet(ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportPlane, ItemClass.Level.Level3) });

            case TransportInfo.TransportType.Trolleybus:
                return(new[] { new ItemClassTriplet(ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportTrolleybus, ItemClass.Level.Level1) });

            default:
                return(new[] { new ItemClassTriplet(ItemClass.Service.None, ItemClass.SubService.None, ItemClass.Level.None) });
            }
        }
Exemplo n.º 8
0
 private TransportSystemDefinition(
     ItemClass.SubService subService,
     VehicleInfo.VehicleType vehicleType,
     TransportInfo.TransportType transportType)
 {
     VehicleType   = vehicleType;
     SubService    = subService;
     TransportType = transportType;
 }
Exemplo n.º 9
0
        public static bool StartTransfer(DepotAI __instance, ushort buildingID, ref Building data, TransferManager.TransferReason reason, TransferManager.TransferOffer offer)
        {
            if (!managedReasons.Contains(reason) || offer.TransportLine == 0)
            {
                return(true);
            }

            TLMUtils.doLog("START TRANSFER!!!!!!!!");
            TransportInfo m_transportInfo = __instance.m_transportInfo;
            BuildingInfo  m_info          = __instance.m_info;

            if (TLMSingleton.instance != null && TLMSingleton.debugMode)
            {
                TLMUtils.doLog("m_info {0} | m_transportInfo {1} | Line: {2}", m_info.name, m_transportInfo.name, offer.TransportLine);
            }


            if (reason == m_transportInfo.m_vehicleReason || (__instance.m_secondaryTransportInfo != null && reason == __instance.m_secondaryTransportInfo.m_vehicleReason))
            {
                VehicleInfo randomVehicleInfo = null;
                var         tsd = TransportSystemDefinition.from(__instance.m_transportInfo);

                TransportLine tl = Singleton <TransportManager> .instance.m_lines.m_buffer[offer.TransportLine];
                TransportInfo.TransportType t = tl.Info.m_transportType;

                if (TLMLineUtils.hasPrefix(ref tl))
                {
                    setRandomBuildingByPrefix(tsd, tl.m_lineNumber / 1000u, ref buildingID);
                }
                else
                {
                    setRandomBuildingByPrefix(tsd, 0, ref buildingID);
                }

                TLMUtils.doLog("randomVehicleInfo");
                randomVehicleInfo = doModelDraw(offer.TransportLine);
                if (randomVehicleInfo == null)
                {
                    randomVehicleInfo = Singleton <VehicleManager> .instance.GetRandomVehicleInfo(ref Singleton <SimulationManager> .instance.m_randomizer, m_info.m_class.m_service, m_info.m_class.m_subService, m_info.m_class.m_level);
                }
                if (randomVehicleInfo != null)
                {
                    TLMUtils.doLog("randomVehicleInfo != null");
                    Array16 <Vehicle> vehicles = Singleton <VehicleManager> .instance.m_vehicles;
                    __instance.CalculateSpawnPosition(buildingID, ref Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingID], ref Singleton <SimulationManager> .instance.m_randomizer, randomVehicleInfo, out Vector3 position, out Vector3 vector);
                    if (Singleton <VehicleManager> .instance.CreateVehicle(out ushort vehicleID, ref Singleton <SimulationManager> .instance.m_randomizer, randomVehicleInfo, position, reason, false, true))
                    {
                        TLMUtils.doLog("CreatedVehicle!!!");
                        randomVehicleInfo.m_vehicleAI.SetSource(vehicleID, ref vehicles.m_buffer[(int)vehicleID], buildingID);
                        randomVehicleInfo.m_vehicleAI.StartTransfer(vehicleID, ref vehicles.m_buffer[(int)vehicleID], reason, offer);
                    }
                    return(false);
                }
            }
            return(true);
        }
        private void CreateTabButton(TransportInfo.TransportType transportType)
        {
            UIPanel uiPanel = this._containerPanel.AddUIComponent <UIPanel>();

            uiPanel.transform.localPosition = Vector3.zero;
            double num1 = 70.0;

            uiPanel.width = (float)num1;
            double num2 = 30.0;

            uiPanel.height = (float)num2;
            int num3 = 0;

            uiPanel.autoLayoutDirection = (LayoutDirection)num3;
            int num4 = 0;

            uiPanel.autoLayoutStart = (LayoutStart)num4;
            RectOffset rectOffset = new RectOffset(8, 0, 4, 4);

            uiPanel.autoLayoutPadding = rectOffset;
            int num5 = 1;

            uiPanel.autoLayout = num5 != 0;
            Color32 transportColor = (Color32)Singleton <TransportManager> .instance.m_properties.m_transportColors[(int)transportType];

            uiPanel.color = transportColor;
            string str1 = "InfoviewPanel";

            uiPanel.backgroundSprite = str1;
            string   vehicleTypeIcon = PublicTransportWorldInfoPanel.GetVehicleTypeIcon(transportType);
            UIButton uiButton        = uiPanel.AddUIComponent <UIButton>();
            double   num6            = 32.0;

            uiButton.width = (float)num6;
            double num7 = 22.0;

            uiButton.height = (float)num7;
            string str2 = vehicleTypeIcon;

            uiButton.normalBgSprite = str2;
            string str3 = vehicleTypeIcon + "Focused";

            uiButton.hoveredBgSprite = str3;
            Vector3 vector3 = new Vector3(278f, 4f);

            uiButton.relativePosition = vector3;
            MouseEventHandler mouseEventHandler = (MouseEventHandler)((c, p) => this.SetTransportType(transportType, (VehicleInfo)null));

            uiButton.eventClick += mouseEventHandler;
        }
Exemplo n.º 11
0
        public MapTransportLine(Color32 color, bool day, bool night, ushort lineId)
        {
            TransportLine t = Singleton <TransportManager> .instance.m_lines.m_buffer[lineId];

            this.lineName = Singleton <TransportManager> .instance.GetLineName(lineId);

            this.lineStringIdentifier = TLMLineUtils.getLineStringId(lineId);
            transportType             = t.Info.m_transportType;
            subservice      = t.Info.GetSubService();
            vehicleType     = t.Info.m_vehicleType;
            stations        = new List <Station>();
            lineColor       = color;
            activeDay       = day;
            activeNight     = night;
            this.lineId     = lineId;
            this.lineNumber = t.m_lineNumber;
        }
Exemplo n.º 12
0
        private void SetTransportType(TransportInfo.TransportType transportType, VehicleInfo selectedPrefab = null)
        {
            Color            transportColor = Singleton <TransportManager> .instance.m_properties.m_transportColors[(int)transportType];
            ItemClassTriplet classTriplet   = VehicleEditor.GetItemClasses(transportType)[0];

            this._selectedService      = classTriplet.Service;
            this._selectedSubService   = classTriplet.SubService;
            this._rightSidePanel.color = (Color32)transportColor;
            UIComponent uiComponent = this._rightSidePanel.Find("CaptionPanel");
            UIPanel     uiPanel1    = this._rightSidePanel.Find <UIPanel>("MaintenanceRow");
            UILabel     uiLabel1    = this._rightSidePanel.Find <UILabel>("CapacityLabel");
            UITextField uiTextField = this._rightSidePanel.Find <UITextField>("Capacity");
            UILabel     uiLabel2    = this._rightSidePanel.Find <UILabel>("TicketPriceLabel2");
            UIPanel     uiPanel2    = this._rightSidePanel.Find <UIPanel>("EngineRow");

            this._rightSidePanel.Find <UIPanel>("ButtonRow");
            Color32 color32 = (Color32)transportColor;

            uiComponent.color = color32;
            if (this._selectedSubService == ItemClass.SubService.PublicTransportTaxi)
            {
                uiPanel1.enabled    = false;
                uiPanel2.enabled    = false;
                uiLabel1.text       = Localization.Get("VEHICLE_EDITOR_CAPACITY_TAXI");
                uiTextField.tooltip = Localization.Get("VEHICLE_EDITOR_CAPACITY_TAXI_TOOLTIP");
                uiLabel2.text       = Localization.Get("VEHICLE_EDITOR_PRICE_PER_KILOMETER");
            }
            else
            {
                uiPanel1.enabled = true;
                if (this._selectedSubService == ItemClass.SubService.PublicTransportTrain)
                {
                    uiPanel2.enabled = true;
                }
                else
                {
                    uiPanel2.enabled = false;
                }
                uiLabel1.text       = Localization.Get("VEHICLE_EDITOR_CAPACITY");
                uiTextField.tooltip = "";
                uiLabel2.text       = Localization.Get("VEHICLE_EDITOR_TICKET_PRICE");
            }
            (this._rightSidePanel.Find("CaptionLabel") as UILabel).text = string.Format(Localization.Get("VEHICLE_EDITOR_SUB_TITLE"), (object)ColossalFramework.Globalization.Locale.Get(VehicleEditor.GetLocaleID(transportType)));
            this.PopulateAssetDropDown(selectedPrefab);
        }
        private int GetLineCount(Vector3 stopPosition, Vector3 stopDirection, TransportInfo.TransportType transportType)
        {
            NetManager       instance  = Singleton <NetManager> .instance;
            TransportManager instance2 = Singleton <TransportManager> .instance;

            stopDirection.Normalize();
            Segment3 segment = new Segment3(stopPosition - stopDirection * 16, stopPosition + stopDirection * 16);
            Vector3  vector  = segment.Min();
            Vector3  vector2 = segment.Max();
            int      num     = Mathf.Max((int)((vector.x - 4) / 64 + 135), 0);
            int      num2    = Mathf.Max((int)((vector.z - 4) / 64 + 135), 0);
            int      num3    = Mathf.Min((int)((vector2.x + 4) / 64 + 135), 269);
            int      num4    = Mathf.Min((int)((vector2.z + 4) / 64 + 135), 269);
            int      num5    = 0;

            for (int i = num2; i <= num4; i++)
            {
                for (int j = num; j <= num3; j++)
                {
                    ushort num6 = instance.m_nodeGrid[i * 270 + j];
                    int    num7 = 0;
                    while (num6 != 0)
                    {
                        ushort transportLine = instance.m_nodes.m_buffer[(int)num6].m_transportLine;
                        if (transportLine != 0)
                        {
                            TransportInfo info = instance2.m_lines.m_buffer[(int)transportLine].Info;
                            if (info.m_transportType == transportType && (instance2.m_lines.m_buffer[(int)transportLine].m_flags & TransportLine.Flags.Temporary) == TransportLine.Flags.None && segment.DistanceSqr(instance.m_nodes.m_buffer[(int)num6].m_position) < 16)
                            {
                                num5++;
                            }
                        }
                        num6 = instance.m_nodes.m_buffer[(int)num6].m_nextGridNode;
                        if (++num7 >= 32768)
                        {
                            CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!" + Environment.StackTrace);

                            break;
                        }
                    }
                }
            }
            return(num5);
        }
Exemplo n.º 14
0
        private static ItemClassTriplet GetItemClass(TransportInfo.TransportType transportType)
        {
            switch (transportType)
            {
            case TransportInfo.TransportType.Bus:
                return(new ItemClassTriplet(ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportBus, ItemClass.Level.Level1));

            case TransportInfo.TransportType.EvacuationBus:
                return(new ItemClassTriplet(ItemClass.Service.Disaster, ItemClass.SubService.None, ItemClass.Level.Level4));

            case TransportInfo.TransportType.Metro:
                return(new ItemClassTriplet(ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportMetro, ItemClass.Level.Level1));

            case TransportInfo.TransportType.Train:
                return(new ItemClassTriplet(ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportTrain, ItemClass.Level.Level1));

            case TransportInfo.TransportType.Ship: //TODO(earalov): handle regional ships
                return(new ItemClassTriplet(ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportShip, ItemClass.Level.Level2));

            case TransportInfo.TransportType.Airplane: //TODO(earalov): handle regional planes
                return(new ItemClassTriplet(ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportPlane, ItemClass.Level.Level2));

            case TransportInfo.TransportType.Taxi:
                return(new ItemClassTriplet(ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportTaxi, ItemClass.Level.Level1));

            case TransportInfo.TransportType.Tram:
                return(new ItemClassTriplet(ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportTram, ItemClass.Level.Level1));

            case TransportInfo.TransportType.Monorail:
                return(new ItemClassTriplet(ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportMonorail, ItemClass.Level.Level1));

            case TransportInfo.TransportType.CableCar:
                return(new ItemClassTriplet(ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportCableCar, ItemClass.Level.Level1));

            default:
                return(new ItemClassTriplet(ItemClass.Service.None, ItemClass.SubService.None, ItemClass.Level.None));
            }
        }
Exemplo n.º 15
0
 private string getLineElement(Vector2[] points, MapTransportLine line, TransportInfo.TransportType tt) => $@"<polyline points=""{string.Join(",", points.Select(x => "" + x.x + "," + x.y).ToArray())}"" class=""path{tt.ToString()} _lid_{line.lineId}"" style='stroke:rgb({ line.lineColor.r},{ line.lineColor.g},{ line.lineColor.b});' stroke-linejoin=""round"" stroke-linecap=""round""/>";
Exemplo n.º 16
0
        internal void drawAllLines()
        {
            TransportLine[] tls = Singleton <TransportManager> .instance.m_lines.m_buffer;
            List <LineSegmentStationsManager.LineSegmentStations> segments = segmentManager.getSegments();
            var segmentDict = new List <Tuple <float, string> >();

            foreach (LineSegmentStationsManager.LineSegmentStations segment in segments)
            {
                List <Vector2> basePoints = segment.path;
                for (int i = 0; i < basePoints.Count; i++)
                {
                    basePoints[i] = (basePoints[i] - offset) * multiplier;
                }
                float offsetNeg = 0;
                float offsetPos = 0;
                var   dir       = CardinalPoint.GetCardinal2D(segment.s1.centralPos, segment.s2.centralPos);
                dir++;
                dir++;
                Vector2 offsetDir = dir.GetCardinalOffset2D();
                foreach (KeyValuePair <MapTransportLine, LineSegmentStationsManager.Direction> line in segment.lines)
                {
                    float width = 0;
                    TransportInfo.TransportType tt = tls[line.Key.lineId].Info.m_transportType;
                    switch (tt)
                    {
                    case TransportInfo.TransportType.Tram:
                    case TransportInfo.TransportType.Bus:
                        width = 1;
                        break;

                    case TransportInfo.TransportType.Train:
                        width = 5;
                        break;

                    case TransportInfo.TransportType.Metro:
                        width = 2.5f;
                        break;

                    case TransportInfo.TransportType.Monorail:
                        width = 4;
                        break;

                    case TransportInfo.TransportType.Ship:
                        width = 8;
                        break;
                    }
                    float coordMultiplier = 0;
                    if (offsetNeg > offsetPos)
                    {
                        coordMultiplier = (offsetPos + width / 2);
                        offsetPos      += width;
                    }
                    else if (offsetNeg < offsetPos)
                    {
                        coordMultiplier = -(offsetNeg + width / 2);
                        offsetNeg      += width;
                    }
                    else
                    {
                        offsetPos = width / 2;
                        offsetNeg = width / 2;
                    }

                    Vector2 lineTotalOffset = offsetDir * coordMultiplier * 2;
                    var     points          = new Vector2[basePoints.Count];
                    for (int i = 0; i < basePoints.Count; i++)
                    {
                        if (i == 0)
                        {
                            CardinalPoint cp = segment.s1.getDirectionForStation(segment.s2);
                            cp++;
                            cp++;
                            points[i] = basePoints[i] + cp.GetCardinalOffset2D() * coordMultiplier * 2;
                        }
                        else if (i == basePoints.Count - 1)
                        {
                            CardinalPoint cp = segment.s2.getDirectionForStation(segment.s1);
                            cp++;
                            cp++;
                            points[i] = basePoints[i] + cp.GetCardinalOffset2D() * coordMultiplier * 2;
                        }
                        else
                        {
                            points[i] = basePoints[i] + lineTotalOffset;
                        }
                    }
                    segmentDict.Add(Tuple.New(width, getLineElement(points, line.Key, tt)));
                }
            }
            segmentDict.Sort((x, y) => (int)(y.First - x.First));
            svgPart.Append(string.Join("\n", segmentDict.Select(x => x.Second).ToArray()));
        }
Exemplo n.º 17
0
        public void StartTransfer(ushort buildingID, ref Building data, TransferManager.TransferReason reason, TransferManager.TransferOffer offer)
        {
            if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
            {
                TLMUtils.doLog("START TRANSFER!!!!!!!!");
            }
            DepotAI       ai = ((DepotAI)data.Info.GetAI());
            TransportInfo m_transportInfo = ((DepotAI)data.Info.GetAI()).m_transportInfo;
            BuildingInfo  m_info          = ((DepotAI)data.Info.GetAI()).m_info;

            if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
            {
                TLMUtils.doLog("m_info {0} | m_transportInfo {1} | Line: {2}", m_info.name, m_transportInfo.name, offer.TransportLine);
            }

            if (reason == m_transportInfo.m_vehicleReason)
            {
                VehicleInfo randomVehicleInfo = null;
                var         tsd = TransportSystemDefinition.from(ai.m_transportInfo.m_class.m_subService, ai.m_transportInfo.m_vehicleType);

                if (offer.TransportLine != 0)
                {
                    TransportLine tl = Singleton <TransportManager> .instance.m_lines.m_buffer[offer.TransportLine];
                    TransportInfo.TransportType t = tl.Info.m_transportType;
                    randomVehicleInfo = doModelDraw(tl);
                    if (TLMConfigWarehouse.getCurrentConfigInt(TLMConfigWarehouse.getConfigIndexForTransportInfo(tl.Info) | TLMConfigWarehouse.ConfigIndex.PREFIX) != (int)ModoNomenclatura.Nenhum)
                    {
                        setRandomBuildingByPrefix(tsd, tl.m_lineNumber / 1000u, ref buildingID);
                    }
                    else
                    {
                        setRandomBuildingByPrefix(tsd, 0, ref buildingID);
                    }
                }
                else
                {
                    setRandomBuildingByPrefix(tsd, 65, ref buildingID);
                }

                if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
                {
                    TLMUtils.doLog("randomVehicleInfo");
                }
                if (randomVehicleInfo == null)
                {
                    randomVehicleInfo = Singleton <VehicleManager> .instance.GetRandomVehicleInfo(ref Singleton <SimulationManager> .instance.m_randomizer, m_info.m_class.m_service, m_info.m_class.m_subService, m_info.m_class.m_level);
                }
                if (randomVehicleInfo != null)
                {
                    if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
                    {
                        TLMUtils.doLog("randomVehicleInfo != null");
                    }
                    Array16 <Vehicle> vehicles = Singleton <VehicleManager> .instance.m_vehicles;
                    Vector3           position;
                    Vector3           vector;
                    this.CalculateSpawnPosition(buildingID, ref Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingID], ref Singleton <SimulationManager> .instance.m_randomizer, randomVehicleInfo, out position, out vector);
                    ushort num;
                    if (Singleton <VehicleManager> .instance.CreateVehicle(out num, ref Singleton <SimulationManager> .instance.m_randomizer, randomVehicleInfo, position, reason, false, true))
                    {
                        if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
                        {
                            TLMUtils.doLog("CreatedVehicle!!!");
                        }
                        randomVehicleInfo.m_vehicleAI.SetSource(num, ref vehicles.m_buffer[(int)num], buildingID);
                        randomVehicleInfo.m_vehicleAI.StartTransfer(num, ref vehicles.m_buffer[(int)num], reason, offer);
                    }
                }
            }
            else
            {
                if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
                {
                    TLMUtils.doLog("nor StartTransferCommonBuildingAI");
                }
                StartTransferCommonBuildingAI(buildingID, ref data, reason, offer);
            }
        }
        internal void drawAllLines()
        {
            TransportLine[] tls       = Singleton <TransportManager> .instance.m_lines.m_buffer;
            var             segments  = segmentManager.getSegments();
            string          mainStyle = "<polyline points=\"{0}\" class=\"path{4}\" style='stroke:rgb({1},{2},{3});' stroke-linejoin=\"round\" stroke-linecap=\"round\" marker-mid=\"url(#5)\"/> ";

            foreach (var segment in segments)
            {
                List <Vector2> basePoints = segment.path;
                for (int i = 0; i < basePoints.Count; i++)
                {
                    basePoints[i] = (basePoints[i] - offset) * multiplier;
                }
                float         offsetNeg = 0;
                float         offsetPos = 0;
                CardinalPoint dir       = CardinalPoint.getCardinal2D(segment.s1.centralPos, segment.s2.centralPos);
                dir++;
                dir++;
                Vector2 offsetDir = dir.getCardinalOffset2D();
                foreach (var line in segment.lines)
                {
                    float width = 0;
                    TransportInfo.TransportType tt = tls[line.Key.lineId].Info.m_transportType;
                    switch (tt)
                    {
                    case TransportInfo.TransportType.Tram:
                    case TransportInfo.TransportType.Bus:
                        width = 1;
                        break;

                    case TransportInfo.TransportType.Train:
                        width = 5;
                        break;

                    case TransportInfo.TransportType.Metro:
                        width = 2.5f;
                        break;

                    case TransportInfo.TransportType.Ship:
                        width = 8;
                        break;
                    }
                    float coordMultiplier = 0;
                    if (offsetNeg > offsetPos)
                    {
                        coordMultiplier = (offsetPos + width / 2);
                        offsetPos      += width;
                    }
                    else if (offsetNeg < offsetPos)
                    {
                        coordMultiplier = -(offsetNeg + width / 2);
                        offsetNeg      += width;
                    }
                    else
                    {
                        offsetPos = width / 2;
                        offsetNeg = width / 2;
                    }

                    var       lineTotalOffset = offsetDir * coordMultiplier * 2;
                    Vector2[] points          = new Vector2[basePoints.Count];
                    for (int i = 0; i < basePoints.Count; i++)
                    {
                        if (i == 0)
                        {
                            var cp = segment.s1.getDirectionForStation(segment.s2);
                            cp++;
                            cp++;
                            points[i] = basePoints[i] + cp.getCardinalOffset2D() * coordMultiplier * 2;
                        }
                        else if (i == basePoints.Count - 1)
                        {
                            var cp = segment.s2.getDirectionForStation(segment.s1);
                            cp++;
                            cp++;
                            points[i] = basePoints[i] + cp.getCardinalOffset2D() * coordMultiplier * 2;
                        }
                        else
                        {
                            points[i] = basePoints[i] + lineTotalOffset;
                        }
                    }
                    svgPart.AppendFormat(mainStyle, string.Join(" ", points.Select(x => "" + x.x + "," + x.y).ToArray()), line.Key.lineColor.r, line.Key.lineColor.g, line.Key.lineColor.b, tt.ToString(), line.Value);
                }
            }
        }
        private string BuildRandomName(ushort lineNumber, TransportInfo.TransportType transportType, List <string> districts, int stopCount)
        {
            // todo could this be localized?
            try
            {
                if (transportType == TransportInfo.TransportType.Train)
                {
                    if (districts.Count == 1)
                    {
                        if (districts[0] == string.Empty)
                        {
                            return(string.Format("#{0} {1} Shuttle", lineNumber, districts[0]));
                        }

                        var rnd = Random.value;
                        if (rnd <= .33f)
                        {
                            return(string.Format("#{0} {1} Limited", lineNumber, districts[0]));
                        }

                        if (rnd <= .66f)
                        {
                            return(string.Format("#{0} {1} Service", lineNumber, districts[0]));
                        }

                        return(string.Format("#{0} {1} Shuttle", lineNumber, districts[0]));
                    }
                    if (districts.Count == 2)
                    {
                        if (string.IsNullOrEmpty(districts[0]) || string.IsNullOrEmpty(districts[1]))
                        {
                            return(string.Format("#{0} {1} Shuttle", lineNumber, districts[0]));
                        }

                        var rnd = Random.value;
                        if (rnd <= .33f)
                        {
                            return(string.Format("#{0} {1}&{2}", lineNumber, districts[0].Substring(0, 1),
                                                 districts[1].Substring(0, 1)));
                        }
                        if (rnd <= .5)
                        {
                            return(string.Format("#{0} {1} Zephr", lineNumber, districts[0].Substring(0, 1)));
                        }
                        if (rnd <= .7)
                        {
                            return(string.Format("#{0} {1} Flyer", lineNumber, districts[0].Substring(0, 1)));
                        }
                        return(string.Format("#{0} {1} & {2}", lineNumber, districts[0], districts[1]));
                    }

                    return(string.Format("#{0} Unlimited", lineNumber));
                }

                if (transportType == TransportInfo.TransportType.Bus ||
                    transportType == TransportInfo.TransportType.Metro)
                {
                    if (districts.Count == 1)
                    {
                        if (string.IsNullOrEmpty(districts[0]))
                        {
                            return(string.Format("#{0} Line", lineNumber));
                        }

                        return(string.Format("#{0} {1} Local", lineNumber, districts[0]));
                    }

                    if (districts.Count == 2 && string.IsNullOrEmpty(districts[0]) && string.IsNullOrEmpty(districts[1]))
                    {
                        return(string.Format("#{0} Line", lineNumber));
                    }


                    if (districts.Count == 2 && stopCount <= 4)
                    {
                        return(string.Format("#{0} {1} / {2} Express", lineNumber, districts[0], districts[1]));
                    }

                    if (districts.Count == 2)
                    {
                        return(string.Format("#{0} {1} / {2} Line", lineNumber, districts[0], districts[1]));
                    }

                    return(string.Format("#{0} Line", lineNumber));
                }
            }
            catch (Exception ex)
            {
                // if we get an exception we'll just drop back to Line number and color name
                Console.Message(ex.ToString(), PluginManager.MessageType.Message);
            }

            return(string.Format("#{0} Line", lineNumber));
        }
 private int GetLineCount(Vector3 stopPosition, Vector3 stopDirection, TransportInfo.TransportType transportType)
 {
     UnityEngine.Debug.Log("GetLineCount");
     return(0);
 }