Ejemplo n.º 1
0
        public static IEnumerable <NetInfo> GetElevations(this NetInfo basic)
        {
            if (basic == null)
            {
                yield break;
            }

            NetInfo elevated = AssetEditorRoadUtils.TryGetElevated(basic);
            NetInfo bridge   = AssetEditorRoadUtils.TryGetBridge(basic);
            NetInfo slope    = AssetEditorRoadUtils.TryGetSlope(basic);
            NetInfo tunnel   = AssetEditorRoadUtils.TryGetTunnel(basic);

            // TODO: add outside connections.

            yield return(basic);

            if (elevated != null)
            {
                yield return(elevated);
            }
            if (bridge != null)
            {
                yield return(bridge);
            }
            if (slope != null)
            {
                yield return(slope);
            }
            if (tunnel != null)
            {
                yield return(tunnel);
            }
        }
Ejemplo n.º 2
0
        public void RemoveRoadBinary(PrefabInfo newPrefab)
        {
            if (newPrefab as NetInfo == null)
            {
                return;
            }

            if (newPrefab.name.EndsWith("0") || newPrefab.name.EndsWith("1"))
            {
                newPrefab.name = newPrefab.name.Substring(0, newPrefab.name.Length - 1);
            }

            NetInfo net = newPrefab as NetInfo;

            NetInfo elevated = AssetEditorRoadUtils.TryGetElevated(net);
            NetInfo bridge   = AssetEditorRoadUtils.TryGetBridge(net);
            NetInfo slope    = AssetEditorRoadUtils.TryGetSlope(net);
            NetInfo tunnel   = AssetEditorRoadUtils.TryGetTunnel(net);

            if (elevated != null)
            {
                if (elevated.name.EndsWith("0") || elevated.name.EndsWith("1"))
                {
                    elevated.name = elevated.name.Substring(0, elevated.name.Length - 1);
                }
            }

            if (bridge != null)
            {
                if (bridge.name.EndsWith("0") || bridge.name.EndsWith("1"))
                {
                    bridge.name = bridge.name.Substring(0, bridge.name.Length - 1);
                }
            }

            if (slope != null)
            {
                if (slope.name.EndsWith("0") || slope.name.EndsWith("1"))
                {
                    slope.name = slope.name.Substring(0, slope.name.Length - 1);
                }
            }

            if (tunnel != null)
            {
                if (tunnel.name.EndsWith("0") || tunnel.name.EndsWith("1"))
                {
                    tunnel.name = tunnel.name.Substring(0, tunnel.name.Length - 1);
                }
            }
        }
Ejemplo n.º 3
0
        public static NetInfo FindDefaultElevation(NetInfo info)
        {
            for (uint i = 0; i < PrefabCollection <NetInfo> .LoadedCount(); i++)
            {
                NetInfo prefab = PrefabCollection <NetInfo> .GetLoaded(i);

                if ((AssetEditorRoadUtils.TryGetBridge(prefab) != null && AssetEditorRoadUtils.TryGetBridge(prefab).name == info.name) ||
                    (AssetEditorRoadUtils.TryGetElevated(prefab) != null && AssetEditorRoadUtils.TryGetElevated(prefab).name == info.name) ||
                    (AssetEditorRoadUtils.TryGetSlope(prefab) != null && AssetEditorRoadUtils.TryGetSlope(prefab).name == info.name) ||
                    (AssetEditorRoadUtils.TryGetTunnel(prefab) != null && AssetEditorRoadUtils.TryGetTunnel(prefab).name == info.name))
                {
                    return(prefab);
                }
            }
            return(info);
        }
