/// <summary>
    /// Gets the singleton.
    /// </summary>
    /// <returns>
    /// The singleton.
    /// </returns>
    public static TransportManager getSingleton()
    {
        if(globalTransportManager == null)
            globalTransportManager = new TransportManager();

        return globalTransportManager;
    }
 public void SetOriginalValues(TransportManager originalTransportManager)
 {
     this.m_simulationProfiler = originalTransportManager.m_simulationProfiler;
     this.m_drawCallData = originalTransportManager.m_drawCallData;
     this.m_properties = originalTransportManager.m_properties;
     this.m_lineCount = originalTransportManager.m_lineCount;
     this.m_infoCount = originalTransportManager.m_infoCount;
     this.m_passengers = originalTransportManager.m_passengers;
     this.m_lineNumber = (ushort[])this.fi_lineNumber.GetValue(originalTransportManager);
     this.m_linesVisible = (bool)this.fi_linesVisible.GetValue(originalTransportManager);
     this.m_undergroundCamera = (Camera)this.fi_undergroundCamera.GetValue(originalTransportManager);
     this.m_patches = (TransportPatch[])this.fi_patches.GetValue(originalTransportManager);
     this.m_patchesDirty = (bool)this.fi_patchesDirty.GetValue(originalTransportManager);
 }
        private bool EnsureTempLine(TransportInfo info, ushort sourceLine, int moveIndex, int addIndex, Vector3 addPos, bool fixedPlatform)
        {
            TransportManager instance = Singleton <TransportManager> .instance;

            if (this.m_tempLine != 0)
            {
                if ((instance.m_lines.m_buffer[(int)this.m_tempLine].m_flags & TransportLine.Flags.Temporary) == TransportLine.Flags.None)
                {
                    this.m_tempLine = 0;
                    this.SetEditLine(0, true);
                }
                else if (instance.m_lines.m_buffer[(int)this.m_tempLine].Info != info)
                {
                    instance.ReleaseLine(this.m_tempLine);
                    this.m_tempLine = 0;
                    this.SetEditLine(0, true);
                }
            }
            if (this.m_tempLine == 0)
            {
                for (int i = 1; i < 256; i++)
                {
                    if ((instance.m_lines.m_buffer[i].m_flags & TransportLine.Flags.Temporary) != TransportLine.Flags.None)
                    {
                        if (instance.m_lines.m_buffer[i].Info != info)
                        {
                            instance.ReleaseLine((ushort)i);
                        }
                        else
                        {
                            this.m_tempLine = (ushort)i;
                            this.SetEditLine(sourceLine, true);
                        }
                        break;
                    }
                }
            }
            ushort tempLine = this.m_tempLine;
            bool   flag     = this.m_tempLine == 0 && Singleton <TransportManager> .instance.CreateLine(out tempLine, ref Singleton <SimulationManager> .instance.m_randomizer, info, false);

            this.m_tempLine = tempLine;
            if (flag)
            {
                TransportLine[] expr_141_cp_0 = instance.m_lines.m_buffer;
                ushort          expr_141_cp_1 = this.m_tempLine;
                expr_141_cp_0[(int)expr_141_cp_1].m_flags = (expr_141_cp_0[(int)expr_141_cp_1].m_flags | TransportLine.Flags.Temporary);
                this.SetEditLine(sourceLine, true);
            }
            if (this.m_tempLine != 0)
            {
                this.SetEditLine(sourceLine, false);
                if (this.m_lastMoveIndex != moveIndex || this.m_lastAddIndex != addIndex || this.m_lastAddPos != addPos)
                {
                    if (this.m_lastAddIndex != -2 && instance.m_lines.m_buffer[(int)this.m_tempLine].RemoveStop(this.m_tempLine, this.m_lastAddIndex))
                    {
                        this.m_lastAddIndex = -2;
                        this.m_lastAddPos   = Vector3.zero;
                    }
                    if (this.m_lastMoveIndex != -2 && instance.m_lines.m_buffer[(int)this.m_tempLine].MoveStop(this.m_tempLine, this.m_lastMoveIndex, this.m_lastMovePos, fixedPlatform))
                    {
                        this.m_lastMoveIndex = -2;
                        this.m_lastMovePos   = Vector3.zero;
                    }
                    instance.m_lines.m_buffer[(int)this.m_tempLine].CopyMissingPaths(sourceLine);
                    Vector3 lastMovePos;
                    if (moveIndex != -2 && instance.m_lines.m_buffer[(int)this.m_tempLine].MoveStop(this.m_tempLine, moveIndex, addPos, fixedPlatform, out lastMovePos))
                    {
                        this.m_lastMoveIndex = moveIndex;
                        this.m_lastMovePos   = lastMovePos;
                        this.m_lastAddPos    = addPos;
                    }
                    if (addIndex != -2 && instance.m_lines.m_buffer[(int)this.m_tempLine].AddStop(this.m_tempLine, addIndex, addPos, fixedPlatform))
                    {
                        this.m_lastAddIndex = addIndex;
                        this.m_lastAddPos   = addPos;
                    }
                }
                instance.m_lines.m_buffer[(int)this.m_tempLine].m_color = instance.m_lines.m_buffer[(int)sourceLine].m_color;
                TransportLine[] expr_327_cp_0 = instance.m_lines.m_buffer;
                ushort          expr_327_cp_1 = this.m_tempLine;
                expr_327_cp_0[(int)expr_327_cp_1].m_flags = (expr_327_cp_0[(int)expr_327_cp_1].m_flags & ~TransportLine.Flags.Hidden);
                if ((instance.m_lines.m_buffer[(int)sourceLine].m_flags & TransportLine.Flags.CustomColor) != TransportLine.Flags.None)
                {
                    TransportLine[] expr_36C_cp_0 = instance.m_lines.m_buffer;
                    ushort          expr_36C_cp_1 = this.m_tempLine;
                    expr_36C_cp_0[(int)expr_36C_cp_1].m_flags = (expr_36C_cp_0[(int)expr_36C_cp_1].m_flags | TransportLine.Flags.CustomColor);
                }
                else
                {
                    TransportLine[] expr_398_cp_0 = instance.m_lines.m_buffer;
                    ushort          expr_398_cp_1 = this.m_tempLine;
                    expr_398_cp_0[(int)expr_398_cp_1].m_flags = (expr_398_cp_0[(int)expr_398_cp_1].m_flags & ~TransportLine.Flags.CustomColor);
                }
                return(true);
            }
            this.SetEditLine(0, false);
            return(false);
        }
        public override void SimulationStep()
        {
            TransportInfo prefab = this.m_prefab;

            if (prefab == null)
            {
                return;
            }
            ToolBase.ToolErrors toolErrors = ToolBase.ToolErrors.None;
            switch (this.m_mode)
            {
            case CustomTransportTool.Mode.NewLine:
            {
                Vector3 vector;
                ushort  num;
                int     hoverStopIndex;
                int     hoverSegmentIndex;
                if ((Singleton <TransportManager> .instance as CustomTransportManager).RayCast(this.m_mouseRay, this.m_mouseRayLength, out vector, out num, out hoverStopIndex, out hoverSegmentIndex))
                {
                    TransportInfo info = Singleton <TransportManager> .instance.m_lines.m_buffer[(int)num].Info;
                    bool          flag = info == prefab;
                    if (flag)
                    {
                        flag = this.EnsureTempLine(prefab, num, -2, -2, vector, false);
                    }
                    if (flag)
                    {
                        this.m_hitPosition       = vector;
                        this.m_fixedPlatform     = false;
                        this.m_hoverStopIndex    = hoverStopIndex;
                        this.m_hoverSegmentIndex = hoverSegmentIndex;
                        if (this.m_hoverSegmentIndex != -1 && !Singleton <NetManager> .instance.CheckLimits())
                        {
                            toolErrors |= ToolBase.ToolErrors.TooManyObjects;
                        }
                    }
                    else
                    {
                        this.EnsureTempLine(prefab, 0, -2, -2, Vector3.zero, false);
                        this.m_hoverStopIndex    = -1;
                        this.m_hoverSegmentIndex = -1;
                        toolErrors |= ToolBase.ToolErrors.RaycastFailed;
                    }
                }
                else
                {
                    ToolBase.RaycastOutput raycastOutput;
                    bool flag2 = ToolBase.RayCast(new ToolBase.RaycastInput(this.m_mouseRay, this.m_mouseRayLength)
                        {
                            m_buildingService     = new ToolBase.RaycastService(prefab.m_stationService, prefab.m_stationSubService, prefab.m_stationLayer),
                            m_netService          = new ToolBase.RaycastService(prefab.m_netService, prefab.m_netSubService, prefab.m_netLayer),
                            m_ignoreTerrain       = true,
                            m_ignoreSegmentFlags  = (prefab.m_netService == ItemClass.Service.None) ? NetSegment.Flags.All : NetSegment.Flags.None,
                            m_ignoreBuildingFlags = (prefab.m_stationService == ItemClass.Service.None) ? Building.Flags.All : Building.Flags.None
                        }, out raycastOutput);
                    bool fixedPlatform = false;
                    if (flag2)
                    {
                        flag2 = this.GetStopPosition(prefab, raycastOutput.m_netSegment, raycastOutput.m_building, 0, ref raycastOutput.m_hitPos, out fixedPlatform);
                    }
                    if (flag2)
                    {
                        flag2 = this.CanAddStop(prefab, 0, -1, raycastOutput.m_hitPos);
                    }
                    if (flag2)
                    {
                        flag2 = this.EnsureTempLine(prefab, 0, -2, -1, raycastOutput.m_hitPos, fixedPlatform);
                    }
                    if (flag2)
                    {
                        this.m_hitPosition       = raycastOutput.m_hitPos;
                        this.m_fixedPlatform     = fixedPlatform;
                        this.m_hoverStopIndex    = -1;
                        this.m_hoverSegmentIndex = -1;
                        if (!Singleton <NetManager> .instance.CheckLimits())
                        {
                            toolErrors |= ToolBase.ToolErrors.TooManyObjects;
                        }
                        if (!Singleton <TransportManager> .instance.CheckLimits())
                        {
                            toolErrors |= ToolBase.ToolErrors.TooManyObjects;
                        }
                    }
                    else
                    {
                        this.EnsureTempLine(prefab, 0, -2, -2, Vector3.zero, fixedPlatform);
                        this.m_hoverStopIndex    = -1;
                        this.m_hoverSegmentIndex = -1;
                        toolErrors |= ToolBase.ToolErrors.RaycastFailed;
                    }
                }
                break;
            }

            case CustomTransportTool.Mode.AddStops:
                if (this.m_line == 0)
                {
                    this.m_mode = CustomTransportTool.Mode.NewLine;
                    toolErrors |= ToolBase.ToolErrors.RaycastFailed;
                }
                else
                {
                    ToolBase.RaycastOutput raycastOutput2;
                    bool flag3 = ToolBase.RayCast(new ToolBase.RaycastInput(this.m_mouseRay, this.m_mouseRayLength)
                    {
                        m_buildingService     = new ToolBase.RaycastService(prefab.m_stationService, prefab.m_stationSubService, prefab.m_stationLayer),
                        m_netService          = new ToolBase.RaycastService(prefab.m_netService, prefab.m_netSubService, prefab.m_netLayer),
                        m_ignoreTerrain       = true,
                        m_ignoreSegmentFlags  = (prefab.m_netService == ItemClass.Service.None) ? NetSegment.Flags.All : NetSegment.Flags.None,
                        m_ignoreBuildingFlags = (prefab.m_stationService == ItemClass.Service.None) ? Building.Flags.All : Building.Flags.None
                    }, out raycastOutput2);
                    bool fixedPlatform2 = false;
                    if (flag3)
                    {
                        ushort firstStop = 0;
                        if (this.m_line != 0)
                        {
                            TransportManager instance = Singleton <TransportManager> .instance;
                            if (!instance.m_lines.m_buffer[(int)this.m_line].Complete)
                            {
                                firstStop = instance.m_lines.m_buffer[(int)this.m_line].m_stops;
                            }
                        }
                        flag3 = this.GetStopPosition(prefab, raycastOutput2.m_netSegment, raycastOutput2.m_building, firstStop, ref raycastOutput2.m_hitPos, out fixedPlatform2);
                    }
                    if (flag3)
                    {
                        flag3 = this.CanAddStop(prefab, this.m_line, -1, raycastOutput2.m_hitPos);
                    }
                    if (flag3)
                    {
                        flag3 = this.EnsureTempLine(prefab, this.m_line, -2, -1, raycastOutput2.m_hitPos, fixedPlatform2);
                    }
                    if (flag3)
                    {
                        this.m_hitPosition   = raycastOutput2.m_hitPos;
                        this.m_fixedPlatform = fixedPlatform2;
                        if (!Singleton <NetManager> .instance.CheckLimits())
                        {
                            toolErrors |= ToolBase.ToolErrors.TooManyObjects;
                        }
                    }
                    else
                    {
                        this.EnsureTempLine(prefab, this.m_line, -2, -2, Vector3.zero, fixedPlatform2);
                        toolErrors |= ToolBase.ToolErrors.RaycastFailed;
                    }
                }
                break;

            case CustomTransportTool.Mode.MoveStops:
                if (this.m_line == 0)
                {
                    this.m_mode = CustomTransportTool.Mode.NewLine;
                    toolErrors |= ToolBase.ToolErrors.RaycastFailed;
                }
                else
                {
                    ToolBase.RaycastOutput raycastOutput3;
                    bool flag4 = ToolBase.RayCast(new ToolBase.RaycastInput(this.m_mouseRay, this.m_mouseRayLength)
                    {
                        m_buildingService     = new ToolBase.RaycastService(prefab.m_stationService, prefab.m_stationSubService, prefab.m_stationLayer),
                        m_netService          = new ToolBase.RaycastService(prefab.m_netService, prefab.m_netSubService, prefab.m_netLayer),
                        m_ignoreTerrain       = true,
                        m_ignoreSegmentFlags  = (prefab.m_netService == ItemClass.Service.None) ? NetSegment.Flags.All : NetSegment.Flags.None,
                        m_ignoreBuildingFlags = (prefab.m_stationService == ItemClass.Service.None) ? Building.Flags.All : Building.Flags.None
                    }, out raycastOutput3);
                    bool fixedPlatform3 = false;
                    if (flag4)
                    {
                        flag4 = this.GetStopPosition(prefab, raycastOutput3.m_netSegment, raycastOutput3.m_building, 0, ref raycastOutput3.m_hitPos, out fixedPlatform3);
                    }
                    if (this.m_hoverStopIndex != -1)
                    {
                        if (flag4)
                        {
                            flag4 = this.CanMoveStop(prefab, this.m_line, this.m_hoverStopIndex, raycastOutput3.m_hitPos);
                        }
                        if (flag4)
                        {
                            flag4 = this.EnsureTempLine(prefab, this.m_line, this.m_hoverStopIndex, -2, raycastOutput3.m_hitPos, fixedPlatform3);
                        }
                    }
                    else if (this.m_hoverSegmentIndex != -1)
                    {
                        if (flag4)
                        {
                            flag4 = this.CanAddStop(prefab, this.m_line, this.m_hoverSegmentIndex + 1, raycastOutput3.m_hitPos);
                        }
                        if (flag4)
                        {
                            flag4 = this.EnsureTempLine(prefab, this.m_line, -2, this.m_hoverSegmentIndex + 1, raycastOutput3.m_hitPos, fixedPlatform3);
                        }
                    }
                    if (flag4)
                    {
                        this.m_hitPosition   = raycastOutput3.m_hitPos;
                        this.m_fixedPlatform = fixedPlatform3;
                        if (this.m_hoverSegmentIndex != -1 && !Singleton <NetManager> .instance.CheckLimits())
                        {
                            toolErrors |= ToolBase.ToolErrors.TooManyObjects;
                        }
                    }
                    else
                    {
                        this.EnsureTempLine(prefab, this.m_line, -2, -2, Vector3.zero, fixedPlatform3);
                        toolErrors |= ToolBase.ToolErrors.RaycastFailed;
                    }
                }
                break;

            default:
                toolErrors |= ToolBase.ToolErrors.RaycastFailed;
                break;
            }
            this.m_errors = toolErrors;
        }
