Add overworld region-zone-chunk data model and admin live world editor
This commit is contained in:
@@ -0,0 +1,248 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SystemRevivalServer.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddOverworldRegionZoneChunkEditor : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "world_regions",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
Name = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
ZonesPerRegionX = table.Column<int>(type: "int", nullable: false),
|
||||
ZonesPerRegionY = table.Column<int>(type: "int", nullable: false),
|
||||
ChunksPerZoneX = table.Column<int>(type: "int", nullable: false),
|
||||
ChunksPerZoneY = table.Column<int>(type: "int", nullable: false),
|
||||
ChunkWidthTiles = table.Column<int>(type: "int", nullable: false),
|
||||
ChunkHeightTiles = table.Column<int>(type: "int", nullable: false),
|
||||
IsEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_world_regions", x => x.Id);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "world_zones",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
RegionId = table.Column<int>(type: "int", nullable: false),
|
||||
ZoneX = table.Column<int>(type: "int", nullable: false),
|
||||
ZoneY = table.Column<int>(type: "int", nullable: false),
|
||||
Name = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
IsEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_world_zones", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_world_zones_world_regions_RegionId",
|
||||
column: x => x.RegionId,
|
||||
principalTable: "world_regions",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "world_chunks",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
WorldZoneId = table.Column<long>(type: "bigint", nullable: false),
|
||||
ChunkX = table.Column<int>(type: "int", nullable: false),
|
||||
ChunkY = table.Column<int>(type: "int", nullable: false),
|
||||
Version = table.Column<long>(type: "bigint", nullable: false),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_world_chunks", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_world_chunks_world_zones_WorldZoneId",
|
||||
column: x => x.WorldZoneId,
|
||||
principalTable: "world_zones",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "world_chunk_npc_spawns",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
WorldChunkId = table.Column<long>(type: "bigint", nullable: false),
|
||||
NpcDefinitionId = table.Column<int>(type: "int", nullable: false),
|
||||
TileX = table.Column<int>(type: "int", nullable: false),
|
||||
TileY = table.Column<int>(type: "int", nullable: false),
|
||||
Rotation = table.Column<int>(type: "int", nullable: false),
|
||||
MetadataJson = table.Column<string>(type: "varchar(1024)", maxLength: 1024, nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_world_chunk_npc_spawns", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_world_chunk_npc_spawns_dungeon_npc_definitions_NpcDefinition~",
|
||||
column: x => x.NpcDefinitionId,
|
||||
principalTable: "dungeon_npc_definitions",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_world_chunk_npc_spawns_world_chunks_WorldChunkId",
|
||||
column: x => x.WorldChunkId,
|
||||
principalTable: "world_chunks",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "world_chunk_objects",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
WorldChunkId = table.Column<long>(type: "bigint", nullable: false),
|
||||
ObjectDefinitionId = table.Column<int>(type: "int", nullable: false),
|
||||
TileX = table.Column<int>(type: "int", nullable: false),
|
||||
TileY = table.Column<int>(type: "int", nullable: false),
|
||||
Rotation = table.Column<int>(type: "int", nullable: false),
|
||||
MetadataJson = table.Column<string>(type: "varchar(1024)", maxLength: 1024, nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_world_chunk_objects", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_world_chunk_objects_dungeon_objects_ObjectDefinitionId",
|
||||
column: x => x.ObjectDefinitionId,
|
||||
principalTable: "dungeon_objects",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_world_chunk_objects_world_chunks_WorldChunkId",
|
||||
column: x => x.WorldChunkId,
|
||||
principalTable: "world_chunks",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "world_chunk_tiles",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
WorldChunkId = table.Column<long>(type: "bigint", nullable: false),
|
||||
TileX = table.Column<int>(type: "int", nullable: false),
|
||||
TileY = table.Column<int>(type: "int", nullable: false),
|
||||
SheetId = table.Column<int>(type: "int", nullable: false),
|
||||
FrameIndex = table.Column<int>(type: "int", nullable: false),
|
||||
IsWalkable = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||
IsInvisiblePaywall = table.Column<bool>(type: "tinyint(1)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_world_chunk_tiles", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_world_chunk_tiles_world_chunks_WorldChunkId",
|
||||
column: x => x.WorldChunkId,
|
||||
principalTable: "world_chunks",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_world_chunk_npc_spawns_NpcDefinitionId",
|
||||
table: "world_chunk_npc_spawns",
|
||||
column: "NpcDefinitionId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_world_chunk_npc_spawns_WorldChunkId_TileX_TileY_NpcDefinitio~",
|
||||
table: "world_chunk_npc_spawns",
|
||||
columns: new[] { "WorldChunkId", "TileX", "TileY", "NpcDefinitionId" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_world_chunk_objects_ObjectDefinitionId",
|
||||
table: "world_chunk_objects",
|
||||
column: "ObjectDefinitionId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_world_chunk_objects_WorldChunkId_TileX_TileY_ObjectDefinitio~",
|
||||
table: "world_chunk_objects",
|
||||
columns: new[] { "WorldChunkId", "TileX", "TileY", "ObjectDefinitionId" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_world_chunk_tiles_WorldChunkId_TileX_TileY",
|
||||
table: "world_chunk_tiles",
|
||||
columns: new[] { "WorldChunkId", "TileX", "TileY" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_world_chunks_WorldZoneId_ChunkX_ChunkY",
|
||||
table: "world_chunks",
|
||||
columns: new[] { "WorldZoneId", "ChunkX", "ChunkY" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_world_regions_Name",
|
||||
table: "world_regions",
|
||||
column: "Name",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_world_zones_RegionId_ZoneX_ZoneY",
|
||||
table: "world_zones",
|
||||
columns: new[] { "RegionId", "ZoneX", "ZoneY" },
|
||||
unique: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "world_chunk_npc_spawns");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "world_chunk_objects");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "world_chunk_tiles");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "world_chunks");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "world_zones");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "world_regions");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user