public static bool RoomHasDupConnection(Room rm, string dupString) { var dupes = 0; foreach (var element in rm.GetConnections()) { if (element.GetTargetRoom() == rm && element.EndText == dupString) { dupes++; } if (element.GetSourceRoom() == rm && element.StartText == dupString) { dupes++; } } return(dupes > 1); }
void IAutomapCanvas.RemoveExitStub(Room room, AutomapDirection direction) { if (!Project.Current.Elements.Contains(room)) { // avoid issues if the user has just deleted one of these rooms return; } var compassPoint = CompassPointHelper.GetCompassDirection(direction); foreach (var connection in room.GetConnections(compassPoint)) { CompassPoint sourceCompassPoint, targetCompassPoint; var source = connection.GetSourceRoom(out sourceCompassPoint); var target = connection.GetTargetRoom(out targetCompassPoint); if (source == room && target == room && sourceCompassPoint == compassPoint && targetCompassPoint == compassPoint) { Project.Current.Elements.Remove(connection); } } }