Beispiel #5
0
        private float addStationToLinearMap(string stationPrefix, string stationName, Vector3 location, float offsetX, List <ushort> intersections, string airport, string harbor, string taxi, string regionalTrainStation, ushort stationNodeId, ItemClass.SubService ss, bool simple = false)//, out float intersectionPanelHeight)
        {
            ushort           lineID = lineInfoPanel.lineIdSelecionado.TransportLine;
            TransportLine    t      = lineInfoPanel.controller.tm.m_lines.m_buffer[(int)lineID];
            TransportManager tm     = Singleton <TransportManager> .instance;

            UIButton stationButton = null;

            TLMUtils.createUIElement <UIButton>(ref stationButton, lineStationsPanel.transform);
            stationButton.relativePosition = new Vector3(offsetX, 15f);
            stationButton.width            = 20;
            stationButton.height           = 20;
            stationButton.name             = "Station [" + stationName + "]";
            TLMUtils.initButton(stationButton, true, "IconPolicyBaseCircle");

            UITextField stationLabel = null;

            TLMUtils.createUIElement <UITextField>(ref stationLabel, stationButton.transform);
            stationLabel.autoSize            = true;
            stationLabel.width               = 220;
            stationLabel.height              = 20;
            stationLabel.useOutline          = true;
            stationLabel.pivot               = UIPivotPoint.MiddleLeft;
            stationLabel.horizontalAlignment = UIHorizontalAlignment.Left;
            stationLabel.verticalAlignment   = UIVerticalAlignment.Middle;
            stationLabel.name             = "Station [" + stationName + "] Name";
            stationLabel.relativePosition = new Vector3(23f, -13f);
            stationLabel.text             = (!string.IsNullOrEmpty(stationPrefix) ? stationPrefix.Trim() + " " : "") + stationName.Trim();
            stationLabel.textScale        = Math.Max(0.5f, Math.Min(1, 24f / stationLabel.text.Length));

            TLMUtils.uiTextFieldDefaults(stationLabel);
            stationLabel.color           = new Color(0.3f, 0.3f, 0.3f, 1);
            stationLabel.textColor       = Color.white;
            stationLabel.cursorWidth     = 2;
            stationLabel.cursorBlinkTime = 100;
            stationLabel.eventGotFocus  += (x, y) =>
            {
                stationLabel.text = TLMUtils.getStationName(stationNodeId, lineID, ss);
            };
            stationLabel.eventTextSubmitted += (x, y) =>
            {
                TLMUtils.setStopName(y, stationNodeId, lineID, () =>
                {
                    stationLabel.text = TLMUtils.getFullStationName(stationNodeId, lineID, ss);
                    m_autoName        = TLMUtils.calculateAutoName(lineID);
                    lineInfoPanel.autoNameLabel.text = autoName;
                });
            };

            stationButton.gameObject.transform.localPosition    = new Vector3(0, 0, 0);
            stationButton.gameObject.transform.localEulerAngles = new Vector3(0, 0, 45);
            stationButton.eventClick += (component, eventParam) =>
            {
                lineInfoPanel.cameraController.SetTarget(lineInfoPanel.lineIdSelecionado, location, false);
                lineInfoPanel.cameraController.ClearTarget();
            };
            if (!simple)
            {
                stationOffsetX.Add(stationNodeId, offsetX);
                if (showIntersections)
                {
                    var otherLinesIntersections = TLMLineUtils.SortLines(intersections, t);

                    int intersectionCount = otherLinesIntersections.Count + (airport != string.Empty ? 1 : 0) + (taxi != string.Empty ? 1 : 0) + (harbor != string.Empty ? 1 : 0) + (regionalTrainStation != string.Empty ? 1 : 0);
                    if (intersectionCount > 0)
                    {
                        UIPanel intersectionsPanel = null;
                        TLMUtils.createUIElement <UIPanel>(ref intersectionsPanel, stationButton.transform);
                        intersectionsPanel.autoSize                  = false;
                        intersectionsPanel.autoLayout                = false;
                        intersectionsPanel.autoLayoutStart           = LayoutStart.TopLeft;
                        intersectionsPanel.autoLayoutDirection       = LayoutDirection.Horizontal;
                        intersectionsPanel.relativePosition          = new Vector3(-20, 10);
                        intersectionsPanel.wrapLayout                = false;
                        intersectionsPanel.autoFitChildrenVertically = true;

                        TLMLineUtils.PrintIntersections(airport, harbor, taxi, regionalTrainStation, intersectionsPanel, otherLinesIntersections);

                        intersectionsPanel.autoLayout = true;
                        intersectionsPanel.wrapLayout = true;
                        intersectionsPanel.width      = 55;
                        //
                        return(42f);
                    }
                    else
                    {
                        return(25f);
                    }
                }
                else if (showExtraStopInfo)
                {
                    float normalWidth = 42.5f;

                    NetNode stopNode = Singleton <NetManager> .instance.m_nodes.m_buffer[(int)stationNodeId];

                    int residents, tourists;
                    TLMLineUtils.GetQuantityPassengerWaiting(stationNodeId, out residents, out tourists);

                    UIPanel stationInfoStatsPanel = null;
                    TLMUtils.createUIElement <UIPanel>(ref stationInfoStatsPanel, stationButton.transform);
                    stationInfoStatsPanel.autoSize   = false;
                    stationInfoStatsPanel.autoLayout = false;
                    stationInfoStatsPanel.autoFitChildrenVertically = true;
                    stationInfoStatsPanel.autoLayoutStart           = LayoutStart.TopLeft;
                    stationInfoStatsPanel.autoLayoutDirection       = LayoutDirection.Horizontal;
                    stationInfoStatsPanel.relativePosition          = new Vector3(-20, 10);
                    stationInfoStatsPanel.autoLayout = true;
                    stationInfoStatsPanel.wrapLayout = true;
                    stationInfoStatsPanel.width      = normalWidth;

                    UILabel residentsWaiting = null;
                    TLMUtils.createUIElement <UILabel>(ref residentsWaiting, stationInfoStatsPanel.transform);
                    residentsWaiting.autoSize         = false;
                    residentsWaiting.useOutline       = true;
                    residentsWaiting.text             = residents.ToString();
                    residentsWaiting.tooltipLocaleID  = "TLM_RESIDENTS_WAITING";
                    residentsWaiting.backgroundSprite = "EmptySprite";
                    residentsWaiting.color            = new Color32(0x12, 0x68, 0x34, 255);
                    residentsWaiting.width            = normalWidth;
                    residentsWaiting.padding          = new RectOffset(0, 0, 4, 2);
                    residentsWaiting.height           = 20;
                    residentsWaiting.textScale        = 0.7f;
                    residentsWaiting.textAlignment    = UIHorizontalAlignment.Center;
                    residentCounters[stationNodeId]   = residentsWaiting;

                    UILabel touristsWaiting = null;
                    TLMUtils.createUIElement <UILabel>(ref touristsWaiting, stationInfoStatsPanel.transform);
                    touristsWaiting.autoSize         = false;
                    touristsWaiting.text             = tourists.ToString();
                    touristsWaiting.tooltipLocaleID  = "TLM_TOURISTS_WAITING";
                    touristsWaiting.useOutline       = true;
                    touristsWaiting.width            = normalWidth;
                    touristsWaiting.height           = 20;
                    touristsWaiting.padding          = new RectOffset(0, 0, 4, 2);
                    touristsWaiting.textScale        = 0.7f;
                    touristsWaiting.backgroundSprite = "EmptySprite";
                    touristsWaiting.color            = new Color32(0x1f, 0x25, 0x68, 255);
                    touristsWaiting.textAlignment    = UIHorizontalAlignment.Center;
                    touristCounters[stationNodeId]   = touristsWaiting;
                    //
                    return(normalWidth);
                }
                else
                {
                    return(25f);
                }
            }
            else
            {
                return(30f);
            }
        }
 public UniqueTransportManagerRegistration(TransportManager uniqueManager, Uri listenUri, HostNameComparisonMode hostNameComparisonMode)
     : base(listenUri, hostNameComparisonMode)
 {
     this.list = new List<TransportManager>();
     this.list.Add(uniqueManager);
 }
        public void ApplyStartSettings()
        {
            // Resolution
            if (DaggerfallUnity.Settings.ExclusiveFullscreen && DaggerfallUnity.Settings.Fullscreen)
            {
                Screen.SetResolution(
                    DaggerfallUnity.Settings.ResolutionWidth,
                    DaggerfallUnity.Settings.ResolutionHeight,
                    FullScreenMode.ExclusiveFullScreen);
            }
            else
            {
                Screen.SetResolution(
                    DaggerfallUnity.Settings.ResolutionWidth,
                    DaggerfallUnity.Settings.ResolutionHeight,
                    DaggerfallUnity.Settings.Fullscreen);
            }

            // Camera settings
            GameObject cameraObject = GameObject.FindGameObjectWithTag("MainCamera");

            if (cameraObject)
            {
                // Set camera FOV
                Camera camera = cameraObject.GetComponent <Camera>();
                if (camera)
                {
                    camera.fieldOfView = DaggerfallUnity.Settings.FieldOfView;
                }

                // Set mouse look
                PlayerMouseLook mouseLook = cameraObject.GetComponent <PlayerMouseLook>();
                if (mouseLook)
                {
                    mouseLook.invertMouseY = DaggerfallUnity.Settings.InvertMouseVertical;
                    // Set mouse look smoothing
                    mouseLook.enableSmoothing = DaggerfallUnity.Settings.MouseLookSmoothing;
                    // Set mouse look sensitivity
                    mouseLook.sensitivityScale = DaggerfallUnity.Settings.MouseLookSensitivity;

                    mouseLook.joystickSensitivityScale = DaggerfallUnity.Settings.JoystickLookSensitivity;
                }
            }

            InputManager.Instance.JoystickCursorSensitivity = DaggerfallUnity.Settings.JoystickCursorSensitivity;

            InputManager.Instance.JoystickMovementThreshold = DaggerfallUnity.Settings.JoystickMovementThreshold;

            // Set shadow resolution
            GameManager.UpdateShadowResolution();

            // VSync settings
            if (DaggerfallUnity.Settings.VSync)
            {
                QualitySettings.vSyncCount = 1;
            }
            else
            {
                QualitySettings.vSyncCount = 0;
            }

            // Target frame rate settings
            // Does nothing if VSync enabled
            // Default is 0 but anything below 30 is ignored and treated as disabled
            if (DaggerfallUnity.Settings.TargetFrameRate >= 30 && !DaggerfallUnity.Settings.VSync)
            {
                Application.targetFrameRate = DaggerfallUnity.Settings.TargetFrameRate;
            }

            // Filter settings
            DaggerfallUnity.Instance.MaterialReader.MainFilterMode         = (FilterMode)DaggerfallUnity.Settings.MainFilterMode;
            DaggerfallUnity.Instance.MaterialReader.CompressModdedTextures = DaggerfallUnity.Settings.CompressModdedTextures;

            // HUD settings
            DaggerfallHUD hud = DaggerfallUI.Instance.DaggerfallHUD;

            if (hud != null)                                              //null at startup
            {
                hud.ShowCrosshair = DaggerfallUnity.Settings.Crosshair;
            }

            // Weapon swing settings
            WeaponManager weaponManager = GameManager.Instance.WeaponManager;

            weaponManager.AttackThreshold = DaggerfallUnity.Settings.WeaponAttackThreshold;
            TransportManager transportManager = GameManager.Instance.TransportManager;

            // Weapon hand settings
            // Only supporting left-hand rendering for now
            // More handedness options may be added later
            if (DaggerfallUnity.Settings.Handedness == 1)
            {
                weaponManager.ScreenWeapon.FlipHorizontal = true;
            }

            // GodMode setting
            PlayerEntity playerEntity = FindPlayerEntity();

            playerEntity.GodMode = GodMode;

            PlayerSpeedChanger speedChanger = FindPlayerSpeedChanger();

            speedChanger.ToggleSneak = DaggerfallUnity.Settings.ToggleSneak;

            // Enable/disable videos
            DaggerfallUI.Instance.enableVideos = EnableVideos;

            // Streaming world terrain distance
            GameManager.Instance.StreamingWorld.TerrainDistance = DaggerfallUnity.Settings.TerrainDistance;
        }