Ejemplo n.º 4
0
        public void ReadFromGame(NetInfo game_basic)
        {
            NetInfo game_elevated = AssetEditorRoadUtils.TryGetElevated(game_basic);
            NetInfo game_bridge   = AssetEditorRoadUtils.TryGetBridge(game_basic);
            NetInfo game_slope    = AssetEditorRoadUtils.TryGetSlope(game_basic);
            NetInfo game_tunnel   = AssetEditorRoadUtils.TryGetTunnel(game_basic);

            basic   = new NetInfoDTO();
            basicAI = new RoadAIDTO();
            basic.ReadFromGame(game_basic);
            DTOUtil.CopyAllMatchingFields <RoadAIDTO>(basicAI, game_basic.m_netAI);

            if (game_elevated)
            {
                elevated = new NetInfoDTO();
                elevated.ReadFromGame(game_elevated);
                elevatedAI = new BridgeAIDTO();
                DTOUtil.CopyAllMatchingFields <BridgeAIDTO>(elevatedAI, game_elevated.m_netAI);
            }
            if (game_bridge)
            {
                bridge = new NetInfoDTO();
                bridge.ReadFromGame(game_bridge);
                bridgeAI = new BridgeAIDTO();
                DTOUtil.CopyAllMatchingFields <BridgeAIDTO>(bridgeAI, game_bridge.m_netAI);
            }
            if (game_slope)
            {
                slope = new NetInfoDTO();
                slope.ReadFromGame(game_slope);
                slopeAI = new TunnelAIDTO();
                DTOUtil.CopyAllMatchingFields <TunnelAIDTO>(slopeAI, game_slope.m_netAI);
            }
            if (game_tunnel)
            {
                tunnel = new NetInfoDTO();
                tunnel.ReadFromGame(game_tunnel);
                tunnelAI = new TunnelAIDTO();
                DTOUtil.CopyAllMatchingFields <TunnelAIDTO>(tunnelAI, game_tunnel.m_netAI);
            }

            //basicModel.Read(game_basic, "Basic");
            //elevatedModel.Read(gameRoadAI.m_elevatedInfo, "Elevated");
            //bridgeModel.Read(gameRoadAI.m_bridgeInfo, "Bridge");
            //slopeModel.Read(gameRoadAI.m_slopeInfo, "Slope");
            //tunnelModel.Read(gameRoadAI.m_tunnelInfo, "Tunnel");
        }
Ejemplo n.º 5
0
        public static List <string> RenameEditNet(string name, bool reportOnly)
        {
            try {
                if (name.IsNullOrWhiteSpace())
                {
                    throw new Exception("name is empty");
                }
                var ground = ToolsModifierControl.toolController.m_editPrefabInfo as NetInfo;
                if (ground == null)
                {
                    throw new Exception("m_editPrefabInfo is not netInfo");
                }

                NetInfo elevated = AssetEditorRoadUtils.TryGetElevated(ground);
                NetInfo bridge   = AssetEditorRoadUtils.TryGetBridge(ground);
                NetInfo slope    = AssetEditorRoadUtils.TryGetSlope(ground);
                NetInfo tunnel   = AssetEditorRoadUtils.TryGetTunnel(ground);

                var ret = new List <string>();
                void Rename(NetInfo _info, string _postfix)
                {
                    if (!_info)
                    {
                        return;
                    }
                    ret.Add(GetUniqueNetInfoName(name + _postfix, true));
                    if (!reportOnly)
                    {
                        _info.name = ret.Last();
                    }
                    ret.AddRange(_info.NameAIBuildings(ret.Last(), reportOnly));
                }

                Rename(ground, "_Data");
                Rename(elevated, " E");
                Rename(bridge, " B");
                Rename(slope, " S");
                Rename(tunnel, " T");

                return(ret);
            } catch (Exception ex) {
                Log.Exception(ex);
                return(null);
            }
        }
Ejemplo n.º 6
0
        public static void Load(AssetData assetData, NetInfo groundInfo)
        {
            NetInfo elevated = AssetEditorRoadUtils.TryGetElevated(groundInfo);
            NetInfo bridge   = AssetEditorRoadUtils.TryGetBridge(groundInfo);
            NetInfo slope    = AssetEditorRoadUtils.TryGetSlope(groundInfo);
            NetInfo tunnel   = AssetEditorRoadUtils.TryGetTunnel(groundInfo);

            foreach (var info in NetInfoExtionsion.AllElevations(groundInfo))
            {
                info.UndoVanillaForbidden();
            }

            assetData.Ground?.Apply(groundInfo);
            assetData.Elevated?.Apply(elevated);
            assetData.Bridge?.Apply(bridge);
            assetData.Slope?.Apply(slope);
            assetData.Tunnel?.Apply(tunnel);
        }
