77de740b63
Enum renamed in StatIds.cs (byte values unchanged - serialized definitions/saves never re-mean); all call sites + doc mentions swept (ClassTraits, PlayerAuthoring, CharacterStatsDefinition field type, menu/UI, tests). CharacterStatsDefinition SO CLASS name kept (asset-binding risk; deferred per plan). 390 green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
86 lines
4.0 KiB
C#
86 lines
4.0 KiB
C#
using Unity.Entities;
|
|
using Unity.NetCode;
|
|
|
|
namespace ProjectM.Simulation
|
|
{
|
|
/// <summary>Socket count / index constants for the LANTERN 4-socket kit.</summary>
|
|
public static class SocketId
|
|
{
|
|
public const int Count = 4;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Per-player ability socket loadout — one replicated row per socket (buffer index = socket 0..3),
|
|
/// each holding the <see cref="AbilityId"/> (Spark) occupying that socket (0 = empty). The LANTERN
|
|
/// 4-socket-kit analog of the single <see cref="AbilityRef"/>; modelled on <see cref="EquipmentSlot"/>:
|
|
/// COLD (mutated only when socketing in the hub, server-sole-writer — NOT predicted). Read by
|
|
/// <c>AbilityFireSystem</c> via a <c>BufferLookup</c>, never as a SystemAPI.Query type arg (the 7-arg cap).
|
|
/// </summary>
|
|
[InternalBufferCapacity(4)]
|
|
[GhostComponent(OwnerSendType = SendToOwnerType.All)]
|
|
public struct AbilitySocket : IBufferElementData
|
|
{
|
|
/// <summary>The <see cref="AbilityId"/> (Spark) occupying this socket; 0 = empty.</summary>
|
|
[GhostField] public byte SparkId;
|
|
}
|
|
|
|
/// <summary>
|
|
/// HOT, owner-predicted per-socket ability cooldown for the 4-socket kit — the LANTERN analog of the
|
|
/// single scalar <see cref="AbilityCooldown"/> (deliberately NOT the cold <see cref="EquipmentSlot"/>
|
|
/// buffer: a scalar-shaped, index-addressable cooldown whose per-tick rollback restore is proven, unlike
|
|
/// a per-tick-mutating <c>[GhostField]</c> buffer). Four raw next-fire ticks, one per socket, each a
|
|
/// <see cref="GhostField"/> so the gate survives the frame→tick→rollback boundary and converges without
|
|
/// double-firing. <c>0</c> = ready. Route stored ticks through <see cref="TickUtil.NonZero"/> and compare
|
|
/// by wrapping into a <see cref="NetworkTick"/> + <see cref="NetworkTick.IsNewerThan"/> (raw subtraction
|
|
/// is unsafe across wraparound). Explicit <c>SendToOwnerType.All</c> (parity with today's implicit-send-all
|
|
/// <see cref="AbilityCooldown"/>, so remote clients still drive teammates' ability feel).
|
|
/// </summary>
|
|
[GhostComponent(OwnerSendType = SendToOwnerType.All)]
|
|
public struct SocketCooldown : IComponentData
|
|
{
|
|
[GhostField] public uint Next0;
|
|
[GhostField] public uint Next1;
|
|
[GhostField] public uint Next2;
|
|
[GhostField] public uint Next3;
|
|
|
|
/// <summary>Next-fire tick for socket <paramref name="i"/> (0..3). Burst-safe (switch, not a field index).</summary>
|
|
public uint Get(int i)
|
|
{
|
|
switch (i)
|
|
{
|
|
case 0: return Next0;
|
|
case 1: return Next1;
|
|
case 2: return Next2;
|
|
default: return Next3;
|
|
}
|
|
}
|
|
|
|
/// <summary>Set the next-fire tick for socket <paramref name="i"/> (0..3).</summary>
|
|
public void Set(int i, uint v)
|
|
{
|
|
switch (i)
|
|
{
|
|
case 0: Next0 = v; break;
|
|
case 1: Next1 = v; break;
|
|
case 2: Next2 = v; break;
|
|
default: Next3 = v; break;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Replicated per-player frame/class signal (a LANTERN suit-frame IS the class). Baked on the player
|
|
/// ghost, written server-side when the frame/class is chosen. Exists because, under the 4-socket kit, no
|
|
/// single ability id maps 1:1 to a class the way the old single <see cref="AbilityRef"/> did — the HUD/
|
|
/// feel systems read this instead of <c>ClassTraits.ClassForAbility(AbilityRef.Id)</c>. <c>SendToOwner</c>:
|
|
/// only the owning client's HUD needs its own frame. (Distinct from the server-only <c>PlayerClass</c>,
|
|
/// which is runtime-added and cannot carry a GhostField.)
|
|
/// </summary>
|
|
[GhostComponent(OwnerSendType = SendToOwnerType.SendToOwner)]
|
|
public struct FrameId : IComponentData
|
|
{
|
|
/// <summary>The frame/class id (see the <c>FrameKind</c> / <c>ClassId</c> convention).</summary>
|
|
[GhostField] public byte Value;
|
|
}
|
|
}
|