CDN Integration
This commit is contained in:
@@ -80,7 +80,9 @@ public sealed class DungeonHandler : IClientMessageHandler
|
|||||||
// Dungeon browser
|
// Dungeon browser
|
||||||
DungeonOpCodes.DUNGEON_LIST_REQUEST,
|
DungeonOpCodes.DUNGEON_LIST_REQUEST,
|
||||||
DungeonOpCodes.DUNGEON_CREATE,
|
DungeonOpCodes.DUNGEON_CREATE,
|
||||||
DungeonOpCodes.DUNGEON_JOIN
|
DungeonOpCodes.DUNGEON_JOIN,
|
||||||
|
// Asset management
|
||||||
|
DungeonOpCodes.ASSET_MANIFEST_REQUEST
|
||||||
};
|
};
|
||||||
|
|
||||||
public async Task InitializeAsync()
|
public async Task InitializeAsync()
|
||||||
@@ -228,6 +230,9 @@ public sealed class DungeonHandler : IClientMessageHandler
|
|||||||
case DungeonOpCodes.DUNGEON_JOIN:
|
case DungeonOpCodes.DUNGEON_JOIN:
|
||||||
await HandleDungeonJoin(connection, session, payload, ct);
|
await HandleDungeonJoin(connection, session, payload, ct);
|
||||||
break;
|
break;
|
||||||
|
case DungeonOpCodes.ASSET_MANIFEST_REQUEST:
|
||||||
|
await HandleAssetManifestRequest(connection, ct);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -783,7 +788,7 @@ public sealed class DungeonHandler : IClientMessageHandler
|
|||||||
var emptyTime = DateTime.UtcNow - instance.LastPlayerActivity;
|
var emptyTime = DateTime.UtcNow - instance.LastPlayerActivity;
|
||||||
|
|
||||||
// If boss not killed and empty for 10+ minutes, persist to database
|
// If boss not killed and empty for 10+ minutes, persist to database
|
||||||
if (!instance.BossKilled && !instance.IsPersisted && emptyTime.TotalMinutes >= 5)
|
if (!instance.BossKilled && !instance.IsPersisted && emptyTime.TotalMinutes >= 10)
|
||||||
{
|
{
|
||||||
_ = PersistDungeonAsync(instance, CancellationToken.None);
|
_ = PersistDungeonAsync(instance, CancellationToken.None);
|
||||||
_dungeons.TryRemove(dungeonId, out _);
|
_dungeons.TryRemove(dungeonId, out _);
|
||||||
@@ -1614,6 +1619,38 @@ public sealed class DungeonHandler : IClientMessageHandler
|
|||||||
|
|
||||||
#region Dungeon Browser Handlers
|
#region Dungeon Browser Handlers
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handle request for asset manifest (list of all CDN files for hot-update)
|
||||||
|
/// </summary>
|
||||||
|
private async Task HandleAssetManifestRequest(IConnection connection, CancellationToken ct)
|
||||||
|
{
|
||||||
|
using var scope = _scopeFactory.CreateScope();
|
||||||
|
var db = scope.ServiceProvider.GetRequiredService<GameDbContext>();
|
||||||
|
|
||||||
|
var assets = await db.ClientAssets
|
||||||
|
.Where(a => a.IsEnabled)
|
||||||
|
.Select(a => new
|
||||||
|
{
|
||||||
|
filePath = a.FilePath,
|
||||||
|
assetType = (int)a.AssetType,
|
||||||
|
fileHash = a.FileHash,
|
||||||
|
fileSize = a.FileSize,
|
||||||
|
version = a.Version,
|
||||||
|
isRequired = a.IsRequired,
|
||||||
|
minClientVersion = a.MinClientVersion,
|
||||||
|
cdnPath = a.CdnPath ?? a.FilePath
|
||||||
|
})
|
||||||
|
.ToListAsync(ct);
|
||||||
|
|
||||||
|
await SendAsync(connection, DungeonOpCodes.ASSET_MANIFEST_RESPONSE, new
|
||||||
|
{
|
||||||
|
cdnBaseUrl = "https://assets.aeternalisgames.com/downloads/",
|
||||||
|
assets = assets
|
||||||
|
}, ct);
|
||||||
|
|
||||||
|
_log.LogInformation("Sent asset manifest with {Count} files", assets.Count);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handle request for list of available dungeons
|
/// Handle request for list of available dungeons
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -1905,10 +1942,9 @@ public sealed class DungeonHandler : IClientMessageHandler
|
|||||||
y = m.Y,
|
y = m.Y,
|
||||||
health = m.Health,
|
health = m.Health,
|
||||||
maxHealth = m.MaxHealth,
|
maxHealth = m.MaxHealth,
|
||||||
spriteSheet = m.SpriteSheet,
|
scenePath = m.ScenePath,
|
||||||
spriteWidth = m.SpriteWidth,
|
tintColor = m.TintColor,
|
||||||
spriteHeight = m.SpriteHeight,
|
scale = m.Scale
|
||||||
tintColor = m.TintColor
|
|
||||||
}),
|
}),
|
||||||
chests = instance.Simulation.Chests.Values.Select(c => new
|
chests = instance.Simulation.Chests.Values.Select(c => new
|
||||||
{
|
{
|
||||||
@@ -2022,13 +2058,13 @@ public sealed class DungeonHandler : IClientMessageHandler
|
|||||||
instance.Simulation.DroppedItems.Clear();
|
instance.Simulation.DroppedItems.Clear();
|
||||||
|
|
||||||
// Reset portals (exit portal should be inactive until boss killed)
|
// Reset portals (exit portal should be inactive until boss killed)
|
||||||
//foreach (var portal in instance.Simulation.Portals.Values)
|
foreach (var portal in instance.Simulation.Portals.Values)
|
||||||
//{
|
{
|
||||||
// if (portal.Type == PortalType.Exit)
|
if (portal.Type == PortalType.Exit)
|
||||||
// {
|
{
|
||||||
// portal.IsActive = false;
|
portal.IsActive = false;
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
|
|
||||||
_log.LogDebug("Respawned {MobCount} mobs in dungeon {Id}", instance.Simulation.Mobs.Count, instance.Id);
|
_log.LogDebug("Respawned {MobCount} mobs in dungeon {Id}", instance.Simulation.Mobs.Count, instance.Id);
|
||||||
}
|
}
|
||||||
@@ -2455,10 +2491,9 @@ public sealed class DungeonHandler : IClientMessageHandler
|
|||||||
health = m.Health,
|
health = m.Health,
|
||||||
maxHealth = m.MaxHealth,
|
maxHealth = m.MaxHealth,
|
||||||
state = m.State.ToString().ToLower(),
|
state = m.State.ToString().ToLower(),
|
||||||
spriteSheet = m.SpriteSheet,
|
scenePath = m.ScenePath,
|
||||||
spriteWidth = m.SpriteWidth,
|
tintColor = m.TintColor,
|
||||||
spriteHeight = m.SpriteHeight,
|
scale = m.Scale
|
||||||
tintColor = m.TintColor
|
|
||||||
}),
|
}),
|
||||||
|
|
||||||
chests = sim.Chests.Values.Select(c => new
|
chests = sim.Chests.Values.Select(c => new
|
||||||
|
|||||||
@@ -123,10 +123,9 @@ public class DungeonSimulation
|
|||||||
MaxHealth = stats.MaxHealth,
|
MaxHealth = stats.MaxHealth,
|
||||||
Stats = stats,
|
Stats = stats,
|
||||||
State = MobState.Idle,
|
State = MobState.Idle,
|
||||||
SpriteSheet = mobDef.SpriteSheet,
|
ScenePath = mobDef.ScenePath,
|
||||||
SpriteWidth = mobDef.SpriteWidth,
|
|
||||||
SpriteHeight = mobDef.SpriteHeight,
|
|
||||||
TintColor = mobDef.TintColor,
|
TintColor = mobDef.TintColor,
|
||||||
|
Scale = mobDef.Scale,
|
||||||
Type = mobDef.Type
|
Type = mobDef.Type
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,11 +46,10 @@ public class MobInstance
|
|||||||
public ulong? TargetId { get; set; }
|
public ulong? TargetId { get; set; }
|
||||||
public long LastAttackTick { get; set; }
|
public long LastAttackTick { get; set; }
|
||||||
|
|
||||||
// Visual
|
// Visual - CDN scene path
|
||||||
public string SpriteSheet { get; set; } = "";
|
public string? ScenePath { get; set; }
|
||||||
public int SpriteWidth { get; set; } = 32;
|
|
||||||
public int SpriteHeight { get; set; } = 32;
|
|
||||||
public string TintColor { get; set; } = "#ffffff";
|
public string TintColor { get; set; } = "#ffffff";
|
||||||
|
public float Scale { get; set; } = 1.0f;
|
||||||
|
|
||||||
// Carried loot from player kills
|
// Carried loot from player kills
|
||||||
public List<CarriedLoot> CarriedPlayerLoot { get; set; } = new();
|
public List<CarriedLoot> CarriedPlayerLoot { get; set; } = new();
|
||||||
|
|||||||
+1880
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,161 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace SystemRevivalServer.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class CDNIntegration : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "AttackFrames",
|
||||||
|
table: "dungeon_mob_definitions");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "DeathFrames",
|
||||||
|
table: "dungeon_mob_definitions");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "IdleFrames",
|
||||||
|
table: "dungeon_mob_definitions");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "SpriteIndex",
|
||||||
|
table: "dungeon_mob_definitions");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "WalkFrames",
|
||||||
|
table: "dungeon_mob_definitions");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<float>(
|
||||||
|
name: "Scale",
|
||||||
|
table: "dungeon_mob_definitions",
|
||||||
|
type: "float",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0f);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "ScenePath",
|
||||||
|
table: "dungeon_mob_definitions",
|
||||||
|
type: "varchar(256)",
|
||||||
|
maxLength: 256,
|
||||||
|
nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "SpritePath",
|
||||||
|
table: "dungeon_item_definitions",
|
||||||
|
type: "varchar(256)",
|
||||||
|
maxLength: 256,
|
||||||
|
nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "TintColor",
|
||||||
|
table: "dungeon_item_definitions",
|
||||||
|
type: "varchar(16)",
|
||||||
|
maxLength: 16,
|
||||||
|
nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "client_assets",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
|
FilePath = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
AssetType = table.Column<int>(type: "int", nullable: false),
|
||||||
|
FileHash = table.Column<string>(type: "varchar(32)", maxLength: 32, nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
FileSize = table.Column<long>(type: "bigint", nullable: false),
|
||||||
|
Version = table.Column<int>(type: "int", nullable: false),
|
||||||
|
IsRequired = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||||
|
MinClientVersion = table.Column<string>(type: "varchar(16)", maxLength: 16, nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
CdnPath = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||||
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||||
|
IsEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_client_assets", x => x.Id);
|
||||||
|
})
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "client_assets");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Scale",
|
||||||
|
table: "dungeon_mob_definitions");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "ScenePath",
|
||||||
|
table: "dungeon_mob_definitions");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "SpritePath",
|
||||||
|
table: "dungeon_item_definitions");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "TintColor",
|
||||||
|
table: "dungeon_item_definitions");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "AttackFrames",
|
||||||
|
table: "dungeon_mob_definitions",
|
||||||
|
type: "varchar(256)",
|
||||||
|
maxLength: 256,
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: "")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "DeathFrames",
|
||||||
|
table: "dungeon_mob_definitions",
|
||||||
|
type: "varchar(256)",
|
||||||
|
maxLength: 256,
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: "")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "IdleFrames",
|
||||||
|
table: "dungeon_mob_definitions",
|
||||||
|
type: "varchar(256)",
|
||||||
|
maxLength: 256,
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: "")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "SpriteIndex",
|
||||||
|
table: "dungeon_mob_definitions",
|
||||||
|
type: "int",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "WalkFrames",
|
||||||
|
table: "dungeon_mob_definitions",
|
||||||
|
type: "varchar(256)",
|
||||||
|
maxLength: 256,
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: "")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -81,6 +81,58 @@ namespace SystemRevivalServer.Migrations
|
|||||||
b.ToTable("accounts", (string)null);
|
b.ToTable("accounts", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Server.Data.Entities.ClientAsset", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("AssetType")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("CdnPath")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("varchar(256)");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.HasColumnType("datetime(6)");
|
||||||
|
|
||||||
|
b.Property<string>("FileHash")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(32)
|
||||||
|
.HasColumnType("varchar(32)");
|
||||||
|
|
||||||
|
b.Property<string>("FilePath")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("varchar(256)");
|
||||||
|
|
||||||
|
b.Property<long>("FileSize")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<bool>("IsEnabled")
|
||||||
|
.HasColumnType("tinyint(1)");
|
||||||
|
|
||||||
|
b.Property<bool>("IsRequired")
|
||||||
|
.HasColumnType("tinyint(1)");
|
||||||
|
|
||||||
|
b.Property<string>("MinClientVersion")
|
||||||
|
.HasMaxLength(16)
|
||||||
|
.HasColumnType("varchar(16)");
|
||||||
|
|
||||||
|
b.Property<DateTime>("UpdatedAt")
|
||||||
|
.HasColumnType("datetime(6)");
|
||||||
|
|
||||||
|
b.Property<int>("Version")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("client_assets");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Server.Data.Entities.DeathChest", b =>
|
modelBuilder.Entity("Server.Data.Entities.DeathChest", b =>
|
||||||
{
|
{
|
||||||
b.Property<ulong>("Id")
|
b.Property<ulong>("Id")
|
||||||
@@ -425,6 +477,10 @@ namespace SystemRevivalServer.Migrations
|
|||||||
b.Property<int>("SpriteId")
|
b.Property<int>("SpriteId")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("SpritePath")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("varchar(256)");
|
||||||
|
|
||||||
b.Property<bool>("Stackable")
|
b.Property<bool>("Stackable")
|
||||||
.HasColumnType("tinyint(1)");
|
.HasColumnType("tinyint(1)");
|
||||||
|
|
||||||
@@ -434,6 +490,10 @@ namespace SystemRevivalServer.Migrations
|
|||||||
b.Property<int?>("TeachesSpellId")
|
b.Property<int?>("TeachesSpellId")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("TintColor")
|
||||||
|
.HasMaxLength(16)
|
||||||
|
.HasColumnType("varchar(16)");
|
||||||
|
|
||||||
b.Property<int>("Type")
|
b.Property<int>("Type")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
@@ -584,11 +644,6 @@ namespace SystemRevivalServer.Migrations
|
|||||||
b.Property<float>("ArmorPerTier")
|
b.Property<float>("ArmorPerTier")
|
||||||
.HasColumnType("float");
|
.HasColumnType("float");
|
||||||
|
|
||||||
b.Property<string>("AttackFrames")
|
|
||||||
.IsRequired()
|
|
||||||
.HasMaxLength(256)
|
|
||||||
.HasColumnType("varchar(256)");
|
|
||||||
|
|
||||||
b.Property<float>("AttackRange")
|
b.Property<float>("AttackRange")
|
||||||
.HasColumnType("float");
|
.HasColumnType("float");
|
||||||
|
|
||||||
@@ -622,11 +677,6 @@ namespace SystemRevivalServer.Migrations
|
|||||||
b.Property<float>("DamagePerTier")
|
b.Property<float>("DamagePerTier")
|
||||||
.HasColumnType("float");
|
.HasColumnType("float");
|
||||||
|
|
||||||
b.Property<string>("DeathFrames")
|
|
||||||
.IsRequired()
|
|
||||||
.HasMaxLength(256)
|
|
||||||
.HasColumnType("varchar(256)");
|
|
||||||
|
|
||||||
b.Property<string>("Description")
|
b.Property<string>("Description")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(256)
|
.HasMaxLength(256)
|
||||||
@@ -638,11 +688,6 @@ namespace SystemRevivalServer.Migrations
|
|||||||
b.Property<float>("HealthPerTier")
|
b.Property<float>("HealthPerTier")
|
||||||
.HasColumnType("float");
|
.HasColumnType("float");
|
||||||
|
|
||||||
b.Property<string>("IdleFrames")
|
|
||||||
.IsRequired()
|
|
||||||
.HasMaxLength(256)
|
|
||||||
.HasColumnType("varchar(256)");
|
|
||||||
|
|
||||||
b.Property<bool>("IsEnabled")
|
b.Property<bool>("IsEnabled")
|
||||||
.HasColumnType("tinyint(1)");
|
.HasColumnType("tinyint(1)");
|
||||||
|
|
||||||
@@ -671,10 +716,14 @@ namespace SystemRevivalServer.Migrations
|
|||||||
.HasMaxLength(1024)
|
.HasMaxLength(1024)
|
||||||
.HasColumnType("varchar(1024)");
|
.HasColumnType("varchar(1024)");
|
||||||
|
|
||||||
b.Property<int>("SpriteHeight")
|
b.Property<float>("Scale")
|
||||||
.HasColumnType("int");
|
.HasColumnType("float");
|
||||||
|
|
||||||
b.Property<int>("SpriteIndex")
|
b.Property<string>("ScenePath")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("varchar(256)");
|
||||||
|
|
||||||
|
b.Property<int>("SpriteHeight")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<string>("SpriteSheet")
|
b.Property<string>("SpriteSheet")
|
||||||
@@ -693,11 +742,6 @@ namespace SystemRevivalServer.Migrations
|
|||||||
b.Property<int>("Type")
|
b.Property<int>("Type")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<string>("WalkFrames")
|
|
||||||
.IsRequired()
|
|
||||||
.HasMaxLength(256)
|
|
||||||
.HasColumnType("varchar(256)");
|
|
||||||
|
|
||||||
b.Property<float>("XpPerTier")
|
b.Property<float>("XpPerTier")
|
||||||
.HasColumnType("float");
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ public static class DungeonOpCodes
|
|||||||
public const int DUNGEON_LIST_RESPONSE = 311;
|
public const int DUNGEON_LIST_RESPONSE = 311;
|
||||||
public const int DUNGEON_CREATE = 312;
|
public const int DUNGEON_CREATE = 312;
|
||||||
public const int DUNGEON_JOIN = 313;
|
public const int DUNGEON_JOIN = 313;
|
||||||
|
|
||||||
|
// Asset Management (320-329)
|
||||||
|
public const int ASSET_MANIFEST_REQUEST = 320;
|
||||||
|
public const int ASSET_MANIFEST_RESPONSE = 321;
|
||||||
|
|
||||||
// Input (400-449)
|
// Input (400-449)
|
||||||
public const int DUNGEON_INPUT_MOVE = 400;
|
public const int DUNGEON_INPUT_MOVE = 400;
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ public sealed class GameDbContext : DbContext
|
|||||||
public DbSet<DeathChest> DeathChests => Set<DeathChest>();
|
public DbSet<DeathChest> DeathChests => Set<DeathChest>();
|
||||||
public DbSet<DeathChestItem> DeathChestItems => Set<DeathChestItem>();
|
public DbSet<DeathChestItem> DeathChestItems => Set<DeathChestItem>();
|
||||||
public DbSet<DungeonPersistence> DungeonInstances => Set<DungeonPersistence>();
|
public DbSet<DungeonPersistence> DungeonInstances => Set<DungeonPersistence>();
|
||||||
|
public DbSet<ClientAsset> ClientAssets => Set<ClientAsset>();
|
||||||
protected override void OnModelCreating(ModelBuilder b)
|
protected override void OnModelCreating(ModelBuilder b)
|
||||||
{
|
{
|
||||||
b.ApplyConfigurationsFromAssembly(typeof(GameDbContext).Assembly);
|
b.ApplyConfigurationsFromAssembly(typeof(GameDbContext).Assembly);
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace Server.Data.Entities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tracks all client-side files that can be hot-updated from CDN.
|
||||||
|
/// Files are stored at: https://assets.aeternalisgames.com/downloads/{FilePath}
|
||||||
|
/// </summary>
|
||||||
|
[Table("client_assets")]
|
||||||
|
public class ClientAsset
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Path relative to client root (e.g., "scenes/mobs/skeleton.tscn", "scripts/ui/hud.gd")
|
||||||
|
/// This is where the file will be saved on the client
|
||||||
|
/// </summary>
|
||||||
|
[Required]
|
||||||
|
[MaxLength(256)]
|
||||||
|
public string FilePath { get; set; } = "";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Type of asset for categorization and loading behavior
|
||||||
|
/// </summary>
|
||||||
|
public ClientAssetType AssetType { get; set; } = ClientAssetType.Texture;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// MD5 hash of file contents for change detection
|
||||||
|
/// </summary>
|
||||||
|
[Required]
|
||||||
|
[MaxLength(32)]
|
||||||
|
public string FileHash { get; set; } = "";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// File size in bytes (for download progress)
|
||||||
|
/// </summary>
|
||||||
|
public long FileSize { get; set; } = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Version number - increment when file changes
|
||||||
|
/// </summary>
|
||||||
|
public int Version { get; set; } = 1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If true, must be downloaded before game can start
|
||||||
|
/// If false, can be lazy-loaded when needed
|
||||||
|
/// </summary>
|
||||||
|
public bool IsRequired { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Minimum client version required to use this asset
|
||||||
|
/// Clients below this version will be told to update
|
||||||
|
/// Format: "1.0.0"
|
||||||
|
/// </summary>
|
||||||
|
[MaxLength(16)]
|
||||||
|
public string? MinClientVersion { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Optional CDN path if different from FilePath
|
||||||
|
/// If null, uses FilePath as CDN path
|
||||||
|
/// </summary>
|
||||||
|
[MaxLength(256)]
|
||||||
|
public string? CdnPath { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// When the file was last updated
|
||||||
|
/// </summary>
|
||||||
|
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// When the file was first added
|
||||||
|
/// </summary>
|
||||||
|
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||||
|
|
||||||
|
public bool IsEnabled { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the CDN download path
|
||||||
|
/// </summary>
|
||||||
|
[NotMapped]
|
||||||
|
public string DownloadPath => CdnPath ?? FilePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ClientAssetType
|
||||||
|
{
|
||||||
|
/// <summary>Scene file (.tscn) - mobs, UI, effects</summary>
|
||||||
|
Scene = 0,
|
||||||
|
|
||||||
|
/// <summary>GDScript file (.gd)</summary>
|
||||||
|
Script = 1,
|
||||||
|
|
||||||
|
/// <summary>Image file (.png, .jpg, .webp)</summary>
|
||||||
|
Texture = 2,
|
||||||
|
|
||||||
|
/// <summary>Resource file (.tres) - themes, materials, etc.</summary>
|
||||||
|
Resource = 3,
|
||||||
|
|
||||||
|
/// <summary>Audio file (.ogg, .wav, .mp3)</summary>
|
||||||
|
Audio = 4,
|
||||||
|
|
||||||
|
/// <summary>Shader file (.gdshader)</summary>
|
||||||
|
Shader = 5,
|
||||||
|
|
||||||
|
/// <summary>Font file (.ttf, .otf)</summary>
|
||||||
|
Font = 6,
|
||||||
|
|
||||||
|
/// <summary>JSON data file</summary>
|
||||||
|
Data = 7
|
||||||
|
}
|
||||||
@@ -64,6 +64,20 @@ public class DungeonItemDefinition
|
|||||||
public int MaxStack { get; set; } = 1;
|
public int MaxStack { get; set; } = 1;
|
||||||
|
|
||||||
// Visuals
|
// Visuals
|
||||||
|
/// <summary>
|
||||||
|
/// Path to the item's sprite image on CDN (e.g., "textures/items/sword_iron.png")
|
||||||
|
/// If null/empty, client uses fallback placeholder based on item type
|
||||||
|
/// </summary>
|
||||||
|
[MaxLength(256)]
|
||||||
|
public string? SpritePath { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Optional color tint as hex (e.g., "#ff0000" for red tint)
|
||||||
|
/// </summary>
|
||||||
|
[MaxLength(16)]
|
||||||
|
public string? TintColor { get; set; }
|
||||||
|
|
||||||
|
// Legacy field - kept for backwards compatibility
|
||||||
public int SpriteId { get; set; } = 0;
|
public int SpriteId { get; set; } = 0;
|
||||||
|
|
||||||
public bool IsEnabled { get; set; } = true;
|
public bool IsEnabled { get; set; } = true;
|
||||||
|
|||||||
@@ -68,26 +68,31 @@ public class DungeonMobDefinition
|
|||||||
[MaxLength(1024)]
|
[MaxLength(1024)]
|
||||||
public string AbilitiesJson { get; set; } = "{}";
|
public string AbilitiesJson { get; set; } = "{}";
|
||||||
|
|
||||||
// Visuals - reference to sprite/animation
|
// Visuals
|
||||||
|
/// <summary>
|
||||||
|
/// Path to the mob's .tscn scene file on CDN (e.g., "scenes/mobs/skeleton.tscn")
|
||||||
|
/// If null/empty, client uses fallback placeholder shape
|
||||||
|
/// </summary>
|
||||||
|
[MaxLength(256)]
|
||||||
|
public string? ScenePath { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Color tint applied to the mob (hex, e.g., "#ff0000" for red variant)
|
||||||
|
/// </summary>
|
||||||
|
[MaxLength(16)]
|
||||||
|
public string TintColor { get; set; } = "#ffffff";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Scale multiplier for the mob (1.0 = normal size)
|
||||||
|
/// </summary>
|
||||||
|
public float Scale { get; set; } = 1.0f;
|
||||||
|
|
||||||
|
// Legacy fields - kept for backwards compatibility, ScenePath takes priority
|
||||||
[MaxLength(128)]
|
[MaxLength(128)]
|
||||||
public string SpriteSheet { get; set; } = "mobs/skeleton.png";
|
public string SpriteSheet { get; set; } = "";
|
||||||
public int SpriteIndex { get; set; } = 0; // Index in spritesheet
|
|
||||||
public int SpriteWidth { get; set; } = 32;
|
public int SpriteWidth { get; set; } = 32;
|
||||||
public int SpriteHeight { get; set; } = 32;
|
public int SpriteHeight { get; set; } = 32;
|
||||||
|
|
||||||
[MaxLength(16)]
|
|
||||||
public string TintColor { get; set; } = "#ffffff"; // Color tint for variants
|
|
||||||
|
|
||||||
// Animation frames (JSON array of frame indices)
|
|
||||||
[MaxLength(256)]
|
|
||||||
public string IdleFrames { get; set; } = "[0]";
|
|
||||||
[MaxLength(256)]
|
|
||||||
public string WalkFrames { get; set; } = "[0,1,2,3]";
|
|
||||||
[MaxLength(256)]
|
|
||||||
public string AttackFrames { get; set; } = "[4,5]";
|
|
||||||
[MaxLength(256)]
|
|
||||||
public string DeathFrames { get; set; } = "[6,7]";
|
|
||||||
|
|
||||||
public float AnimationSpeed { get; set; } = 8f; // Frames per second
|
public float AnimationSpeed { get; set; } = 8f; // Frames per second
|
||||||
|
|
||||||
public bool IsEnabled { get; set; } = true;
|
public bool IsEnabled { get; set; } = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user