Files
Project-M/Assets/_Project/Scripts/Simulation/Combat/BoonEffects.cs
T
2026-07-13 18:30:41 -07:00

62 lines
3.3 KiB
C#

using Unity.Entities;
using Unity.NetCode;
namespace ProjectM.Simulation
{
/// <summary>
/// Phase 1.7 mechanic-changer boon state on a player — the run-scoped counterpart to the flat-stat
/// <see cref="StatModifier"/> band. Stackable counts (<see cref="Pierce"/>/<see cref="Fork"/>/<see cref="Chain"/>)
/// and boolean <see cref="Flags"/> (see <see cref="BoonFlag"/>) that combat systems read to alter behaviour.
/// <para>
/// Replicated <see cref="SendToOwnerType.SendToOwner"/> (matching <c>BoonOffer</c>): rollback-correctness is
/// provided by the <c>[GhostField]</c>s themselves — the owner is the sole predicting client and needs the
/// replicated Fork/Pierce/Chain so its OWN predict-spawned projectiles (in <c>AbilityFireSystem</c>, which
/// filters <c>.WithAll&lt;Simulate&gt;()</c>) don't mispredict. Non-owning clients render forked/pierced/chained
/// projectiles as interpolated server ghosts and never read the shooter's effects; every other read is
/// server-only. NOT <see cref="SendToOwnerType.All"/> — the send type is not what enables rollback, the
/// <c>[GhostField]</c> is.
/// </para>
/// Baked INERT (all 0) on the player prefab (the <c>BoonOffer</c> idiom) so a pick is a non-structural mutate;
/// zeroed on the Returning edge in <c>RunDirectorSystem</c> alongside the StatModifier band strips.
/// </summary>
[GhostComponent(OwnerSendType = SendToOwnerType.SendToOwner)]
public struct BoonEffects : IComponentData
{
/// <summary>Extra enemy hits a projectile survives before despawning (stacks).</summary>
[GhostField] public byte Pierce;
/// <summary>Extra spread projectiles spawned per shot (stacks).</summary>
[GhostField] public byte Fork;
/// <summary>Targets a projectile chains to after a hit (stacks).</summary>
[GhostField] public byte Chain;
/// <summary>Boolean effect bits — see <see cref="BoonFlag"/>.</summary>
[GhostField] public byte Flags;
}
/// <summary>Bit masks for <see cref="BoonEffects.Flags"/>. Plain byte consts (never an enum compared in Burst).</summary>
public static class BoonFlag
{
public const byte DashTrail = 1; // dashing damages enemies passed through
public const byte FinisherDetonate = 2; // the melee combo finisher blasts an AoE
public const byte KnockToPull = 4; // this player's knockback pulls enemies IN instead of away
public const byte Siphon = 8; // killing an enemy heals this player
public const byte Frenzy = 16; // a kill grants a short cooldown-reduction surge
}
/// <summary>
/// Stable byte discriminator for a <c>BoonDefBlob</c> mechanic-changer effect (0 = a plain stat boon).
/// Bytes only — Burst-safe, never an enum compared inside a Bursted system.
/// </summary>
public static class BoonEffectKind
{
public const byte None = 0;
public const byte Pierce = 1;
public const byte Fork = 2;
public const byte Chain = 3;
public const byte DashTrail = 4;
public const byte FinisherDetonate = 5;
public const byte KnockToPull = 6;
public const byte Siphon = 7;
public const byte Frenzy = 8;
}
}