コード例 #1
0
        public static void GenerateDefaultRoomLayout(PrototypeDungeonRoom room, CellType DefaultCellType = CellType.FLOOR)
        {
            if (room == null)
            {
                return;
            }
            int       width        = room.Width;
            int       height       = room.Height;
            FieldInfo privateField = typeof(PrototypeDungeonRoom).GetField("m_cellData", BindingFlags.Instance | BindingFlags.NonPublic);

            PrototypeDungeonRoomCellData[] m_cellData = new PrototypeDungeonRoomCellData[width * height];

            CellType[,] cellData = new CellType[width, height];
            for (int Y = 0; Y < height; Y++)
            {
                for (int X = 0; X < width; X++)
                {
                    cellData[X, Y] = DefaultCellType;
                }
            }

            for (int X = 0; X < width; X++)
            {
                for (int Y = 0; Y < height; Y++)
                {
                    m_cellData[Y * width + X] = GenerateDefaultCellData(cellData[X, Y]);
                }
            }

            privateField.SetValue(room, m_cellData);
            room.UpdatePrecalculatedData();
        }
コード例 #2
0
        public static PrototypeDungeonRoom CreateEmptyRoom(int width = 12, int height = 12)
        {
            try {
                Tools.Print("  Create Empty Room...", "5599FF");
                PrototypeDungeonRoom room = GetNewPrototypeDungeonRoom(width, height);
                AddExit(room, new Vector2(width / 2, height), DungeonData.Direction.NORTH);
                AddExit(room, new Vector2(width / 2, 0), DungeonData.Direction.SOUTH);
                AddExit(room, new Vector2(width, height / 2), DungeonData.Direction.EAST);
                AddExit(room, new Vector2(0, height / 2), DungeonData.Direction.WEST);

                room.FullCellData = new PrototypeDungeonRoomCellData[width * height];
                for (int x = 0; x < width; x++)
                {
                    for (int y = 0; y < height; y++)
                    {
                        room.FullCellData[x + y * width] = new PrototypeDungeonRoomCellData()
                        {
                            state      = CellType.FLOOR,
                            appearance = new PrototypeDungeonRoomCellAppearance()
                            {
                                OverrideFloorType = FloorType.Stone,
                            },
                        };
                    }
                }

                room.OnBeforeSerialize();
                room.OnAfterDeserialize();
                room.UpdatePrecalculatedData();
                return(room);
            } catch (Exception e) {
                Tools.PrintException(e);
                return(null);
            }
        }
コード例 #3
0
 public static PrototypeDungeonRoom Build(AssetBundle[] Bundles, Texture2D texture, RoomData roomData, bool SetRoomCategory, bool AutoAssignToFloor, bool AssignDecorationProperties, float?Weight)
 {
     try {
         PrototypeDungeonRoom room = CreateRoomFromTexture(texture);
         ApplyRoomData(Bundles, room, roomData, SetRoomCategory, AutoAssignToFloor, AssignDecorationProperties, Weight);
         room.OnBeforeSerialize();
         room.OnAfterDeserialize();
         room.UpdatePrecalculatedData();
         return(room);
     } catch (Exception e) {
         Tools.PrintError("Failed to build room!");
         Tools.PrintException(e);
     }
     return(CreateEmptyRoom(12, 12));
 }
コード例 #4
0
 // 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));
 }
