Exemple #1
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();
        }
Exemple #2
0
        public static PrototypeDungeonRoomCellData GenerateCellData(CellType cellType, DiagonalWallType diagnalWallType = DiagonalWallType.NONE, bool DoesDamage = false, bool IsPoison = false, CoreDamageTypes DamageType = CoreDamageTypes.None, float DamageToPlayersPerTick = 0, float DamageToEnemiesPerTick = 0, float TickFrequency = 0, bool RespectsFlying = true, CellVisualData.CellFloorType OverrideFloorType = CellVisualData.CellFloorType.Stone)
        {
            PrototypeDungeonRoomCellData m_NewCellData = new PrototypeDungeonRoomCellData(string.Empty, cellType)
            {
                state            = cellType,
                diagonalWallType = diagnalWallType,
                breakable        = false,
                str = string.Empty,
                conditionalOnParentExit     = false,
                conditionalCellIsPit        = false,
                parentExitIndex             = -1,
                containsManuallyPlacedLight = false,
                lightPixelsOffsetY          = 0,
                lightStampIndex             = 0,
                doesDamage       = DoesDamage,
                damageDefinition = new CellDamageDefinition()
                {
                    damageTypes            = DamageType,
                    damageToPlayersPerTick = DamageToEnemiesPerTick,
                    damageToEnemiesPerTick = DamageToEnemiesPerTick,
                    tickFrequency          = TickFrequency,
                    respectsFlying         = RespectsFlying,
                    isPoison = IsPoison
                },
                appearance = new PrototypeDungeonRoomCellAppearance()
                {
                    overrideDungeonMaterialIndex = -1,
                    IsPhantomCarpet       = false,
                    ForceDisallowGoop     = false,
                    OverrideFloorType     = OverrideFloorType,
                    globalOverrideIndices = new PrototypeIndexOverrideData()
                    {
                        indices = new List <int>(0)
                    }
                },
                ForceTileNonDecorated         = false,
                additionalPlacedObjectIndices = new List <int>()
                {
                    -1
                },
                placedObjectRUBELIndex = -1
            };

            if (DamageType == CoreDamageTypes.Poison)
            {
                m_NewCellData.ForceTileNonDecorated        = true;
                m_NewCellData.appearance.OverrideFloorType = CellVisualData.CellFloorType.Stone;
                m_NewCellData.damageDefinition.damageTypes = CoreDamageTypes.Poison;
            }
            else if (DamageType == CoreDamageTypes.Fire)
            {
                m_NewCellData.ForceTileNonDecorated        = true;
                m_NewCellData.appearance.OverrideFloorType = CellVisualData.CellFloorType.Stone;
                m_NewCellData.damageDefinition.damageTypes = CoreDamageTypes.Fire;
            }

            return(m_NewCellData);
        }
