// Token: 0x06000007 RID: 7 RVA: 0x00002D88 File Offset: 0x00000F88
        public static void Register(RoomFactory.RoomData roomData)
        {
            PrototypeDungeonRoom room = roomData.room;
            WeightedRoom         w    = new WeightedRoom
            {
                room = room,
                additionalPrerequisites = new DungeonPrerequisite[0],
                weight = ((roomData.weight == 0f) ? DungeonHandler.GlobalRoomWeight : roomData.weight)
            };

            switch (room.category)
            {
            case PrototypeDungeonRoom.RoomCategory.BOSS:
                return;

            case PrototypeDungeonRoom.RoomCategory.SPECIAL:
            {
                PrototypeDungeonRoom.RoomSpecialSubCategory subCategorySpecial     = room.subCategorySpecial;
                PrototypeDungeonRoom.RoomSpecialSubCategory roomSpecialSubCategory = subCategorySpecial;
                bool flag = roomSpecialSubCategory != PrototypeDungeonRoom.RoomSpecialSubCategory.STANDARD_SHOP;
                if (flag)
                {
                    bool flag2 = roomSpecialSubCategory != PrototypeDungeonRoom.RoomSpecialSubCategory.WEIRD_SHOP;
                    if (flag2)
                    {
                        StaticReferences.RoomTables["special"].includedRooms.Add(w);
                    }
                    else
                    {
                        StaticReferences.subShopTable.InjectionData.Add(DungeonHandler.GetFlowModifier(roomData));
                    }
                }
                else
                {
                    StaticReferences.RoomTables["shop"].includedRooms.Add(w);
                }
                return;
            }

            case PrototypeDungeonRoom.RoomCategory.SECRET:
                StaticReferences.RoomTables["secret"].includedRooms.Add(w);
                return;
            }
            List <DungeonPrerequisite> list = new List <DungeonPrerequisite>();

            foreach (DungeonPrerequisite dungeonPrerequisite in room.prerequisites)
            {
                bool requireTileset = dungeonPrerequisite.requireTileset;
                bool flag3          = requireTileset;
                if (flag3)
                {
                    StaticReferences.GetRoomTable(dungeonPrerequisite.requiredTileset).includedRooms.Add(w);
                    list.Add(dungeonPrerequisite);
                }
            }
            foreach (DungeonPrerequisite item in list)
            {
                room.prerequisites.Remove(item);
            }
        }
        // Token: 0x06000009 RID: 9 RVA: 0x00002FFC File Offset: 0x000011FC
        public static bool BelongsOnThisFloor(RoomFactory.RoomData data, string dungeonName)
        {
            bool flag  = data.floors == null || data.floors.Length == 0;
            bool flag2 = flag;
            bool result;

            if (flag2)
            {
                result = true;
            }
            else
            {
                bool flag3 = false;
                foreach (string text in data.floors)
                {
                    bool flag4 = text.ToLower().Equals(dungeonName.ToLower());
                    bool flag5 = flag4;
                    if (flag5)
                    {
                        flag3 = true;
                        break;
                    }
                }
                result = flag3;
            }
            return(result);
        }
        // Token: 0x0600003C RID: 60 RVA: 0x00003AD8 File Offset: 0x00001CD8
        public static RoomFactory.RoomData BuildFromResource(string roomPath)
        {
            Texture2D textureFromResource = ResourceExtractor.GetTextureFromResource(roomPath);

            RoomFactory.RoomData roomData = RoomFactory.ExtractRoomDataFromResource(roomPath);
            roomData.room = RoomFactory.Build(textureFromResource, roomData);
            return(roomData);
        }
        // Token: 0x0600003B RID: 59 RVA: 0x00003A94 File Offset: 0x00001C94
        public static RoomFactory.RoomData BuildFromFile(string roomPath)
        {
            Texture2D textureFromFile = ResourceExtractor.GetTextureFromFile(roomPath, ".room");

            textureFromFile.name = Path.GetFileName(roomPath);
            RoomFactory.RoomData roomData = RoomFactory.ExtractRoomDataFromFile(roomPath);
            roomData.room = RoomFactory.Build(textureFromFile, roomData);
            return(roomData);
        }
 // Token: 0x0600003D RID: 61 RVA: 0x00003B08 File Offset: 0x00001D08
 public static PrototypeDungeonRoom Build(Texture2D texture, RoomFactory.RoomData roomData)
 {
     try
     {
         PrototypeDungeonRoom prototypeDungeonRoom = RoomFactory.CreateRoomFromTexture(texture);
         RoomFactory.ApplyRoomData(prototypeDungeonRoom, roomData);
         prototypeDungeonRoom.UpdatePrecalculatedData();
         return(prototypeDungeonRoom);
     }
     catch (Exception e)
     {
         Tools.PrintError <string>("Failed to build room!", "FF0000");
         Tools.PrintException(e, "FF0000");
     }
     return(RoomFactory.CreateEmptyRoom(12, 12));
 }
 // Token: 0x0600003A RID: 58 RVA: 0x00003A08 File Offset: 0x00001C08
 public static void LoadRoomsFromRoomDirectory()
 {
     Directory.CreateDirectory(RoomFactory.roomDirectory);
     foreach (string text in Directory.GetFiles(RoomFactory.roomDirectory))
     {
         bool flag = !text.EndsWith(".room");
         if (!flag)
         {
             string fileName = Path.GetFileName(text);
             Tools.Log <string>("Found room: \"" + fileName + "\"");
             RoomFactory.RoomData roomData = RoomFactory.BuildFromFile(text);
             DungeonHandler.Register(roomData);
             RoomFactory.rooms.Add(fileName, roomData);
         }
     }
 }
 // Token: 0x06000008 RID: 8 RVA: 0x00002F78 File Offset: 0x00001178
 public static ProceduralFlowModifierData GetFlowModifier(RoomFactory.RoomData roomData)
 {
     return(new ProceduralFlowModifierData
     {
         annotation = roomData.room.name,
         placementRules = new List <ProceduralFlowModifierData.FlowModifierPlacementType>
         {
             ProceduralFlowModifierData.FlowModifierPlacementType.END_OF_CHAIN,
             ProceduralFlowModifierData.FlowModifierPlacementType.HUB_ADJACENT_NO_LINK
         },
         exactRoom = roomData.room,
         selectionWeight = roomData.weight,
         chanceToSpawn = 1f,
         prerequisites = roomData.room.prerequisites.ToArray(),
         CanBeForcedSecret = true
     });
 }