Beispiel #8
0
 public override IObservable <IDisposable> Generate()
 {
     return(Observable.Using(
                () => TransportManager.ReserveConnection(configuration.Name, configuration),
                connection => Observable.Return(connection.Transport).Concat(Observable.Never(connection.Transport))));
 }
Beispiel #9
0
 static Server()
 {
     TransportManager.InitializeDefaultTransports();
 }
Beispiel #10
0
        private void GetAmountAndCapacity(string name, out int amount, out int capacity, out bool modded)
        {
            CitizenManager citizenManager;
            NetManager     netManager;
            AudioManager   audioManager;
            VehicleManager vehicleManager;

            switch (name)
            {
            case "Areas":
                GameAreaManager gameAreaManager = Singleton <GameAreaManager> .instance;
                amount   = gameAreaManager.m_areaCount;
                capacity = gameAreaManager.m_maxAreaCount;
                modded   = gameAreaManager.m_maxAreaCount > 9 ? true : false;
                break;

            case "Buildings":
                BuildingManager buildingManager = Singleton <BuildingManager> .instance;
                amount   = buildingManager.m_buildingCount;
                capacity = BuildingManager.MAX_BUILDING_COUNT;
                modded   = false;
                break;

            case "Citizens":
                citizenManager = Singleton <CitizenManager> .instance;
                amount         = citizenManager.m_citizenCount;
                capacity       = CitizenManager.MAX_CITIZEN_COUNT;
                modded         = false;
                break;

            case "Citizen Units":
                citizenManager = Singleton <CitizenManager> .instance;
                amount         = citizenManager.m_unitCount;
                capacity       = CitizenManager.MAX_UNIT_COUNT;
                modded         = false;
                break;

            case "Citizen Instances":
                citizenManager = Singleton <CitizenManager> .instance;
                amount         = citizenManager.m_instanceCount;
                capacity       = CitizenManager.MAX_INSTANCE_COUNT;
                modded         = false;
                break;

            case "Disasters":
                DisasterManager disasterManager = Singleton <DisasterManager> .instance;
                amount   = disasterManager.m_disasterCount;
                capacity = DisasterManager.MAX_DISASTER_COUNT;
                modded   = false;
                break;

            case "Districts":
                DistrictManager districtManager = Singleton <DistrictManager> .instance;
                amount   = districtManager.m_districtCount;
                capacity = DistrictManager.MAX_DISTRICT_COUNT;
                modded   = false;
                break;

            case "Events":
                EventManager eventManager = Singleton <EventManager> .instance;
                amount   = eventManager.m_eventCount;
                capacity = EventManager.MAX_EVENT_COUNT;
                modded   = false;
                break;

            case "Loans":
                EconomyManager economyManager = Singleton <EconomyManager> .instance;
                amount   = economyManager.CountLoans();
                capacity = EconomyManager.MAX_LOANS;
                modded   = false;
                break;

            case "Net Segments":
                netManager = Singleton <NetManager> .instance;
                amount     = netManager.m_segmentCount;
                capacity   = NetManager.MAX_SEGMENT_COUNT;
                modded     = false;
                break;

            case "Net Nodes":
                netManager = Singleton <NetManager> .instance;
                amount     = netManager.m_nodeCount;
                capacity   = NetManager.MAX_NODE_COUNT;
                modded     = false;
                break;

            case "Net Lanes":
                netManager = Singleton <NetManager> .instance;
                amount     = netManager.m_laneCount;
                capacity   = NetManager.MAX_LANE_COUNT;
                modded     = false;
                break;

            case "Path Units":
                PathManager pathManager = Singleton <PathManager> .instance;
                amount   = pathManager.m_pathUnitCount;
                capacity = PathManager.MAX_PATHUNIT_COUNT;
                modded   = false;
                break;

            case "Props":
                PropManager propManager = Singleton <PropManager> .instance;
                amount   = propManager.m_propCount;
                capacity = PropManager.MAX_PROP_COUNT;
                modded   = false;
                break;

            case "Radio Channels":
                audioManager = Singleton <AudioManager> .instance;
                amount       = audioManager.m_radioChannelCount;
                capacity     = AudioManager.MAX_RADIO_CHANNEL_COUNT;
                modded       = false;
                break;

            case "Radio Contents":
                audioManager = Singleton <AudioManager> .instance;
                amount       = audioManager.m_radioContentCount;
                capacity     = AudioManager.MAX_RADIO_CONTENT_COUNT;
                modded       = false;
                break;

            case "Transport Lines":
                TransportManager transportManager = Singleton <TransportManager> .instance;
                amount   = transportManager.m_lineCount;
                capacity = TransportManager.MAX_LINE_COUNT;
                modded   = false;
                break;

            case "Trees":
                TreeManager treeManager = Singleton <TreeManager> .instance;
                amount   = treeManager.m_treeCount;
                capacity = treeManager.m_trees.m_size > 262144 ? (int)treeManager.m_trees.m_size : TreeManager.MAX_TREE_COUNT;
                modded   = treeManager.m_trees.m_size > 262144 ? true : false;
                break;

            case "Vehicles":
                vehicleManager = Singleton <VehicleManager> .instance;
                amount         = vehicleManager.m_vehicleCount;
                capacity       = VehicleManager.MAX_VEHICLE_COUNT;
                modded         = false;
                break;

            case "Vehicles Parked":
                vehicleManager = Singleton <VehicleManager> .instance;
                amount         = vehicleManager.m_parkedCount;
                capacity       = VehicleManager.MAX_PARKED_COUNT;
                modded         = false;
                break;

            case "Zoned Blocks":
                ZoneManager zoneManager = Singleton <ZoneManager> .instance;
                amount   = zoneManager.m_blockCount;
                capacity = ZoneManager.MAX_BLOCK_COUNT;
                modded   = false;
                break;

            default:
                amount   = 0;
                capacity = 0;
                modded   = false;
                break;
            }
        }
