Beispiel #1
0
        private static List <StaticRoom> ProcessMap(MapData map, Dictionary <String, RandoConfigRoom> config)
        {
            var result    = new List <StaticRoom>();
            var resultMap = new Dictionary <string, StaticRoom>();

            foreach (LevelData level in map.Levels)
            {
                if (level.Dummy)
                {
                    continue;
                }
                if (!config.TryGetValue(level.Name, out RandoConfigRoom roomConfig))
                {
                    continue;
                }
                if (roomConfig == null || roomConfig.Holes == null)
                {
                    continue;
                }
                var holes = RandoLogic.FindHoles(level);
                var room  = new StaticRoom(map.Area, roomConfig, level, holes);
                result.Add(room);
                resultMap[level.Name] = room;
            }

            foreach (var room in result)
            {
                room.ProcessWarps(resultMap);
            }

            return(result);
        }
Beispiel #2
0
            public static StartRoomReceipt Do(RandoLogic logic, StaticRoom newRoomStatic)
            {
                Logger.Log("randomizer", $"Adding room {newRoomStatic.Name} at start");
                var newRoom = new LinkedRoom(newRoomStatic, Vector2.Zero);

                logic.Map.AddRoom(newRoom);

                if (!logic.Settings.RepeatRooms)
                {
                    logic.RemainingRooms.Remove(newRoomStatic);
                }

                return(new StartRoomReceipt {
                    Logic = logic,
                    NewRoom = newRoom,
                });
            }
Beispiel #3
0
 public LinkedRoom(StaticRoom Room, Vector2 Position)
 {
     this.Static      = Room;
     this.Bounds      = new Rectangle((int)Position.X, (int)Position.Y, Room.Level.Bounds.Width, Room.Level.Bounds.Height);
     this.ExtraBounds = new List <Rectangle>();
     foreach (var r in Room.ExtraSpace)
     {
         this.ExtraBounds.Add(new Rectangle((int)Position.X + r.X, (int)Position.Y + r.Y, r.Width, r.Height));
     }
     foreach (var staticnode in Room.Nodes.Values)
     {
         var node = new LinkedNode()
         {
             Static = staticnode, Room = this
         };
         this.Nodes.Add(staticnode.Name, node);
     }
 }
Beispiel #4
0
            public static StartRoomReceipt Do(RandoLogic logic, StaticRoom newRoomStatic)
            {
                Logger.Log("randomizer", $"Adding room {newRoomStatic.Name} at start");
                var newRoom = new LinkedRoom(newRoomStatic, Vector2.Zero);
                var extras  = ConnectAndMapReceipt.WarpClosure(logic, newRoom.Nodes["main"]);

                logic.Map.AddRoom(newRoom);

                if (!logic.Settings.RepeatRooms)
                {
                    logic.RemainingRooms.Remove(newRoomStatic);
                    foreach (var extra in extras)
                    {
                        logic.RemainingRooms.Remove(extra.Static);
                    }
                }

                return(new StartRoomReceipt {
                    Logic = logic,
                    NewRoom = newRoom,
                    ExtraRooms = extras,
                });
            }
 public LabyrinthStartRoom(StaticRoom room) : base(room, Vector2.Zero)
 {
 }
Beispiel #6
0
            public static LinkedRoom LinkRoomAnywhere(RandoLogic logic, LinkedRoom start, StaticRoom room, bool isBacktrack = false)
            {
                float      jumpScale = 8 * 150;
                int        jumpDir   = 0;
                LinkedRoom toRoom    = null;
                Vector2    newPosition;

                while (true)
                {
                    newPosition = start.Position + Vector2.UnitX * jumpScale * (jumpDir == 0 ? 1 : jumpDir == 1 ? -1 : 0)
                                  + Vector2.UnitY * jumpScale * (jumpDir == 2 ? 1 : jumpDir == 3 ? -1 : 0);
                    toRoom             = new LinkedRoom(room, newPosition);
                    toRoom.IsBacktrack = isBacktrack;

                    if (logic.Map.AreaFree(toRoom))
                    {
                        break;
                    }

                    if (++jumpDir == 4)
                    {
                        jumpDir    = 0;
                        jumpScale *= 2f;
                    }
                }

                logic.Map.AddRoom(toRoom);
                return(toRoom);
            }
Beispiel #7
0
            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,
                });
            }
Beispiel #8
0
 private bool RoomFilter(StaticRoom room)
 {
     return(!this.TriedRooms.Contains(room) &&
            this.IsEnd == room.End &&
            room.Worth <= PathwayMaxRoom[(int)Logic.Settings.Length + (this.IsEnd ? 1 : 0)]);
 }
 private bool RoomFilter(StaticRoom room)
 {
     return(!this.TriedRooms.Contains(room) &&
            (this.IsEnd ? room.ReqEnd.Able(this.Logic.Caps) : room.ReqEnd is Impossible) &&
            room.Worth <= PathwayMaxRoom[(int)Logic.Settings.Length + (this.IsEnd ? 1 : 0)]);
 }