public void PlacePipe(Coordinate position, ConnectingPipe pipe) { blocks.Get(position).AddPipe(pipe); foreach (var observer in observers) { observer.ConnectingPipeAdded(this, position, pipe); } }
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))); }
public bool IsEqualTo(ConnectingPipe pipe) { return(Edge == pipe.Edge); }
public void DeletePipe(ConnectingPipe pipe) { pipesWithOneEdge.Remove(pipe); }
public void AddPipe(ConnectingPipe pipe) { pipesWithOneEdge.Add(pipe); }