Example #8
0
        public static void RegisterShrineRoom(GameObject shrine, PrototypeDungeonRoom protoroom, string ID, Vector2 offset)
        {
            protoroom.category = PrototypeDungeonRoom.RoomCategory.NORMAL;

            DungeonPrerequisite[] emptyReqs = new DungeonPrerequisite[0];
            Vector2 position = new Vector2(protoroom.Width / 2 + offset.x, protoroom.Height / 2 + offset.y);

            protoroom.placedObjectPositions.Add(position);

            var placeableContents = ScriptableObject.CreateInstance <DungeonPlaceable>();

            placeableContents.width  = 2;
            placeableContents.height = 2;
            placeableContents.respectsEncounterableDifferentiator = true;
            placeableContents.variantTiers = new List <DungeonPlaceableVariant>()
            {
                new DungeonPlaceableVariant()
                {
                    percentChance        = 1,
                    nonDatabasePlaceable = shrine,
                    prerequisites        = emptyReqs,
                    materialRequirements = new DungeonPlaceableRoomMaterialRequirement[0]
                }
            };

            protoroom.placedObjects.Add(new PrototypePlacedObjectData()
            {
                contentsBasePosition  = position,
                fieldData             = new List <PrototypePlacedObjectFieldData>(),
                instancePrerequisites = emptyReqs,
                linkedTriggerAreaIDs  = new List <int>(),
                placeableContents     = placeableContents
            });

            var data = new RoomFactory.RoomData()
            {
                room               = protoroom,
                isSpecialRoom      = true,
                category           = "SPECIAL",
                specialSubCategory = "UNSPECIFIED_SPECIAL"
            };

            RoomFactory.rooms.Add(ID, data);
            DungeonHandler.Register(data);
        }
 // Token: 0x06000050 RID: 80 RVA: 0x00004840 File Offset: 0x00002A40
 public static void StraightLine()
 {
     try
     {
         Vector2[] array  = new Vector2[100];
         string[]  array2 = new string[100];
         int[]     array3 = new int[100];
         for (int i = 0; i < array2.Length; i++)
         {
             List <EnemyDatabaseEntry> entries = EnemyDatabase.Instance.Entries;
             int index = UnityEngine.Random.Range(0, entries.Count);
             array2[i] = entries[index].encounterGuid;
             array[i]  = new Vector2((float)(i * 2), 10f);
             array3[i] = 0;
         }
         Vector2[] exitPositions = new Vector2[]
         {
             new Vector2(0f, 9f),
             new Vector2(200f, 9f)
         };
         string[] exitDirections = new string[]
         {
             "WEST",
             "EAST"
         };
         RoomFactory.RoomData roomData = new RoomFactory.RoomData
         {
             enemyPositions           = array,
             enemyGUIDs               = array2,
             enemyReinforcementLayers = array3,
             exitPositions            = exitPositions,
             exitDirections           = exitDirections
         };
         Tools.Log <string>("Data to JSON: " + JsonUtility.ToJson(roomData));
     }
     catch (Exception e)
     {
         Tools.PrintException(e, "FF0000");
     }
 }
        // Token: 0x0600005A RID: 90 RVA: 0x000050E4 File Offset: 0x000032E4
        public static void RegisterShrineRoom(GameObject shrine, PrototypeDungeonRoom protoroom, string ID, Vector2 offset)
        {
            protoroom.category = PrototypeDungeonRoom.RoomCategory.NORMAL;
            DungeonPrerequisite[] array = new DungeonPrerequisite[0];
            Vector2 vector = new Vector2((float)(protoroom.Width / 2) + offset.x, (float)(protoroom.Height / 2) + offset.y);

            protoroom.placedObjectPositions.Add(vector);
            protoroom.placedObjects.Add(new PrototypePlacedObjectData
            {
                contentsBasePosition  = vector,
                fieldData             = new List <PrototypePlacedObjectFieldData>(),
                instancePrerequisites = array,
                linkedTriggerAreaIDs  = new List <int>(),
                placeableContents     = new DungeonPlaceable
                {
                    width  = 2,
                    height = 2,
                    respectsEncounterableDifferentiator = true,
                    variantTiers = new List <DungeonPlaceableVariant>
                    {
                        new DungeonPlaceableVariant
                        {
                            percentChance        = 1f,
                            nonDatabasePlaceable = shrine,
                            prerequisites        = array,
                            materialRequirements = new DungeonPlaceableRoomMaterialRequirement[0]
                        }
                    }
                }
            });
            RoomFactory.RoomData roomData = new RoomFactory.RoomData
            {
                room                = protoroom,
                isSpecialRoom       = true,
                category            = "SPECIAL",
                specialSubCatergory = "UNSPECIFIED_SPECIAL"
            };
            RoomFactory.rooms.Add(ID, roomData);
            DungeonHandler.Register(roomData);
        }
 // Token: 0x0600004F RID: 79 RVA: 0x000046D8 File Offset: 0x000028D8
 public static void LogExampleRoomData()
 {
     Vector2[] enemyPositions = new Vector2[]
     {
         new Vector2(4f, 4f),
         new Vector2(4f, 14f),
         new Vector2(14f, 4f),
         new Vector2(14f, 14f)
     };
     string[] enemyGUIDs = new string[]
     {
         "01972dee89fc4404a5c408d50007dad5",
         "7b0b1b6d9ce7405b86b75ce648025dd6",
         "ffdc8680bdaa487f8f31995539f74265",
         "01972dee89fc4404a5c408d50007dad5"
     };
     Vector2[] exitPositions = new Vector2[]
     {
         new Vector2(0f, 9f),
         new Vector2(9f, 0f),
         new Vector2(20f, 9f),
         new Vector2(9f, 20f)
     };
     string[] exitDirections = new string[]
     {
         "EAST",
         "SOUTH",
         "WEST",
         "NORTH"
     };
     RoomFactory.RoomData roomData = new RoomFactory.RoomData
     {
         enemyPositions = enemyPositions,
         enemyGUIDs     = enemyGUIDs,
         exitPositions  = exitPositions,
         exitDirections = exitDirections
     };
     Tools.Print <string>("Data to JSON: " + JsonUtility.ToJson(roomData), "FFFFFF", false);
 }
        // Token: 0x06000018 RID: 24 RVA: 0x0000399C File Offset: 0x00001B9C
        public static void RegisterShrineRoom(GameObject shrine, PrototypeDungeonRoom protoroom, string ID, Vector2 offset, float roomweight)
        {
            DungeonPrerequisite[] array = new DungeonPrerequisite[0];
            Vector2 vector = new Vector2((float)(protoroom.Width / 2) + offset.x, (float)(protoroom.Height / 2) + offset.y);

            protoroom.placedObjectPositions.Add(vector);
            protoroom.placedObjects.Add(new PrototypePlacedObjectData
            {
                contentsBasePosition  = vector,
                fieldData             = new List <PrototypePlacedObjectFieldData>(),
                instancePrerequisites = array,
                linkedTriggerAreaIDs  = new List <int>(),
                placeableContents     = new DungeonPlaceable
                {
                    width  = 2,
                    height = 2,
                    respectsEncounterableDifferentiator = true,
                    variantTiers = new List <DungeonPlaceableVariant>
                    {
                        new DungeonPlaceableVariant
                        {
                            percentChance        = 1f,
                            nonDatabasePlaceable = shrine,
                            prerequisites        = array,
                            materialRequirements = new DungeonPlaceableRoomMaterialRequirement[0]
                        }
                    }
                }
            });
            RoomFactory.RoomData roomData = new RoomFactory.RoomData
            {
                room     = protoroom,
                category = protoroom.category.ToString(),
                weight   = roomweight,
            };
            //RoomFactory.RoomData roomData = RoomFactory.ExtractRoomDataFromResource(roomPath);
            RoomFactory.rooms.Add(ID, roomData);
            DungeonHandler.RegisterForShrine(roomData);
        }
        // Token: 0x0600003E RID: 62 RVA: 0x00003B70 File Offset: 0x00001D70
        public static void ApplyRoomData(PrototypeDungeonRoom room, RoomFactory.RoomData roomData)
        {
            bool flag = roomData.exitPositions != null;

            if (flag)
            {
                for (int i = 0; i < roomData.exitPositions.Length; i++)
                {
                    DungeonData.Direction direction = (DungeonData.Direction)Enum.Parse(typeof(DungeonData.Direction), roomData.exitDirections[i].ToUpper());
                    RoomFactory.AddExit(room, roomData.exitPositions[i], direction);
                }
            }
            else
            {
                RoomFactory.AddExit(room, new Vector2((float)(room.Width / 2), (float)room.Height), DungeonData.Direction.NORTH);
                RoomFactory.AddExit(room, new Vector2((float)(room.Width / 2), 0f), DungeonData.Direction.SOUTH);
                RoomFactory.AddExit(room, new Vector2((float)room.Width, (float)(room.Height / 2)), DungeonData.Direction.EAST);
                RoomFactory.AddExit(room, new Vector2(0f, (float)(room.Height / 2)), DungeonData.Direction.WEST);
            }
            bool flag2 = roomData.enemyPositions != null;

            if (flag2)
            {
                for (int j = 0; j < roomData.enemyPositions.Length; j++)
                {
                    RoomFactory.AddEnemyToRoom(room, roomData.enemyPositions[j], roomData.enemyGUIDs[j], roomData.enemyReinforcementLayers[j]);
                }
            }
            bool flag3 = roomData.placeablePositions != null;

            if (flag3)
            {
                for (int k = 0; k < roomData.placeablePositions.Length; k++)
                {
                    RoomFactory.AddPlaceableToRoom(room, roomData.placeablePositions[k], roomData.placeableGUIDs[k]);
                }
            }
            bool flag4 = roomData.floors != null;

            if (flag4)
            {
                foreach (string val in roomData.floors)
                {
                    room.prerequisites.Add(new DungeonPrerequisite
                    {
                        prerequisiteType = DungeonPrerequisite.PrerequisiteType.TILESET,
                        requiredTileset  = Tools.GetEnumValue <GlobalDungeonData.ValidTilesets>(val)
                    });
                }
            }
            bool flag5 = !string.IsNullOrEmpty(roomData.category);

            if (flag5)
            {
                room.category = Tools.GetEnumValue <PrototypeDungeonRoom.RoomCategory>(roomData.category);
            }
            bool flag6 = !string.IsNullOrEmpty(roomData.normalSubCategory);

            if (flag6)
            {
                room.subCategoryNormal = Tools.GetEnumValue <PrototypeDungeonRoom.RoomNormalSubCategory>(roomData.normalSubCategory);
            }
            bool flag7 = !string.IsNullOrEmpty(roomData.bossSubCategory);

            if (flag7)
            {
                room.subCategoryBoss = Tools.GetEnumValue <PrototypeDungeonRoom.RoomBossSubCategory>(roomData.bossSubCategory);
            }
            bool flag8 = !string.IsNullOrEmpty(roomData.specialSubCatergory);

            if (flag8)
            {
                room.subCategorySpecial = Tools.GetEnumValue <PrototypeDungeonRoom.RoomSpecialSubCategory>(roomData.specialSubCatergory);
            }
        }