コード例 #5
0
        // Token: 0x06000047 RID: 71 RVA: 0x0000407C File Offset: 0x0000227C
        public static PrototypeDungeonRoom CreateEmptyRoom(int width = 12, int height = 12)
        {
            PrototypeDungeonRoom result;

            try
            {
                PrototypeDungeonRoom newPrototypeDungeonRoom = RoomFactory.GetNewPrototypeDungeonRoom(width, height);
                RoomFactory.AddExit(newPrototypeDungeonRoom, new Vector2((float)(width / 2), (float)height), DungeonData.Direction.NORTH);
                RoomFactory.AddExit(newPrototypeDungeonRoom, new Vector2((float)(width / 2), 0f), DungeonData.Direction.SOUTH);
                RoomFactory.AddExit(newPrototypeDungeonRoom, new Vector2((float)width, (float)(height / 2)), DungeonData.Direction.EAST);
                RoomFactory.AddExit(newPrototypeDungeonRoom, new Vector2(0f, (float)(height / 2)), DungeonData.Direction.WEST);
                PrototypeDungeonRoomCellData[] array = RoomFactory.m_cellData.GetValue(newPrototypeDungeonRoom) as PrototypeDungeonRoomCellData[];
                array = new PrototypeDungeonRoomCellData[width * height];
                for (int i = 0; i < width; i++)
                {
                    for (int j = 0; j < height; j++)
                    {
                        array[i + j * width] = new PrototypeDungeonRoomCellData
                        {
                            state      = CellType.FLOOR,
                            appearance = new PrototypeDungeonRoomCellAppearance
                            {
                                OverrideFloorType = CellVisualData.CellFloorType.Stone
                            }
                        };
                    }
                }
                RoomFactory.m_cellData.SetValue(newPrototypeDungeonRoom, array);
                newPrototypeDungeonRoom.UpdatePrecalculatedData();
                result = newPrototypeDungeonRoom;
            }
            catch (Exception e)
            {
                Tools.PrintException(e, "FF0000");
                result = null;
            }
            return(result);
        }
コード例 #6
0
        public static PrototypeDungeonRoom CreateEmptyRoom(int width = 12, int height = 12)
        {
            try
            {
                PrototypeDungeonRoom room = GetNewPrototypeDungeonRoom(width, height);
                AddExit(room, new Vector2(width / 2, height), DungeonData.Direction.NORTH);
                AddExit(room, new Vector2(width / 2, 0), DungeonData.Direction.SOUTH);
                AddExit(room, new Vector2(width, height / 2), DungeonData.Direction.EAST);
                AddExit(room, new Vector2(0, height / 2), DungeonData.Direction.WEST);

                PrototypeDungeonRoomCellData[] cellData = m_cellData.GetValue(room) as PrototypeDungeonRoomCellData[];
                cellData = new PrototypeDungeonRoomCellData[width * height];
                for (int x = 0; x < width; x++)
                {
                    for (int y = 0; y < height; y++)
                    {
                        cellData[x + y * width] = new PrototypeDungeonRoomCellData()
                        {
                            state      = CellType.FLOOR,
                            appearance = new PrototypeDungeonRoomCellAppearance()
                            {
                                OverrideFloorType = CellVisualData.CellFloorType.Stone,
                            },
                        };
                    }
                }
                m_cellData.SetValue(room, cellData);

                room.UpdatePrecalculatedData();
                return(room);
            }
            catch (Exception e)
            {
                Tools.PrintException(e);
                return(null);
            }
        }
コード例 #7
0
        public static void GenerateBasicRoomLayout(PrototypeDungeonRoom room, CellType DefaultCellType = CellType.FLOOR, PrototypeRoomPitEntry.PitBorderType pitBorderType = PrototypeRoomPitEntry.PitBorderType.FLAT)
        {
            int width       = room.Width;
            int height      = room.Height;
            int ArrayLength = (width * height);

            room.FullCellData = new PrototypeDungeonRoomCellData[ArrayLength];
            List <Vector2> m_Pits = new List <Vector2>();

            for (int X = 0; X < width; X++)
            {
                for (int Y = 0; Y < height; Y++)
                {
                    int ArrayPosition = (Y * width + X);
                    room.FullCellData[ArrayPosition] = GenerateCellData(DefaultCellType);
                    if (DefaultCellType == CellType.PIT)
                    {
                        m_Pits.Add(new Vector2(X, Y));
                    }
                }
            }

            if (m_Pits.Count > 0)
            {
                room.pits = new List <PrototypeRoomPitEntry>()
                {
                    new PrototypeRoomPitEntry(m_Pits)
                    {
                        containedCells = m_Pits,
                        borderType     = pitBorderType
                    }
                };
            }

            room.OnBeforeSerialize();
            room.UpdatePrecalculatedData();
        }