Ejemplo n.º 7
0
        public PrefabInfo DefaultPrefab(PrefabInfo resolve)
        {
            if (!(resolve is NetInfo))
            {
                return(resolve);
            }

            NetInfo info = resolve as NetInfo;

            for (uint i = 0; i < PrefabCollection <NetInfo> .LoadedCount(); i++)
            {
                NetInfo prefab = PrefabCollection <NetInfo> .GetLoaded(i);

                if ((AssetEditorRoadUtils.TryGetBridge(prefab) != null && AssetEditorRoadUtils.TryGetBridge(prefab).name == info.name) ||
                    (AssetEditorRoadUtils.TryGetElevated(prefab) != null && AssetEditorRoadUtils.TryGetElevated(prefab).name == info.name) ||
                    (AssetEditorRoadUtils.TryGetSlope(prefab) != null && AssetEditorRoadUtils.TryGetSlope(prefab).name == info.name) ||
                    (AssetEditorRoadUtils.TryGetTunnel(prefab) != null && AssetEditorRoadUtils.TryGetTunnel(prefab).name == info.name))
                {
                    if (AssetEditorRoadUtils.TryGetBridge(prefab) != null && AssetEditorRoadUtils.TryGetBridge(prefab).name == info.name)
                    {
                        FRTSet("BridgeMode");
                    }
                    else if (AssetEditorRoadUtils.TryGetElevated(prefab) != null && AssetEditorRoadUtils.TryGetElevated(prefab).name == info.name)
                    {
                        FRTSet("ElevatedMode");
                    }
                    else if (AssetEditorRoadUtils.TryGetTunnel(prefab) != null && AssetEditorRoadUtils.TryGetTunnel(prefab).name == info.name)
                    {
                        FRTSet("TunnelMode");
                    }
                    else
                    {
                        FRTSet("GroundMode");
                    }

                    return(prefab);
                }
                else if (prefab == info)
                {
                    FRTSet("GroundMode");
                }
            }
            return(info);
        }
Ejemplo n.º 8
0
        public void WriteToGame(NetInfo game_basic)
        {
            NetInfo game_elevated = AssetEditorRoadUtils.TryGetElevated(game_basic);
            NetInfo game_bridge   = AssetEditorRoadUtils.TryGetBridge(game_basic);
            NetInfo game_slope    = AssetEditorRoadUtils.TryGetSlope(game_basic);
            NetInfo game_tunnel   = AssetEditorRoadUtils.TryGetTunnel(game_basic);

            basic.WriteToGame(game_basic);
            elevated?.WriteToGame(game_elevated);
            bridge?.WriteToGame(game_bridge);
            slope?.WriteToGame(game_slope);
            tunnel?.WriteToGame(game_tunnel);

            DTOUtil.CopyAllMatchingFields <RoadAIDTO>(game_basic.m_netAI, basicAI);
            DTOUtil.CopyAllMatchingFields <BridgeAIDTO>(game_elevated.m_netAI, elevatedAI);
            DTOUtil.CopyAllMatchingFields <BridgeAIDTO>(game_bridge.m_netAI, bridgeAI);
            DTOUtil.CopyAllMatchingFields <TunnelAIDTO>(game_slope.m_netAI, slopeAI);
            DTOUtil.CopyAllMatchingFields <TunnelAIDTO>(game_tunnel.m_netAI, tunnelAI);
        }
