Пример #1
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
            }
        }