public static ConnectAndMapReceipt Do(RandoLogic logic, UnlinkedEdge fromEdge, StaticEdge toEdge) { var toRoomStatic = toEdge.FromNode.ParentRoom; var fromRoom = fromEdge.Node.Room; if (fromEdge.Static.HoleTarget == null || toEdge.HoleTarget == null) { return(null); } var newOffset = fromEdge.Static.HoleTarget.Compatible(toEdge.HoleTarget); if (newOffset == Hole.INCOMPATIBLE) { return(null); } var newPosition = toRoomStatic.AdjacentPosition(fromRoom.Bounds, fromEdge.Static.HoleTarget.Side, newOffset); var toRoom = new LinkedRoom(toRoomStatic, newPosition); if (!logic.Map.AreaFree(toRoom)) { return(null); } logic.Map.AddRoom(toRoom); var newEdge = new LinkedEdge { NodeA = fromEdge.Node, NodeB = toRoom.Nodes[toEdge.FromNode.Name], StaticA = fromEdge.Static, StaticB = toEdge, }; newEdge.NodeA.Edges.Add(newEdge); newEdge.NodeB.Edges.Add(newEdge); if (!logic.Settings.RepeatRooms) { logic.RemainingRooms.Remove(toRoomStatic); } Logger.Log("randomizer", $"Adding room {toRoomStatic.Name} at {newPosition} ({logic.Map.Count})"); return(new ConnectAndMapReceipt { NewRoom = toRoom, Logic = logic, Edge = newEdge, EntryNode = toRoom.Nodes[toEdge.FromNode.Name], }); }
public static ConnectAndMapReceipt DoWarp(RandoLogic logic, UnlinkedEdge fromEdge, StaticRoom toRoomStatic) { var fromRoom = fromEdge.Node.Room; if (!fromEdge.Static.CustomWarp) { return(null); } var toRoom = LinkRoomAnywhere(logic, fromRoom, toRoomStatic); var extras = WarpClosure(logic, toRoom.Nodes["main"]); if (extras == null) { return(null); } var newEdge = new LinkedEdge { NodeA = fromEdge.Node, NodeB = toRoom.Nodes["main"], StaticA = fromEdge.Static, StaticB = toRoomStatic.Nodes["main"].WarpEdge, }; newEdge.NodeA.Edges.Add(newEdge); newEdge.NodeB.Edges.Add(newEdge); if (!logic.Settings.RepeatRooms) { logic.RemainingRooms.Remove(toRoomStatic); foreach (var extra in extras) { logic.RemainingRooms.Remove(extra.Static); } } Logger.Log("randomizer", $"Adding room {toRoomStatic.Name} at {toRoom.Position} ({logic.Map.Count})"); return(new ConnectAndMapReceipt { NewRoom = toRoom, Logic = logic, Edge = newEdge, EntryNode = toRoom.Nodes["main"], ExtraRooms = extras, }); }