/// <summary>
        /// Combines all unique lines in a cell in order
        /// </summary>
        /// <param name="cell"></param>
        public void Combine(LineContainer <T> cell)
        {
            if (this == cell)
            {
                return;
            }
            var node = _list.First;

            foreach (var line in cell)
            {
                if (node != null)
                {
                    while (line.ID < node.Value.ID)
                    {
                        node = node.Next;
                        if (node == null)
                        {
                            break;
                        }
                    }
                    if (node == null)
                    {
                        node = _list.AddLast(line);
                    }
                    else if (node.Value.ID != line.ID) // no redundant lines
                    {
                        _list.AddBefore(node, line);
                    }
                }
                else
                {
                    node = _list.AddFirst(line);
                }
            }
        }
        public LineContainer <T> Clone()
        {
            var ret = new LineContainer <T>();

            foreach (var l in this)
            {
                ret.AddLine(l);
            }
            return(ret);
        }
Example #3
0
        private SimulationCell GetPairs(StandardLine input)
        {
            var list  = new SimulationCell();
            var c1    = _editorcells.GetCellFromPoint(input.Position);
            var c2    = _editorcells.GetCellFromPoint(input.Position2);
            var cells = new LineContainer <GameLine>[]
            {
                c1,
                c1 == c2 ? null : c2
            };

            foreach (var cell in cells)
            {
                if (cell == null)
                {
                    continue;
                }
                foreach (var line in cell)
                {
                    if (line.Type == LineType.Scenery)
                    {
                        continue;
                    }
                    if (line.ID != input.ID)
                    {
                        if (
                            line.End == input.Start ||
                            line.Start == input.End)
                        {
                            list.AddLine((StandardLine)line);
                        }
                    }
                }
            }
            return(list);
        }