Beispiel #1
0
        /// <summary>
        /// Extrude the road out, by creating a new node
        /// </summary>
        /// <returns>The newly created road section</returns>
        public GameObject ExtrudeRoad()
        {
            Details.CompressRoads();
            Details.Modified = true;

            float roadAngle = GetCurrentAngle() + (float)(Math.PI / 2);

            if (Details.Union != UNION_TYPE.END)
            {
                roadAngle += (float)(Math.PI / 2);
            }

            Vector3    pos     = MathsHelper.OffSetVector(transform.position, roadAngle, 100);
            GameObject newNode = RoadNetworkNodeHelper.CreateBasicNode(pos, RoadConstructorHelper.GetUniqueRoadName(gameObject), gameObject);

            GameObject rnnB = gameObject;

            RoadNetworkLayout.AddRoadToNode(newNode.GetComponent <RoadNetworkNode>(), rnnB.GetComponent <RoadNetworkNode>());
            RoadNetworkLayout.AddRoadToNode(rnnB.GetComponent <RoadNetworkNode>(), newNode.GetComponent <RoadNetworkNode>());

            ICrossSection sc = gameObject.GetComponent <ICrossSection>();

            if (sc != null)
            {
                newNode.AddComponent <OverridableCrossSection>();
                OverridableCrossSection ocs = newNode.GetComponent <OverridableCrossSection>();
                ocs.Copy(sc);
            }

            IMaterialFrequency fm = gameObject.GetComponent <IMaterialFrequency>();

            if (fm != null)
            {
                newNode.AddComponent <OverridableMaterialFrequency>();
                OverridableMaterialFrequency ocs = newNode.GetComponent <OverridableMaterialFrequency>();
                ocs.Copy(fm);
            }

            return(newNode);
        }
Beispiel #2
0
        /// <summary>
        /// Do we have a Cross section override?
        /// </summary>
        /// <returns>Whether or not we have cross section details</returns>
        public bool HasOverridenCrossSection()
        {
            OverridableCrossSection ocs = gameObject.GetComponent <OverridableCrossSection>();

            return(ocs != null);
        }