Slice 2 (WIP): class carrier (GoInGameRequest.ClassId) + Warrior cone archetype
The per-player class travels on GoInGameRequest.ClassId (client reads a ClassSelection singleton); GoInGameServerSystem seeds the class at spawn via ClassTraits (AbilityRef + permanent trait StatModifiers on a reserved ClassSourceId; CharacterStatsRef stays Default so the DRG-asymmetry deltas ride the replicated OwnerSendType.All buffer). AbilityFireSystem gains the aim-directed Cone archetype: cooldown predicted both worlds, server-only cone damage to living enemies (same-tick, SourceTick-stamped, like the melee cleave). 345/345. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
using Unity.Entities;
|
||||
|
||||
namespace ProjectM.Simulation
|
||||
{
|
||||
/// <summary>
|
||||
/// Slice 2 — pure mapping from a chosen class (a <see cref="CharacterId"/> byte) to its spawn-time setup: the
|
||||
/// Fire-slot ability id + the permanent trait <see cref="StatModifier"/>s (tagged with the reserved
|
||||
/// <see cref="Tuning.ClassSourceId"/>, NEVER stripped). Applied by GoInGameServerSystem on the just-spawned
|
||||
/// player and unit-tested. Burst-safe (byte-only, no managed types).
|
||||
/// <para>
|
||||
/// Trait deltas seed onto the <see cref="CharacterId.Default"/> character (no per-class blob row needed — the
|
||||
/// deltas ride the replicated StatModifier buffer, OwnerSendType.All, so the owning client folds the correct
|
||||
/// EffectiveCharacterStats). The DRG-asymmetry (operator-locked): <b>Warrior</b> = melee bruiser (tankier,
|
||||
/// slower, harder + longer-reach melee via MeleeDamage/MeleeRange); <b>Ranger</b> = ranged anchor (faster,
|
||||
/// squishier, longer projectile range + a wider auto-target assist — the co-op synergy hook the Warrior's
|
||||
/// knockback feeds). The Warrior's Fire = the aim-directed cone (<see cref="AbilityId.WarriorCone"/>); the
|
||||
/// Ranger's Fire = the default projectile (<see cref="AbilityId.Primary"/>).
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static class ClassTraits
|
||||
{
|
||||
public const byte WarriorClass = (byte)CharacterId.Warrior;
|
||||
public const byte RangerClass = (byte)CharacterId.Ranger;
|
||||
|
||||
/// <summary>Normalize a wire ClassId to a known class (0 / unknown -> Warrior).</summary>
|
||||
public static byte Normalize(byte classId) => classId == RangerClass ? RangerClass : WarriorClass;
|
||||
|
||||
/// <summary>The Fire-slot ability id for a class (Warrior = cone, Ranger = the default projectile).</summary>
|
||||
public static byte AbilityFor(byte classId)
|
||||
=> classId == RangerClass ? (byte)AbilityId.Primary : (byte)AbilityId.WarriorCone;
|
||||
|
||||
/// <summary>Append a class's permanent trait modifiers onto a player's StatModifier buffer (via ECB at spawn).</summary>
|
||||
public static void AppendSeeds(byte classId, Entity player, EntityCommandBuffer ecb)
|
||||
{
|
||||
uint src = Tuning.ClassSourceId;
|
||||
if (classId == RangerClass)
|
||||
{
|
||||
ecb.AppendToBuffer(player, new StatModifier { Target = (byte)StatTarget.MoveSpeed, Op = (byte)ModOp.PercentMult, Value = 0.15f, SourceId = src });
|
||||
ecb.AppendToBuffer(player, new StatModifier { Target = (byte)StatTarget.MaxHealth, Op = (byte)ModOp.PercentMult, Value = -0.15f, SourceId = src + 1u });
|
||||
ecb.AppendToBuffer(player, new StatModifier { Target = (byte)StatTarget.Range, Op = (byte)ModOp.PercentAdd, Value = 0.30f, SourceId = src + 2u });
|
||||
ecb.AppendToBuffer(player, new StatModifier { Target = (byte)StatTarget.AutoTargetRange, Op = (byte)ModOp.Flat, Value = 3f, SourceId = src + 3u });
|
||||
}
|
||||
else
|
||||
{
|
||||
ecb.AppendToBuffer(player, new StatModifier { Target = (byte)StatTarget.MaxHealth, Op = (byte)ModOp.Flat, Value = 30f, SourceId = src });
|
||||
ecb.AppendToBuffer(player, new StatModifier { Target = (byte)StatTarget.MoveSpeed, Op = (byte)ModOp.PercentMult, Value = -0.15f, SourceId = src + 1u });
|
||||
ecb.AppendToBuffer(player, new StatModifier { Target = (byte)StatTarget.MeleeDamage, Op = (byte)ModOp.Flat, Value = 6f, SourceId = src + 2u });
|
||||
ecb.AppendToBuffer(player, new StatModifier { Target = (byte)StatTarget.MeleeRange, Op = (byte)ModOp.Flat, Value = 0.8f, SourceId = src + 3u });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user