Exemple #3
0
        public static Texture2D LogDungeonToTexture2D()
        {
            int width  = GameManager.Instance.Dungeon.data.Height;
            int height = GameManager.Instance.Dungeon.data.Width;
            // int width = 1000;
            // int height = 1000;

            Texture2D m_NewImage = new Texture2D(width, height, TextureFormat.RGBA32, false);

            m_NewImage.name = GameManager.Instance.Dungeon.gameObject.name;

            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

            Color BlackPixel = new Color32(0, 0, 0, 255);               // NULL Cell

            for (int X = 0; X < width; X++)
            {
                for (int Y = 0; Y < height; Y++)
                {
                    if (GameManager.Instance.Dungeon.data.CheckInBoundsAndValid(X, Y))
                    {
                        IntVector2       m_CellPosition   = new IntVector2(X, Y);
                        CellType?        cellData         = GameManager.Instance.Dungeon.data[m_CellPosition].type;
                        CellData         localDungeonData = GameManager.Instance.Dungeon.data[m_CellPosition];
                        bool             DamageCell       = false;
                        DiagonalWallType diagonalWallType = DiagonalWallType.NONE;
                        if (localDungeonData != null)
                        {
                            DamageCell       = localDungeonData.doesDamage;
                            diagonalWallType = localDungeonData.diagonalWallType;
                        }
                        if (localDungeonData == null | !cellData.HasValue)
                        {
                            m_NewImage.SetPixel(X, Y, BlackPixel);
                        }
                        else if (cellData.Value == CellType.FLOOR)
                        {
                            if (DamageCell)
                            {
                                m_NewImage.SetPixel(X, Y, GreenPixel);
                            }
                            else
                            {
                                CellVisualData.CellFloorType overrideFloorType = localDungeonData.cellVisualData.floorType;
                                if (overrideFloorType == CellVisualData.CellFloorType.Stone)
                                {
                                    m_NewImage.SetPixel(X, Y, BluePixel);
                                }
                                else if (overrideFloorType == CellVisualData.CellFloorType.Ice)
                                {
                                    m_NewImage.SetPixel(X, Y, BlueHalfGreenPixel);
                                }
                                else if (overrideFloorType == CellVisualData.CellFloorType.Water)
                                {
                                    m_NewImage.SetPixel(X, Y, HalfBluePixel);
                                }
                                else if (overrideFloorType == CellVisualData.CellFloorType.Carpet)
                                {
                                    m_NewImage.SetPixel(X, Y, HalfRedPixel);
                                }
                                else if (overrideFloorType == CellVisualData.CellFloorType.Grass)
                                {
                                    m_NewImage.SetPixel(X, Y, GreenHalfRBPixel);
                                }
                                else if (overrideFloorType == CellVisualData.CellFloorType.Bone)
                                {
                                    m_NewImage.SetPixel(X, Y, HalfWhitePixel);
                                }
                                else if (overrideFloorType == CellVisualData.CellFloorType.Flesh)
                                {
                                    m_NewImage.SetPixel(X, Y, OrangePixel);
                                }
                                else if (overrideFloorType == CellVisualData.CellFloorType.ThickGoop)
                                {
                                    m_NewImage.SetPixel(X, Y, RedHalfGBPixel);
                                }
                                else
                                {
                                    m_NewImage.SetPixel(X, Y, BluePixel);
                                }
                            }
                        }
                        else if (cellData.Value == CellType.WALL)
                        {
                            if (diagonalWallType == DiagonalWallType.NORTHEAST)
                            {
                                m_NewImage.SetPixel(X, Y, PinkPixel);
                            }
                            else if (diagonalWallType == DiagonalWallType.NORTHWEST)
                            {
                                m_NewImage.SetPixel(X, Y, YellowPixel);
                            }
                            else if (diagonalWallType == DiagonalWallType.SOUTHEAST)
                            {
                                m_NewImage.SetPixel(X, Y, HalfPinkPixel);
                            }
                            else if (diagonalWallType == DiagonalWallType.SOUTHWEST)
                            {
                                m_NewImage.SetPixel(X, Y, HalfYellowPixel);
                            }
                            else
                            {
                                m_NewImage.SetPixel(X, Y, WhitePixel);
                            }
                        }
                        else if (cellData.Value == CellType.PIT)
                        {
                            m_NewImage.SetPixel(X, Y, RedPixel);
                        }
                    }
                    else
                    {
                        m_NewImage.SetPixel(X, Y, BlackPixel);
                    }
                }
            }

            m_NewImage.Apply();

            return(m_NewImage);
        }
