From c16dc1259da5b3e5cc579c594a826f5c8dae8c96 Mon Sep 17 00:00:00 2001 From: dingo Date: Sat, 27 Dec 2025 20:12:40 -0500 Subject: [PATCH] Admin tools for mob sprites --- ...011218_Admin Tools for Sprites.Designer.cs | 2138 +++++++++++++++++ .../20251228011218_Admin Tools for Sprites.cs | 162 ++ Migrations/GameDbContextModelSnapshot.cs | 197 ++ Services/Admin/Pages/Mobs/Edit.cshtml | 134 ++ Services/Admin/Pages/Mobs/Edit.cshtml.cs | 78 +- Services/Admin/Pages/Shared/_Layout.cshtml | 7 + Services/Admin/Pages/SpriteSheets/Edit.cshtml | 292 +++ .../Admin/Pages/SpriteSheets/Edit.cshtml.cs | 226 ++ .../Admin/Pages/SpriteSheets/Index.cshtml | 77 + .../Admin/Pages/SpriteSheets/Index.cshtml.cs | 54 + data/GameDbContext.cs | 6 + data/entities/MobSpriteSheet.cs | 167 ++ 12 files changed, 3536 insertions(+), 2 deletions(-) create mode 100644 Migrations/20251228011218_Admin Tools for Sprites.Designer.cs create mode 100644 Migrations/20251228011218_Admin Tools for Sprites.cs create mode 100644 Services/Admin/Pages/SpriteSheets/Edit.cshtml create mode 100644 Services/Admin/Pages/SpriteSheets/Edit.cshtml.cs create mode 100644 Services/Admin/Pages/SpriteSheets/Index.cshtml create mode 100644 Services/Admin/Pages/SpriteSheets/Index.cshtml.cs create mode 100644 data/entities/MobSpriteSheet.cs diff --git a/Migrations/20251228011218_Admin Tools for Sprites.Designer.cs b/Migrations/20251228011218_Admin Tools for Sprites.Designer.cs new file mode 100644 index 0000000..e0f2a52 --- /dev/null +++ b/Migrations/20251228011218_Admin Tools for Sprites.Designer.cs @@ -0,0 +1,2138 @@ +// +using System; +using DataServer.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace SystemRevivalServer.Migrations +{ + [DbContext(typeof(GameDbContext))] + [Migration("20251228011218_Admin Tools for Sprites")] + partial class AdminToolsforSprites + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.10") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); + + modelBuilder.Entity("DataServer.Data.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("BannedUntil") + .HasColumnType("datetime(6)"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnType("datetime(6)") + .HasDefaultValueSql("CURRENT_TIMESTAMP(6)"); + + b.Property("Email") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("IsBanned") + .HasColumnType("tinyint(1)"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("varbinary(64)"); + + b.Property("PasswordSalt") + .IsRequired() + .HasColumnType("varbinary(32)"); + + b.Property("Role") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("UpdatedAt") + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("datetime(6)") + .HasDefaultValueSql("CURRENT_TIMESTAMP(6)"); + + MySqlPropertyBuilderExtensions.UseMySqlComputedColumn(b.Property("UpdatedAt")); + + b.Property("Username") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.HasKey("Id"); + + b.HasIndex("Email") + .IsUnique(); + + b.HasIndex("Username") + .IsUnique(); + + b.ToTable("accounts", (string)null); + }); + + modelBuilder.Entity("DataServer.Data.Entities.ClientAsset", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AssetType") + .HasColumnType("int"); + + b.Property("CdnPath") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("FileHash") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("FilePath") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("FileSize") + .HasColumnType("bigint"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("IsRequired") + .HasColumnType("tinyint(1)"); + + b.Property("MinClientVersion") + .HasMaxLength(16) + .HasColumnType("varchar(16)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("client_assets"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DamageResistanceType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Color") + .IsRequired() + .HasMaxLength(16) + .HasColumnType("varchar(16)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("IconPath") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("damage_resistance_types"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DeathChest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("DungeonInstanceId") + .HasColumnType("char(36)"); + + b.Property("EmptiedAt") + .HasColumnType("datetime(6)"); + + b.Property("GoldAmount") + .HasColumnType("bigint"); + + b.Property("IsEmpty") + .HasColumnType("tinyint(1)"); + + b.Property("OwnerCharacterId") + .HasColumnType("bigint unsigned"); + + b.Property("VictimCharacterId") + .HasColumnType("bigint unsigned"); + + b.Property("VictimMobDefinitionId") + .HasColumnType("int"); + + b.Property("X") + .HasColumnType("float"); + + b.Property("Y") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("OwnerCharacterId"); + + b.HasIndex("VictimCharacterId"); + + b.ToTable("dungeon_death_chests"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DeathChestItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("DeathChestId") + .HasColumnType("bigint unsigned"); + + b.Property("IsTaken") + .HasColumnType("tinyint(1)"); + + b.Property("ItemDefinitionId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("SlotIndex") + .HasColumnType("int"); + + b.Property("TakenAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("DeathChestId"); + + b.HasIndex("ItemDefinitionId"); + + b.ToTable("dungeon_death_chest_items"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonBeltItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("CharacterId") + .HasColumnType("bigint unsigned"); + + b.Property("InventorySlotIndex") + .HasColumnType("int"); + + b.Property("SlotIndex") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CharacterId"); + + b.ToTable("dungeon_belt_items"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCharacter", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("bigint unsigned"); + + b.Property("BossesKilled") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CurrentHealth") + .HasColumnType("int"); + + b.Property("CurrentMana") + .HasColumnType("int"); + + b.Property("Dexterity") + .HasColumnType("int"); + + b.Property("DungeonsCompleted") + .HasColumnType("int"); + + b.Property("Endurance") + .HasColumnType("int"); + + b.Property("EquippedAccessory") + .HasColumnType("bigint unsigned"); + + b.Property("EquippedBoots") + .HasColumnType("bigint unsigned"); + + b.Property("EquippedChest") + .HasColumnType("bigint unsigned"); + + b.Property("EquippedGloves") + .HasColumnType("bigint unsigned"); + + b.Property("EquippedHead") + .HasColumnType("bigint unsigned"); + + b.Property("EquippedLegs") + .HasColumnType("bigint unsigned"); + + b.Property("EquippedOffhand") + .HasColumnType("bigint unsigned"); + + b.Property("EquippedWeapon") + .HasColumnType("bigint unsigned"); + + b.Property("Experience") + .HasColumnType("bigint"); + + b.Property("Gold") + .HasColumnType("bigint"); + + b.Property("Intelligence") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("tinyint(1)"); + + b.Property("LastPlayedAt") + .HasColumnType("datetime(6)"); + + b.Property("Level") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("PlayersKilled") + .HasColumnType("int"); + + b.Property("ResistancesJson") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.Property("Strength") + .HasColumnType("int"); + + b.Property("TotalDeaths") + .HasColumnType("int"); + + b.Property("TotalKills") + .HasColumnType("int"); + + b.Property("UnspentStatPoints") + .HasColumnType("int"); + + b.Property("Wisdom") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.ToTable("dungeon_characters"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCharacterCraftingSkill", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("CharacterId") + .HasColumnType("bigint unsigned"); + + b.Property("Experience") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("int"); + + b.Property("SkillType") + .HasColumnType("int"); + + b.Property("TotalItemsCrafted") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CharacterId"); + + b.ToTable("dungeon_character_crafting_skills"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCharacterItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AcquiredAt") + .HasColumnType("datetime(6)"); + + b.Property("CharacterId") + .HasColumnType("bigint unsigned"); + + b.Property("EquipSlot") + .HasColumnType("int"); + + b.Property("IsEquipped") + .HasColumnType("tinyint(1)"); + + b.Property("ItemDefinitionId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("SlotIndex") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CharacterId"); + + b.HasIndex("ItemDefinitionId"); + + b.ToTable("dungeon_character_items"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCharacterItemCraftedLink", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("CharacterItemId") + .HasColumnType("bigint unsigned"); + + b.Property("CraftedItemId") + .HasColumnType("bigint unsigned"); + + b.HasKey("Id"); + + b.HasIndex("CharacterItemId"); + + b.HasIndex("CraftedItemId"); + + b.ToTable("dungeon_character_item_crafted_link"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCharacterKnownRecipe", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("CharacterId") + .HasColumnType("bigint unsigned"); + + b.Property("DiscoveredAt") + .HasColumnType("datetime(6)"); + + b.Property("RecipeId") + .HasColumnType("int"); + + b.Property("TimesCrafted") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CharacterId"); + + b.HasIndex("RecipeId"); + + b.ToTable("dungeon_character_known_recipes"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCraftedItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("BaseItemDefinitionId") + .HasColumnType("int"); + + b.Property("CraftedAt") + .HasColumnType("datetime(6)"); + + b.Property("CrafterId") + .HasColumnType("bigint unsigned"); + + b.Property("CrafterName") + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("CraftingLevelAtCreation") + .HasColumnType("int"); + + b.Property("CustomName") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("QualityRating") + .HasColumnType("int"); + + b.Property("RecipeId") + .HasColumnType("int"); + + b.Property("RollHistoryJson") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.Property("RolledBonusArmor") + .HasColumnType("int"); + + b.Property("RolledBonusDexterity") + .HasColumnType("int"); + + b.Property("RolledBonusEndurance") + .HasColumnType("int"); + + b.Property("RolledBonusHealAmount") + .HasColumnType("int"); + + b.Property("RolledBonusHealth") + .HasColumnType("int"); + + b.Property("RolledBonusIntelligence") + .HasColumnType("int"); + + b.Property("RolledBonusMagicResist") + .HasColumnType("int"); + + b.Property("RolledBonusMana") + .HasColumnType("int"); + + b.Property("RolledBonusManaRestore") + .HasColumnType("int"); + + b.Property("RolledBonusMaxDamage") + .HasColumnType("int"); + + b.Property("RolledBonusMinDamage") + .HasColumnType("int"); + + b.Property("RolledBonusStrength") + .HasColumnType("int"); + + b.Property("RolledBonusWisdom") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("BaseItemDefinitionId"); + + b.HasIndex("CrafterId"); + + b.HasIndex("RecipeId"); + + b.ToTable("dungeon_crafted_items"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCraftingRecipe", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("BaseXp") + .HasColumnType("int"); + + b.Property("BonusOutputChanceAtMinLevel") + .HasColumnType("float"); + + b.Property("BonusOutputItemDefinitionId") + .HasColumnType("int"); + + b.Property("BonusOutputMaxLevel") + .HasColumnType("int"); + + b.Property("BonusOutputMinLevel") + .HasColumnType("int"); + + b.Property("BonusOutputQuantity") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("HasStatRolls") + .HasColumnType("tinyint(1)"); + + b.Property("IsBaseRecipe") + .HasColumnType("tinyint(1)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("OutputItemDefinitionId") + .HasColumnType("int"); + + b.Property("OutputQuantity") + .HasColumnType("int"); + + b.Property("PossibleStatsJson") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.Property("RequiredLevel") + .HasColumnType("int"); + + b.Property("SkillType") + .HasColumnType("int"); + + b.Property("Tier") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("OutputItemDefinitionId"); + + b.ToTable("dungeon_crafting_recipes"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCraftingRecipeIngredient", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("ItemDefinitionId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("RecipeId") + .HasColumnType("int"); + + b.Property("SlotOrder") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ItemDefinitionId"); + + b.HasIndex("RecipeId"); + + b.ToTable("dungeon_crafting_recipe_ingredients"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonItemDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Armor") + .HasColumnType("int"); + + b.Property("AttackRange") + .HasColumnType("float"); + + b.Property("BonusDexterity") + .HasColumnType("int"); + + b.Property("BonusEndurance") + .HasColumnType("int"); + + b.Property("BonusHealth") + .HasColumnType("int"); + + b.Property("BonusIntelligence") + .HasColumnType("int"); + + b.Property("BonusMana") + .HasColumnType("int"); + + b.Property("BonusStrength") + .HasColumnType("int"); + + b.Property("BonusWisdom") + .HasColumnType("int"); + + b.Property("BuffDuration") + .HasColumnType("int"); + + b.Property("BuffResistancesJson") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.Property("DamageTypeKey") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("EquipSlot") + .HasColumnType("int"); + + b.Property("HealAmount") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("IsTeleportScroll") + .HasColumnType("tinyint(1)"); + + b.Property("ManaRestore") + .HasColumnType("int"); + + b.Property("MaxDamage") + .HasColumnType("int"); + + b.Property("MaxStack") + .HasColumnType("int"); + + b.Property("MinDamage") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Rarity") + .HasColumnType("int"); + + b.Property("RequiredDexterity") + .HasColumnType("int"); + + b.Property("RequiredIntelligence") + .HasColumnType("int"); + + b.Property("RequiredLevel") + .HasColumnType("int"); + + b.Property("RequiredStrength") + .HasColumnType("int"); + + b.Property("RequiredWisdom") + .HasColumnType("int"); + + b.Property("ResistancesJson") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.Property("SpriteId") + .HasColumnType("int"); + + b.Property("SpritePath") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("Stackable") + .HasColumnType("tinyint(1)"); + + b.Property("StaminaRestore") + .HasColumnType("int"); + + b.Property("TeachesSpellId") + .HasColumnType("int"); + + b.Property("TintColor") + .HasMaxLength(16) + .HasColumnType("varchar(16)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("dungeon_item_definitions"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonLearnedSpell", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("CharacterId") + .HasColumnType("bigint unsigned"); + + b.Property("DefinitionId") + .HasColumnType("int"); + + b.Property("LearnedAt") + .HasColumnType("datetime(6)"); + + b.Property("SpellDefinitionId") + .HasColumnType("int"); + + b.Property("SpellLevel") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CharacterId"); + + b.HasIndex("DefinitionId"); + + b.ToTable("dungeon_learned_spells"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonLootTable", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Description") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("DropChanceMultiplier") + .HasColumnType("float"); + + b.Property("GuaranteedDrop") + .HasColumnType("tinyint(1)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("MaxDrops") + .HasColumnType("int"); + + b.Property("MaxTier") + .HasColumnType("int"); + + b.Property("MinDrops") + .HasColumnType("int"); + + b.Property("MinTier") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.HasKey("Id"); + + b.ToTable("dungeon_loot_tables"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonLootTableEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("DropChance") + .HasColumnType("float"); + + b.Property("DropChancePerTier") + .HasColumnType("float"); + + b.Property("Guaranteed") + .HasColumnType("tinyint(1)"); + + b.Property("ItemDefinitionId") + .HasColumnType("int"); + + b.Property("LootTableId") + .HasColumnType("int"); + + b.Property("MaxDropChance") + .HasColumnType("float"); + + b.Property("MaxQuantity") + .HasColumnType("int"); + + b.Property("MinQuantity") + .HasColumnType("int"); + + b.Property("Weight") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ItemDefinitionId"); + + b.HasIndex("LootTableId"); + + b.ToTable("dungeon_loot_table_entries"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonMobDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AggroRange") + .HasColumnType("float"); + + b.Property("AnimationSpeed") + .HasColumnType("float"); + + b.Property("ArmorPerTier") + .HasColumnType("float"); + + b.Property("AttackRange") + .HasColumnType("float"); + + b.Property("AttackSpeed") + .HasColumnType("float"); + + b.Property("BaseArmor") + .HasColumnType("int"); + + b.Property("BaseHealth") + .HasColumnType("int"); + + b.Property("BaseMagicDamage") + .HasColumnType("int"); + + b.Property("BaseMagicResist") + .HasColumnType("int"); + + b.Property("BaseMana") + .HasColumnType("int"); + + b.Property("BasePhysicalDamage") + .HasColumnType("int"); + + b.Property("BaseXp") + .HasColumnType("int"); + + b.Property("Behavior") + .HasColumnType("int"); + + b.Property("CallForHelpRadius") + .HasColumnType("float"); + + b.Property("Category") + .HasColumnType("int"); + + b.Property("DamagePerTier") + .HasColumnType("float"); + + b.Property("DamageTypeKey") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("DropChanceMultiplier") + .HasColumnType("float"); + + b.Property("FleeThreshold") + .HasColumnType("float"); + + b.Property("HealthPerTier") + .HasColumnType("float"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("LeashRange") + .HasColumnType("float"); + + b.Property("LootTableId") + .HasColumnType("int"); + + b.Property("MaxTier") + .HasColumnType("int"); + + b.Property("MinTier") + .HasColumnType("int"); + + b.Property("MoveSpeed") + .HasColumnType("float"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("PhasesJson") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("PreferredRange") + .HasColumnType("float"); + + b.Property("ResistancesJson") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.Property("Scale") + .HasColumnType("float"); + + b.Property("SpriteConfigJson") + .HasMaxLength(8192) + .HasColumnType("varchar(8192)"); + + b.Property("TintColor") + .IsRequired() + .HasMaxLength(16) + .HasColumnType("varchar(16)"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("XpPerTier") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("dungeon_mob_definitions"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonMobLootTable", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("LootTableId") + .HasColumnType("int"); + + b.Property("MobDefinitionId") + .HasColumnType("int"); + + b.Property("Priority") + .HasColumnType("int"); + + b.Property("RollChance") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("LootTableId"); + + b.HasIndex("MobDefinitionId"); + + b.ToTable("dungeon_mob_loot_tables"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonPersistence", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("BossKilled") + .HasColumnType("tinyint(1)"); + + b.Property("ChestStateJson") + .HasColumnType("json"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatorCharacterId") + .HasColumnType("bigint unsigned"); + + b.Property("CreatorId") + .HasColumnType("bigint unsigned"); + + b.Property("CreatorLevel") + .HasColumnType("int"); + + b.Property("CreatorName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsCleared") + .HasColumnType("tinyint(1)"); + + b.Property("LastActivity") + .HasColumnType("datetime(6)"); + + b.Property("LevelBracketMax") + .HasColumnType("int"); + + b.Property("LevelBracketMin") + .HasColumnType("int"); + + b.Property("LootChestStateJson") + .HasColumnType("json"); + + b.Property("MobStateJson") + .HasColumnType("json"); + + b.Property("PersistedAt") + .HasColumnType("datetime(6)"); + + b.Property("Seed") + .HasColumnType("int"); + + b.Property("Tier") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CreatorId"); + + b.ToTable("dungeon_instances"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonRecipeScroll", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("ItemDefinitionId") + .HasColumnType("int"); + + b.Property("RecipeId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ItemDefinitionId"); + + b.HasIndex("RecipeId"); + + b.ToTable("dungeon_recipe_scrolls"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonSpellDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AreaOfEffect") + .HasColumnType("float"); + + b.Property("BaseDamage") + .HasColumnType("int"); + + b.Property("BaseHealing") + .HasColumnType("int"); + + b.Property("Cooldown") + .HasColumnType("float"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("EffectColor") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("IsShield") + .HasColumnType("tinyint(1)"); + + b.Property("IsTeleport") + .HasColumnType("tinyint(1)"); + + b.Property("ManaCost") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Range") + .HasColumnType("float"); + + b.Property("RequiredIntelligence") + .HasColumnType("int"); + + b.Property("RequiredLevel") + .HasColumnType("int"); + + b.Property("RequiredWisdom") + .HasColumnType("int"); + + b.Property("ShieldAmount") + .HasColumnType("int"); + + b.Property("SpriteId") + .HasColumnType("int"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("dungeon_spell_definitions"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonStashItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("CharacterId") + .HasColumnType("bigint unsigned"); + + b.Property("DefinitionId") + .HasColumnType("int"); + + b.Property("ItemDefinitionId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("SlotIndex") + .HasColumnType("int"); + + b.Property("StoredAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("CharacterId"); + + b.HasIndex("DefinitionId"); + + b.ToTable("dungeon_stash_items"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.MobAbilityAnimationMapping", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AbilityAssignmentId") + .HasColumnType("int"); + + b.Property("AnimationKey") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("DirectionSuffix") + .HasMaxLength(16) + .HasColumnType("varchar(16)"); + + b.HasKey("Id"); + + b.HasIndex("AbilityAssignmentId"); + + b.ToTable("mob_ability_animation_mappings"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.MobAbilityAssignment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AbilityDefinitionId") + .HasColumnType("int"); + + b.Property("CooldownOverride") + .HasColumnType("float"); + + b.Property("DamageOverride") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("MaxHpPercent") + .HasColumnType("float"); + + b.Property("MinHpPercent") + .HasColumnType("float"); + + b.Property("MobDefinitionId") + .HasColumnType("int"); + + b.Property("Phase") + .HasColumnType("int"); + + b.Property("PriorityOverride") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("AbilityDefinitionId"); + + b.HasIndex("MobDefinitionId"); + + b.ToTable("dungeon_mob_ability_assignments"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.MobAbilityDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AbilityType") + .HasColumnType("int"); + + b.Property("AffectedStat") + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("AnimationDuration") + .HasColumnType("float"); + + b.Property("AnimationKey") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("AoeRadius") + .HasColumnType("float"); + + b.Property("BaseDamage") + .HasColumnType("int"); + + b.Property("CastTime") + .HasColumnType("float"); + + b.Property("ConeAngle") + .HasColumnType("float"); + + b.Property("Cooldown") + .HasColumnType("float"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("DamagePerTier") + .HasColumnType("float"); + + b.Property("DamageTypeKey") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("DisplacementDistance") + .HasColumnType("float"); + + b.Property("DotDamagePerTick") + .HasColumnType("int"); + + b.Property("DotTickInterval") + .HasColumnType("float"); + + b.Property("EffectDuration") + .HasColumnType("float"); + + b.Property("HpThresholdAbove") + .HasColumnType("float"); + + b.Property("HpThresholdBelow") + .HasColumnType("float"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ManaCost") + .HasColumnType("int"); + + b.Property("MinTargetsInRange") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Priority") + .HasColumnType("int"); + + b.Property("ProjectileSpeed") + .HasColumnType("float"); + + b.Property("ProjectileSprite") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("Range") + .HasColumnType("float"); + + b.Property("SoundEffectKey") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("SpeedModifier") + .HasColumnType("float"); + + b.Property("StatModifier") + .HasColumnType("float"); + + b.Property("SummonCount") + .HasColumnType("int"); + + b.Property("SummonMobId") + .HasColumnType("int"); + + b.Property("Targeting") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("VisualEffectKey") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.HasKey("Id"); + + b.ToTable("dungeon_mob_abilities"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.MobAnimationAssignment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AnimationDefinitionId") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("MobDefinitionId") + .HasColumnType("int"); + + b.Property("OverrideKey") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Priority") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("AnimationDefinitionId"); + + b.HasIndex("MobDefinitionId"); + + b.ToTable("mob_animation_assignments"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.MobAnimationDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("FlipX") + .HasColumnType("tinyint(1)"); + + b.Property("FlipY") + .HasColumnType("tinyint(1)"); + + b.Property("Fps") + .HasColumnType("float"); + + b.Property("FrameSequence") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Loop") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("SpriteSheetId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("SpriteSheetId"); + + b.ToTable("mob_animation_definitions"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.MobSpriteSheet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("CdnPath") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("FrameHeight") + .HasColumnType("int"); + + b.Property("FrameWidth") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("SheetHeight") + .HasColumnType("int"); + + b.Property("SheetWidth") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.ToTable("mob_sprite_sheets"); + }); + + modelBuilder.Entity("DataServer.Data.Session", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("bigint unsigned"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnType("datetime(6)") + .HasDefaultValueSql("CURRENT_TIMESTAMP(6)"); + + b.Property("CreatedIp") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ExpiresAt") + .HasColumnType("datetime(6)"); + + b.Property("RevokedAt") + .HasColumnType("datetime(6)"); + + b.Property("TokenHash") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("UserAgent") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("TokenHash") + .IsUnique(); + + b.ToTable("sessions", (string)null); + }); + + modelBuilder.Entity("DataServer.Data.Zone", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnType("datetime(6)") + .HasDefaultValueSql("CURRENT_TIMESTAMP(6)"); + + b.Property("MaxX") + .HasColumnType("double"); + + b.Property("MaxY") + .HasColumnType("double"); + + b.Property("MaxZ") + .HasColumnType("double"); + + b.Property("MinX") + .HasColumnType("double"); + + b.Property("MinY") + .HasColumnType("double"); + + b.Property("MinZ") + .HasColumnType("double"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("UpdatedAt") + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("datetime(6)") + .HasDefaultValueSql("CURRENT_TIMESTAMP(6)"); + + MySqlPropertyBuilderExtensions.UseMySqlComputedColumn(b.Property("UpdatedAt")); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("zones", (string)null); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DeathChest", b => + { + b.HasOne("DataServer.Data.Entities.DungeonCharacter", "OwnerCharacter") + .WithMany() + .HasForeignKey("OwnerCharacterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DataServer.Data.Entities.DungeonCharacter", "VictimCharacter") + .WithMany() + .HasForeignKey("VictimCharacterId"); + + b.Navigation("OwnerCharacter"); + + b.Navigation("VictimCharacter"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DeathChestItem", b => + { + b.HasOne("DataServer.Data.Entities.DeathChest", "DeathChest") + .WithMany("Items") + .HasForeignKey("DeathChestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DataServer.Data.Entities.DungeonItemDefinition", "ItemDefinition") + .WithMany() + .HasForeignKey("ItemDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DeathChest"); + + b.Navigation("ItemDefinition"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonBeltItem", b => + { + b.HasOne("DataServer.Data.Entities.DungeonCharacter", "Character") + .WithMany() + .HasForeignKey("CharacterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Character"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCharacter", b => + { + b.HasOne("DataServer.Data.Account", "Account") + .WithMany("Characters") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCharacterCraftingSkill", b => + { + b.HasOne("DataServer.Data.Entities.DungeonCharacter", "Character") + .WithMany("CraftingSkills") + .HasForeignKey("CharacterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Character"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCharacterItem", b => + { + b.HasOne("DataServer.Data.Entities.DungeonCharacter", "Character") + .WithMany("Inventory") + .HasForeignKey("CharacterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DataServer.Data.Entities.DungeonItemDefinition", "ItemDefinition") + .WithMany() + .HasForeignKey("ItemDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Character"); + + b.Navigation("ItemDefinition"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCharacterItemCraftedLink", b => + { + b.HasOne("DataServer.Data.Entities.DungeonCharacterItem", "CharacterItem") + .WithMany() + .HasForeignKey("CharacterItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DataServer.Data.Entities.DungeonCraftedItem", "CraftedItem") + .WithMany() + .HasForeignKey("CraftedItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CharacterItem"); + + b.Navigation("CraftedItem"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCharacterKnownRecipe", b => + { + b.HasOne("DataServer.Data.Entities.DungeonCharacter", "Character") + .WithMany("KnownRecipes") + .HasForeignKey("CharacterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DataServer.Data.Entities.DungeonCraftingRecipe", "Recipe") + .WithMany() + .HasForeignKey("RecipeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Character"); + + b.Navigation("Recipe"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCraftedItem", b => + { + b.HasOne("DataServer.Data.Entities.DungeonItemDefinition", "BaseItemDefinition") + .WithMany() + .HasForeignKey("BaseItemDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DataServer.Data.Entities.DungeonCharacter", "Crafter") + .WithMany() + .HasForeignKey("CrafterId"); + + b.HasOne("DataServer.Data.Entities.DungeonCraftingRecipe", "Recipe") + .WithMany() + .HasForeignKey("RecipeId"); + + b.Navigation("BaseItemDefinition"); + + b.Navigation("Crafter"); + + b.Navigation("Recipe"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCraftingRecipe", b => + { + b.HasOne("DataServer.Data.Entities.DungeonItemDefinition", "OutputItem") + .WithMany() + .HasForeignKey("OutputItemDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OutputItem"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCraftingRecipeIngredient", b => + { + b.HasOne("DataServer.Data.Entities.DungeonItemDefinition", "ItemDefinition") + .WithMany() + .HasForeignKey("ItemDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DataServer.Data.Entities.DungeonCraftingRecipe", "Recipe") + .WithMany("Ingredients") + .HasForeignKey("RecipeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ItemDefinition"); + + b.Navigation("Recipe"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonLearnedSpell", b => + { + b.HasOne("DataServer.Data.Entities.DungeonCharacter", "Character") + .WithMany("LearnedSpells") + .HasForeignKey("CharacterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DataServer.Data.Entities.DungeonSpellDefinition", "Definition") + .WithMany() + .HasForeignKey("DefinitionId"); + + b.Navigation("Character"); + + b.Navigation("Definition"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonLootTableEntry", b => + { + b.HasOne("DataServer.Data.Entities.DungeonItemDefinition", "ItemDefinition") + .WithMany() + .HasForeignKey("ItemDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DataServer.Data.Entities.DungeonLootTable", "LootTable") + .WithMany("Entries") + .HasForeignKey("LootTableId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ItemDefinition"); + + b.Navigation("LootTable"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonMobLootTable", b => + { + b.HasOne("DataServer.Data.Entities.DungeonLootTable", "LootTable") + .WithMany() + .HasForeignKey("LootTableId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DataServer.Data.Entities.DungeonMobDefinition", "MobDefinition") + .WithMany() + .HasForeignKey("MobDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LootTable"); + + b.Navigation("MobDefinition"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonPersistence", b => + { + b.HasOne("DataServer.Data.Entities.DungeonCharacter", "Creator") + .WithMany() + .HasForeignKey("CreatorId"); + + b.Navigation("Creator"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonRecipeScroll", b => + { + b.HasOne("DataServer.Data.Entities.DungeonItemDefinition", "ItemDefinition") + .WithMany() + .HasForeignKey("ItemDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DataServer.Data.Entities.DungeonCraftingRecipe", "Recipe") + .WithMany() + .HasForeignKey("RecipeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ItemDefinition"); + + b.Navigation("Recipe"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonStashItem", b => + { + b.HasOne("DataServer.Data.Entities.DungeonCharacter", "Character") + .WithMany("Stash") + .HasForeignKey("CharacterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DataServer.Data.Entities.DungeonItemDefinition", "Definition") + .WithMany() + .HasForeignKey("DefinitionId"); + + b.Navigation("Character"); + + b.Navigation("Definition"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.MobAbilityAnimationMapping", b => + { + b.HasOne("DataServer.Data.Entities.MobAbilityAssignment", "AbilityAssignment") + .WithMany() + .HasForeignKey("AbilityAssignmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AbilityAssignment"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.MobAbilityAssignment", b => + { + b.HasOne("DataServer.Data.Entities.MobAbilityDefinition", "AbilityDefinition") + .WithMany() + .HasForeignKey("AbilityDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DataServer.Data.Entities.DungeonMobDefinition", "MobDefinition") + .WithMany("AbilityAssignments") + .HasForeignKey("MobDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AbilityDefinition"); + + b.Navigation("MobDefinition"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.MobAnimationAssignment", b => + { + b.HasOne("DataServer.Data.Entities.MobAnimationDefinition", "AnimationDefinition") + .WithMany() + .HasForeignKey("AnimationDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DataServer.Data.Entities.DungeonMobDefinition", "MobDefinition") + .WithMany() + .HasForeignKey("MobDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AnimationDefinition"); + + b.Navigation("MobDefinition"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.MobAnimationDefinition", b => + { + b.HasOne("DataServer.Data.Entities.MobSpriteSheet", "SpriteSheet") + .WithMany("Animations") + .HasForeignKey("SpriteSheetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("SpriteSheet"); + }); + + modelBuilder.Entity("DataServer.Data.Session", b => + { + b.HasOne("DataServer.Data.Account", "Account") + .WithMany("Sessions") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + }); + + modelBuilder.Entity("DataServer.Data.Account", b => + { + b.Navigation("Characters"); + + b.Navigation("Sessions"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DeathChest", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCharacter", b => + { + b.Navigation("CraftingSkills"); + + b.Navigation("Inventory"); + + b.Navigation("KnownRecipes"); + + b.Navigation("LearnedSpells"); + + b.Navigation("Stash"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCraftingRecipe", b => + { + b.Navigation("Ingredients"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonLootTable", b => + { + b.Navigation("Entries"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonMobDefinition", b => + { + b.Navigation("AbilityAssignments"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.MobSpriteSheet", b => + { + b.Navigation("Animations"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20251228011218_Admin Tools for Sprites.cs b/Migrations/20251228011218_Admin Tools for Sprites.cs new file mode 100644 index 0000000..ea78e06 --- /dev/null +++ b/Migrations/20251228011218_Admin Tools for Sprites.cs @@ -0,0 +1,162 @@ +using System; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace SystemRevivalServer.Migrations +{ + /// + public partial class AdminToolsforSprites : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "mob_ability_animation_mappings", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + AbilityAssignmentId = table.Column(type: "int", nullable: false), + AnimationKey = table.Column(type: "varchar(64)", maxLength: 64, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + DirectionSuffix = table.Column(type: "varchar(16)", maxLength: 16, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_mob_ability_animation_mappings", x => x.Id); + table.ForeignKey( + name: "FK_mob_ability_animation_mappings_dungeon_mob_ability_assignmen~", + column: x => x.AbilityAssignmentId, + principalTable: "dungeon_mob_ability_assignments", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "mob_sprite_sheets", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Name = table.Column(type: "varchar(64)", maxLength: 64, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + CdnPath = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + SheetWidth = table.Column(type: "int", nullable: false), + SheetHeight = table.Column(type: "int", nullable: false), + FrameWidth = table.Column(type: "int", nullable: false), + FrameHeight = table.Column(type: "int", nullable: false), + IsEnabled = table.Column(type: "tinyint(1)", nullable: false), + CreatedAt = table.Column(type: "datetime(6)", nullable: false), + UpdatedAt = table.Column(type: "datetime(6)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_mob_sprite_sheets", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "mob_animation_definitions", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + SpriteSheetId = table.Column(type: "int", nullable: false), + Key = table.Column(type: "varchar(64)", maxLength: 64, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Name = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + FrameSequence = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Fps = table.Column(type: "float", nullable: false), + Loop = table.Column(type: "tinyint(1)", nullable: false), + FlipX = table.Column(type: "tinyint(1)", nullable: false), + FlipY = table.Column(type: "tinyint(1)", nullable: false), + IsEnabled = table.Column(type: "tinyint(1)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_mob_animation_definitions", x => x.Id); + table.ForeignKey( + name: "FK_mob_animation_definitions_mob_sprite_sheets_SpriteSheetId", + column: x => x.SpriteSheetId, + principalTable: "mob_sprite_sheets", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "mob_animation_assignments", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + MobDefinitionId = table.Column(type: "int", nullable: false), + AnimationDefinitionId = table.Column(type: "int", nullable: false), + OverrideKey = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Priority = table.Column(type: "int", nullable: false), + IsEnabled = table.Column(type: "tinyint(1)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_mob_animation_assignments", x => x.Id); + table.ForeignKey( + name: "FK_mob_animation_assignments_dungeon_mob_definitions_MobDefinit~", + column: x => x.MobDefinitionId, + principalTable: "dungeon_mob_definitions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_mob_animation_assignments_mob_animation_definitions_Animatio~", + column: x => x.AnimationDefinitionId, + principalTable: "mob_animation_definitions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateIndex( + name: "IX_mob_ability_animation_mappings_AbilityAssignmentId", + table: "mob_ability_animation_mappings", + column: "AbilityAssignmentId"); + + migrationBuilder.CreateIndex( + name: "IX_mob_animation_assignments_AnimationDefinitionId", + table: "mob_animation_assignments", + column: "AnimationDefinitionId"); + + migrationBuilder.CreateIndex( + name: "IX_mob_animation_assignments_MobDefinitionId", + table: "mob_animation_assignments", + column: "MobDefinitionId"); + + migrationBuilder.CreateIndex( + name: "IX_mob_animation_definitions_SpriteSheetId", + table: "mob_animation_definitions", + column: "SpriteSheetId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "mob_ability_animation_mappings"); + + migrationBuilder.DropTable( + name: "mob_animation_assignments"); + + migrationBuilder.DropTable( + name: "mob_animation_definitions"); + + migrationBuilder.DropTable( + name: "mob_sprite_sheets"); + } + } +} diff --git a/Migrations/GameDbContextModelSnapshot.cs b/Migrations/GameDbContextModelSnapshot.cs index 5c97a36..a646df6 100644 --- a/Migrations/GameDbContextModelSnapshot.cs +++ b/Migrations/GameDbContextModelSnapshot.cs @@ -1309,6 +1309,33 @@ namespace SystemRevivalServer.Migrations b.ToTable("dungeon_stash_items"); }); + modelBuilder.Entity("DataServer.Data.Entities.MobAbilityAnimationMapping", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AbilityAssignmentId") + .HasColumnType("int"); + + b.Property("AnimationKey") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("DirectionSuffix") + .HasMaxLength(16) + .HasColumnType("varchar(16)"); + + b.HasKey("Id"); + + b.HasIndex("AbilityAssignmentId"); + + b.ToTable("mob_ability_animation_mappings"); + }); + modelBuilder.Entity("DataServer.Data.Entities.MobAbilityAssignment", b => { b.Property("Id") @@ -1488,6 +1515,130 @@ namespace SystemRevivalServer.Migrations b.ToTable("dungeon_mob_abilities"); }); + modelBuilder.Entity("DataServer.Data.Entities.MobAnimationAssignment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AnimationDefinitionId") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("MobDefinitionId") + .HasColumnType("int"); + + b.Property("OverrideKey") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Priority") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("AnimationDefinitionId"); + + b.HasIndex("MobDefinitionId"); + + b.ToTable("mob_animation_assignments"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.MobAnimationDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("FlipX") + .HasColumnType("tinyint(1)"); + + b.Property("FlipY") + .HasColumnType("tinyint(1)"); + + b.Property("Fps") + .HasColumnType("float"); + + b.Property("FrameSequence") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Loop") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("SpriteSheetId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("SpriteSheetId"); + + b.ToTable("mob_animation_definitions"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.MobSpriteSheet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("CdnPath") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("FrameHeight") + .HasColumnType("int"); + + b.Property("FrameWidth") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("SheetHeight") + .HasColumnType("int"); + + b.Property("SheetWidth") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.ToTable("mob_sprite_sheets"); + }); + modelBuilder.Entity("DataServer.Data.Session", b => { b.Property("Id") @@ -1863,6 +2014,17 @@ namespace SystemRevivalServer.Migrations b.Navigation("Definition"); }); + modelBuilder.Entity("DataServer.Data.Entities.MobAbilityAnimationMapping", b => + { + b.HasOne("DataServer.Data.Entities.MobAbilityAssignment", "AbilityAssignment") + .WithMany() + .HasForeignKey("AbilityAssignmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AbilityAssignment"); + }); + modelBuilder.Entity("DataServer.Data.Entities.MobAbilityAssignment", b => { b.HasOne("DataServer.Data.Entities.MobAbilityDefinition", "AbilityDefinition") @@ -1882,6 +2044,36 @@ namespace SystemRevivalServer.Migrations b.Navigation("MobDefinition"); }); + modelBuilder.Entity("DataServer.Data.Entities.MobAnimationAssignment", b => + { + b.HasOne("DataServer.Data.Entities.MobAnimationDefinition", "AnimationDefinition") + .WithMany() + .HasForeignKey("AnimationDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DataServer.Data.Entities.DungeonMobDefinition", "MobDefinition") + .WithMany() + .HasForeignKey("MobDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AnimationDefinition"); + + b.Navigation("MobDefinition"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.MobAnimationDefinition", b => + { + b.HasOne("DataServer.Data.Entities.MobSpriteSheet", "SpriteSheet") + .WithMany("Animations") + .HasForeignKey("SpriteSheetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("SpriteSheet"); + }); + modelBuilder.Entity("DataServer.Data.Session", b => { b.HasOne("DataServer.Data.Account", "Account") @@ -1932,6 +2124,11 @@ namespace SystemRevivalServer.Migrations { b.Navigation("AbilityAssignments"); }); + + modelBuilder.Entity("DataServer.Data.Entities.MobSpriteSheet", b => + { + b.Navigation("Animations"); + }); #pragma warning restore 612, 618 } } diff --git a/Services/Admin/Pages/Mobs/Edit.cshtml b/Services/Admin/Pages/Mobs/Edit.cshtml index 4f6f547..932f931 100644 --- a/Services/Admin/Pages/Mobs/Edit.cshtml +++ b/Services/Admin/Pages/Mobs/Edit.cshtml @@ -490,6 +490,131 @@ } + + @if (!Model.IsNew) + { +
+
+

