コード例 #1
0
        public bool AddDoubleEdgedPipe(Coordinate position, EdgeType firstEdge, EdgeType secondEdge)
        {
            var pipe  = new DoubleEdgedPipe(firstEdge, secondEdge);
            var block = GetBlock(position);

            if (block != null)
            {
                if (!CheckIfDoubleEdgeAlreadyExists(pipe, block))
                {
                    if (!(block.HasShipComponent()))
                    {
                        var intersectingPipe = HasIntersectingPipes(block, pipe);
                        if (intersectingPipe != null)
                        {
                            blueprint.PlaceShipComponent(position, emptyShipComponentFactory.Create(block));
                            TransformDoubleEdgedPipeIntoConnectingPipe(position, intersectingPipe);
                            TransformDoubleEdgedPipeIntoConnectingPipe(position, pipe);
                            ClearPipes(position, block.PipesWithBothEdges);
                        }
                        else
                        {
                            blueprint.PlacePipe(position, pipe);
                        }
                        return(true);
                    }
                    else
                    {
                        TransformDoubleEdgedPipeIntoConnectingPipe(position, pipe);
                        return(true);
                    }
                }
                return(false);
            }
            return(false);
        }