Beispiel #11
0
        private void CreatePanel()
        {
            this.name             = "VehicleEditor";
            this.width            = 314f;
            this.height           = 303f;
            this.backgroundSprite = "MenuPanel2";
            this.canFocus         = true;
            this.isInteractive    = true;
            this.isVisible        = false;
            UILabel uiLabel = this.AddUIComponent <UILabel>();

            uiLabel.name          = "Title";
            uiLabel.text          = Localization.Get("VEHICLE_EDITOR_TITLE");
            uiLabel.textAlignment = UIHorizontalAlignment.Center;
            uiLabel.font          = UIHelper.Font;
            uiLabel.position      = new Vector3((float)((double)this.width / 2.0 - (double)uiLabel.width / 2.0), (float)((double)uiLabel.height / 2.0 - 20.0));
            UIButton uiButton = this.AddUIComponent <UIButton>();
            string   str1     = "SettingsButton";

            uiButton.name = str1;
            double num1 = 32.0;

            uiButton.width = (float)num1;
            double num2 = 32.0;

            uiButton.height = (float)num2;
            string str2 = "Options";

            uiButton.normalBgSprite = str2;
            string str3 = "OptionsHovered";

            uiButton.hoveredBgSprite = str3;
            string str4 = "OptionsPressed";

            uiButton.pressedBgSprite = str4;
            Vector3 vector3 = new Vector3(278f, 4f);

            uiButton.relativePosition = vector3;
            MouseEventHandler mouseEventHandler = new MouseEventHandler(this.OnSettingsButtonClick);

            uiButton.eventClick        += mouseEventHandler;
            this._containerPanel        = this.AddUIComponent <UIPanel>();
            this._containerPanel.name   = "ContainerPanel";
            this._containerPanel.anchor = UIAnchorStyle.Top | UIAnchorStyle.Left | UIAnchorStyle.Right;
            this._containerPanel.transform.localPosition = Vector3.zero;
            this._containerPanel.width               = 300f;
            this._containerPanel.height              = this.height - 60f;
            this._containerPanel.autoLayout          = true;
            this._containerPanel.autoLayoutDirection = LayoutDirection.Vertical;
            this._containerPanel.autoLayoutPadding   = new RectOffset(0, 0, 0, 1);
            this._containerPanel.autoLayoutStart     = LayoutStart.TopLeft;
            this._containerPanel.relativePosition    = new Vector3(6f, 50f);
            UIPanel uiPanel = this._containerPanel.AddUIComponent <UIPanel>();
            double  num3    = 70.0;

            uiPanel.width = (float)num3;
            double num4 = 13.0;

            uiPanel.height = (float)num4;
            TransportManager instance = Singleton <TransportManager> .instance;

            this.CreateTabButton(TransportInfo.TransportType.Bus);
            int num5 = 6;

            if (instance.TransportTypeLoaded((TransportInfo.TransportType)num5))
            {
                this.CreateTabButton(TransportInfo.TransportType.Tram);
            }
            this.CreateTabButton(TransportInfo.TransportType.Metro);
            this.CreateTabButton(TransportInfo.TransportType.Train);
            this.CreateTabButton(TransportInfo.TransportType.Ship);
            this.CreateTabButton(TransportInfo.TransportType.Airplane);
            int num6 = 5;

            if (instance.TransportTypeLoaded((TransportInfo.TransportType)num6))
            {
                this.CreateTabButton(TransportInfo.TransportType.Taxi);
            }
            this.CreateVehicleOptionsPanel();
        }
