Exemplo n.º 1
0
        public void PlacePipe(Coordinate position, ConnectingPipe pipe)
        {
            blocks.Get(position).AddPipe(pipe);

            foreach (var observer in observers)
            {
                observer.ConnectingPipeAdded(this, position, pipe);
            }
        }
Exemplo n.º 2
0
        public void RemovePipe(Coordinate position, ConnectingPipe pipe)
        {
            blocks.Get(position).DeletePipe(pipe);

            foreach (var observer in observers)
            {
                observer.ConnectingPipeDeleted(this, position, pipe);
            }
        }
        public bool DeleteConnectingPipe(Coordinate position, ConnectingPipe pipe)
        {
            var block = GetBlock(position);

            if (block != null)
            {
                if (CheckIfConnectingPipeAlreadyExists(pipe, block))
                {
                    blueprint.RemovePipe(position, pipe);
                    return(true);
                }
            }
            return(false);
        }
        public bool AddConnectingPipe(Coordinate position, EdgeType edge)
        {
            var block = GetBlock(position);
            var pipe  = new ConnectingPipe(edge);

            if (block != null)
            {
                if (!CheckIfConnectingPipeAlreadyExists(pipe, block) && block.HasShipComponent())
                {
                    blueprint.PlacePipe(position, pipe);
                    return(true);
                }
            }
            return(false);
        }
 private bool CheckIfConnectingPipeAlreadyExists(ConnectingPipe pipe, IConstBlock block)
 {
     return(block.PipesWithOneEdge.Any(p => p.IsEqualTo(pipe)));
 }
Exemplo n.º 6
0
 public bool IsEqualTo(ConnectingPipe pipe)
 {
     return(Edge == pipe.Edge);
 }
Exemplo n.º 7
0
 public void DeletePipe(ConnectingPipe pipe)
 {
     pipesWithOneEdge.Remove(pipe);
 }
Exemplo n.º 8
0
 public void AddPipe(ConnectingPipe pipe)
 {
     pipesWithOneEdge.Add(pipe);
 }