public bool Reroll(Func <RandomLevelData, bool> requirements)
        {
            TileConnection requirement = TileConnection.None;

            if (this.data.up && this.up != null && this.up.data != null)
            {
                requirement |= TileConnection.Up;
            }
            if (this.data.down && this.down != null && this.down.data != null)
            {
                requirement |= TileConnection.Down;
            }
            if (this.data.left && this.left != null && this.left.data != null)
            {
                requirement |= TileConnection.Left;
            }
            if (this.data.right && this.right != null && this.right.data != null)
            {
                requirement |= TileConnection.Right;
            }
            RandomLevelData tile = LevelGenerator.GetTile(requirement, this.data, type: LevGenType.Deathmatch, lambdaReq: requirements);

            if (tile == null)
            {
                return(false);
            }
            this.data = tile;
            if (this.symmetricalPartner != null)
            {
                this.symmetricalPartner.data = tile.Flipped();
            }
            return(true);
        }
Exemple #2
0
        public static RandomLevelData LoadInTile(string tile, string realName = null)
        {
            RandomLevelData element = new RandomLevelData();

            element.file = tile;
            if (realName != null)
            {
                element.file = realName;
            }
            LevelData levelData = Content.GetLevel(tile) ?? DuckFile.LoadLevel(tile);
            int       sideMask  = levelData.proceduralData.sideMask;

            if (sideMask == 0)
            {
                return((RandomLevelData)null);
            }
            if ((sideMask & 1) != 0)
            {
                element.up = true;
            }
            if ((sideMask & 2) != 0)
            {
                element.right = true;
            }
            if ((sideMask & 4) != 0)
            {
                element.down = true;
            }
            if ((sideMask & 8) != 0)
            {
                element.left = true;
            }
            element.chance = levelData.proceduralData.chance;
            element.max    = levelData.proceduralData.maxPerLevel;
            element.single = levelData.proceduralData.enableSingle;
            element.multi  = levelData.proceduralData.enableMulti;
            element.ApplyWeaponData(levelData.proceduralData.weaponConfig);
            element.ApplySpawnerData(levelData.proceduralData.spawnerConfig);
            element.numArmor       = levelData.proceduralData.numArmor;
            element.numEquipment   = levelData.proceduralData.numEquipment;
            element.numKeys        = levelData.proceduralData.numKeys;
            element.numLockedDoors = levelData.proceduralData.numLockedDoors;
            element.numSpawns      = levelData.proceduralData.numSpawns;
            element.numTeamSpawns  = levelData.proceduralData.numTeamSpawns;
            element.canMirror      = levelData.proceduralData.canMirror;
            element.isMirrored     = levelData.proceduralData.isMirrored;
            element.data           = levelData.objects.objects;
            LevelGenerator._tiles.Add(element);
            if (element.up)
            {
                LevelGenerator._connections.Add(TileConnection.Up, element);
            }
            if (element.down)
            {
                LevelGenerator._connections.Add(TileConnection.Down, element);
            }
            if (element.left)
            {
                LevelGenerator._connections.Add(TileConnection.Left, element);
                LevelGenerator._connections.Add(TileConnection.Right, element.Flipped());
            }
            if (element.right)
            {
                LevelGenerator._connections.Add(TileConnection.Right, element);
                LevelGenerator._connections.Add(TileConnection.Left, element.Flipped());
            }
            LevelGenerator._tiles.Add(element.Flipped());
            return(element);
        }