Vixen
caa30e12
csharp
public sealed class AbilityCaster

One thing's abilities: what is ready, what is being cast, and what it costs.

Read the guide page for this →

Remarks

Timing and eligibility, and nothing about damage. What an ability does when it completes is CombatResolver's, because that needs the targets it hit and this only knows the one it was aimed at. The split is what lets a cone ability go through the same caster as a single-target one.

⚠ Costs are paid when the cast completes, not when it starts. Paying up front means an interrupted cast has spent the resource, which every game refunds by hand and gets wrong for channels. A channel pays per tick, which is the only reading of "it costs mana per second" that survives being interrupted halfway.

Fields and properties (8)

  • public GameplaySubject Subject

    Whose abilities these are.

  • public AbilityLibrary Abilities

    Where ability templates come from.

  • public float GlobalCooldown

    How long the global cooldown lasts, in seconds.

  • public float GlobalCooldownRemaining

    How much of it is left.

  • public AbilityTemplate? Casting

    What is being cast, or null.

  • public AbilityTarget CastTarget

    What it is aimed at.

  • public float CastRemaining

    How much longer the cast or channel has, in seconds.

  • public bool IsCasting

    Whether anything is being cast.

Methods (8)

  • public AbilityCaster(GameplaySubject subject, AbilityLibrary abilities)

    Makes a caster.

  • public AbilityFailure CanBegin(DefId ability, in AbilityTarget at)

    Whether an ability could start right now.

  • public AbilityFailure TryBegin(DefId ability, in AbilityTarget at, ICollection<AbilityEvent>? events = null)

    Starts an ability.

  • public bool Interrupt(ICollection<AbilityEvent>? events = null)

    Stops whatever is being cast.

  • public void Tick(float delta, ICollection<AbilityEvent>? events = null)

    Advances the cast, the channel, the global cooldown and every recharging ability.

  • public int ChargesOf(DefId ability)

    How many charges of an ability are ready.

  • public float CooldownOf(DefId ability)

    How long until an ability's next charge, in seconds.

  • public void ResetCooldowns()

    Puts every charge back and clears the global cooldown. What a reset does.

Used by (1)

  • AbilityCasterTestsVixen.Gameplay.Combat.Tests