Ejemplo n.º 9
0
        private static string GetElevationName(string rawNetInfo, int elevationType)
        {
            switch (elevationType)
            {
            case 1:
                return(AssetEditorRoadUtils.TryGetElevated(PrefabCollection <NetInfo> .FindLoaded(rawNetInfo)).name);

            case 2:
                return(AssetEditorRoadUtils.TryGetBridge(PrefabCollection <NetInfo> .FindLoaded(rawNetInfo)).name);

            case 3:
                return(AssetEditorRoadUtils.TryGetSlope(PrefabCollection <NetInfo> .FindLoaded(rawNetInfo)).name);

            case 4:
                return(AssetEditorRoadUtils.TryGetTunnel(PrefabCollection <NetInfo> .FindLoaded(rawNetInfo)).name);

            default:
                return("");   // make it return error maybe?
            }
        }
Ejemplo n.º 10
0
        public static AssetData Create(NetInfo ground)
        {
            if (ground == null)
            {
                return(null);
            }
            NetInfo elevated = AssetEditorRoadUtils.TryGetElevated(ground);
            NetInfo bridge   = AssetEditorRoadUtils.TryGetBridge(ground);
            NetInfo slope    = AssetEditorRoadUtils.TryGetSlope(ground);
            NetInfo tunnel   = AssetEditorRoadUtils.TryGetTunnel(ground);

            var ret = new AssetData {
                Ground   = NetInfoMetaData.Create(ground),
                Elevated = NetInfoMetaData.Create(elevated),
                Bridge   = NetInfoMetaData.Create(bridge),
                Slope    = NetInfoMetaData.Create(slope),
                Tunnel   = NetInfoMetaData.Create(tunnel),
            };

            return(ret);
        }
Ejemplo n.º 11
0
        public void DumpPillar()
        {
            try
            {
                string extraType = "Pillar";

                NetInfo elevatedNet = AssetEditorRoadUtils.TryGetElevated(loadedPrefab);
                DumpBuildingInfo(GetActivePillar(elevatedNet, PillarType.BridgePillar));
                DumpBuildingInfo(GetActivePillar(elevatedNet, PillarType.MiddlePillar));

                NetInfo bridgeNet = AssetEditorRoadUtils.TryGetBridge(loadedPrefab);
                DumpBuildingInfo(GetActivePillar(bridgeNet, PillarType.BridgePillar));
                DumpBuildingInfo(GetActivePillar(bridgeNet, PillarType.MiddlePillar));

                //check ground elevation for things such as monorail net pillars etc
                DumpBuildingInfo(GetActivePillar(loadedPrefab, PillarType.BridgePillar));
                DumpBuildingInfo(GetActivePillar(loadedPrefab, PillarType.BridgePillar2));
                DumpBuildingInfo(GetActivePillar(loadedPrefab, PillarType.BridgePillar3));
                DumpBuildingInfo(GetActivePillar(loadedPrefab, PillarType.MiddlePillar));

                if (pillarsDumped != 0)
                {
                    string         importFolder = Path.Combine(DataLocation.addonsPath, "Import");
                    ExceptionPanel panel        = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");
                    panel.SetMessage("Pillar Dumping Successful", "Network Name: " + networkName_init + "\nExported To: " + importFolder + propDumpedMesssage + "\nPillars Dumped: " + pillarsDumped, false);
                    //explain how to replace after that not that straightfoward (restart the game or reload the asset editor with no workshop on!)

                    RoadExtrasAlert.instance.setExtraType(extraType);
                    RoadExtrasAlert.instance.Show();
                }
                else
                {
                    Lib.ExtraUtils.ShowErrorWindow("Pillar Dumping Failed", "No Pillars Found");
                }
            }
            catch (Exception e)
            {
                Lib.ExtraUtils.ShowErrorWindow("Pillar Dumping Failed", e.ToString());
            }
        }
