private void deleteRoomFromWorldToolStripMenuItem_Click(object sender, EventArgs e)
{
if(currentState == State.EDITING_WORLD){
if(world.Rooms.Count <= 1){
showMessage("Room Delete Error", "There is only one room, you cannot delete any more!");
}else{
RoomSelectDialog dialog = new RoomSelectDialog(world, true, "Select room to delete.");
if(dialog.ShowDialog() == DialogResult.OK)
{
Room toDelete = dialog.SelectedRoom;
//First, remove the room from the list if rooms.
world.Rooms.Remove(toDelete);
//Next, clear all the links into this room from other doors.
foreach(Door door in toDelete.Doors)
{
if(door.Link != null)
{
door.Link.Link = null;
}
}
//Finally, if this was the room with the player, set the world's
// starting room to null.
if(toDelete == world.CurrentRoom)
{
world.CurrentRoom = null;
}
}
}
}
}