Example #1
0
            public static void CopyMetadata(NetInfo source, NetInfo target)
            {
                NetInfoExtionsion.EnsureExtended(target);

                for (int i = 0; i < source.m_nodes.Length; ++i)
                {
                    var metadata = source.m_nodes[i].GetMetaData()?.Clone();
                    (target.m_nodes[i] as IInfoExtended).SetMetaData(metadata);
                }
                for (int i = 0; i < source.m_segments.Length; ++i)
                {
                    var metadata = source.m_segments[i].GetMetaData()?.Clone();
                    (target.m_segments[i] as IInfoExtended).SetMetaData(metadata);
                }

                for (int laneIndex = 0; laneIndex < source.m_lanes.Length; ++laneIndex)
                {
                    var m_propsTarget   = target.m_lanes[laneIndex]?.m_laneProps?.m_props;
                    var m_propsTemplate = source.m_lanes[laneIndex]?.m_laneProps?.m_props;
                    if (m_propsTemplate == null)
                    {
                        continue;
                    }
                    for (int i = 0; i < m_propsTemplate.Length; ++i)
                    {
                        var metadata = m_propsTemplate[i].GetMetaData()?.Clone();
                        (m_propsTarget[i] as IInfoExtended).SetMetaData(metadata);
                    }
                }

                source.SetMetedata(target.GetMetaData()?.Clone());
            }
Example #2
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);
        }