Exemple #4
0
        public static void LogDungeonToPNGFile()
        {
            // int width = GameManager.Instance.Dungeon.data.Height;
            // int height = GameManager.Instance.Dungeon.data.Width;
            int width  = 1000;
            int height = 1000;

            Texture2D m_NewImage = new Texture2D(width, height, TextureFormat.RGBA32, false);

            m_NewImage.name = GameManager.Instance.Dungeon.gameObject.name;

            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

            Color BlackPixel = new Color32(0, 0, 0, 255);               // NULL Cell

            for (int X = 0; X < width; X++)
            {
                for (int Y = 0; Y < height; Y++)
                {
                    if (GameManager.Instance.Dungeon.data.CheckInBoundsAndValid(X, Y))
                    {
                        IntVector2       m_CellPosition   = new IntVector2(X, Y);
                        CellType?        cellData         = GameManager.Instance.Dungeon.data[m_CellPosition].type;
                        CellData         localDungeonData = GameManager.Instance.Dungeon.data[m_CellPosition];
                        bool             DamageCell       = false;
                        DiagonalWallType diagonalWallType = DiagonalWallType.NONE;
                        if (localDungeonData != null)
                        {
                            DamageCell       = localDungeonData.doesDamage;
                            diagonalWallType = localDungeonData.diagonalWallType;
                        }
                        if (localDungeonData == null | !cellData.HasValue)
                        {
                            m_NewImage.SetPixel(X, Y, BlackPixel);
                        }
                        else if (cellData.Value == CellType.FLOOR)
                        {
                            if (DamageCell)
                            {
                                m_NewImage.SetPixel(X, Y, GreenPixel);
                            }
                            else
                            {
                                CellVisualData.CellFloorType overrideFloorType = localDungeonData.cellVisualData.floorType;
                                if (overrideFloorType == CellVisualData.CellFloorType.Stone)
                                {
                                    m_NewImage.SetPixel(X, Y, BluePixel);
                                }
                                else if (overrideFloorType == CellVisualData.CellFloorType.Ice)
                                {
                                    m_NewImage.SetPixel(X, Y, BlueHalfGreenPixel);
                                }
                                else if (overrideFloorType == CellVisualData.CellFloorType.Water)
                                {
                                    m_NewImage.SetPixel(X, Y, HalfBluePixel);
                                }
                                else if (overrideFloorType == CellVisualData.CellFloorType.Carpet)
                                {
                                    m_NewImage.SetPixel(X, Y, HalfRedPixel);
                                }
                                else if (overrideFloorType == CellVisualData.CellFloorType.Grass)
                                {
                                    m_NewImage.SetPixel(X, Y, GreenHalfRBPixel);
                                }
                                else if (overrideFloorType == CellVisualData.CellFloorType.Bone)
                                {
                                    m_NewImage.SetPixel(X, Y, HalfWhitePixel);
                                }
                                else if (overrideFloorType == CellVisualData.CellFloorType.Flesh)
                                {
                                    m_NewImage.SetPixel(X, Y, OrangePixel);
                                }
                                else if (overrideFloorType == CellVisualData.CellFloorType.ThickGoop)
                                {
                                    m_NewImage.SetPixel(X, Y, RedHalfGBPixel);
                                }
                                else
                                {
                                    m_NewImage.SetPixel(X, Y, BluePixel);
                                }
                            }
                        }
                        else if (cellData.Value == CellType.WALL)
                        {
                            if (diagonalWallType == DiagonalWallType.NORTHEAST)
                            {
                                m_NewImage.SetPixel(X, Y, PinkPixel);
                            }
                            else if (diagonalWallType == DiagonalWallType.NORTHWEST)
                            {
                                m_NewImage.SetPixel(X, Y, YellowPixel);
                            }
                            else if (diagonalWallType == DiagonalWallType.SOUTHEAST)
                            {
                                m_NewImage.SetPixel(X, Y, HalfPinkPixel);
                            }
                            else if (diagonalWallType == DiagonalWallType.SOUTHWEST)
                            {
                                m_NewImage.SetPixel(X, Y, HalfYellowPixel);
                            }
                            else
                            {
                                m_NewImage.SetPixel(X, Y, WhitePixel);
                            }
                        }
                        else if (cellData.Value == CellType.PIT)
                        {
                            m_NewImage.SetPixel(X, Y, RedPixel);
                        }
                    }
                    else
                    {
                        m_NewImage.SetPixel(X, Y, BlackPixel);
                    }
                }
            }

            m_NewImage.Apply();

            string basePath = "DumpedDungeonLayouts/";

            string fileName = (basePath + m_NewImage.name);

            if (string.IsNullOrEmpty(m_NewImage.name))
            {
                fileName += ("DungeonLayout_" + Guid.NewGuid().ToString());
            }

            fileName += "_Layout";

            string path = Path.Combine(ETGMod.ResourcesDirectory, fileName.Replace('/', Path.DirectorySeparatorChar).Replace('\\', Path.DirectorySeparatorChar) + ".png");

            if (!File.Exists(path))
            {
                Directory.GetParent(path).Create();
            }

            File.WriteAllBytes(path, ImageConversion.EncodeToPNG(m_NewImage));
        }
