public void Detach() { //TODO: release gas to environmental air SetAnchored(false); SetSpriteLayer(); int neighboorPipes = 0; for (int i = 0; i < nodes.Count; i++) { var pipe = nodes[i]; pipe.nodes.Remove(this); pipe.SpriteChange(); neighboorPipes++; } nodes = new List <Pipe>(); Pipenet oldPipenet = pipenet; pipenet.RemovePipe(this); if (oldPipenet.members.Count == 0) { //we're the only pipe on the net, delete it oldPipenet.DeletePipenet(); return; } if (neighboorPipes == 1) { //we're at an edge of the pipenet, safe to remove return; } oldPipenet.Separate(); }
public void Detach() { var foundMeters = MatrixManager.GetAt <Meter>(registerTile.WorldPositionServer, true); for (int i = 0; i < foundMeters.Count; i++) { var meter = foundMeters[i]; if (meter.anchored) { foundMeters[i].Detach(); } } //TODO: release gas to environmental air SetAnchored(false); SetSpriteLayer(false); int neighboorPipes = 0; for (int i = 0; i < nodes.Count; i++) { var pipe = nodes[i]; pipe.nodes.Remove(this); pipe.CalculateSprite(); neighboorPipes++; } nodes = new List <Pipe>(); Pipenet oldPipenet = pipenet; pipenet.RemovePipe(this); if (oldPipenet.members.Count == 0) { //we're the only pipe on the net, delete it oldPipenet.DeletePipenet(); return; } if (neighboorPipes == 1) { //we're at an edge of the pipenet, safe to remove return; } oldPipenet.Separate(); }