Class AbilitySummary
Everything the UI needs to describe an ability, composed once from one set of rules.
public sealed class AbilitySummary
- Inheritance
-
AbilitySummary
- Inherited Members
Remarks
Why this exists. An ability's numbers were worked out in three places that disagreed. Ability sums the template's stats, the events baked into the template, and any crafted events. The template's tooltip summed only the template and whatever the crafting panel passed it, ignoring the template's own events entirely — so a fireball whose bundled movement event supplies its speed advertised numbers the crafted ability would never have. The crafting panel then added its own third rule for the price. A player comparing the preview against the ability they got was comparing two different calculations.
One composition now serves the template tooltip, the learned ability's tooltip, the knowledge panel and the crafting preview. It also keeps BaseStats beside Stats, which is what lets the crafting UI show what each chosen effect actually changed rather than only the total.
Fields
BaseResourceCosts
Resource cost of the base ability alone.
public readonly Dictionary<CharacterAttributeTemplate, int> BaseResourceCosts
Field Value
BaseStats
The base ability with only the effects its template ships with.
public AbilityStatBlock BaseStats
Field Value
CraftedEvents
Effects crafted onto the base ability.
public readonly List<AbilityEvent> CraftedEvents
Field Value
Effects
What the composed ability does when it connects.
public readonly List<string> Effects
Field Value
Requirements
What the character must have or be, in the order the conditions were authored.
public readonly List<string> Requirements
Field Value
ResourceCosts
Resource cost of the composed ability.
public readonly Dictionary<CharacterAttributeTemplate, int> ResourceCosts
Field Value
Stats
The composed ability, including every crafted effect.
public AbilityStatBlock Stats
Field Value
Targeting
How the composed ability picks what it affects.
public readonly List<string> Targeting
Field Value
TemplateEvents
Effects the template ships with. The player did not choose these and cannot remove them.
public readonly List<AbilityEvent> TemplateEvents
Field Value
Properties
CraftPrice
What crafting this composition costs: the base ability plus every chosen effect.
public int CraftPrice { get; }
Property Value
Description
The ability's description.
public string Description { get; }
Property Value
EventSlots
How many effects may be crafted onto this base ability.
public int EventSlots { get; }
Property Value
HasCraftedEvents
True when at least one effect was crafted on, so deltas are worth drawing.
public bool HasCraftedEvents { get; }
Property Value
Icon
The ability's icon.
public Sprite Icon { get; }
Property Value
- Sprite
Name
The ability's name.
public string Name { get; }
Property Value
Template
The base ability this was composed from.
public AbilityTemplate Template { get; }
Property Value
Type
The effective ability type, after any override event.
public AbilityType Type { get; }
Property Value
TypeOverride
The override event that replaced the type, when one was chosen.
public AbilityTypeOverrideEventType TypeOverride { get; }
Property Value
Methods
BuildTooltip(TooltipContent, bool, bool)
Writes the whole composition into a tooltip.
public void BuildTooltip(TooltipContent content, bool showDeltas = false, bool includePrice = true)
Parameters
contentTooltipContentThe content being assembled.
showDeltasboolWhen true, each stat carries what the crafted effects changed it by. The crafting panel wants that; a finished ability's tooltip does not, because there is nothing to compare against once the ability exists.
includePriceboolWhether to write the crafting price. A seller writes its own.
Compose(AbilityTemplate, IReadOnlyList<ITooltip>)
Composes a base ability with the effects a player has chosen for it.
public static AbilitySummary Compose(AbilityTemplate template, IReadOnlyList<ITooltip> chosen = null)
Parameters
templateAbilityTemplateThe base ability.
chosenIReadOnlyList<ITooltip>Effects and type overrides being crafted onto it. Entries that are neither are ignored, which is what lets a UI pass its slot contents straight in.
Returns
EventCategory(AbilityEvent)
When an event runs, in words a player can act on.
public static string EventCategory(AbilityEvent abilityEvent)
Parameters
abilityEventAbilityEvent
Returns
FormatDelta(float, float, string)
The change a stat underwent, or null when nothing changed it.
public static string FormatDelta(float baseValue, float composed, string suffix)
Parameters
baseValuefloatThe base ability's value.
composedfloatThe composed value.
suffixstringUnit suffix, e.g. "s" or "m".
Returns
FromAbility(Ability)
Describes an ability the character has already learned.
public static AbilitySummary FromAbility(Ability ability)
Parameters
abilityAbility
Returns
Remarks
The crafted effects are recovered by subtracting the template's own: an ability holds one flat dictionary of events and does not record where each came from, but the template does, and a player looking at a crafted ability wants to see the parts they chose separately from the ones that came in the box.
ToneForDelta(float, bool)
Whether a change to a stat is an improvement.
public static TooltipTone ToneForDelta(float delta, bool moreIsBetter)
Parameters
Returns
Remarks
Direction is per-stat and is not guessable from the sign: more range is good, more cooldown is not. Getting this wrong colours a penalty green, so it is stated once here rather than at each call site.