Exemple #5
0
        public static void LogRoomToPNGFile(PrototypeDungeonRoom room)
        {
            int width  = room.Width;
            int height = room.Height;

            Texture2D m_NewImage = new Texture2D(width, height, TextureFormat.RGBA32, false);

            if (!string.IsNullOrEmpty(room.name))
            {
                m_NewImage.name = room.name;
            }

            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

            Color BlackPixel = new Color32(0, 0, 0, 255);               // NULL Cell

            for (int X = 0; X < width; X++)
            {
                for (int Y = 0; Y < height; Y++)
                {
                    CellType?        cellData         = room.GetCellDataAtPoint(X, Y).state;
                    bool             DamageCell       = false;
                    DiagonalWallType diagonalWallType = DiagonalWallType.NONE;
                    if (room.GetCellDataAtPoint(X, Y) != null && cellData.HasValue)
                    {
                        DamageCell       = room.GetCellDataAtPoint(X, Y).doesDamage;
                        diagonalWallType = room.GetCellDataAtPoint(X, Y).diagonalWallType;
                    }
                    if (room.GetCellDataAtPoint(X, Y) == null | !cellData.HasValue)
                    {
                        m_NewImage.SetPixel(X, Y, BlackPixel);
                    }
                    else if (cellData.Value == CellType.FLOOR)
                    {
                        if (DamageCell)
                        {
                            m_NewImage.SetPixel(X, Y, GreenPixel);
                        }
                        else if (room.GetCellDataAtPoint(X, Y).appearance != null)
                        {
                            CellVisualData.CellFloorType overrideFloorType = room.GetCellDataAtPoint(X, Y).appearance.OverrideFloorType;
                            if (overrideFloorType == CellVisualData.CellFloorType.Stone)
                            {
                                m_NewImage.SetPixel(X, Y, BluePixel);
                            }
                            else if (overrideFloorType == CellVisualData.CellFloorType.Ice)
                            {
                                m_NewImage.SetPixel(X, Y, BlueHalfGreenPixel);
                            }
                            else if (overrideFloorType == CellVisualData.CellFloorType.Water)
                            {
                                m_NewImage.SetPixel(X, Y, HalfBluePixel);
                            }
                            else if (overrideFloorType == CellVisualData.CellFloorType.Carpet)
                            {
                                m_NewImage.SetPixel(X, Y, HalfRedPixel);
                            }
                            else if (overrideFloorType == CellVisualData.CellFloorType.Grass)
                            {
                                m_NewImage.SetPixel(X, Y, GreenHalfRBPixel);
                            }
                            else if (overrideFloorType == CellVisualData.CellFloorType.Bone)
                            {
                                m_NewImage.SetPixel(X, Y, HalfWhitePixel);
                            }
                            else if (overrideFloorType == CellVisualData.CellFloorType.Flesh)
                            {
                                m_NewImage.SetPixel(X, Y, OrangePixel);
                            }
                            else if (overrideFloorType == CellVisualData.CellFloorType.ThickGoop)
                            {
                                m_NewImage.SetPixel(X, Y, RedHalfGBPixel);
                            }
                            else
                            {
                                m_NewImage.SetPixel(X, Y, BluePixel);
                            }
                        }
                        else
                        {
                            m_NewImage.SetPixel(X, Y, BluePixel);
                        }
                    }
                    else if (cellData.Value == CellType.WALL)
                    {
                        if (diagonalWallType == DiagonalWallType.NORTHEAST)
                        {
                            m_NewImage.SetPixel(X, Y, PinkPixel);
                        }
                        else if (diagonalWallType == DiagonalWallType.NORTHWEST)
                        {
                            m_NewImage.SetPixel(X, Y, YellowPixel);
                        }
                        else if (diagonalWallType == DiagonalWallType.SOUTHEAST)
                        {
                            m_NewImage.SetPixel(X, Y, HalfPinkPixel);
                        }
                        else if (diagonalWallType == DiagonalWallType.SOUTHWEST)
                        {
                            m_NewImage.SetPixel(X, Y, HalfYellowPixel);
                        }
                        else
                        {
                            m_NewImage.SetPixel(X, Y, WhitePixel);
                        }
                    }
                    else if (cellData.Value == CellType.PIT)
                    {
                        m_NewImage.SetPixel(X, Y, RedPixel);
                    }
                }
            }

            m_NewImage.Apply();

            string basePath = "DumpedRoomLayouts/";

            string fileName = (basePath + m_NewImage.name);

            if (string.IsNullOrEmpty(m_NewImage.name))
            {
                fileName += ("RoomLayout_" + Guid.NewGuid().ToString());
            }

            fileName += "_Layout";

            string path = Path.Combine(ETGMod.ResourcesDirectory, fileName.Replace('/', Path.DirectorySeparatorChar).Replace('\\', Path.DirectorySeparatorChar) + ".png");

            if (!File.Exists(path))
            {
                Directory.GetParent(path).Create();
            }

            File.WriteAllBytes(path, ImageConversion.EncodeToPNG(m_NewImage));
        }
        public static PrototypeDungeonRoomCellData GenerateDefaultCellData(CellType cellType, DiagonalWallType diagnalWallType = DiagonalWallType.NONE)
        {
            PrototypeDungeonRoomCellData m_NewCellData = new PrototypeDungeonRoomCellData(string.Empty, cellType)
            {
                state            = cellType,
                diagonalWallType = diagnalWallType,
                breakable        = false,
                str = string.Empty,
                conditionalOnParentExit     = false,
                conditionalCellIsPit        = false,
                parentExitIndex             = 0,
                containsManuallyPlacedLight = false,
                lightPixelsOffsetY          = 0,
                lightStampIndex             = 0,
                doesDamage       = false,
                damageDefinition = new CellDamageDefinition()
                {
                    damageTypes            = CoreDamageTypes.None,
                    damageToPlayersPerTick = 0,
                    damageToEnemiesPerTick = 0,
                    tickFrequency          = 0,
                    respectsFlying         = false,
                    isPoison = false
                },
                appearance = new PrototypeDungeonRoomCellAppearance()
                {
                    overrideDungeonMaterialIndex = -1,
                    IsPhantomCarpet       = false,
                    ForceDisallowGoop     = false,
                    OverrideFloorType     = CellVisualData.CellFloorType.Stone,
                    globalOverrideIndices = new PrototypeIndexOverrideData()
                    {
                        indices = new List <int>()
                    },
                },
                ForceTileNonDecorated = false,
            };

            return(m_NewCellData);
        }