Ejemplo n.º 12
0
        public static List <string> GatherEditNames()
        {
            var ground = ToolsModifierControl.toolController.m_editPrefabInfo as NetInfo;

            if (ground == null)
            {
                throw new Exception("m_editPrefabInfo is not netInfo");
            }
            NetInfo elevated = AssetEditorRoadUtils.TryGetElevated(ground);
            NetInfo bridge   = AssetEditorRoadUtils.TryGetBridge(ground);
            NetInfo slope    = AssetEditorRoadUtils.TryGetSlope(ground);
            NetInfo tunnel   = AssetEditorRoadUtils.TryGetTunnel(ground);

            var ret = GatherNetInfoNames(ground);

            ret.AddRange(GatherNetInfoNames(elevated));
            ret.AddRange(GatherNetInfoNames(bridge));
            ret.AddRange(GatherNetInfoNames(slope));
            ret.AddRange(GatherNetInfoNames(tunnel));

            return(ret);
        }
Ejemplo n.º 13
0
        public void FindMesh(string networkName_init)
        {
            if (networkName_init.Contains("_Data"))
            {
                networkName = networkName_init.Substring(0, networkName_init.Length - 1);
            }
            else
            {
                networkName = networkName_init;
            }

            if (NetDumpPanel.instance.GetCustomFilePrefix() == "")
            {
                Debug.Log("no custom prefix");
                if (networkName_init.Contains("_Data"))
                {
                    filename = networkName.Substring(0, networkName.Length - 5).Replace("/", string.Empty);
                }
                else
                {
                    filename = networkName.Substring(0, networkName.Length - 1);
                }
            }
            else
            {
                Debug.Log("custom prefix");
                filename = NetDumpPanel.instance.GetCustomFilePrefix();
            }
            meshnum = 0;

            if (int.TryParse(NetDumpPanel.instance.MeshNumber, out meshnum))
            {
                if (meshnum > 1)
                {
                    filename = filename + "_mesh" + meshnum;
                }
                meshnum = meshnum - 1; //adjust for array
            }
            else
            {
                throw new System.ArgumentException("Mesh Number Not Found");
            }

            //check for elevations
            loadedPrefab = PrefabCollection <NetInfo> .FindLoaded(networkName);

            int netElevationIndex = NetDumpPanel.instance.GetNetEleIndex;

            switch (netElevationIndex) //if null throw error!
            {
            case 0:
                Console.WriteLine("basic ground no change");
                break;

            case 1:
                Console.WriteLine("Elevated");
                loadedPrefab = AssetEditorRoadUtils.TryGetElevated(loadedPrefab);
                if (loadedPrefab == null)
                {
                    throw new Exception("Elevated Elevation Does Not Exist");
                }
                if (!NetDumpPanel.instance.GetRemoveSuffix)
                {
                    filename += " Elevated";
                }
                break;

            case 2:
                Console.WriteLine("Bridge");
                loadedPrefab = AssetEditorRoadUtils.TryGetBridge(loadedPrefab);
                if (loadedPrefab == null)
                {
                    throw new Exception("Bridge Elevation Does Not Exist");
                }
                if (!NetDumpPanel.instance.GetRemoveSuffix)
                {
                    filename += " Bridge";
                }
                break;

            case 3:
                loadedPrefab = AssetEditorRoadUtils.TryGetSlope(loadedPrefab);
                if (loadedPrefab == null)
                {
                    throw new Exception("Slope Elevation Does Not Exist");
                }
                if (!NetDumpPanel.instance.GetRemoveSuffix)
                {
                    filename += " Slope";
                }
                break;

            case 4:
                loadedPrefab = AssetEditorRoadUtils.TryGetTunnel(loadedPrefab);
                if (loadedPrefab == null)
                {
                    throw new Exception("Tunnel Elevation Does Not Exist");
                }
                if (!NetDumpPanel.instance.GetRemoveSuffix)
                {
                    filename += " Tunnel";
                }
                break;

            default:
                throw new System.ArgumentOutOfRangeException("No Elevations Found");
            }

            Debug.Log("Prefab: " + loadedPrefab);


            diffuseTexturePath = Path.Combine(importFolder, filename);
            meshPath           = Path.Combine(importFolder, filename);
            lodMeshPath        = Path.Combine(importFolder, filename);
            aFilePath          = Path.Combine(importFolder, filename);
            pFilePath          = Path.Combine(importFolder, filename);
            rFilePath          = Path.Combine(importFolder, filename);

            if (NetDumpPanel.instance.NetworkType == "Segment")
            {
                material            = loadedPrefab.m_segments[meshnum].m_segmentMaterial;
                diffuseTexturePath += "_d.png";
                meshPath           += ".obj";
                lodMeshPath        += "_lod.obj";
                aFilePath          += "_a.png";
                pFilePath          += "_p.png";
                rFilePath          += "_r.png";
                roadMesh            = loadedPrefab.m_segments[meshnum].m_mesh;
                roadMeshLod         = loadedPrefab.m_segments[meshnum].m_lodMesh;
                aprmaterial         = loadedPrefab.m_segments[meshnum].m_segmentMaterial;
            }
            else if (NetDumpPanel.instance.NetworkType == "Node")
            {
                material = loadedPrefab.m_nodes[meshnum].m_nodeMaterial;
                if (NetDumpPanel.instance.GetRemoveSuffix)
                {
                    diffuseTexturePath += "_d.png";
                    meshPath           += ".obj";
                    lodMeshPath        += "_lod.obj";
                    aFilePath          += "_a.png";
                    pFilePath          += "_p.png";
                    rFilePath          += "_r.png";
                }
                else
                {
                    diffuseTexturePath += "_node_d.png";
                    meshPath           += "_node.obj";
                    lodMeshPath        += "_node_lod.obj";
                    aFilePath          += "_node_a.png";
                    pFilePath          += "_node_p.png";
                    rFilePath          += "_node_r.png";
                }

                roadMesh    = loadedPrefab.m_nodes[meshnum].m_mesh;
                roadMeshLod = loadedPrefab.m_nodes[meshnum].m_lodMesh;
                aprmaterial = loadedPrefab.m_nodes[meshnum].m_nodeMaterial;
            }
            else
            {
                throw new System.ArgumentException("Invalid network selection type");
            }
        }