Animations (@Model.MobAnimations.Count)

+
+ Manage Sheets + +
+
+
+ @if (Model.MobAnimations.Count > 0) + { + + + + + + + + + + + + + + + @foreach (var assignment in Model.MobAnimations) + { + var anim = assignment.AnimationDefinition; + var sheet = anim?.SpriteSheet; + + + + + + + + + + + } + +
KeySheetFramesFPSOptionsOverride KeyStatusActions
@anim?.Key@sheet?.Name@anim?.FrameSequence@anim?.Fps + @if (anim?.Loop == true) { Loop } + @if (anim?.FlipX == true) { FlipX } + @if (anim?.FlipY == true) { FlipY } + @(assignment.OverrideKey ?? "-") + @if (assignment.IsEnabled) + { + Active + } + else + { + Disabled + } + +
+
+ @Html.AntiForgeryToken() + + + +
+
+ @Html.AntiForgeryToken() + + + +
+
+
+ } + else + { +

No animations assigned. Create sprite sheets first, then add animations here.

+ } +
+
+ + + + } + @if (!Model.IsNew) { @@ -613,10 +738,19 @@ document.getElementById('addAbilityModal').classList.add('hidden'); document.getElementById('addAbilityModal').classList.remove('flex'); } + function showAddAnimationModal() { + document.getElementById('addAnimationModal').classList.remove('hidden'); + document.getElementById('addAnimationModal').classList.add('flex'); + } + function closeAddAnimationModal() { + document.getElementById('addAnimationModal').classList.add('hidden'); + document.getElementById('addAnimationModal').classList.remove('flex'); + } document.addEventListener('keydown', e => { if (e.key === 'Escape') { closeAddLootModal(); closeAddAbilityModal(); + closeAddAnimationModal(); } }); diff --git a/Services/Admin/Pages/Mobs/Edit.cshtml.cs b/Services/Admin/Pages/Mobs/Edit.cshtml.cs index bfceb3b..29ee08e 100644 --- a/Services/Admin/Pages/Mobs/Edit.cshtml.cs +++ b/Services/Admin/Pages/Mobs/Edit.cshtml.cs @@ -7,7 +7,7 @@ using System.Text.Json; namespace Server.Services.Admin.Pages.Mobs; -// Helper class for sprite configuration +// Helper class for sprite configuration (legacy - keeping for backwards compatibility) public class MobSpriteConfig { public Dictionary Sprites { get; set; } = new(); @@ -29,10 +29,12 @@ public class MobSpriteConfig public class EditModel : AdminPageModel { private readonly GameDbContext _db; + private readonly IConfiguration _config; - public EditModel(GameDbContext db) + public EditModel(GameDbContext db, IConfiguration config) { _db = db; + _config = config; } [BindProperty] @@ -46,6 +48,11 @@ public class EditModel : AdminPageModel public List MobAbilities { get; set; } = new(); public List AllAbilities { get; set; } = new(); + // Animation management + public List MobAnimations { get; set; } = new(); + public List AllAnimations { get; set; } = new(); + public string CdnBaseUrl { get; set; } = ""; + public bool IsNew => Mob.Id == 0; public string? Message { get; set; } public bool IsError { get; set; } @@ -88,6 +95,8 @@ public class EditModel : AdminPageModel public async Task OnGetAsync(int? id) { + CdnBaseUrl = _config["Cdn:BaseUrl"] ?? "https://assets.aeternalisgames.com"; + AllLootTables = await _db.DungeonLootTables .Where(t => t.IsEnabled) .OrderBy(t => t.Name) @@ -102,6 +111,13 @@ public class EditModel : AdminPageModel .Where(a => a.IsEnabled) .OrderBy(a => a.Name) .ToListAsync(); + + AllAnimations = await _db.MobAnimationDefinitions + .Include(a => a.SpriteSheet) + .Where(a => a.IsEnabled) + .OrderBy(a => a.SpriteSheet!.Name) + .ThenBy(a => a.Key) + .ToListAsync(); if (id.HasValue) { @@ -121,6 +137,13 @@ public class EditModel : AdminPageModel .Where(a => a.MobDefinitionId == id.Value) .OrderBy(a => a.AbilityDefinition!.Name) .ToListAsync(); + + MobAnimations = await _db.MobAnimationAssignments + .Include(a => a.AnimationDefinition) + .ThenInclude(d => d!.SpriteSheet) + .Where(a => a.MobDefinitionId == id.Value) + .OrderBy(a => a.AnimationDefinition!.Key) + .ToListAsync(); } } else @@ -403,4 +426,55 @@ public class EditModel : AdminPageModel return RedirectToPage("/Mobs/Edit", new { id = mobId }); } + + public async Task OnPostAddAnimationAsync(int mobId, int animationId, string? overrideKey, int priority) + { + // Check if already assigned + var existing = await _db.MobAnimationAssignments + .FirstOrDefaultAsync(a => a.MobDefinitionId == mobId && a.AnimationDefinitionId == animationId); + + if (existing != null) + { + TempData["Error"] = "This animation is already assigned to this mob."; + return RedirectToPage("/Mobs/Edit", new { id = mobId }); + } + + var assignment = new MobAnimationAssignment + { + MobDefinitionId = mobId, + AnimationDefinitionId = animationId, + OverrideKey = string.IsNullOrWhiteSpace(overrideKey) ? null : overrideKey, + Priority = priority, + IsEnabled = true + }; + + _db.MobAnimationAssignments.Add(assignment); + await _db.SaveChangesAsync(); + + return RedirectToPage("/Mobs/Edit", new { id = mobId }); + } + + public async Task OnPostRemoveAnimationAsync(int assignmentId, int mobId) + { + var assignment = await _db.MobAnimationAssignments.FindAsync(assignmentId); + if (assignment != null) + { + _db.MobAnimationAssignments.Remove(assignment); + await _db.SaveChangesAsync(); + } + + return RedirectToPage("/Mobs/Edit", new { id = mobId }); + } + + public async Task OnPostToggleAnimationAsync(int assignmentId, int mobId) + { + var assignment = await _db.MobAnimationAssignments.FindAsync(assignmentId); + if (assignment != null) + { + assignment.IsEnabled = !assignment.IsEnabled; + await _db.SaveChangesAsync(); + } + + return RedirectToPage("/Mobs/Edit", new { id = mobId }); + } } diff --git a/Services/Admin/Pages/Shared/_Layout.cshtml b/Services/Admin/Pages/Shared/_Layout.cshtml index b201b04..68d3a5a 100644 --- a/Services/Admin/Pages/Shared/_Layout.cshtml +++ b/Services/Admin/Pages/Shared/_Layout.cshtml @@ -145,6 +145,13 @@ Abilities + + + + + Sprite Sheets + + diff --git a/Services/Admin/Pages/SpriteSheets/Edit.cshtml b/Services/Admin/Pages/SpriteSheets/Edit.cshtml new file mode 100644 index 0000000..51695c8 --- /dev/null +++ b/Services/Admin/Pages/SpriteSheets/Edit.cshtml @@ -0,0 +1,292 @@ +@page "/admin/spritesheets/edit" +@model SpriteSheets.EditModel +@{ + ViewData["Title"] = Model.Sheet.Id > 0 ? $"Edit: {Model.Sheet.Name}" : "New Sprite Sheet"; + var isNew = Model.Sheet.Id == 0; +} + +
+
+
+ ← Back to Sprite Sheets +