コード例 #8
0
        public static void GenerateRoomLayoutFromPNG(PrototypeDungeonRoom room, string filePath, PrototypeRoomPitEntry.PitBorderType PitBorderType = PrototypeRoomPitEntry.PitBorderType.FLAT, CoreDamageTypes DamageCellsType = CoreDamageTypes.None)
        {
            Texture2D m_TextureFromResource = ResourceExtractor.GetTextureFromResource(TextureBasePath + filePath);

            float DamageToPlayersPerTick = 0;
            float DamageToEnemiesPerTick = 0;
            float TickFrequency          = 0;
            bool  RespectsFlying         = true;
            bool  DamageCellsArePoison   = false;

            if (DamageCellsType == CoreDamageTypes.Fire)
            {
                DamageToPlayersPerTick = 0.5f;
                TickFrequency          = 1;
            }
            else if (DamageCellsType == CoreDamageTypes.Poison)
            {
                DamageCellsArePoison   = true;
                DamageToPlayersPerTick = 0.5f;
                TickFrequency          = 1;
            }

            if (m_TextureFromResource == null)
            {
                ETGModConsole.Log("[ExpandTheGungeon] GenerateRoomFromImage: Error! Requested Texture Resource is Null!");
                return;
            }

            Color WhitePixel      = new Color32(255, 255, 255, 255);    // Wall Cell
            Color PinkPixel       = new Color32(255, 0, 255, 255);      // Diagonal Wall Cell (North East)
            Color YellowPixel     = new Color32(255, 255, 0, 255);      // Diagonal Wall Cell (North West)
            Color HalfPinkPixel   = new Color32(127, 0, 127, 255);      // Diagonal Wall Cell (South East)
            Color HalfYellowPixel = new Color32(127, 127, 0, 255);      // Diagonal Wall Cell (South West)

            Color BluePixel = new Color32(0, 0, 255, 255);              // Floor Cell

            Color BlueHalfGreenPixel = new Color32(0, 127, 255, 255);   // Floor Cell (Ice Override)
            Color HalfBluePixel      = new Color32(0, 0, 127, 255);     // Floor Cell (Water Override)
            Color HalfRedPixel       = new Color32(0, 0, 127, 255);     // Floor Cell (Carpet Override)
            Color GreenHalfRBPixel   = new Color32(127, 255, 127, 255); // Floor Cell (Grass Override)
            Color HalfWhitePixel     = new Color32(127, 127, 127, 255); // Floor Cell (Bone Override)
            Color OrangePixel        = new Color32(255, 127, 0, 255);   // Floor Cell (Flesh Override)
            Color RedHalfGBPixel     = new Color32(255, 127, 127, 255); // Floor Cell (ThickGoop Override)

            Color GreenPixel = new Color32(0, 255, 0, 255);             // Damage Floor Cell

            Color RedPixel = new Color32(255, 0, 0, 255);               // Pit Cell

            int width       = room.Width;
            int height      = room.Height;
            int ArrayLength = (width * height);

            if (m_TextureFromResource.GetPixels32().Length != ArrayLength)
            {
                ETGModConsole.Log("[ExpandTheGungeon] GenerateRoomFromImage: Error! Image resolution doesn't match size of room!");
                return;
            }

            room.FullCellData = new PrototypeDungeonRoomCellData[ArrayLength];
            List <Vector2> m_Pits = new List <Vector2>();

            for (int X = 0; X < width; X++)
            {
                for (int Y = 0; Y < height; Y++)
                {
                    int                          ArrayPosition     = (Y * width + X);
                    Color?                       m_Pixel           = m_TextureFromResource.GetPixel(X, Y);
                    CellType                     cellType          = CellType.FLOOR;
                    DiagonalWallType             diagonalWallType  = DiagonalWallType.NONE;
                    CellVisualData.CellFloorType OverrideFloorType = CellVisualData.CellFloorType.Stone;
                    bool                         isDamageCell      = false;
                    bool                         cellDamagesPlayer = false;
                    if (m_Pixel.HasValue)
                    {
                        if (m_Pixel.Value == WhitePixel | m_Pixel.Value == PinkPixel |
                            m_Pixel.Value == YellowPixel | m_Pixel.Value == HalfPinkPixel |
                            m_Pixel.Value == HalfYellowPixel)
                        {
                            cellType = CellType.WALL;
                            if (m_Pixel.Value == PinkPixel)
                            {
                                diagonalWallType = DiagonalWallType.NORTHEAST;
                            }
                            else if (m_Pixel.Value == YellowPixel)
                            {
                                diagonalWallType = DiagonalWallType.NORTHWEST;
                            }
                            else if (m_Pixel.Value == HalfPinkPixel)
                            {
                                diagonalWallType = DiagonalWallType.SOUTHEAST;
                            }
                            else if (m_Pixel.Value == HalfYellowPixel)
                            {
                                diagonalWallType = DiagonalWallType.SOUTHWEST;
                            }
                        }
                        else if (m_Pixel.Value == RedPixel)
                        {
                            cellType = CellType.PIT;
                            m_Pits.Add(new Vector2(X, Y));
                        }
                        else if (m_Pixel.Value == BluePixel | m_Pixel.Value == GreenPixel |
                                 m_Pixel.Value == BlueHalfGreenPixel | m_Pixel.Value == HalfBluePixel |
                                 m_Pixel.Value == HalfRedPixel | m_Pixel.Value == GreenHalfRBPixel |
                                 m_Pixel.Value == HalfWhitePixel | m_Pixel.Value == OrangePixel |
                                 m_Pixel.Value == RedHalfGBPixel)
                        {
                            cellType = CellType.FLOOR;
                            if (m_Pixel.Value == GreenPixel)
                            {
                                isDamageCell = true;
                                if (DamageCellsType == CoreDamageTypes.Ice)
                                {
                                    cellDamagesPlayer = false;
                                }
                                else
                                {
                                    cellDamagesPlayer = true;
                                }
                            }
                            else if (m_Pixel.Value == BlueHalfGreenPixel)
                            {
                                OverrideFloorType = CellVisualData.CellFloorType.Ice;
                            }
                            else if (m_Pixel.Value == HalfBluePixel)
                            {
                                OverrideFloorType = CellVisualData.CellFloorType.Water;
                            }
                            else if (m_Pixel.Value == HalfRedPixel)
                            {
                                OverrideFloorType = CellVisualData.CellFloorType.Carpet;
                            }
                            else if (m_Pixel.Value == GreenHalfRBPixel)
                            {
                                OverrideFloorType = CellVisualData.CellFloorType.Grass;
                            }
                            else if (m_Pixel.Value == HalfWhitePixel)
                            {
                                OverrideFloorType = CellVisualData.CellFloorType.Bone;
                            }
                            else if (m_Pixel.Value == OrangePixel)
                            {
                                OverrideFloorType = CellVisualData.CellFloorType.Flesh;
                            }
                            else if (m_Pixel.Value == RedHalfGBPixel)
                            {
                                OverrideFloorType = CellVisualData.CellFloorType.ThickGoop;
                            }
                        }
                        else
                        {
                            cellType = CellType.FLOOR;
                        }
                    }
                    else
                    {
                        cellType = CellType.FLOOR;
                    }
                    if (DamageCellsType != CoreDamageTypes.None && isDamageCell)
                    {
                        room.FullCellData[ArrayPosition] = GenerateCellData(cellType, diagonalWallType, cellDamagesPlayer, DamageCellsArePoison, DamageCellsType, DamageToPlayersPerTick, DamageToEnemiesPerTick, TickFrequency, RespectsFlying);
                    }
                    else
                    {
                        room.FullCellData[ArrayPosition] = GenerateCellData(cellType, diagonalWallType, OverrideFloorType: OverrideFloorType);
                    }
                }
            }

            if (m_Pits.Count > 0)
            {
                room.pits = new List <PrototypeRoomPitEntry>()
                {
                    new PrototypeRoomPitEntry(m_Pits)
                    {
                        containedCells = m_Pits,
                        borderType     = PitBorderType
                    }
                };
            }
            room.OnBeforeSerialize();
            room.OnAfterDeserialize();
            room.UpdatePrecalculatedData();
        }
