Add HazardZone tile tint config and state payload
This commit is contained in:
@@ -2977,6 +2977,24 @@ public sealed partial class DungeonHandler : IClientMessageHandler
|
||||
backY = p.BackY
|
||||
}),
|
||||
|
||||
hazards = (sendSpatialThisTick ? sim.HazardZones.Values.Where(h => !spatialFiltering || IsNearby(h.X, h.Y)) : Enumerable.Empty<HazardZone>())
|
||||
.Select(h => new
|
||||
{
|
||||
id = h.Id,
|
||||
sourceMobId = h.SourceMobId,
|
||||
x = h.X,
|
||||
y = h.Y,
|
||||
radius = h.Radius,
|
||||
duration = h.Duration,
|
||||
tickInterval = h.TickInterval,
|
||||
nextTickIn = h.NextTickIn,
|
||||
damagePerTick = h.DamagePerTick,
|
||||
damageTypeKey = h.DamageTypeKey,
|
||||
visualKey = h.VisualKey,
|
||||
tintColor = h.TintColor,
|
||||
tintOpacity = h.TintOpacity
|
||||
}),
|
||||
|
||||
portals = sim.Portals.Values
|
||||
.Where(p => p.IsActive)
|
||||
.Select(p => new
|
||||
|
||||
@@ -1282,7 +1282,9 @@ public partial class DungeonSimulation
|
||||
Duration = ability.EffectDuration,
|
||||
NextTickIn = ability.DotTickInterval,
|
||||
DamageTypeKey = ability.DamageTypeKey,
|
||||
VisualKey = ability.VisualEffectKey ?? "hazard_default"
|
||||
VisualKey = ability.VisualEffectKey ?? "hazard_default",
|
||||
TintColor = string.IsNullOrWhiteSpace(ability.HazardTintColor) ? "#ff5500" : ability.HazardTintColor,
|
||||
TintOpacity = Math.Clamp(ability.HazardTintOpacity, 0f, 1f)
|
||||
};
|
||||
|
||||
HazardZones[hazard.Id] = hazard;
|
||||
|
||||
@@ -105,6 +105,8 @@ public class HazardZone
|
||||
|
||||
public string DamageTypeKey { get; set; } = "fire";
|
||||
public string VisualKey { get; set; } = "hazard_default";
|
||||
public string TintColor { get; set; } = "#ff5500";
|
||||
public float TintOpacity { get; set; } = 0.45f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SystemRevivalServer.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddHazardZoneTintFields : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "HazardTintColor",
|
||||
table: "dungeon_mob_abilities",
|
||||
type: "varchar(16)",
|
||||
maxLength: 16,
|
||||
nullable: false,
|
||||
defaultValue: "#ff5500");
|
||||
|
||||
migrationBuilder.AddColumn<float>(
|
||||
name: "HazardTintOpacity",
|
||||
table: "dungeon_mob_abilities",
|
||||
type: "float",
|
||||
nullable: false,
|
||||
defaultValue: 0.45f);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "HazardTintColor",
|
||||
table: "dungeon_mob_abilities");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "HazardTintOpacity",
|
||||
table: "dungeon_mob_abilities");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1952,6 +1952,14 @@ namespace SystemRevivalServer.Migrations
|
||||
b.Property<float?>("HpThresholdBelow")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("HazardTintColor")
|
||||
.IsRequired()
|
||||
.HasMaxLength(16)
|
||||
.HasColumnType("varchar(16)");
|
||||
|
||||
b.Property<float>("HazardTintOpacity")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<bool>("IsEnabled")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
|
||||
@@ -195,6 +195,19 @@
|
||||
<input type="number" asp-for="Ability.SpeedModifier" class="input" step="0.1" />
|
||||
<p class="text-xs text-gray-500 mt-1">0.5 = 50% slow</p>
|
||||
</div>
|
||||
<div>
|
||||
<label class="label">Hazard Tint Color</label>
|
||||
<div class="flex gap-2">
|
||||
<input type="color" value="@Model.Ability.HazardTintColor" class="w-10 h-10 rounded border border-gray-700 bg-gray-800 cursor-pointer" oninput="document.getElementById('hazardTintColor').value=this.value" />
|
||||
<input type="text" id="hazardTintColor" asp-for="Ability.HazardTintColor" class="input flex-1" />
|
||||
</div>
|
||||
<p class="text-xs text-gray-500 mt-1">Used by HazardZone tile tint</p>
|
||||
</div>
|
||||
<div>
|
||||
<label class="label">Hazard Tint Opacity</label>
|
||||
<input type="number" asp-for="Ability.HazardTintOpacity" class="input" step="0.01" min="0" max="1" />
|
||||
<p class="text-xs text-gray-500 mt-1">0 = invisible, 1 = solid</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -88,12 +88,17 @@ public class EditModel : AdminPageModel
|
||||
AnimationKey = Ability.AnimationKey,
|
||||
SoundEffectKey = Ability.SoundEffectKey,
|
||||
VisualEffectKey = Ability.VisualEffectKey,
|
||||
HazardTintColor = Ability.HazardTintColor,
|
||||
HazardTintOpacity = Math.Clamp(Ability.HazardTintOpacity, 0f, 1f),
|
||||
IsEnabled = true
|
||||
};
|
||||
_db.MobAbilityDefinitions.Add(newAbility);
|
||||
await _db.SaveChangesAsync();
|
||||
return RedirectToPage(new { id = newAbility.Id });
|
||||
}
|
||||
|
||||
Ability.HazardTintColor = string.IsNullOrWhiteSpace(Ability.HazardTintColor) ? "#ff5500" : Ability.HazardTintColor;
|
||||
Ability.HazardTintOpacity = Math.Clamp(Ability.HazardTintOpacity, 0f, 1f);
|
||||
|
||||
if (Ability.Id == 0)
|
||||
{
|
||||
@@ -147,6 +152,8 @@ public class EditModel : AdminPageModel
|
||||
existing.AnimationKey = Ability.AnimationKey;
|
||||
existing.SoundEffectKey = Ability.SoundEffectKey;
|
||||
existing.VisualEffectKey = Ability.VisualEffectKey;
|
||||
existing.HazardTintColor = Ability.HazardTintColor;
|
||||
existing.HazardTintOpacity = Ability.HazardTintOpacity;
|
||||
existing.IsEnabled = Ability.IsEnabled;
|
||||
existing.UpdatedAt = DateTime.UtcNow;
|
||||
|
||||
|
||||
@@ -135,6 +135,17 @@ public class MobAbilityDefinition
|
||||
/// </summary>
|
||||
[MaxLength(64)]
|
||||
public string? VisualEffectKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Tile tint color for HazardZone abilities (hex, e.g. "#ff5500")
|
||||
/// </summary>
|
||||
[MaxLength(16)]
|
||||
public string HazardTintColor { get; set; } = "#ff5500";
|
||||
|
||||
/// <summary>
|
||||
/// Tile tint opacity for HazardZone abilities (0 to 1)
|
||||
/// </summary>
|
||||
public float HazardTintOpacity { get; set; } = 0.45f;
|
||||
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
|
||||
|
||||
@@ -1,2 +1,20 @@
|
||||
# Pending Client Changes
|
||||
|
||||
## HazardZone Tile Tinting (Ability Type 29)
|
||||
|
||||
- `DUNGEON_STATE` now includes a top-level `hazards` array every tick.
|
||||
- Each hazard item includes:
|
||||
- `id`
|
||||
- `sourceMobId`
|
||||
- `x`, `y`, `radius` (world-space pixels)
|
||||
- `duration` (seconds remaining)
|
||||
- `tickInterval`, `nextTickIn`
|
||||
- `damagePerTick`, `damageTypeKey`
|
||||
- `visualKey`
|
||||
- `tintColor` (hex from ability config, ex: `#ff5500`)
|
||||
- `tintOpacity` (0..1 from ability config)
|
||||
- Client behavior:
|
||||
- Render tile tint overlay for the area covered by each active hazard in `hazards`.
|
||||
- Keep overlays synchronized to the current `hazards` list from each state packet.
|
||||
- Remove overlay when a hazard no longer exists in the list (expired/removed server-side).
|
||||
- If multiple hazards overlap, blend/stack tints in a deterministic order (recommend by `id` ascending).
|
||||
|
||||
Reference in New Issue
Block a user