@ViewData["Title"]

+
+ @if (!isNew) + { +
+ @Html.AntiForgeryToken() + + +
+ } +
+ + @if (!string.IsNullOrEmpty(Model.Message)) + { +
+ @Model.Message +
+ } + @if (TempData["Error"] != null) + { +
+ @TempData["Error"] +
+ } + +
+ @Html.AntiForgeryToken() + + + + +
+

Sprite Sheet Info

+
+
+ + +
+
+ +
+ + +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + @if (!string.IsNullOrEmpty(Model.Sheet.CdnPath)) + { +
+

Preview (Sheet: @Model.Sheet.SheetWidth x @Model.Sheet.SheetHeight, Frame: @Model.Sheet.FrameWidth x @Model.Sheet.FrameHeight = @Model.Sheet.TotalFrames frames)

+ Sprite sheet preview +
+ } +
+ +
+ + Cancel +
+
+ + + @if (!isNew) + { +
+
+

Animations (@Model.Animations.Count)

+ +
+
+ @if (Model.Animations.Count > 0) + { +
+ @foreach (var anim in Model.Animations) + { +
+
+ @Html.AntiForgeryToken() + + + +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + + + +
+
+ + +
+
+
+ } +
+ } + else + { +

No animations defined. Add animations to use this sprite sheet.

+ } + + +
+

Frame Reference (frames are numbered 0 to @(Model.Sheet.TotalFrames - 1), left-to-right, top-to-bottom)

+
+ @for (int i = 0; i < Model.Sheet.TotalFrames; i++) + { +
@i
+ } +
+
+
+
+ + + + + + + } + + + +
+ +@section Scripts { + +} diff --git a/Services/Admin/Pages/SpriteSheets/Edit.cshtml.cs b/Services/Admin/Pages/SpriteSheets/Edit.cshtml.cs new file mode 100644 index 0000000..0cb3a05 --- /dev/null +++ b/Services/Admin/Pages/SpriteSheets/Edit.cshtml.cs @@ -0,0 +1,226 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using DataServer.Data; +using DataServer.Data.Entities; + +namespace Server.Services.Admin.Pages.SpriteSheets; + +public class EditModel : AdminPageModel +{ + private readonly GameDbContext _db; + private readonly IConfiguration _config; + + public EditModel(GameDbContext db, IConfiguration config) + { + _db = db; + _config = config; + } + + [BindProperty] + public MobSpriteSheet Sheet { get; set; } = new(); + + public List Animations { get; set; } = new(); + public List CdnImages { get; set; } = new(); + public string CdnBaseUrl { get; set; } = ""; + + public string? Message { get; set; } + public bool IsError { get; set; } + + public async Task OnGetAsync(int? id) + { + CdnBaseUrl = _config["Cdn:BaseUrl"] ?? "https://assets.aeternalisgames.com"; + CdnImages = await _db.ClientAssets + .Where(a => a.AssetType == ClientAssetType.Texture && a.IsEnabled) + .OrderBy(a => a.FilePath) + .ToListAsync(); + + if (id.HasValue) + { + var sheet = await _db.MobSpriteSheets + .Include(s => s.Animations) + .FirstOrDefaultAsync(s => s.Id == id.Value); + + if (sheet != null) + { + Sheet = sheet; + Animations = sheet.Animations?.OrderBy(a => a.Key).ToList() ?? new(); + } + } + else + { + Sheet = new MobSpriteSheet + { + IsEnabled = true + }; + } + } + + public async Task OnPostAsync() + { + CdnBaseUrl = _config["Cdn:BaseUrl"] ?? "https://assets.aeternalisgames.com"; + + try + { + if (Sheet.Id == 0) + { + Sheet.CreatedAt = DateTime.UtcNow; + Sheet.UpdatedAt = DateTime.UtcNow; + _db.MobSpriteSheets.Add(Sheet); + await _db.SaveChangesAsync(); + Message = $"Sprite sheet '{Sheet.Name}' created."; + return RedirectToPage(new { id = Sheet.Id }); + } + else + { + var existing = await _db.MobSpriteSheets.FindAsync(Sheet.Id); + if (existing == null) + { + Message = "Sprite sheet not found."; + IsError = true; + return Page(); + } + + existing.Name = Sheet.Name; + existing.CdnPath = Sheet.CdnPath; + existing.SheetWidth = Sheet.SheetWidth; + existing.SheetHeight = Sheet.SheetHeight; + existing.FrameWidth = Sheet.FrameWidth; + existing.FrameHeight = Sheet.FrameHeight; + existing.IsEnabled = Sheet.IsEnabled; + existing.UpdatedAt = DateTime.UtcNow; + + await _db.SaveChangesAsync(); + Sheet = existing; + Message = "Sprite sheet updated."; + + Animations = await _db.MobAnimationDefinitions + .Where(a => a.SpriteSheetId == Sheet.Id) + .OrderBy(a => a.Key) + .ToListAsync(); + } + } + catch (Exception ex) + { + Message = $"Error: {ex.Message}"; + IsError = true; + } + + CdnImages = await _db.ClientAssets + .Where(a => a.AssetType == ClientAssetType.Texture && a.IsEnabled) + .OrderBy(a => a.FilePath) + .ToListAsync(); + + return Page(); + } + + public async Task OnPostAddAnimationAsync(int sheetId, string key, string? name, string frameSequence, float fps, bool loop, bool flipX, bool flipY) + { + var animation = new MobAnimationDefinition + { + SpriteSheetId = sheetId, + Key = key, + Name = name, + FrameSequence = frameSequence, + Fps = fps, + Loop = loop, + FlipX = flipX, + FlipY = flipY, + IsEnabled = true + }; + + _db.MobAnimationDefinitions.Add(animation); + await _db.SaveChangesAsync(); + + return RedirectToPage(new { id = sheetId }); + } + + public async Task OnPostUpdateAnimationAsync(int animId, int sheetId, string key, string? name, string frameSequence, float fps, bool loop, bool flipX, bool flipY, bool isEnabled) + { + var animation = await _db.MobAnimationDefinitions.FindAsync(animId); + if (animation != null) + { + animation.Key = key; + animation.Name = name; + animation.FrameSequence = frameSequence; + animation.Fps = fps; + animation.Loop = loop; + animation.FlipX = flipX; + animation.FlipY = flipY; + animation.IsEnabled = isEnabled; + await _db.SaveChangesAsync(); + } + + return RedirectToPage(new { id = sheetId }); + } + + public async Task OnPostDeleteAnimationAsync(int animId, int sheetId) + { + var animation = await _db.MobAnimationDefinitions.FindAsync(animId); + if (animation != null) + { + // Check if assigned to any mobs + var assignmentCount = await _db.MobAnimationAssignments + .Where(a => a.AnimationDefinitionId == animId) + .CountAsync(); + + if (assignmentCount > 0) + { + TempData["Error"] = $"Cannot delete: animation is assigned to {assignmentCount} mob(s)."; + return RedirectToPage(new { id = sheetId }); + } + + _db.MobAnimationDefinitions.Remove(animation); + await _db.SaveChangesAsync(); + } + + return RedirectToPage(new { id = sheetId }); + } + + public async Task OnPostDuplicateAsync(int id) + { + var original = await _db.MobSpriteSheets + .Include(s => s.Animations) + .FirstOrDefaultAsync(s => s.Id == id); + + if (original == null) return RedirectToPage(); + + var copy = new MobSpriteSheet + { + Name = original.Name + " (Copy)", + CdnPath = original.CdnPath, + SheetWidth = original.SheetWidth, + SheetHeight = original.SheetHeight, + FrameWidth = original.FrameWidth, + FrameHeight = original.FrameHeight, + IsEnabled = true, + CreatedAt = DateTime.UtcNow, + UpdatedAt = DateTime.UtcNow + }; + + _db.MobSpriteSheets.Add(copy); + await _db.SaveChangesAsync(); + + // Copy animations + if (original.Animations != null) + { + foreach (var anim in original.Animations) + { + _db.MobAnimationDefinitions.Add(new MobAnimationDefinition + { + SpriteSheetId = copy.Id, + Key = anim.Key, + Name = anim.Name, + FrameSequence = anim.FrameSequence, + Fps = anim.Fps, + Loop = anim.Loop, + FlipX = anim.FlipX, + FlipY = anim.FlipY, + IsEnabled = anim.IsEnabled + }); + } + await _db.SaveChangesAsync(); + } + + return RedirectToPage(new { id = copy.Id }); + } +} diff --git a/Services/Admin/Pages/SpriteSheets/Index.cshtml b/Services/Admin/Pages/SpriteSheets/Index.cshtml new file mode 100644 index 0000000..9e3903d --- /dev/null +++ b/Services/Admin/Pages/SpriteSheets/Index.cshtml @@ -0,0 +1,77 @@ +@page "/admin/spritesheets" +@model SpriteSheets.IndexModel +@{ + ViewData["Title"] = "Sprite Sheets"; +} + +
+
+
+

Sprite Sheets

+

Manage sprite sheets and animations for mobs

+
+ + New Sprite Sheet +
+ + @if (TempData["Message"] != null) + { +
+ @TempData["Message"] +
+ } + @if (TempData["Error"] != null) + { +
+ @TempData["Error"] +
+ } + +
+ @foreach (var sheet in Model.SpriteSheets) + { +
+
+
+

@sheet.Name

+

@sheet.CdnPath

+
+ @if (sheet.IsEnabled) + { + Enabled + } + else + { + Disabled + } +
+ +
+
Sheet Size:
+
@sheet.SheetWidth x @sheet.SheetHeight
+
Frame Size:
+
@sheet.FrameWidth x @sheet.FrameHeight
+
Grid:
+
@sheet.Columns x @sheet.Rows (@sheet.TotalFrames frames)
+
Animations:
+
@(sheet.Animations?.Count ?? 0)
+
+ +
+ Edit +
+ @Html.AntiForgeryToken() + + +
+
+
+ } +
+ + @if (Model.SpriteSheets.Count == 0) + { +
+ No sprite sheets found. Create one +
+ } +
diff --git a/Services/Admin/Pages/SpriteSheets/Index.cshtml.cs b/Services/Admin/Pages/SpriteSheets/Index.cshtml.cs new file mode 100644 index 0000000..9c69abc --- /dev/null +++ b/Services/Admin/Pages/SpriteSheets/Index.cshtml.cs @@ -0,0 +1,54 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using DataServer.Data; +using DataServer.Data.Entities; + +namespace Server.Services.Admin.Pages.SpriteSheets; + +public class IndexModel : AdminPageModel +{ + private readonly GameDbContext _db; + + public IndexModel(GameDbContext db) + { + _db = db; + } + + public List SpriteSheets { get; set; } = new(); + + public async Task OnGetAsync() + { + SpriteSheets = await _db.MobSpriteSheets + .Include(s => s.Animations) + .OrderBy(s => s.Name) + .ToListAsync(); + } + + public async Task OnPostDeleteAsync(int id) + { + var sheet = await _db.MobSpriteSheets.FindAsync(id); + if (sheet != null) + { + // Check for animation assignments + var animationIds = await _db.MobAnimationDefinitions + .Where(a => a.SpriteSheetId == id) + .Select(a => a.Id) + .ToListAsync(); + + var assignmentCount = await _db.MobAnimationAssignments + .Where(a => animationIds.Contains(a.AnimationDefinitionId)) + .CountAsync(); + + if (assignmentCount > 0) + { + TempData["Error"] = $"Cannot delete: animations from this sheet are assigned to {assignmentCount} mob(s)."; + return RedirectToPage(); + } + + _db.MobSpriteSheets.Remove(sheet); + await _db.SaveChangesAsync(); + TempData["Message"] = $"Sprite sheet '{sheet.Name}' deleted."; + } + return RedirectToPage(); + } +} diff --git a/data/GameDbContext.cs b/data/GameDbContext.cs index 570cec4..74a2839 100644 --- a/data/GameDbContext.cs +++ b/data/GameDbContext.cs @@ -27,6 +27,12 @@ public sealed class GameDbContext : DbContext public DbSet MobAbilityDefinitions => Set(); public DbSet MobAbilityAssignments => Set(); + // Mob sprite/animation system + public DbSet MobSpriteSheets => Set(); + public DbSet MobAnimationDefinitions => Set(); + public DbSet MobAnimationAssignments => Set(); + public DbSet MobAbilityAnimationMappings => Set(); + public DbSet DungeonBeltItems => Set(); public DbSet DeathChests => Set(); public DbSet DeathChestItems => Set(); diff --git a/data/entities/MobSpriteSheet.cs b/data/entities/MobSpriteSheet.cs new file mode 100644 index 0000000..9572b1b --- /dev/null +++ b/data/entities/MobSpriteSheet.cs @@ -0,0 +1,167 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace DataServer.Data.Entities; + +/// +/// Defines a sprite sheet uploaded to the CDN +/// +[Table("mob_sprite_sheets")] +public class MobSpriteSheet +{ + [Key] + public int Id { get; set; } + + /// Friendly name for admin UI + [Required, MaxLength(64)] + public string Name { get; set; } = ""; + + /// CDN path (e.g., "textures/mobs/skeleton.png") + [Required, MaxLength(256)] + public string CdnPath { get; set; } = ""; + + /// Total width of the sprite sheet in pixels + public int SheetWidth { get; set; } = 512; + + /// Total height of the sprite sheet in pixels + public int SheetHeight { get; set; } = 512; + + /// Width of each frame in pixels + public int FrameWidth { get; set; } = 64; + + /// Height of each frame in pixels + public int FrameHeight { get; set; } = 64; + + /// Number of columns in the sheet (calculated from width/frameWidth) + [NotMapped] + public int Columns => SheetWidth / FrameWidth; + + /// Number of rows in the sheet + [NotMapped] + public int Rows => SheetHeight / FrameHeight; + + /// Total number of frames + [NotMapped] + public int TotalFrames => Columns * Rows; + + public bool IsEnabled { get; set; } = true; + + public DateTime CreatedAt { get; set; } = DateTime.UtcNow; + public DateTime UpdatedAt { get; set; } = DateTime.UtcNow; + + // Navigation + public ICollection? Animations { get; set; } +} + +/// +/// Defines a named animation using frames from a sprite sheet +/// +[Table("mob_animation_definitions")] +public class MobAnimationDefinition +{ + [Key] + public int Id { get; set; } + + /// Which sprite sheet this animation uses + public int SpriteSheetId { get; set; } + + [ForeignKey(nameof(SpriteSheetId))] + public MobSpriteSheet? SpriteSheet { get; set; } + + /// Animation key (e.g., "walk_left", "attack_down", "idle", "cast") + [Required, MaxLength(64)] + public string Key { get; set; } = ""; + + /// Friendly name for admin + [MaxLength(64)] + public string? Name { get; set; } + + /// + /// Comma-separated list of frame indices (0-based) + /// e.g., "0,1,2,3" or "8,9,10,11,10,9" for ping-pong + /// Frames are numbered left-to-right, top-to-bottom + /// + [Required, MaxLength(256)] + public string FrameSequence { get; set; } = "0"; + + /// Frames per second + public float Fps { get; set; } = 8f; + + /// Whether the animation loops + public bool Loop { get; set; } = true; + + /// Optional: flip horizontally (for reusing left as right) + public bool FlipX { get; set; } = false; + + /// Optional: flip vertically + public bool FlipY { get; set; } = false; + + public bool IsEnabled { get; set; } = true; + + /// Parse frame sequence into array of ints + [NotMapped] + public int[] Frames => string.IsNullOrEmpty(FrameSequence) + ? new[] { 0 } + : FrameSequence.Split(',').Select(s => int.TryParse(s.Trim(), out var n) ? n : 0).ToArray(); +} + +/// +/// Links a mob to its animations - which animations from which sheets it uses +/// +[Table("mob_animation_assignments")] +public class MobAnimationAssignment +{ + [Key] + public int Id { get; set; } + + /// Which mob this animation is for + public int MobDefinitionId { get; set; } + + [ForeignKey(nameof(MobDefinitionId))] + public DungeonMobDefinition? MobDefinition { get; set; } + + /// Which animation definition to use + public int AnimationDefinitionId { get; set; } + + [ForeignKey(nameof(AnimationDefinitionId))] + public MobAnimationDefinition? AnimationDefinition { get; set; } + + /// + /// Override key for this mob (e.g., map "walk" to specific directional animation) + /// If null, uses the animation's original key + /// + [MaxLength(64)] + public string? OverrideKey { get; set; } + + /// Priority when multiple animations match (higher = preferred) + public int Priority { get; set; } = 0; + + public bool IsEnabled { get; set; } = true; +} + +/// +/// Maps ability to animation for a specific mob +/// +[Table("mob_ability_animation_mappings")] +public class MobAbilityAnimationMapping +{ + [Key] + public int Id { get; set; } + + /// The mob-ability assignment this mapping is for + public int AbilityAssignmentId { get; set; } + + [ForeignKey(nameof(AbilityAssignmentId))] + public MobAbilityAssignment? AbilityAssignment { get; set; } + + /// + /// Animation key to play when this ability is used + /// This should match one of the mob's assigned animations + /// + [Required, MaxLength(64)] + public string AnimationKey { get; set; } = "attack"; + + /// Optional: specific direction variant (down, up, left, right) + [MaxLength(16)] + public string? DirectionSuffix { get; set; } +}