37 lines
1.5 KiB
C#
37 lines
1.5 KiB
C#
// Assets/_Project/Scripts/Gameplay/Draft/BuilderEffectDraftOption.cs
|
|
using UnityEngine;
|
|
using TD.Core;
|
|
using TD.Gameplay.BuilderEffects;
|
|
|
|
namespace TD.Gameplay.Draft
|
|
{
|
|
/// <summary>
|
|
/// Draft choice #2 — "gain a builder effect". Grants the player a passive effect that
|
|
/// applies to every tower they own, adding it to their <see cref="BuilderUpgradeManager"/>.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Unlike <see cref="NewTowerDraftOption"/>, this carries the <see cref="BuilderEffectKind"/>
|
|
/// directly rather than an asset reference — there's no id to resolve, the enum value is the
|
|
/// stable identifier <see cref="BuilderUpgradeManager"/> and <see cref="BuilderEffectPool"/>
|
|
/// already key off of.
|
|
/// </remarks>
|
|
[CreateAssetMenu(fileName = "BuilderEffectOption", menuName = "TD/Draft/Builder Effect Option")]
|
|
public class BuilderEffectDraftOption : DraftOption
|
|
{
|
|
[Header("Payload")]
|
|
[Tooltip("The builder effect this option grants.")]
|
|
public BuilderEffectKind Kind;
|
|
|
|
public override bool IsValidFor(ulong clientId)
|
|
{
|
|
var upgrades = BuilderUpgradeManager.GetForClient(clientId);
|
|
return upgrades != null && !upgrades.PlayerHasEffect(Kind);
|
|
}
|
|
|
|
public override bool ServerApply(ulong clientId)
|
|
{
|
|
var upgrades = BuilderUpgradeManager.GetForClient(clientId);
|
|
return upgrades != null && upgrades.ServerGrantEffect(Kind);
|
|
}
|
|
}
|
|
}
|