Esempio n. 1
0
        public void RemoveFirst(DcTable tab) // Remove first segments till this table (the new path will start from the specified table if trimmed)
        {
            if (Input == tab)
            {
                return;               // Already here
            }
            // Find a path to the specified table
            int index = this.IndexOfGreater(tab);

            if (index < 0)
            {
                return;
            }

            Segments.RemoveRange(0, index + 1);

            if (Segments.Count > 0)
            {
                Input = Segments[0].Input;
            }
            else
            {
                Input = Output;
            }
        }
Esempio n. 2
0
    public void DeleteLastSectn()
    {
        //Actually we delete the penultimate section because the last section is empty
        if (Sectns.Count < 2)
        {
            return;
        }
        int        LastSectnId   = Sectns.Count - 1;
        int        PenultSectnId = Sectns.Count - 2;
        iRoadSectn LastSection   = Sectns.Last();
        iRoadSectn PenultSection = Sectns[Sectns.Count - 2];
        //iRoadSectn PrevSection = Sectns[Sectns.Count - 3];
        //int PrevSegCount = PrevSection.Segments.Count;
        int PenultSegCount   = PenultSection.Segments.Count;
        int PenultSegStartId = PenultSegCount > 0 ? PenultSection.Segments[0].Idx : 0;

        //I tested this function using Watches on all the XSecCounts, SegmentCounts and SegStart and SegCount for each section
        //comparing them before adding and deleting a section and then after

        //Remove Section's Segment GameObjects
        foreach (RoadSegment seg in PenultSection.Segments)
        {
            GameObject.Destroy(seg.goSeg);
        }

        if (!IsCircular)
        {
            Segments.RemoveRange(PenultSegStartId, PenultSegCount);
            PenultSection.Segments.Clear();
            PenultSection.DeleteFence();
            XSecs.RemoveRange(PenultSegStartId, PenultSegCount);
            //PenultSection.XSecs.Clear();
        }

        if (IsCircular)
        {
            PenultSection.DeleteFence();
            Segments.RemoveRange(PenultSegStartId, PenultSegCount);
            PenultSection.Segments.Clear();
            XSecs.RemoveRange(PenultSegStartId, PenultSegCount);
            //PenultSection.XSecs.Clear();
            //Road.Instance.XSecs.RemoveRange(PrevSegStartId, PrevSegCount);
        }

        //Delete Section
        GameObject.Destroy(LastSection.goSectn);
        Sectns.Remove(LastSection);

        BezierLine.Instance.RemoveLastControlPoint();  //also removes the path points and selects the previous CtrlPt
        IsCircular         = false;
        Game.current.Dirty = true;
    }
Esempio n. 3
0
        public void RemoveFirst(ColumnPath path) // Remove first segments
        {
            if (Segments.Count < path.Segments.Count)
            {
                return;                                       // Nothing to remove
            }
            if (!this.StartsWith(path))
            {
                return;
            }

            Segments.RemoveRange(0, path.Segments.Count);

            if (Segments.Count > 0)
            {
                Input = Segments[0].Input;
            }
            else
            {
                Input = Output;
            }
        }