コード例 #9
0
        public static void AssignCellData(PrototypeDungeonRoom room, string fileName)
        {
            string[] linesFromEmbeddedResource = ResourceExtractor.GetLinesFromEmbeddedResource(fileName);
            int      width  = room.Width;
            int      height = room.Height;

            CellType[,] cellData = new CellType[width, height];
            for (int Y = 0; Y < height; Y++)
            {
                string text = linesFromEmbeddedResource[Y];
                for (int X = 0; X < width; X++)
                {
                    // Corrects final row being off by one unit (read as first line in text file)
                    if (Y == 0 && X > 0)
                    {
                        char c = text[X];
                        if (c != '-')
                        {
                            if (c != 'P')
                            {
                                if (c == 'W')
                                {
                                    cellData[X - 1, height - Y - 1] = CellType.WALL;
                                }
                            }
                            else
                            {
                                cellData[X - 1, height - Y - 1] = CellType.PIT;
                            }
                        }
                        else
                        {
                            cellData[X - 1, height - Y - 1] = CellType.FLOOR;
                        }
                    }
                    else
                    {
                        char c = text[X];
                        if (c != '-')
                        {
                            if (c != 'P')
                            {
                                if (c == 'W')
                                {
                                    cellData[X, height - Y - 1] = CellType.WALL;
                                }
                            }
                            else
                            {
                                cellData[X, height - Y - 1] = CellType.PIT;
                            }
                        }
                        else
                        {
                            cellData[X, height - Y - 1] = CellType.FLOOR;
                        }
                    }
                }
            }

            // Set Final Cell (it was left null for some reason)
            string text2 = linesFromEmbeddedResource[height - 1];
            char   C     = text2[width - 1];

            if (C != '-')
            {
                if (C != 'P')
                {
                    if (C == 'W')
                    {
                        cellData[width - 1, height - 1] = CellType.WALL;
                    }
                }
                else
                {
                    cellData[width - 1, height - 1] = CellType.PIT;
                }
            }
            else
            {
                cellData[width - 1, height - 1] = CellType.FLOOR;
            }

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    room.GetCellDataAtPoint(i, j).state = cellData[i, j];
                }
            }
            room.UpdatePrecalculatedData();
        }
