// Assets/_Project/Scripts/Gameplay/EnemyAbilities/EnemySpawnContext.cs
namespace TD.Gameplay.EnemyAbilities
{
///
/// Mutable per-spawn copy of an enemy's stats, handed to each of its abilities before the
/// enemy is built so they can alter what it spawns as.
///
///
/// Why a context rather than more parameters. Wave buffs like "grounded enemies become
/// flying" or "enemies spawn at half health" have to land before
/// EnemyHealth.InitializeServer and before the spawn position is computed (flyers are
/// raised by their flight height). Threading each new stat through SpawnEnemy as another
/// argument was already unwieldy at two; this keeps the signature flat and gives abilities one
/// obvious place to write.
///
/// Seeded from the , never written back to it — the
/// definition is a shared asset and a buff that mutated it would leak across waves, matches,
/// and (in the editor) sessions.
///
public struct EnemySpawnContext
{
public float MaxHp;
public float MoveSpeed;
public bool IsFlying;
public float FlightHeight;
public int LivesCost;
/// Uniform transform scale relative to the prefab's authored scale.
public float VisualScale;
///
/// Seeds a context from an enemy definition's authored stats, with health supplied by the
/// caller.
///
/// The type being spawned. Supplies everything except health.
/// Health this enemy spawns with, already resolved from the
/// encounter's budget and the type's — see
/// . Passed in rather than read off the
/// definition because it depends on run position and the wave's enemy count, neither of
/// which the asset knows about.
public static EnemySpawnContext FromDefinition(EnemyDefinition def, float resolvedMaxHp)
=> new EnemySpawnContext
{
MaxHp = resolvedMaxHp,
MoveSpeed = def.MoveSpeed,
IsFlying = def.IsFlying,
FlightHeight = def.FlightHeight,
LivesCost = def.LivesCost,
VisualScale = 1f,
};
}
}