Exemple #1
0
            public TaskPathwayPickRoom(RandoLogic Logic, UnlinkedEdge edge) : base(Logic)
            {
                this.Edge = edge;

                float progress = (Logic.Map.Worth - PathwayMinimums[(int)Logic.Settings.Length]) / PathwayRanges[(int)Logic.Settings.Length];

                this.IsEnd = progress > Math.Sqrt(Logic.Random.NextFloat());
            }
            public TaskPathwayPickRoom(RandoLogic Logic, UnlinkedEdge edge) : base(Logic)
            {
                this.Edge = edge;

                double progress = (double)(Logic.Map.Count - Minimums[(int)Logic.Settings.Length]) / (double)Ranges[(int)Logic.Settings.Length];

                this.IsEnd = progress > Math.Sqrt(Logic.Random.NextDouble());
            }
            public TaskPathwayPickRoom(RandoLogic Logic, UnlinkedEdge edge, FlagSet state) : base(Logic)
            {
                this.Edge  = edge;
                this.State = state;

                float progress = (Logic.Map.Worth - PathwayMinimums[(int)Logic.Settings.Length]) / PathwayRanges[(int)Logic.Settings.Length];

                this.IsEnd   = progress > Math.Sqrt(Logic.Random.NextFloat());
                this.FakeEnd = this.IsEnd && Logic.Random.Next(100) == 0;
            }
Exemple #4
0
            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],
                });
            }
Exemple #5
0
            private ConnectAndMapReceipt WorkingPossibility(UnlinkedEdge fromEdge)
            {
                var capsNoKey = this.Logic.Caps.WithoutKey();

                foreach (var toEdge in this.Logic.AvailableNewEdges(capsNoKey, capsNoKey, (StaticEdge e) => !e.FromNode.ParentRoom.End))
                {
                    var result = ConnectAndMapReceipt.Do(this.Logic, fromEdge, toEdge);
                    if (result != null)
                    {
                        return(result);
                    }
                }

                return(null);
            }
Exemple #6
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,
                });
            }
Exemple #7
0
        public List <UnlinkedEdge> UnlinkedEdges(Func <UnlinkedEdge, bool> filter = null)
        {
            var result = new List <UnlinkedEdge>();

            foreach (var node in this.Nodes)
            {
                foreach (var edge in node.UnlinkedEdges(this.CapsForward, this.CapsReverse))
                {
                    var uEdge = new UnlinkedEdge(node, edge);
                    if (filter != null && !filter(uEdge))
                    {
                        continue;
                    }
                    result.Add(uEdge);
                }
            }
            if (this.Random != null)
            {
                result.Shuffle(this.Random);
            }
            return(result);
        }
Exemple #8
0
 public static Requirement TraversalRequires(LinkedNode start, Capabilities capsForward, bool internalOnly, UnlinkedEdge end)
 {
     return(Requirement.And(new List <Requirement> {
         TraversalRequires(start, capsForward, internalOnly, end.Node),
         end.Static.ReqOut.Conflicts(capsForward)
     }));
 }
Exemple #9
0
 public TaskLabyrinthContinue(RandoLogic logic, UnlinkedEdge edge, int goodwill = 5) : base(logic)
 {
     this.Edge     = edge;
     this.Goodwill = goodwill;
 }