CDN fight 3

This commit is contained in:
dingo
2025-12-20 13:04:31 -05:00
parent 317e14e042
commit 8390fdf42e
8 changed files with 1999 additions and 47 deletions
+4 -7
View File
@@ -130,16 +130,11 @@ public sealed class DungeonHandler : IClientMessageHandler
}
// All dungeon operations require authentication
if (opCode == DungeonOpCodes.ASSET_MANIFEST_REQUEST)
{
await HandleAssetManifestRequest(connection, ct);
}
if (!_sessions.TryGet(connection.Id, out var accountId, out _))
{
await SendErrorAsync(connection, "auth_required", ct);
return;
}
// Get or create player session
var session = await GetOrCreateSessionAsync(connection, accountId, ct);
@@ -1947,7 +1942,8 @@ public sealed class DungeonHandler : IClientMessageHandler
y = m.Y,
health = m.Health,
maxHealth = m.MaxHealth,
scenePath = m.ScenePath,
spriteConfig = string.IsNullOrEmpty(m.SpriteConfigJson) ? null :
System.Text.Json.JsonSerializer.Deserialize<object>(m.SpriteConfigJson),
tintColor = m.TintColor,
scale = m.Scale
}),
@@ -2496,7 +2492,8 @@ public sealed class DungeonHandler : IClientMessageHandler
health = m.Health,
maxHealth = m.MaxHealth,
state = m.State.ToString().ToLower(),
scenePath = m.ScenePath,
spriteConfig = string.IsNullOrEmpty(m.SpriteConfigJson) ? null :
System.Text.Json.JsonSerializer.Deserialize<object>(m.SpriteConfigJson),
tintColor = m.TintColor,
scale = m.Scale
}),
+1 -1
View File
@@ -123,7 +123,7 @@ public class DungeonSimulation
MaxHealth = stats.MaxHealth,
Stats = stats,
State = MobState.Idle,
ScenePath = mobDef.ScenePath,
SpriteConfigJson = mobDef.SpriteConfigJson,
TintColor = mobDef.TintColor,
Scale = mobDef.Scale,
Type = mobDef.Type
+2 -2
View File
@@ -46,8 +46,8 @@ public class MobInstance
public ulong? TargetId { get; set; }
public long LastAttackTick { get; set; }
// Visual - CDN scene path
public string? ScenePath { get; set; }
// Visual - sprite configuration JSON
public string? SpriteConfigJson { get; set; }
public string TintColor { get; set; } = "#ffffff";
public float Scale { get; set; } = 1.0f;
File diff suppressed because it is too large Load Diff
+77
View File
@@ -0,0 +1,77 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SystemRevivalServer.Migrations
{
/// <inheritdoc />
public partial class CDNFight4 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ScenePath",
table: "dungeon_mob_definitions");
migrationBuilder.DropColumn(
name: "SpriteHeight",
table: "dungeon_mob_definitions");
migrationBuilder.DropColumn(
name: "SpriteSheet",
table: "dungeon_mob_definitions");
migrationBuilder.DropColumn(
name: "SpriteWidth",
table: "dungeon_mob_definitions");
migrationBuilder.AddColumn<string>(
name: "SpriteConfigJson",
table: "dungeon_mob_definitions",
type: "varchar(4096)",
maxLength: 4096,
nullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "SpriteConfigJson",
table: "dungeon_mob_definitions");
migrationBuilder.AddColumn<string>(
name: "ScenePath",
table: "dungeon_mob_definitions",
type: "varchar(256)",
maxLength: 256,
nullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<int>(
name: "SpriteHeight",
table: "dungeon_mob_definitions",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<string>(
name: "SpriteSheet",
table: "dungeon_mob_definitions",
type: "varchar(128)",
maxLength: 128,
nullable: false,
defaultValue: "")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<int>(
name: "SpriteWidth",
table: "dungeon_mob_definitions",
type: "int",
nullable: false,
defaultValue: 0);
}
}
}
+3 -14
View File
@@ -719,20 +719,9 @@ namespace SystemRevivalServer.Migrations
b.Property<float>("Scale")
.HasColumnType("float");
b.Property<string>("ScenePath")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<int>("SpriteHeight")
.HasColumnType("int");
b.Property<string>("SpriteSheet")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("varchar(128)");
b.Property<int>("SpriteWidth")
.HasColumnType("int");
b.Property<string>("SpriteConfigJson")
.HasMaxLength(4096)
.HasColumnType("varchar(4096)");
b.Property<string>("TintColor")
.IsRequired()
+14 -14
View File
@@ -27,7 +27,7 @@ public static class DefaultDungeonMobs
AggroRange = 120f,
BaseXp = 15,
ResistancesJson = """{"poison": 1.0, "holy": -0.5}""",
SpriteSheet = "mobs/skeleton.png"
//SpriteSheet = "mobs/skeleton.png"
},
new DungeonMobDefinition
{
@@ -46,7 +46,7 @@ public static class DefaultDungeonMobs
AggroRange = 100f,
BaseXp = 12,
ResistancesJson = """{"poison": 1.0, "fire": -0.25, "holy": -0.5}""",
SpriteSheet = "mobs/zombie.png"
//SpriteSheet = "mobs/zombie.png"
},
new DungeonMobDefinition
{
@@ -65,7 +65,7 @@ public static class DefaultDungeonMobs
AggroRange = 80f,
BaseXp = 5,
ResistancesJson = """{"poison": 0.5}""",
SpriteSheet = "mobs/rat.png"
//SpriteSheet = "mobs/rat.png"
},
new DungeonMobDefinition
{
@@ -86,7 +86,7 @@ public static class DefaultDungeonMobs
BaseXp = 18,
ResistancesJson = """{"poison": 1.0}""",
AbilitiesJson = """{"poisonOnHit": true, "poisonDamage": 2, "poisonDuration": 3}""",
SpriteSheet = "mobs/spider.png"
//SpriteSheet = "mobs/spider.png"
},
// Tier 1 Elite
@@ -107,7 +107,7 @@ public static class DefaultDungeonMobs
AggroRange = 150f,
BaseXp = 50,
ResistancesJson = """{"poison": 1.0, "holy": -0.5, "physical": 0.1}""",
SpriteSheet = "mobs/skeleton_knight.png"
//SpriteSheet = "mobs/skeleton_knight.png"
},
// Tier 1 Boss
@@ -134,9 +134,9 @@ public static class DefaultDungeonMobs
BaseXp = 500,
ResistancesJson = """{"poison": 1.0, "dark": 0.5, "holy": -0.75}""",
AbilitiesJson = """{"summonSkeletons": true, "summonCount": 3, "summonCooldown": 15}""",
SpriteSheet = "mobs/bone_lord.png",
SpriteWidth = 64,
SpriteHeight = 64
//SpriteSheet = "mobs/bone_lord.png",
//SpriteWidth = 64,
//SpriteHeight = 64
},
// Tier 2 - Intermediate enemies
@@ -157,7 +157,7 @@ public static class DefaultDungeonMobs
AggroRange = 180f,
BaseXp = 25,
ResistancesJson = """{"fire": 0.75, "holy": -0.5}""",
SpriteSheet = "mobs/imp.png"
//SpriteSheet = "mobs/imp.png"
},
new DungeonMobDefinition
{
@@ -177,7 +177,7 @@ public static class DefaultDungeonMobs
AggroRange = 200f,
BaseXp = 30,
ResistancesJson = """{"dark": 0.25, "holy": -0.25}""",
SpriteSheet = "mobs/cultist.png"
//SpriteSheet = "mobs/cultist.png"
},
// Tier 3 - Advanced enemies
@@ -199,9 +199,9 @@ public static class DefaultDungeonMobs
AggroRange = 100f,
BaseXp = 100,
ResistancesJson = """{"poison": 1.0, "physical": 0.3, "lightning": -0.25}""",
SpriteSheet = "mobs/golem.png",
SpriteWidth = 48,
SpriteHeight = 48
//SpriteSheet = "mobs/golem.png",
//SpriteWidth = 48,
//SpriteHeight = 48
},
new DungeonMobDefinition
{
@@ -221,7 +221,7 @@ public static class DefaultDungeonMobs
BaseXp = 45,
ResistancesJson = """{"fire": 1.0, "ice": -0.75, "physical": 0.5}""",
AbilitiesJson = """{"burnOnHit": true, "burnDamage": 5, "burnDuration": 4}""",
SpriteSheet = "mobs/fire_elemental.png",
//SpriteSheet = "mobs/fire_elemental.png",
TintColor = "#ff6600"
}
};
+29 -9
View File
@@ -70,11 +70,25 @@ public class DungeonMobDefinition
// Visuals
/// <summary>
/// Path to the mob's .tscn scene file on CDN (e.g., "scenes/mobs/skeleton.tscn")
/// JSON configuration for mob sprites and animations
/// Example: {
/// "sprites": {
/// "idle_front": "assets/sprites/skeleton_idle_front.png",
/// "idle_back": "assets/sprites/skeleton_idle_back.png",
/// "run_front": "assets/sprites/skeleton_run_front.png"
/// },
/// "frameWidth": 64,
/// "frameHeight": 64,
/// "fps": 8,
/// "animations": {
/// "idle_front": {"frames": 8, "loop": true},
/// "run_front": {"frames": 8, "loop": true}
/// }
/// }
/// If null/empty, client uses fallback placeholder shape
/// </summary>
[MaxLength(256)]
public string? ScenePath { get; set; }
[MaxLength(4096)]
public string? SpriteConfigJson { get; set; }
/// <summary>
/// Color tint applied to the mob (hex, e.g., "#ff0000" for red variant)
@@ -87,16 +101,22 @@ public class DungeonMobDefinition
/// </summary>
public float Scale { get; set; } = 1.0f;
// Legacy fields - kept for backwards compatibility, ScenePath takes priority
[MaxLength(128)]
public string SpriteSheet { get; set; } = "";
public int SpriteWidth { get; set; } = 32;
public int SpriteHeight { get; set; } = 32;
public float AnimationSpeed { get; set; } = 8f; // Frames per second
public bool IsEnabled { get; set; } = true;
// Helper to get parsed sprite config
[NotMapped]
public Dictionary<string, object>? SpriteConfig
{
get
{
if (string.IsNullOrEmpty(SpriteConfigJson)) return null;
try { return System.Text.Json.JsonSerializer.Deserialize<Dictionary<string, object>>(SpriteConfigJson); }
catch { return null; }
}
}
// Helper methods for JSON parsing
[NotMapped]
public Dictionary<string, float> Resistances