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(); }
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); }
public static PrototypeDungeonRoomCellData CellDataFromColor(Color32 color) { if (color.Equals(Color.magenta)) { return(null); } var data = new PrototypeDungeonRoomCellData(); data.state = TypeFromColor(color); data.diagonalWallType = DiagonalWallTypeFromColor(color); data.appearance = new PrototypeDungeonRoomCellAppearance() { OverrideFloorType = FloorType.Stone }; return(data); }
public static PrototypeDungeonRoom CreateRoomFromTexture(Texture2D texture) { int width = texture.width; int height = texture.height; PrototypeDungeonRoom room = GetNewPrototypeDungeonRoom(width, height); PrototypeDungeonRoomCellData[] cellData = new PrototypeDungeonRoomCellData[width * height]; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { cellData[x + y * width] = CellDataFromColor(texture.GetPixel(x, y)); } } room.FullCellData = cellData; room.name = texture.name; return(room); }
// Token: 0x06000042 RID: 66 RVA: 0x00003E80 File Offset: 0x00002080 public static PrototypeDungeonRoom CreateRoomFromTexture(Texture2D texture) { int width = texture.width; int height = texture.height; PrototypeDungeonRoom newPrototypeDungeonRoom = RoomFactory.GetNewPrototypeDungeonRoom(width, height); 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] = RoomFactory.CellDataFromColor(texture.GetPixel(i, j)); } } RoomFactory.m_cellData.SetValue(newPrototypeDungeonRoom, array); newPrototypeDungeonRoom.name = texture.name; return(newPrototypeDungeonRoom); }
public static PrototypeDungeonRoomCellData CellDataFromColor(Color32 color) { // if (color.Equals(Color.magenta)) return null; PrototypeDungeonRoomCellData data = new PrototypeDungeonRoomCellData(); data.state = TypeFromColor(color); data.diagonalWallType = DiagonalWallTypeFromColor(color); data.appearance = new PrototypeDungeonRoomCellAppearance() { OverrideFloorType = CellVisualData.CellFloorType.Stone }; if (color == Color.red) { data.appearance.OverrideFloorType = CellVisualData.CellFloorType.Carpet; data.appearance.IsPhantomCarpet = true; } return(data); }
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); }
// New stuff for extra floor cell types public static void ApplyExtraFloorCellData(PrototypeDungeonRoomCellData cellData, CoreDamageTypes DamageType, FloorType FloorType, float DamageToPlayersPerTick = 0, float DamageToEnemiesPerTick = 0, float TickFrequency = 0, bool RespectsFlying = true, bool DoesDamage = false, bool IsPoison = false) { cellData.doesDamage = DoesDamage; cellData.damageDefinition = new CellDamageDefinition() { damageTypes = DamageType, damageToPlayersPerTick = DamageToPlayersPerTick, damageToEnemiesPerTick = DamageToEnemiesPerTick, tickFrequency = TickFrequency, respectsFlying = RespectsFlying, isPoison = IsPoison }; if (cellData.appearance == null) { cellData.appearance = new PrototypeDungeonRoomCellAppearance() { overrideDungeonMaterialIndex = -1, IsPhantomCarpet = false, ForceDisallowGoop = false, globalOverrideIndices = new PrototypeIndexOverrideData() { indices = new List <int>(0) } }; } if (DamageType == CoreDamageTypes.Poison) { cellData.ForceTileNonDecorated = true; // cellData.appearance.OverrideFloorType = FloorType.Stone; cellData.damageDefinition.damageTypes = CoreDamageTypes.Poison; } else if (DamageType == CoreDamageTypes.Fire) { cellData.ForceTileNonDecorated = true; // cellData.appearance.OverrideFloorType = FloorType.Stone; cellData.damageDefinition.damageTypes = CoreDamageTypes.Fire; } cellData.appearance.OverrideFloorType = FloorType; }
// 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); }
// Token: 0x06000043 RID: 67 RVA: 0x00003F2C File Offset: 0x0000212C public static PrototypeDungeonRoomCellData CellDataFromColor(Color32 color) { bool flag = color.Equals(Color.magenta); PrototypeDungeonRoomCellData result; if (flag) { result = null; } else { result = new PrototypeDungeonRoomCellData { state = RoomFactory.TypeFromColor(color), diagonalWallType = RoomFactory.DiagonalWallTypeFromColor(color), appearance = new PrototypeDungeonRoomCellAppearance { OverrideFloorType = CellVisualData.CellFloorType.Stone } }; } return(result); }
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); } }
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(); }
public static void ApplyExtraFloorCellDataFromTexture2D(PrototypeDungeonRoom room, Texture2D sourceTexture) { if (sourceTexture == null) { ETGModConsole.Log("[ExpandTheGungeon] ApplyExtraFloorCellDataFromTexture2D: WARNING! Requested Texture for extra floor data is null!", ExpandSettings.debugMode); ETGModConsole.Log("[ExpandTheGungeon] Room: " + room.name + " will not have any extra floor data!", ExpandSettings.debugMode); return; } int width = room.Width; int height = room.Height; int ArrayLength = (width * height); if (sourceTexture.GetPixels32().Length != ArrayLength) { ETGModConsole.Log("[ExpandTheGungeon] ApplyExtraFloorCellDataFromTexture2D: WARNING! Image resolution doesn't match size of room!", ExpandSettings.debugMode); ETGModConsole.Log("[ExpandTheGungeon] Room: " + room.name + " will not have any extra floor data!", ExpandSettings.debugMode); return; } Color WhitePixel = new Color32(255, 255, 255, 255); // Normal Floor Color RedPixel = new Color32(255, 0, 0, 255); // Fire damage cell Color GreenPixel = new Color32(0, 255, 0, 255); // Poison damage cell Color BlueHalfGreenPixel = new Color32(0, 127, 255, 255); // Ice Override Color HalfBluePixel = new Color32(0, 0, 127, 255); // Water Override Color HalfRedPixel = new Color32(0, 0, 127, 255); // Carpet Override Color GreenHalfRBPixel = new Color32(127, 255, 127, 255); // Grass Override Color HalfWhitePixel = new Color32(127, 127, 127, 255); // Bone Override Color OrangePixel = new Color32(255, 127, 0, 255); // Flesh Override Color RedHalfGBPixel = new Color32(255, 127, 127, 255); // ThickGoop Override for (int X = 0; X < width; X++) { for (int Y = 0; Y < height; Y++) { int ArrayPosition = (Y * width + X); Color?m_Pixel = sourceTexture.GetPixel(X, Y); PrototypeDungeonRoomCellData cellData = room.FullCellData[ArrayPosition]; float DamageToPlayersPerTick = 0; float DamageToEnemiesPerTick = 0; float TickFrequency = 0; bool RespectsFlying = true; bool IsPoison = false; bool isDamageCell = false; CoreDamageTypes DamageCellsType = CoreDamageTypes.None; FloorType floorType = FloorType.Stone; if (cellData != null && m_Pixel.HasValue && cellData.state == CellType.FLOOR) { if (m_Pixel.Value == RedPixel) { floorType = FloorType.Stone; DamageCellsType = CoreDamageTypes.Fire; } else if (m_Pixel.Value == BlueHalfGreenPixel) { floorType = FloorType.Ice; } else if (m_Pixel.Value == HalfBluePixel) { floorType = FloorType.Water; } else if (m_Pixel.Value == HalfRedPixel) { floorType = FloorType.Carpet; } else if (m_Pixel.Value == GreenHalfRBPixel) { floorType = FloorType.Grass; } else if (m_Pixel.Value == HalfWhitePixel) { floorType = FloorType.Bone; } else if (m_Pixel.Value == OrangePixel) { floorType = FloorType.Flesh; } else if (m_Pixel.Value == RedHalfGBPixel) { floorType = FloorType.ThickGoop; } if (DamageCellsType == CoreDamageTypes.Fire) { isDamageCell = true; DamageToPlayersPerTick = 0.5f; TickFrequency = 1; } else if (DamageCellsType == CoreDamageTypes.Poison) { IsPoison = true; isDamageCell = true; DamageToPlayersPerTick = 0.5f; TickFrequency = 1; } ApplyExtraFloorCellData(cellData, DamageCellsType, floorType, DamageToPlayersPerTick, DamageToEnemiesPerTick, TickFrequency, RespectsFlying, isDamageCell, IsPoison); } } } }