Ejemplo n.º 14
0
        public static void CopyToGame(object source, object target)
        {
            Debug.Log("Invoke copytogame");
            Debug.Log($"source:{source}, target:{target}");
            if (source == null || target == null)
            {
                return;
            }
            FieldInfo[] fields = source.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
            foreach (FieldInfo fieldInfo in fields)
            {
                if (fieldInfo.GetValue(source) == null)
                {
                    Debug.Log($"Field {fieldInfo.Name} is null, skipping import");
                    continue;
                }
                FieldInfo gameFieldInfo = target.GetType().GetField(fieldInfo.Name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                Debug.Log(gameFieldInfo);
                Debug.Log(fieldInfo);
                if (gameFieldInfo.FieldType.IsArray)
                {
                    Array savedObjects = (Array)fieldInfo.GetValue(source);
                    int   len          = savedObjects.Length;
                    Type  elementType  = gameFieldInfo.FieldType.GetElementType();
                    gameFieldInfo.SetValue(target, Array.CreateInstance(elementType, 0));
                    for (int i = 0; i < len; i++)
                    {
                        AssetEditorRoadUtils.AddArrayElement(target, gameFieldInfo);
                        Array gameObjects = (Array)gameFieldInfo.GetValue(target);
                        CopyToGame(savedObjects.GetValue(i), gameObjects.GetValue(i));
                    }
                }
                else if (gameFieldInfo.FieldType == typeof(NetLaneProps))
                {
                    CSNetInfo.Prop[] savedObjects = (CSNetInfo.Prop[])fieldInfo.GetValue(source);
                    int          len         = savedObjects.Length;
                    NetLaneProps gameObjects = new NetLaneProps {
                        m_props = new NetLaneProps.Prop[len]
                    };
                    for (int i = 0; i < len; i++)
                    {
                        gameObjects.m_props[i] = new NetLaneProps.Prop();
                        CopyToGame(savedObjects[i], gameObjects.m_props[i]);
                    }
                    gameFieldInfo.SetValue(target, gameObjects);
                }
                else if (gameFieldInfo.FieldType == typeof(Vector3))
                {
                    float[] vals = (float[])fieldInfo.GetValue(source);
                    Vector3 vec  = new Vector3(vals[0], vals[1], vals[2]);
                    gameFieldInfo.SetValue(target, vec);
                }
                else if (gameFieldInfo.FieldType.IsEnum)
                {
                    object val = Enum.ToObject(gameFieldInfo.FieldType, fieldInfo.GetValue(source));
                    gameFieldInfo.SetValue(target, val);
                }
                else if (gameFieldInfo.FieldType.IsSubclassOf(typeof(PrefabInfo)))
                {
                    string prefabName = (string)fieldInfo.GetValue(source);

                    if (prefabName.Equals(""))
                    {
                        gameFieldInfo.SetValue(target, null);
                    }
                    else
                    {
                        if (gameFieldInfo.FieldType == typeof(PropInfo))
                        {
                            PropInfo prefab = PrefabCollection <PropInfo> .FindLoaded(prefabName);

                            gameFieldInfo.SetValue(target, prefab);
                        }
                        else if (gameFieldInfo.FieldType == typeof(BuildingInfo))
                        {
                            BuildingInfo prefab = PrefabCollection <BuildingInfo> .FindLoaded(prefabName);

                            gameFieldInfo.SetValue(target, prefab);
                        }
                        else if (gameFieldInfo.FieldType == typeof(TreeInfo))
                        {
                            TreeInfo prefab = PrefabCollection <TreeInfo> .FindLoaded(prefabName);

                            gameFieldInfo.SetValue(target, prefab);
                        }
                    }
                }
                else
                {
                    gameFieldInfo.SetValue(target, fieldInfo.GetValue(source));
                }
            }
        }
Ejemplo n.º 15
0
        public void GetMeshPoints()
        {
            var prefab = PrefabCollection <NetInfo> .FindLoaded(Singleton <ToolController> .instance.m_editPrefabInfo.name);

            int netElevationIndex = NetDumpPanel.instance.GetNetEleIndex;

            switch (netElevationIndex)
            {
            case 1:
                prefab = AssetEditorRoadUtils.TryGetElevated(prefab);
                break;

            case 2:
                prefab = AssetEditorRoadUtils.TryGetBridge(prefab);
                break;

            case 3:
                prefab = AssetEditorRoadUtils.TryGetSlope(prefab);
                break;

            case 4:
                prefab = AssetEditorRoadUtils.TryGetTunnel(prefab);
                break;
            }
            var meshnum = int.Parse(NetDumpPanel.instance.MeshNumber) - 1;

            Vector3[] meshVertices = prefab.m_segments[meshnum].m_mesh.vertices;

            // Debug.Log("coordBoxCount: " + coordBox.Count);


            for (int i = 0; i < coordBox.Count; i++)
            {
                DestroyImmediate(coordBox[i].gameObject);
            }
            coordBox.Clear();


            // Debug.Log("grab new points?");

            List <KeyValuePair <float, float> > xylist = new List <KeyValuePair <float, float> >();

            for (int a = 0; a < meshVertices.Length; a++)
            {
                Console.WriteLine("loop" + a);
                if (Mathf.Approximately(meshVertices[a].z, 32f))
                {
                    var element = new KeyValuePair <float, float>(meshVertices[a].x, meshVertices[a].y);
                    xylist.Add(element);
                }
            }

            xylist = xylist.OrderBy(item => item.Key).ToList();
            xylist = xylist.OrderBy(item => item.Value).ToList();
            xylist = xylist.OrderBy(item => item.Key).ToList();

            //generate grid needed
            Debug.Log("xylistcount: " + xylist.Count);
            GenerateGrid(xylist.Count * 2);

            int cell = 0;

            foreach (var item in xylist)
            {
                coordBox[cell].text     = Math.Round(item.Key, 1).ToString();
                coordBox[cell + 1].text = Math.Round(item.Value, 1).ToString();
                Debug.Log("aworks? cell" + cell);
                cell = cell + 2;
            }
        }