コード例 #10
0
        public static void AssignCellDataForNewRoom(PrototypeDungeonRoom room, string fileName)
        {
            string[] linesFromEmbeddedResource = ResourceExtractor.GetLinesFromEmbeddedResource(fileName);
            int      width  = room.Width;
            int      height = room.Height;

            FieldInfo privateField = typeof(PrototypeDungeonRoom).GetField("m_cellData", BindingFlags.Instance | BindingFlags.NonPublic);

            PrototypeDungeonRoomCellData[] m_cellData = new PrototypeDungeonRoomCellData[width * height];

            CellType[,] cellData = new CellType[width, height];
            for (int Y = 0; Y < height; Y++)
            {
                string text = linesFromEmbeddedResource[Y];
                for (int X = 0; X < width; X++)
                {
                    // Corrects final row being off by one unit (read as first line in text file)
                    if (Y == 0 && X > 0)
                    {
                        char c = text[X];
                        if (c != '-')
                        {
                            if (c != 'P')
                            {
                                if (c == 'W')
                                {
                                    cellData[X - 1, height - Y - 1] = CellType.WALL;
                                }
                            }
                            else
                            {
                                cellData[X - 1, height - Y - 1] = CellType.PIT;
                            }
                        }
                        else
                        {
                            cellData[X - 1, height - Y - 1] = CellType.FLOOR;
                        }
                    }
                    else
                    {
                        char c = text[X];
                        if (c != '-')
                        {
                            if (c != 'P')
                            {
                                if (c == 'W')
                                {
                                    cellData[X, height - Y - 1] = CellType.WALL;
                                }
                            }
                            else
                            {
                                cellData[X, height - Y - 1] = CellType.PIT;
                            }
                        }
                        else
                        {
                            cellData[X, height - Y - 1] = CellType.FLOOR;
                        }
                    }
                }
            }

            // Set Final Cell (it was left null for some reason)
            string text2 = linesFromEmbeddedResource[height - 1];
            char   C     = text2[width - 1];

            if (C != '-')
            {
                if (C != 'P')
                {
                    if (C == 'W')
                    {
                        cellData[width - 1, height - 1] = CellType.WALL;
                    }
                }
                else
                {
                    cellData[width - 1, height - 1] = CellType.PIT;
                }
            }
            else
            {
                cellData[width - 1, height - 1] = CellType.FLOOR;
            }

            for (int X = 0; X < width; X++)
            {
                for (int Y = 0; Y < height; Y++)
                {
                    m_cellData[Y * width + X] = GenerateDefaultCellData(cellData[X, Y]);
                }
            }
            privateField.SetValue(room, m_cellData);
            room.UpdatePrecalculatedData();
        }