Beispiel #12
0
 public Form1()
 {
     transMgr = new TransportManager(portNum, true);
     InitializeComponent();
 }
        Vector3 getStation(ushort lineId, ushort stopId, ItemClass.SubService ss, out string stationName, out List <ushort> linhas, out string airport, out string harbor, out string taxiStand, out string regionalTrainStation, out string cableCarStation, out string prefix)
        {
            NetManager      nm = Singleton <NetManager> .instance;
            BuildingManager bm = Singleton <BuildingManager> .instance;
            NetNode         nn = nm.m_nodes.m_buffer[(int)stopId];

            stationName = TLMLineUtils.getStationName(stopId, lineId, ss, out ItemClass.Service servFound, out ItemClass.SubService subServFound, out prefix, out ushort buildingId, out NamingType namingType);

            //paradas proximas (metro e trem)
            TransportManager tm           = Singleton <TransportManager> .instance;
            TransportInfo    thisLineInfo = tm.m_lines.m_buffer[(int)nn.m_transportLine].Info;
            TransportLine    thisLine     = tm.m_lines.m_buffer[(int)nn.m_transportLine];

            linhas = new List <ushort>();
            Vector3 location = nn.m_position;

            if (buildingId > 0 && ss == subServFound)
            {
                location = Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingId].CalculateSidewalkPosition();
            }
            TLMLineUtils.GetNearLines(location, 120f, ref linhas);

            airport              = String.Empty;
            taxiStand            = String.Empty;
            harbor               = String.Empty;
            regionalTrainStation = String.Empty;
            cableCarStation      = string.Empty;

            if (TLMCW.getCurrentConfigBool(TLMCW.ConfigIndex.TRAIN_SHOW_IN_LINEAR_MAP))
            {
                ushort trainStation = TLMUtils.FindBuilding(location != Vector3.zero ? location : nn.m_position, 120f, ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportTrain, null, Building.Flags.None, Building.Flags.Untouchable | Building.Flags.Downgrading);

                if (trainStation > 0)
                {
                    InstanceID iid = default(InstanceID);
                    iid.Building         = trainStation;
                    regionalTrainStation = bm.GetBuildingName(trainStation, iid);
                }
            }

            if (TLMCW.getCurrentConfigBool(TLMCW.ConfigIndex.PLANE_SHOW_IN_LINEAR_MAP))
            {
                ushort airportId = TLMUtils.FindBuilding(location != Vector3.zero ? location : nn.m_position, 120f, ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportPlane, new TransferManager.TransferReason[] { TransferManager.TransferReason.PassengerPlane }, Building.Flags.None, Building.Flags.Untouchable);

                if (airportId > 0)
                {
                    InstanceID iid = default(InstanceID);
                    iid.Building = airportId;
                    airport      = bm.GetBuildingName(airportId, iid);
                }
            }

            if (TLMCW.getCurrentConfigBool(TLMCW.ConfigIndex.SHIP_SHOW_IN_LINEAR_MAP))
            {
                ushort harborId = TLMUtils.FindBuilding(location != Vector3.zero ? location : nn.m_position, 120f, ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportShip, new TransferManager.TransferReason[] { TransferManager.TransferReason.PassengerShip }, Building.Flags.None, Building.Flags.Untouchable);

                if (harborId > 0)
                {
                    InstanceID iid = default(InstanceID);
                    iid.Building = harborId;
                    harbor       = bm.GetBuildingName(harborId, iid);
                }
            }
            if (TLMCW.getCurrentConfigBool(TLMCW.ConfigIndex.TAXI_SHOW_IN_LINEAR_MAP))
            {
                ushort taxiId = TLMUtils.FindBuilding(location != Vector3.zero ? location : nn.m_position, 50f, ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportTaxi, null, Building.Flags.None, Building.Flags.Untouchable);

                if (taxiId > 0)
                {
                    InstanceID iid = default(InstanceID);
                    iid.Building = taxiId;
                    taxiStand    = bm.GetBuildingName(taxiId, iid);
                }
            }
            if (TLMCW.getCurrentConfigBool(TLMCW.ConfigIndex.CABLE_CAR_SHOW_IN_LINEAR_MAP))
            {
                ushort cableCarId = TLMUtils.FindBuilding(location != Vector3.zero ? location : nn.m_position, 120f, ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportCableCar, null, Building.Flags.None, Building.Flags.Untouchable);

                if (cableCarId > 0)
                {
                    InstanceID iid = default(InstanceID);
                    iid.Building    = cableCarId;
                    cableCarStation = bm.GetBuildingName(cableCarId, iid);
                }
            }


            return(location);
        }
        private float addStationToLinearMap(string stationPrefix, string stationName, Vector3 location, float offsetX, List <ushort> intersections,
                                            string airport, string harbor, string taxi, string regionalTrainStation, string cableCarStation,
                                            ushort stationNodeId, ItemClass.SubService ss, Color lineColor, bool simple)//, out float intersectionPanelHeight)
        {
            ushort           lineID = parent.CurrentSelectedId;
            TransportLine    t      = TLMController.instance.tm.m_lines.m_buffer[(int)lineID];
            TransportManager tm     = Singleton <TransportManager> .instance;

            if (stationName == null)
            {
                stationName = "???";
            }

            TLMUtils.createUIElement(out UIButton stationButton, lineStationsPanel.transform);
            stationButton.relativePosition = new Vector3(offsetX - 13, 15f);
            stationButton.width            = 20;
            stationButton.height           = 20;
            stationButton.color            = lineColor;
            stationButton.name             = "Station [" + stationName + "]";
            stationButton.atlas            = TLMController.taLineNumber;
            stationButton.tooltip          = stationName + "(id:" + stationNodeId + ")";
            TLMUtils.initButton(stationButton, true, "LinearStation");

            TLMUtils.createUIElement(out DroppableStationInfo dsi, stationButton.transform);
            dsi.nodeId = stationNodeId;
            dsi.name   = "DSI Station [" + stationName + "] - " + stationNodeId;

            TLMUtils.createUIElement(out UITextField stationLabel, stationButton.transform);
            stationLabel.autoSize            = true;
            stationLabel.width               = 220;
            stationLabel.height              = 20;
            stationLabel.useOutline          = true;
            stationLabel.pivot               = UIPivotPoint.MiddleLeft;
            stationLabel.horizontalAlignment = UIHorizontalAlignment.Left;
            stationLabel.verticalAlignment   = UIVerticalAlignment.Middle;
            stationLabel.name             = "Station [" + stationName + "] Name";
            stationLabel.relativePosition = new Vector3(23f, -13f);
            stationLabel.text             = (!string.IsNullOrEmpty(stationPrefix) ? stationPrefix.Trim() + " " : "") + stationName.Trim();
            stationLabel.textScale        = Math.Max(0.5f, Math.Min(1, 24f / stationLabel.text.Length));

            TLMUtils.uiTextFieldDefaults(stationLabel);
            stationLabel.color           = new Color(0.3f, 0.3f, 0.3f, 1);
            stationLabel.textColor       = Color.white;
            stationLabel.cursorWidth     = 2;
            stationLabel.cursorBlinkTime = 100;
            stationLabel.eventGotFocus  += (x, y) =>
            {
                stationLabel.text = TLMLineUtils.getStationName(stationNodeId, lineID, ss);
            };
            stationLabel.eventTextSubmitted += (x, y) =>
            {
                TLMLineUtils.setStopName(y, stationNodeId, lineID, () =>
                {
                    stationLabel.text = TLMLineUtils.getFullStationName(stationNodeId, lineID, ss);
                    m_autoName        = TLMLineUtils.calculateAutoName(lineID);
                    parent.OnRenameStationAction(autoName);
                });
            };

            stationButton.gameObject.transform.localPosition    = new Vector3(0, 0, 0);
            stationButton.gameObject.transform.localEulerAngles = new Vector3(0, 0, 45);
            stationButton.eventClick += (component, eventParam) =>
            {
                GameObject gameObject = GameObject.FindGameObjectWithTag("MainCamera");
                if (gameObject != null)
                {
                    var        cameraController = gameObject.GetComponent <CameraController>();
                    InstanceID x = default(InstanceID);
                    x.TransportLine = parent.CurrentSelectedId;
                    cameraController.SetTarget(x, location, false);
                    cameraController.ClearTarget();
                }
            };
            if (!simple)
            {
                if (!stationOffsetX.ContainsKey(stationNodeId))
                {
                    stationOffsetX.Add(stationNodeId, offsetX);
                }
                if (showIntersections)
                {
                    var     otherLinesIntersections = TLMLineUtils.SortLines(intersections, t);
                    UILabel distance          = null;
                    int     intersectionCount = otherLinesIntersections.Count + (airport != string.Empty ? 1 : 0) + (taxi != string.Empty ? 1 : 0) + (harbor != string.Empty ? 1 : 0) + (regionalTrainStation != string.Empty ? 1 : 0) + (cableCarStation != string.Empty ? 1 : 0);

                    if ((TLMSingleton.showDistanceInLinearMap || parent.ForceShowStopsDistances) && offsetX > 0)
                    {
                        NetSegment seg = Singleton <NetManager> .instance.m_segments.m_buffer[Singleton <NetManager> .instance.m_nodes.m_buffer[stationNodeId].m_segment0];
                        if (seg.m_endNode != stationNodeId)
                        {
                            seg = Singleton <NetManager> .instance.m_segments.m_buffer[Singleton <NetManager> .instance.m_nodes.m_buffer[stationNodeId].m_segment1];
                        }
                        if (seg.m_endNode != stationNodeId)
                        {
                            seg = Singleton <NetManager> .instance.m_segments.m_buffer[Singleton <NetManager> .instance.m_nodes.m_buffer[stationNodeId].m_segment2];
                        }
                        if (seg.m_endNode != stationNodeId)
                        {
                            seg = Singleton <NetManager> .instance.m_segments.m_buffer[Singleton <NetManager> .instance.m_nodes.m_buffer[stationNodeId].m_segment3];
                        }
                        if (seg.m_endNode != stationNodeId)
                        {
                            seg = Singleton <NetManager> .instance.m_segments.m_buffer[Singleton <NetManager> .instance.m_nodes.m_buffer[stationNodeId].m_segment4];
                        }
                        if (seg.m_endNode != stationNodeId)
                        {
                            seg = Singleton <NetManager> .instance.m_segments.m_buffer[Singleton <NetManager> .instance.m_nodes.m_buffer[stationNodeId].m_segment5];
                        }
                        if (seg.m_endNode != stationNodeId)
                        {
                            seg = Singleton <NetManager> .instance.m_segments.m_buffer[Singleton <NetManager> .instance.m_nodes.m_buffer[stationNodeId].m_segment6];
                        }
                        if (seg.m_endNode != stationNodeId)
                        {
                            seg = Singleton <NetManager> .instance.m_segments.m_buffer[Singleton <NetManager> .instance.m_nodes.m_buffer[stationNodeId].m_segment7];
                        }
                        if (seg.m_endNode != stationNodeId)
                        {
                            seg = default(NetSegment);
                        }
                        TLMUtils.createUIElement(out UIPanel distContainer, stationButton.transform);
                        distContainer.size             = new Vector2(0, 0);
                        distContainer.relativePosition = new Vector3(0, 0, 0);
                        TLMUtils.createUIElement(out distance, distContainer.transform);
                        distance.autoSize   = false;
                        distance.useOutline = true;
                        if (seg.Equals(default(NetSegment)))
                        {
                            distance.text  = "???";
                            distance.color = Color.red;
                        }
                        else
                        {
                            distance.text = (int)seg.m_averageLength + "m";
                        }
                        distance.textScale         = 0.7f;
                        distance.textAlignment     = UIHorizontalAlignment.Center;
                        distance.verticalAlignment = UIVerticalAlignment.Middle;
                        distance.name                       = "dist.";
                        distance.font                       = UIHelperExtension.defaultFontCheckbox;
                        distance.width                      = 50f;
                        distance.height                     = 50;
                        distance.relativePosition           = new Vector3(-42, 0);
                        distance.transform.localEulerAngles = new Vector3(0, 0, 45);
                        distance.isInteractive              = false;
                    }

                    if (intersectionCount > 0)
                    {
                        TLMUtils.createUIElement(out UIPanel intersectionsPanel, stationButton.transform);
                        intersectionsPanel.autoSize                  = false;
                        intersectionsPanel.autoLayout                = false;
                        intersectionsPanel.autoLayoutStart           = LayoutStart.TopLeft;
                        intersectionsPanel.autoLayoutDirection       = LayoutDirection.Horizontal;
                        intersectionsPanel.relativePosition          = new Vector3(-20, 10);
                        intersectionsPanel.wrapLayout                = false;
                        intersectionsPanel.autoFitChildrenVertically = true;

                        TLMLineUtils.PrintIntersections(airport, harbor, taxi, regionalTrainStation, cableCarStation, intersectionsPanel, otherLinesIntersections);
                        intersectionsPanel.autoLayout = true;
                        intersectionsPanel.wrapLayout = true;
                        intersectionsPanel.width      = 55;
                        //
                        return(42f);
                    }
                    else
                    {
                        TLMUtils.initButton(stationButton, true, "LinearHalfStation");
                        if (offsetX == 0)
                        {
                            stationButton.relativePosition = new Vector3(offsetX - 13, 15f);
                            return(31f);
                        }
                        else if (distance == null)
                        {
                            stationButton.relativePosition = new Vector3(offsetX - 23, 15f);
                            return(21f);
                        }
                        else
                        {
                            return(42f);
                        }
                    }
                }
                else if (showExtraStopInfo)
                {
                    float normalWidth = 42.5f;

                    NetNode stopNode = Singleton <NetManager> .instance.m_nodes.m_buffer[(int)stationNodeId];

                    TLMLineUtils.GetQuantityPassengerWaiting(stationNodeId, out int residents, out int tourists, out int ttb);

                    TLMUtils.createUIElement(out UIPanel stationInfoStatsPanel, stationButton.transform);
                    stationInfoStatsPanel.autoSize   = false;
                    stationInfoStatsPanel.autoLayout = false;
                    stationInfoStatsPanel.autoFitChildrenVertically = true;
                    stationInfoStatsPanel.autoLayoutStart           = LayoutStart.TopLeft;
                    stationInfoStatsPanel.autoLayoutDirection       = LayoutDirection.Horizontal;
                    stationInfoStatsPanel.relativePosition          = new Vector3(-20, 10);
                    stationInfoStatsPanel.autoLayout = true;
                    stationInfoStatsPanel.wrapLayout = true;
                    stationInfoStatsPanel.width      = normalWidth;

                    TLMUtils.createUIElement(out UILabel residentsWaiting, stationInfoStatsPanel.transform);
                    residentsWaiting.autoSize         = false;
                    residentsWaiting.useOutline       = true;
                    residentsWaiting.text             = residents.ToString();
                    residentsWaiting.tooltipLocaleID  = "TLM_RESIDENTS_WAITING";
                    residentsWaiting.backgroundSprite = "EmptySprite";
                    residentsWaiting.color            = new Color32(0x12, 0x68, 0x34, 255);
                    residentsWaiting.width            = normalWidth;
                    residentsWaiting.padding          = new RectOffset(0, 0, 4, 2);
                    residentsWaiting.height           = 20;
                    residentsWaiting.textScale        = 0.7f;
                    residentsWaiting.textAlignment    = UIHorizontalAlignment.Center;
                    residentCounters[stationNodeId]   = residentsWaiting;

                    TLMUtils.createUIElement(out UILabel touristsWaiting, stationInfoStatsPanel.transform);
                    touristsWaiting.autoSize         = false;
                    touristsWaiting.text             = tourists.ToString();
                    touristsWaiting.tooltipLocaleID  = "TLM_TOURISTS_WAITING";
                    touristsWaiting.useOutline       = true;
                    touristsWaiting.width            = normalWidth;
                    touristsWaiting.height           = 20;
                    touristsWaiting.padding          = new RectOffset(0, 0, 4, 2);
                    touristsWaiting.textScale        = 0.7f;
                    touristsWaiting.backgroundSprite = "EmptySprite";
                    touristsWaiting.color            = new Color32(0x1f, 0x25, 0x68, 255);
                    touristsWaiting.textAlignment    = UIHorizontalAlignment.Center;
                    touristCounters[stationNodeId]   = touristsWaiting;

                    TLMUtils.createUIElement(out UILabel timeTilBored, stationInfoStatsPanel.transform);
                    timeTilBored.autoSize         = false;
                    timeTilBored.text             = tourists.ToString();
                    timeTilBored.tooltipLocaleID  = "TLM_TIME_TIL_BORED";
                    timeTilBored.useOutline       = true;
                    timeTilBored.width            = normalWidth;
                    timeTilBored.height           = 20;
                    timeTilBored.padding          = new RectOffset(0, 0, 4, 2);
                    timeTilBored.textScale        = 0.7f;
                    timeTilBored.backgroundSprite = "EmptySprite";
                    timeTilBored.color            = new Color32(0x1f, 0x25, 0x68, 255);
                    timeTilBored.textAlignment    = UIHorizontalAlignment.Center;
                    ttbTimers[stationNodeId]      = timeTilBored;
                    //
                    return(normalWidth);
                }
                else
                {
                    return(30f);
                }
            }
            else
            {
                return(30f);
            }
        }
        void ApplyStartSettings()
        {
            // Resolution
            Screen.SetResolution(
                DaggerfallUnity.Settings.ResolutionWidth,
                DaggerfallUnity.Settings.ResolutionHeight,
                DaggerfallUnity.Settings.Fullscreen);

            // Camera settings
            GameObject cameraObject = GameObject.FindGameObjectWithTag("MainCamera");

            if (cameraObject)
            {
                // Set camera FOV
                Camera camera = cameraObject.GetComponent <Camera>();
                if (camera)
                {
                    camera.fieldOfView = DaggerfallUnity.Settings.FieldOfView;
                }

                // Set mouse look
                PlayerMouseLook mouseLook = cameraObject.GetComponent <PlayerMouseLook>();
                if (mouseLook)
                {
                    mouseLook.invertMouseY = DaggerfallUnity.Settings.InvertMouseVertical;
                }

                // Set mouse look smoothing
                if (mouseLook)
                {
                    mouseLook.enableSmoothing = DaggerfallUnity.Settings.MouseLookSmoothing;
                }

                // Set mouse look sensitivity
                if (mouseLook)
                {
                    mouseLook.sensitivityScale = DaggerfallUnity.Settings.MouseLookSensitivity;
                }

                // Set rendering path
                if (DaggerfallUnity.Settings.UseLegacyDeferred)
                {
                    camera.renderingPath = RenderingPath.DeferredLighting;
                }
            }

            // Shadow Resoltion Mode
            switch (DaggerfallUnity.Settings.ShadowResolutionMode)
            {
            case 0:
                QualitySettings.shadowResolution = ShadowResolution.Low;
                break;

            case 1:
            default:
                QualitySettings.shadowResolution = ShadowResolution.Medium;
                break;

            case 2:
                QualitySettings.shadowResolution = ShadowResolution.High;
                break;

            case 3:
                QualitySettings.shadowResolution = ShadowResolution.VeryHigh;
                break;
            }

            // VSync settings
            if (DaggerfallUnity.Settings.VSync)
            {
                QualitySettings.vSyncCount = 1;
            }
            else
            {
                QualitySettings.vSyncCount = 0;
            }

            // Filter settings
            DaggerfallUnity.Instance.MaterialReader.MainFilterMode         = (FilterMode)DaggerfallUnity.Settings.MainFilterMode;
            DaggerfallUnity.Instance.MaterialReader.CompressModdedTextures = DaggerfallUnity.Settings.CompressModdedTextures;

            // HUD settings
            DaggerfallHUD hud = DaggerfallUI.Instance.DaggerfallHUD;

            if (hud != null)                                              //null at startup
            {
                hud.ShowCrosshair = DaggerfallUnity.Settings.Crosshair;
            }

            // Weapon swing settings
            WeaponManager weaponManager = GameManager.Instance.WeaponManager;

            weaponManager.AttackThreshold = DaggerfallUnity.Settings.WeaponAttackThreshold;
            TransportManager transportManager = GameManager.Instance.TransportManager;

            // Weapon hand settings
            // Only supporting left-hand rendering for now
            // More handedness options may be added later
            if (DaggerfallUnity.Settings.Handedness == 1)
            {
                weaponManager.ScreenWeapon.FlipHorizontal = true;
            }

            // GodMode setting
            PlayerEntity playerEntity = FindPlayerEntity();

            playerEntity.GodMode = GodMode;

            // Enable/disable videos
            DaggerfallUI.Instance.enableVideos = EnableVideos;

            // Streaming world terrain distance
            GameManager.Instance.StreamingWorld.TerrainDistance = DaggerfallUnity.Settings.TerrainDistance;
        }
        private bool GetStopPosition(TransportInfo info, ushort segment, ushort building, ushort firstStop, ref Vector3 hitPos, out bool fixedPlatform)
        {
            //begin mod(+): detect key
            bool alternateMode = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);
            //end mod

            NetManager       instance1 = Singleton <NetManager> .instance;
            BuildingManager  instance2 = Singleton <BuildingManager> .instance;
            TransportManager instance3 = Singleton <TransportManager> .instance;

            fixedPlatform = false;
            if (info.m_transportType == TransportInfo.TransportType.Pedestrian)
            {
                Vector3 position   = Vector3.zero;
                float   laneOffset = 0.0f;
                uint    laneID     = 0;
                int     laneIndex;
                if ((int)segment != 0 && !instance1.m_segments.m_buffer[(int)segment].GetClosestLanePosition(hitPos, NetInfo.LaneType.Pedestrian, VehicleInfo.VehicleType.None, VehicleInfo.VehicleType.None, out position, out laneID, out laneIndex, out laneOffset))
                {
                    laneID = 0U;
                    if ((instance1.m_segments.m_buffer[(int)segment].m_flags & NetSegment.Flags.Untouchable) != NetSegment.Flags.None && (int)building == 0)
                    {
                        building = NetSegment.FindOwnerBuilding(segment, 363f);
                    }
                }
                if ((int)building != 0)
                {
                    if (instance2.m_buildings.m_buffer[(int)building].Info.m_hasPedestrianPaths)
                    {
                        laneID = instance2.m_buildings.m_buffer[(int)building].FindLane(NetInfo.LaneType.Pedestrian, VehicleInfo.VehicleType.None, hitPos, out position, out laneOffset);
                    }
                    if ((int)laneID == 0)
                    {
                        Vector3 sidewalkPosition = instance2.m_buildings.m_buffer[(int)building].CalculateSidewalkPosition();
                        laneID = instance2.m_buildings.m_buffer[(int)building].FindAccessLane(NetInfo.LaneType.Pedestrian, VehicleInfo.VehicleType.None, sidewalkPosition, out position, out laneOffset);
                    }
                }
                if ((int)laneID == 0)
                {
                    return(false);
                }
                if ((double)laneOffset < 0.00392156885936856)
                {
                    laneOffset = 0.003921569f;
                    position   = instance1.m_lanes.m_buffer[laneID].CalculatePosition(laneOffset);
                }
                else if ((double)laneOffset > 0.996078431606293)
                {
                    laneOffset = 0.9960784f;
                    position   = instance1.m_lanes.m_buffer[laneID].CalculatePosition(laneOffset);
                }
                if ((int)this.m_line != 0)
                {
                    firstStop = instance3.m_lines.m_buffer[(int)this.m_line].m_stops;
                    ushort stop = firstStop;
                    int    num  = 0;
                    while ((int)stop != 0)
                    {
                        if ((int)instance1.m_nodes.m_buffer[(int)stop].m_lane == (int)laneID)
                        {
                            hitPos        = instance1.m_nodes.m_buffer[(int)stop].m_position;
                            fixedPlatform = true;
                            return(true);
                        }
                        stop = TransportLine.GetNextStop(stop);
                        if ((int)stop != (int)firstStop)
                        {
                            if (++num >= 32768)
                            {
                                CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!\n" + System.Environment.StackTrace);

                                break;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                hitPos        = position;
                fixedPlatform = true;
                return(true);
            }
            if ((int)segment != 0)
            {
                if ((instance1.m_segments.m_buffer[(int)segment].m_flags & NetSegment.Flags.Untouchable) != NetSegment.Flags.None)
                {
                    building = NetSegment.FindOwnerBuilding(segment, 363f);
                    if ((int)building != 0)
                    {
                        BuildingInfo  info1 = instance2.m_buildings.m_buffer[(int)building].Info;
                        TransportInfo transportLineInfo1 = info1.m_buildingAI.GetTransportLineInfo();
                        TransportInfo transportLineInfo2 = info1.m_buildingAI.GetSecondaryTransportLineInfo();
                        //begin mod(*): check for !alternateMode
                        if (!alternateMode && transportLineInfo1 != null && transportLineInfo1.m_transportType == info.m_transportType || !alternateMode && transportLineInfo2 != null && transportLineInfo2.m_transportType == info.m_transportType)
                        {
                            //end mod
                            segment = (ushort)0;
                        }
                        else
                        {
                            building = (ushort)0;
                        }
                    }
                }
                Vector3 position1;
                uint    laneID1;
                int     laneIndex1;
                float   laneOffset1;
                if ((int)segment != 0 && instance1.m_segments.m_buffer[(int)segment].GetClosestLanePosition(hitPos, NetInfo.LaneType.Pedestrian, VehicleInfo.VehicleType.None, info.m_vehicleType, out position1, out laneID1, out laneIndex1, out laneOffset1))
                {
                    if (info.m_vehicleType == VehicleInfo.VehicleType.None)
                    {
                        NetLane.Flags flags1 = (NetLane.Flags)((int)instance1.m_lanes.m_buffer[laneID1].m_flags & 768);
                        NetLane.Flags flags2 = info.m_stopFlag;
                        NetInfo       info1  = instance1.m_segments.m_buffer[(int)segment].Info;
                        if (info1.m_vehicleTypes != VehicleInfo.VehicleType.None)
                        {
                            flags2 = NetLane.Flags.None;
                        }
                        if (flags1 != NetLane.Flags.None && flags2 != NetLane.Flags.None && flags1 != flags2)
                        {
                            return(false);
                        }
                        float stopOffset = info1.m_lanes[laneIndex1].m_stopOffset;
                        if ((instance1.m_segments.m_buffer[(int)segment].m_flags & NetSegment.Flags.Invert) != NetSegment.Flags.None)
                        {
                            stopOffset = -stopOffset;
                        }
                        Vector3 direction;
                        instance1.m_lanes.m_buffer[laneID1].CalculateStopPositionAndDirection(0.5019608f, stopOffset, out hitPos, out direction);
                        fixedPlatform = true;
                        return(true);
                    }
                    Vector3 position2;
                    uint    laneID2;
                    int     laneIndex2;
                    float   laneOffset2;
                    if (instance1.m_segments.m_buffer[(int)segment].GetClosestLanePosition(position1, NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle, info.m_vehicleType, out position2, out laneID2, out laneIndex2, out laneOffset2))
                    {
                        NetLane.Flags flags = (NetLane.Flags)((int)instance1.m_lanes.m_buffer[laneID1].m_flags & 768);
                        if (flags != NetLane.Flags.None && info.m_stopFlag != NetLane.Flags.None && flags != info.m_stopFlag)
                        {
                            return(false);
                        }
                        float stopOffset = instance1.m_segments.m_buffer[(int)segment].Info.m_lanes[laneIndex2].m_stopOffset;
                        if ((instance1.m_segments.m_buffer[(int)segment].m_flags & NetSegment.Flags.Invert) != NetSegment.Flags.None)
                        {
                            stopOffset = -stopOffset;
                        }
                        Vector3 direction;
                        instance1.m_lanes.m_buffer[laneID2].CalculateStopPositionAndDirection(0.5019608f, stopOffset, out hitPos, out direction);
                        fixedPlatform = true;
                        return(true);
                    }
                }
            }
            //begin mod(*): check for !alternateMode
            if (!alternateMode && (int)building != 0)
            {
                //end mod
                ushort num1 = 0;
                if ((instance2.m_buildings.m_buffer[(int)building].m_flags & Building.Flags.Untouchable) != Building.Flags.None)
                {
                    num1 = Building.FindParentBuilding(building);
                }
                if (this.m_building != 0 && (int)firstStop != 0 && (this.m_building == (int)building || this.m_building == (int)num1))
                {
                    hitPos = instance1.m_nodes.m_buffer[(int)firstStop].m_position;
                    return(true);
                }
                VehicleInfo randomVehicleInfo = Singleton <VehicleManager> .instance.GetRandomVehicleInfo(ref Singleton <SimulationManager> .instance.m_randomizer, info.m_class.m_service, info.m_class.m_subService, info.m_class.m_level);

                if (randomVehicleInfo != null)
                {
                    BuildingInfo  info1 = instance2.m_buildings.m_buffer[(int)building].Info;
                    TransportInfo transportLineInfo1 = info1.m_buildingAI.GetTransportLineInfo();
                    if (transportLineInfo1 == null && (int)num1 != 0)
                    {
                        building           = num1;
                        info1              = instance2.m_buildings.m_buffer[(int)building].Info;
                        transportLineInfo1 = info1.m_buildingAI.GetTransportLineInfo();
                    }
                    TransportInfo transportLineInfo2 = info1.m_buildingAI.GetSecondaryTransportLineInfo();
                    if (transportLineInfo1 != null && transportLineInfo1.m_transportType == info.m_transportType || transportLineInfo2 != null && transportLineInfo2.m_transportType == info.m_transportType)
                    {
                        Vector3 vector3 = Vector3.zero;
                        int     num2    = 1000000;
                        for (int index = 0; index < 12; ++index)
                        {
                            Randomizer randomizer = new Randomizer((ulong)index);
                            Vector3    position;
                            Vector3    target;
                            info1.m_buildingAI.CalculateSpawnPosition(building, ref instance2.m_buildings.m_buffer[(int)building], ref randomizer, randomVehicleInfo, out position, out target);
                            int num3 = 0;
                            if (info.m_avoidSameStopPlatform)
                            {
                                num3 = this.GetLineCount(position, target - position, info.m_transportType);
                            }
                            if (num3 < num2)
                            {
                                vector3 = position;
                                num2    = num3;
                            }
                            else if (num3 == num2 && (double)Vector3.SqrMagnitude(position - hitPos) < (double)Vector3.SqrMagnitude(vector3 - hitPos))
                            {
                                vector3 = position;
                            }
                        }
                        if ((int)firstStop != 0)
                        {
                            Vector3 position = instance1.m_nodes.m_buffer[(int)firstStop].m_position;
                            if ((double)Vector3.SqrMagnitude(position - vector3) < 16384.0)
                            {
                                uint lane = instance1.m_nodes.m_buffer[(int)firstStop].m_lane;
                                if ((int)lane != 0)
                                {
                                    ushort segment1 = instance1.m_lanes.m_buffer[lane].m_segment;
                                    if ((int)segment1 != 0 && (instance1.m_segments.m_buffer[(int)segment1].m_flags & NetSegment.Flags.Untouchable) != NetSegment.Flags.None)
                                    {
                                        ushort ownerBuilding = NetSegment.FindOwnerBuilding(segment1, 363f);
                                        if ((int)building == (int)ownerBuilding)
                                        {
                                            hitPos = position;
                                            return(true);
                                        }
                                    }
                                }
                            }
                        }
                        hitPos = vector3;
                        return(num2 != 1000000);
                    }
                }
            }
            return(false);
        }
Beispiel #17
0
 //constructor
 public HeartBeatManager(string mHeartBeatMsg, TransportManager mTransMgr)
 {
     this.heartBeatMsg = mHeartBeatMsg;
     this.transMgr     = mTransMgr;
     this.hrtBtTimer   = new Timer();
 }
Beispiel #18
0
        private void UnloadPassengers(ushort vehicleID, ref Vehicle data, ushort currentStop, ushort nextStop)
        {
            if ((int)currentStop == 0)
            {
                return;
            }
            VehicleManager   instance1 = Singleton <VehicleManager> .instance;
            NetManager       instance2 = Singleton <NetManager> .instance;
            TransportManager instance3 = Singleton <TransportManager> .instance;
            Vector3          position  = instance2.m_nodes.m_buffer[(int)currentStop].m_position;
            Vector3          targetPos = Vector3.zero;

            if ((int)nextStop != 0)
            {
                targetPos = instance2.m_nodes.m_buffer[(int)nextStop].m_position;
            }
            int serviceCounter = 0;
            int num            = 0;

            //begin mod (+): calculate passenger count before unloading passengers
            ushort vehicleID1 = vehicleID;

            GetBufferStatus(vehicleID1, ref instance1.m_vehicles.m_buffer[(int)vehicleID1], out string localeKey,
                            out int bufferStatusBefore, out int max);
            //end mod

            while ((int)vehicleID != 0)
            {
                if ((int)data.m_transportLine != 0)
                {
                    BusAI.TransportArriveAtTarget(vehicleID, ref instance1.m_vehicles.m_buffer[(int)vehicleID],
                                                  position, targetPos, ref serviceCounter,
                                                  ref instance3.m_lines.m_buffer[(int)data.m_transportLine].m_passengers, (int)nextStop == 0);
                }
                else
                {
                    BusAI.TransportArriveAtTarget(vehicleID, ref instance1.m_vehicles.m_buffer[(int)vehicleID],
                                                  position, targetPos, ref serviceCounter,
                                                  ref instance3.m_passengers[(int)this.m_transportInfo.m_transportType], (int)nextStop == 0);
                }
                vehicleID = instance1.m_vehicles.m_buffer[(int)vehicleID].m_trailingVehicle;
                if (++num > VehicleManagerMod.MaxVehicleCount)
                {
                    CODebugBase <LogChannel> .Error(LogChannel.Core,
                                                    "Invalid list detected!\n" + System.Environment.StackTrace);

                    break;
                }
            }
            Singleton <StatisticsManager> .instance.Acquire <StatisticArray>(StatisticType.PassengerCount)
            .Acquire <StatisticInt32>((int)this.m_transportInfo.m_transportType, 10)
            .Add(serviceCounter);

            serviceCounter += (int)instance2.m_nodes.m_buffer[(int)currentStop].m_tempCounter;
            instance2.m_nodes.m_buffer[(int)currentStop].m_tempCounter =
                (ushort)Mathf.Min(serviceCounter, (int)ushort.MaxValue);

            //begin mod (+): calculate passenger count after unloading passengers
            GetBufferStatus(vehicleID1, ref instance1.m_vehicles.m_buffer[(int)vehicleID1], out localeKey,
                            out int bufferStatusAfter, out max);
            int diff = bufferStatusBefore - bufferStatusAfter;

            VehicleManagerMod.m_cachedVehicleData[(int)vehicleID1].LastStopGonePassengers = diff;
            VehicleManagerMod.m_cachedVehicleData[(int)vehicleID1].CurrentStop            = currentStop;
            NetManagerMod.m_cachedNodeData[(int)currentStop].PassengersOut += diff;
            //end mod
        }
        private void CreatePanel()
        {
            this.name             = "VehicleEditor";
            this.width            = 314f;
            this.height           = 394f;
            this.backgroundSprite = "MenuPanel2";
            this.canFocus         = true;
            this.isInteractive    = true;
            this.isVisible        = false;
            UILabel uiLabel = this.AddUIComponent <UILabel>();

            uiLabel.name          = "Title";
            uiLabel.text          = Localization.Get("VEHICLE_EDITOR_TITLE");
            uiLabel.textAlignment = UIHorizontalAlignment.Center;
            uiLabel.font          = UIUtils.Font;
            uiLabel.position      = new Vector3((float)((double)this.width / 2.0 - (double)uiLabel.width / 2.0), (float)((double)uiLabel.height / 2.0 - 20.0));

            this._containerPanel        = this.AddUIComponent <UIPanel>();
            this._containerPanel.name   = "ContainerPanel";
            this._containerPanel.anchor = UIAnchorStyle.Top | UIAnchorStyle.Left | UIAnchorStyle.Right;
            this._containerPanel.transform.localPosition = Vector3.zero;
            this._containerPanel.width               = 300f;
            this._containerPanel.height              = this.height - 60f;
            this._containerPanel.autoLayout          = true;
            this._containerPanel.autoLayoutDirection = LayoutDirection.Vertical;
            this._containerPanel.autoLayoutPadding   = new RectOffset(0, 0, 0, 1);
            this._containerPanel.autoLayoutStart     = LayoutStart.TopLeft;
            this._containerPanel.relativePosition    = new Vector3(6f, 50f);
            UIPanel uiPanel = this._containerPanel.AddUIComponent <UIPanel>();
            double  num3    = 70.0;

            uiPanel.width = (float)num3;
            double num4 = 13.0;

            uiPanel.height = (float)num4;
            TransportManager instance = Singleton <TransportManager> .instance;

            this.CreateTabButton(TransportInfo.TransportType.Bus);
            if (instance.TransportTypeLoaded(TransportInfo.TransportType.Trolleybus))
            {
                this.CreateTabButton(TransportInfo.TransportType.Trolleybus);
            }
            if (instance.TransportTypeLoaded(TransportInfo.TransportType.Tram))
            {
                this.CreateTabButton(TransportInfo.TransportType.Tram);
            }
            this.CreateTabButton(TransportInfo.TransportType.Metro);
            this.CreateTabButton(TransportInfo.TransportType.Train);
            this.CreateTabButton(TransportInfo.TransportType.Ship);
            this.CreateTabButton(TransportInfo.TransportType.Airplane);
            if (instance.TransportTypeLoaded(TransportInfo.TransportType.Monorail))
            {
                this.CreateTabButton(TransportInfo.TransportType.Monorail);
            }
            if (instance.TransportTypeLoaded(TransportInfo.TransportType.CableCar))
            {
                this.CreateTabButton(TransportInfo.TransportType.CableCar);
            }
            if (instance.TransportTypeLoaded(TransportInfo.TransportType.Taxi))
            {
                this.CreateTabButton(TransportInfo.TransportType.Taxi);
            }
            this.CreateVehicleOptionsPanel();
        }
Beispiel #20
0
        // from TransportLine

        public static bool UpdateMeshData(ref TransportLine transportLine, ushort lineID)
        {
            //return transportLine.UpdateMeshData(lineID);
            bool             flag      = true;
            int              num       = 0;
            int              num2      = 0;
            int              num3      = 0;
            float            num4      = 0f;
            TransportManager instance  = Singleton <TransportManager> .instance;
            NetManager       instance2 = Singleton <NetManager> .instance;
            PathManager      instance3 = Singleton <PathManager> .instance;
            ushort           stops     = transportLine.m_stops;
            ushort           num5      = stops;
            int              num6      = 0;

            while (num5 != 0)
            {
                ushort num7 = 0;
                for (int i = 0; i < 8; i++)
                {
                    ushort segment = instance2.m_nodes.m_buffer[(int)num5].GetSegment(i);
                    if (segment != 0 && instance2.m_segments.m_buffer[(int)segment].m_startNode == num5)
                    {
                        uint path = instance2.m_segments.m_buffer[(int)segment].m_path;
                        if (path != 0u)
                        {
                            byte pathFindFlags = instance3.m_pathUnits.m_buffer[(int)((UIntPtr)path)].m_pathFindFlags;
                            if ((pathFindFlags & 4) != 0)
                            {
                                if (!TransportLine.CalculatePathSegmentCount(path, ref num2, ref num3, ref num4))
                                {
                                    TransportInfo info = transportLine.Info;
                                    BusTransportLineAI.StartPathFind(segment, ref instance2.m_segments.m_buffer[(int)segment], info.m_netService, info.m_vehicleType, (transportLine.m_flags & TransportLine.Flags.Temporary) != TransportLine.Flags.None);
                                    flag = false;
                                }
                            }
                            else if ((pathFindFlags & 8) == 0)
                            {
                                flag = false;
                            }
                        }
                        num7 = instance2.m_segments.m_buffer[(int)segment].m_endNode;
                        break;
                    }
                }
                num++;
                num2++;
                num5 = num7;
                if (num5 == stops)
                {
                    break;
                }
                if (!flag)
                {
                    break;
                }
                if (++num6 >= 32768)
                {
                    CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);

                    break;
                }
            }
            if (!flag)
            {
                return(flag);
            }
            RenderGroup.MeshData meshData = new RenderGroup.MeshData();
            meshData.m_vertices  = new Vector3[num2 * 8];
            meshData.m_normals   = new Vector3[num2 * 8];
            meshData.m_tangents  = new Vector4[num2 * 8];
            meshData.m_uvs       = new Vector2[num2 * 8];
            meshData.m_uvs1      = new Vector2[num2 * 8];
            meshData.m_colors    = new Color32[num2 * 8];
            meshData.m_triangles = new int[num2 * 30];
            TransportManager.LineSegment[] array = new TransportManager.LineSegment[num];
            Bezier3[] array2      = new Bezier3[num3];
            int       num8        = 0;
            int       num9        = 0;
            int       num10       = 0;
            float     lengthScale = Mathf.Ceil(num4 / 64f) / num4;
            float     num11       = 0f;

            num5 = stops;
            Vector3 vector  = new Vector3(100000f, 100000f, 100000f);
            Vector3 vector2 = new Vector3(-100000f, -100000f, -100000f);

            num6 = 0;
            while (num5 != 0)
            {
                ushort num12 = 0;
                for (int j = 0; j < 8; j++)
                {
                    ushort segment2 = instance2.m_nodes.m_buffer[(int)num5].GetSegment(j);
                    if (segment2 != 0 && instance2.m_segments.m_buffer[(int)segment2].m_startNode == num5)
                    {
                        uint path2 = instance2.m_segments.m_buffer[(int)segment2].m_path;
                        if (path2 != 0u && (instance3.m_pathUnits.m_buffer[(int)((UIntPtr)path2)].m_pathFindFlags & 4) != 0)
                        {
                            array[num8].m_curveStart = num10;
                            Vector3 vector3;
                            Vector3 vector4;
                            TransportLine.FillPathSegments(path2, meshData, array2, ref num9, ref num10, ref num11, lengthScale, out vector3, out vector4);
                            vector  = Vector3.Min(vector, vector3);
                            vector2 = Vector3.Max(vector2, vector4);
                            array[num8].m_bounds.SetMinMax(vector3, vector4);
                            array[num8].m_curveEnd = num10;
                        }
                        num12 = instance2.m_segments.m_buffer[(int)segment2].m_endNode;
                        break;
                    }
                }
                TransportLine.FillPathNode(instance2.m_nodes.m_buffer[(int)num5].m_position, meshData, num9);
                num8++;
                num9++;
                num5 = num12;
                if (num5 == stops)
                {
                    break;
                }
                if (++num6 >= 32768)
                {
                    CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);

                    break;
                }
            }
            while (!Monitor.TryEnter(instance.m_lineMeshData, SimulationManager.SYNCHRONIZE_TIMEOUT))
            {
            }
            try
            {
                instance.m_lineMeshData[(int)lineID] = meshData;
                instance.m_lineSegments[(int)lineID] = array;
                instance.m_lineCurves[(int)lineID]   = array2;
                transportLine.m_bounds.SetMinMax(vector, vector2);
            }
            finally
            {
                Monitor.Exit(instance.m_lineMeshData);
            }

            return(flag);
        }
 private ITransport GetTransport(HttpContextBase context)
 {
     return(TransportManager.GetTransport(context) ??
            new LongPollingTransport(context, _jsonStringifier));
 }
Beispiel #22
0
 private ITransport GetTransport(HostContext context)
 {
     return(TransportManager.GetTransport(context) ??
            new LongPollingTransport(context, _jsonSerializer));
 }
Beispiel #23
0
        public static bool TryLoadData(out LineData[] data)
        {
            data = new LineData[256];
            byte[] data1 = SerializableDataExtension.instance.SerializableData.LoadData(_dataID);
            if (data1 == null)
            {
                return(false);
            }
            int    index1 = 0;
            ushort lineID = 0;
            string empty  = string.Empty;

            try
            {
                Utils.Log((object)"Try to load transport line data.");
                string str = SerializableDataExtension.ReadString(data1, ref index1);
                if (string.IsNullOrEmpty(str) || str.Length != 4)
                {
                    Utils.LogWarning((object)"Unknown data found.");
                    return(false);
                }
                Utils.Log((object)("Found transport line data version: " + str));
                NetManager       instance1 = Singleton <NetManager> .instance;
                TransportManager instance2 = Singleton <TransportManager> .instance;
                while (index1 < data1.Length)
                {
                    if (instance2.m_lines.m_buffer[(int)lineID].Complete)
                    {
                        int int32 = BitConverter.ToInt32(data1, index1);
                        data[(int)lineID].TargetVehicleCount = int32;
                    }
                    index1 += 4;
                    float num = Mathf.Min(BitConverter.ToSingle(data1, index1),
                                          (float)OptionsWrapper <Settings> .Options.SpawnTimeInterval);
                    if ((double)num > 0.0)
                    {
                        data[(int)lineID].NextSpawnTime = SimHelper.SimulationTime + num;
                    }
                    index1 += 4;
                    bool boolean = BitConverter.ToBoolean(data1, index1);
                    data[(int)lineID].BudgetControl = boolean;
                    ++index1;
                    ushort uint16 = BitConverter.ToUInt16(data1, index1);
                    data[(int)lineID].Depot = (int)uint16 != 0
                        ? uint16
                        : DepotUtil.GetClosestDepot(lineID,
                                                    instance1.m_nodes.m_buffer[(int)instance2.m_lines.m_buffer[(int)lineID].GetStop(0)]
                                                    .m_position);
                    index1 += 2;
                    if (str == "v001")
                    {
                        string name = SerializableDataExtension.ReadString(data1, ref index1);
                        if (name != "Random")
                        {
                            if (data[(int)lineID].Prefabs == null)
                            {
                                data[(int)lineID].Prefabs = new HashSet <string>();
                            }
                            if ((UnityEngine.Object)PrefabCollection <VehicleInfo> .FindLoaded(name) !=
                                (UnityEngine.Object)null)
                            {
                                data[(int)lineID].Prefabs.Add(name);
                            }
                        }
                    }
                    else
                    {
                        int int32 = BitConverter.ToInt32(data1, index1);
                        index1 += 4;
                        for (int index2 = 0; index2 < int32; ++index2)
                        {
                            string name = SerializableDataExtension.ReadString(data1, ref index1);
                            if (data[(int)lineID].Prefabs == null)
                            {
                                data[(int)lineID].Prefabs = new HashSet <string>();
                            }
                            if ((UnityEngine.Object)PrefabCollection <VehicleInfo> .FindLoaded(name) !=
                                (UnityEngine.Object)null)
                            {
                                data[(int)lineID].Prefabs.Add(name);
                            }
                        }
                    }
                    if (str != "v001")
                    {
                        int int32 = BitConverter.ToInt32(data1, index1);
                        index1 += 4;
                        for (int index2 = 0; index2 < int32; ++index2)
                        {
                            string name = SerializableDataExtension.ReadString(data1, ref index1);
                            if (!boolean)
                            {
                                if (data[(int)lineID].QueuedVehicles == null)
                                {
                                    data[(int)lineID].QueuedVehicles = new Queue <string>();
                                }
                                if ((UnityEngine.Object)PrefabCollection <VehicleInfo> .FindLoaded(name) !=
                                    (UnityEngine.Object)null)
                                {
                                    lock (data[(int)lineID].QueuedVehicles)
                                        data[(int)lineID].QueuedVehicles.Enqueue(name);
                                }
                            }
                        }
                    }
                    if (str == "v003")
                    {
                        ++index1;
                    }
                    data[(int)lineID].Unbunching = str != "v004"
                        ? OptionsWrapper <Settings> .Options.Unbunching
                        : SerializableDataExtension.ReadBool(data1, ref index1);
                    ++lineID;
                }
                return(true);
            }
            catch (Exception ex)
            {
                Utils.LogWarning((object)("Could not load transport line data. " + ex.Message));
                data = new LineData[256];
                return(false);
            }
        }
Beispiel #24
0
        private static void DeleteLines()
        {
            TransportManager instance = Singleton <TransportManager> .instance;
            int length = instance.m_lines.m_buffer.Length;

            for (int index = 0; index < length; ++index)
            {
                TransportInfo info = instance.m_lines.m_buffer[index].Info;
                if (info == null || instance.m_lines.m_buffer[index].m_flags == TransportLine.Flags.None)
                {
                    continue;
                }
                bool flag       = false;
                var  subService = info.GetSubService();
                var  service    = info.GetService();
                var  level      = info.GetClassLevel();
                if (service == ItemClass.Service.PublicTransport) //TODO(earalov): handle evacuation buses
                {
                    if (level == ItemClass.Level.Level1)
                    {
                        switch (subService)
                        {
                        case ItemClass.SubService.PublicTransportBus:
                            flag = OptionsWrapper <Settings> .Options.DeleteBusLines;
                            break;

                        case ItemClass.SubService.PublicTransportMetro:
                            flag = OptionsWrapper <Settings> .Options.DeleteMetroLines;
                            break;

                        case ItemClass.SubService.PublicTransportTrain:
                            flag = OptionsWrapper <Settings> .Options.DeleteTrainLines;
                            break;

                        case ItemClass.SubService.PublicTransportShip:
                            flag = OptionsWrapper <Settings> .Options.DeleteShipLines;
                            break;

                        case ItemClass.SubService.PublicTransportPlane:
                            flag = OptionsWrapper <Settings> .Options.DeletePlaneLines;
                            break;

                        case ItemClass.SubService.PublicTransportTram:
                            flag = OptionsWrapper <Settings> .Options.DeleteTramLines;
                            break;

                        case ItemClass.SubService.PublicTransportMonorail:
                            flag = OptionsWrapper <Settings> .Options.DeleteMonorailLines;
                            break;

                        case ItemClass.SubService.PublicTransportTrolleybus:
                            flag = OptionsWrapper <Settings> .Options.DeleteBusLines;
                            break;
                        }
                    }
                    else if (level == ItemClass.Level.Level2)
                    {
                        switch (subService)
                        {
                        case ItemClass.SubService.PublicTransportBus:
                            flag = OptionsWrapper <Settings> .Options.DeleteBusLines;
                            break;

                        case ItemClass.SubService.PublicTransportShip:
                            flag = OptionsWrapper <Settings> .Options.DeleteShipLines;
                            break;

                        case ItemClass.SubService.PublicTransportPlane:
                            flag = OptionsWrapper <Settings> .Options.DeletePlaneLines;
                            break;
                        }
                    }
                    else if (level == ItemClass.Level.Level3)
                    {
                        switch (subService)
                        {
                        case ItemClass.SubService.PublicTransportTours:
                            flag = OptionsWrapper <Settings> .Options.DeleteBusLines;
                            break;

                        case ItemClass.SubService.PublicTransportPlane:
                            flag = OptionsWrapper <Settings> .Options.DeletePlaneLines;
                            break;
                        }
                    }
                    if (flag)
                    {
                        instance.ReleaseLine((ushort)index);  //TODO(earalov): make sure that outside connection lines don't get deleted
                    }
                }
            }
        }
 public static void Start()
 {
     TransportManager.Register("webSockets", context => new WebSocketTransport(context, DependencyResolver.Resolve <IJsonStringifier>()));
 }