Ejemplo n.º 1
0
        protected override void OnToolGUI(Event e)
        {
            DrawLabel();
            if (m_toolController.IsInsideUI || e.type != EventType.MouseDown)
            {
                base.OnToolGUI(e);
                return;
            }

            if (m_hoverInstance.IsEmpty)
            {
                return;
            }

            var sceneExplorer = FindObjectOfType <SceneExplorer>();

            if (e.button == 0)
            {
                if (m_hoverInstance.NetNode > 0)
                {
                    sceneExplorer.Show(ReferenceChainBuilder.ForNode(m_hoverInstance.NetNode));
                }
                else if (m_hoverInstance.NetSegment > 0)
                {
                    sceneExplorer.Show(ReferenceChainBuilder.ForSegment(m_hoverInstance.NetSegment));
                }
                else if (m_hoverInstance.Tree > 0)
                {
                    sceneExplorer.Show(ReferenceChainBuilder.ForTree(m_hoverInstance.Tree));
                }
                else if (m_hoverInstance.Prop > 0)
                {
                    sceneExplorer.Show(ReferenceChainBuilder.ForProp(m_hoverInstance.Prop));
                }
                else if (m_hoverInstance.CitizenInstance > 0)
                {
                    sceneExplorer.Show(ReferenceChainBuilder.ForCitizenInstance(m_hoverInstance.CitizenInstance));
                }
                else if (m_hoverInstance.Building > 0)
                {
                    sceneExplorer.Show(ReferenceChainBuilder.ForBuilding(m_hoverInstance.Building));
                }
                else if (m_hoverInstance.Vehicle > 0)
                {
                    sceneExplorer.Show(ReferenceChainBuilder.ForVehicle(m_hoverInstance.Vehicle));
                }
                else if (m_hoverInstance.ParkedVehicle > 0)
                {
                    sceneExplorer.Show(ReferenceChainBuilder.ForParkedVehicle(m_hoverInstance.ParkedVehicle));
                }
                else if (m_hoverInstance.District > 0)
                {
                    sceneExplorer.Show(ReferenceChainBuilder.ForDistrict(m_hoverInstance.District));
                }
                else if (m_hoverInstance.Park > 0)
                {
                    sceneExplorer.Show(ReferenceChainBuilder.ForPark(m_hoverInstance.Park));
                }
                else if (m_hoverInstance.TransportLine > 0)
                {
                    sceneExplorer.Show(ReferenceChainBuilder.ForTransportLine(m_hoverInstance.TransportLine));
                }
            }
            else if (e.button == 1)
            {
                if (m_hoverInstance.CitizenInstance > 0)
                {
                    sceneExplorer.Show(ReferenceChainBuilder.ForCitizen(m_hoverInstance.GetCitizenId()));
                }
                else if (m_hoverInstance.NetNode > 0)
                {
                    sceneExplorer.Show(ReferenceChainBuilder.ForSegment(hoveredSegment));
                }
                else if (m_hoverInstance.NetSegment > 0)
                {
                    sceneExplorer.Show(ReferenceChainBuilder.ForBuilding(hoveredBuilding));
                }
            }
        }
Ejemplo n.º 2
0
        public static void SetupSmartShowButtons(object value, TypeUtil.SmartType smartType)
        {
            if (smartType == TypeUtil.SmartType.Undefined || value == null || value.GetType().IsArray)
            {
                return;
            }

            try
            {
                switch (smartType)
                {
                case TypeUtil.SmartType.Sprite:
                {
                    if (!(value is string stringValue) || !UIView.GetAView().defaultAtlas.spriteNames.Contains(stringValue))
                    {
                        return;
                    }

                    if (GUILayout.Button("Show sprite"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForSprite(stringValue));
                    }

                    break;
                }

                case TypeUtil.SmartType.ParkedVehicle:
                {
                    if (Convert.ToUInt16(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show parked vehicle"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForParkedVehicle(Convert.ToUInt16(value)));
                    }

                    break;
                }

                case TypeUtil.SmartType.Vehicle:
                {
                    if (Convert.ToUInt16(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show vehicle"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForVehicle(Convert.ToUInt16(value)));
                    }

                    break;
                }

                case TypeUtil.SmartType.Building:
                {
                    if (Convert.ToUInt16(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show building"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForBuilding(Convert.ToUInt16(value)));
                    }

                    break;
                }

                case TypeUtil.SmartType.CitizenUnit:
                {
                    if (Convert.ToUInt32(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show citizen unit"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForCitizenUnit(Convert.ToUInt32(value)));
                    }

                    break;
                }

                case TypeUtil.SmartType.Citizen:
                {
                    if (Convert.ToUInt32(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show citizen"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForCitizen(Convert.ToUInt32(value)));
                    }

                    break;
                }

                case TypeUtil.SmartType.TransportLine:
                {
                    if (Convert.ToUInt16(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show transport line"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForTransportLine(Convert.ToUInt16(value)));
                    }

                    break;
                }

                case TypeUtil.SmartType.PathUnit:
                {
                    if (Convert.ToUInt32(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show path unit"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForPathUnit(Convert.ToUInt32(value)));
                    }

                    break;
                }

                case TypeUtil.SmartType.NetNode:
                {
                    if (Convert.ToUInt16(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show network node"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForNode(Convert.ToUInt16(value)));
                    }

                    break;
                }

                case TypeUtil.SmartType.NetSegment:
                {
                    if (Convert.ToUInt16(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show network segment"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForSegment(Convert.ToUInt16(value)));
                    }

                    break;
                }

                case TypeUtil.SmartType.NetLane:
                {
                    if (Convert.ToUInt32(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show network lane"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForLane(Convert.ToUInt32(value)));
                    }

                    break;
                }

                case TypeUtil.SmartType.ParkDistrict:
                {
                    if (Convert.ToByte(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show park district"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForPark(Convert.ToByte(value)));
                    }

                    break;
                }

                case TypeUtil.SmartType.District:
                {
                    if (Convert.ToByte(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show district"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForDistrict(Convert.ToByte(value)));
                    }

                    break;
                }

                case TypeUtil.SmartType.Tree:
                {
                    if (Convert.ToUInt32(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show tree"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForTree(Convert.ToUInt32(value)));
                    }

                    break;
                }

                case TypeUtil.SmartType.Prop:
                {
                    if (Convert.ToUInt16(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show prop"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForProp(Convert.ToUInt16(value)));
                    }

                    break;
                }

                case TypeUtil.SmartType.CitizenInstance:
                {
                    if (Convert.ToUInt16(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show citizen instance"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForCitizenInstance(Convert.ToUInt16(value)));
                    }

                    break;
                }

                case TypeUtil.SmartType.ZoneBlock:
                {
                    if (Convert.ToUInt16(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show zone block"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForZoneBlock(Convert.ToUInt16(value)));
                    }

                    break;
                }

                default:
                    return;
                }
            }
            catch
            {
                // suppress
            }
        }