UMageItCombatTextSubsystem
Base Class: ULocalPlayerSubsystem
Overview
Section titled “Overview”UMageItCombatTextSubsystem is the single entry point for spawning combat text. Being a ULocalPlayerSubsystem, it
is automatically instantiated per local player, making it highly efficient and easy to access without manual
initialization.
It owns a map of renderer instances (ActiveRenderers), keyed by FGameplayTag, and is responsible for resolving
which renderer should handle a given event, initializing it (lazily by default, or eagerly for renderers opted into
bInitializeAtBeginPlay), and shutting all of them down when the player is deinitialized.
How to Access
Section titled “How to Access”In Blueprints
Section titled “In Blueprints”Right-click anywhere in an Event Graph and search for Get MageItCombatTextSubsystem.
In C++
Section titled “In C++”if (APlayerController* PC = GetWorld()->GetFirstPlayerController()){ if (ULocalPlayer* LocalPlayer = PC->GetLocalPlayer()) { UMageItCombatTextSubsystem* CombatTextSubsystem = LocalPlayer->GetSubsystem<UMageItCombatTextSubsystem>(); }}Properties (Variables)
Section titled “Properties (Variables)”ActiveRenderers(Map<GameplayTag, UMageItCombatTextRendererBase*>,BlueprintReadOnly): Renderer instances created so far. A single instance can appear under multiple keys — both the registry tag it was created for and every leaf tag that has since fallen back to it — so lookups for any of those tags stay O(1).
Methods (Functions)
Section titled “Methods (Functions)”Initialize
Section titled “Initialize”virtual void Initialize(FSubsystemCollectionBase& Collection) override;Called automatically by the engine when the local player subsystem is created. Reads
UMageItCombatTextSettings::RendererRegistry and calls GetRenderer up front for every entry
whose bInitializeAtBeginPlay is true, warming those renderers up immediately instead of waiting
for their first damage event. All other entries remain lazy.
GetRenderer
Section titled “GetRenderer”UMageItCombatTextRendererBase* GetRenderer(const FGameplayTag DamageTag);(Blueprint Callable) Lazily loads and initializes the renderer for DamageTag, returning the cached instance on
subsequent calls.
Resolution order:
- Look up
DamageTagdirectly inActiveRenderers. Return immediately if found. - Otherwise, read
UMageItCombatTextSettings::RendererRegistryand walk up the tag hierarchy —DamageTag, thenDamageTag.RequestDirectParent(), and so on — until an entry with a non-nullRendererClassis found (call the tag this entry is registered under the resolved tag). - If an instance is already cached under the resolved tag (because another, more specific leaf tag resolved to
the same registry entry earlier), reuse it. Otherwise, synchronously load
RendererClass, construct a new instance (NewObject), and callInitializeon it — logging anErrorand returningnullptrinstead if the loaded class can’t be loaded or is abstract. - Cache the instance in
ActiveRenderersunder both the resolved tag and the original leafDamageTag. This is what lets several leaf tags that fall back to the same registry entry (e.g.Damage.FireandDamage.Iceboth falling back toDamage) share a single renderer instance — one widget pool, one Niagara system — while keeping O(1) lookups for every tag that has ever been resolved. - Returns
nullptrif no tag anywhere up the hierarchy has a registered renderer class.
AddDamageEvent
Section titled “AddDamageEvent”void AddDamageEvent(const FMageItCombatTextEvent& Event);(Blueprint Callable) Resolves the renderer for Event.DamageTag via GetRenderer and forwards the event to its
RenderDamage. If no renderer resolves, logs a Warning to the LogMageitCombatText category and drops the event.
Deinitialize
Section titled “Deinitialize”virtual void Deinitialize() override;Calls Shutdown() once per unique renderer instance (several tags can share the same instance — see
GetRenderer above) and empties ActiveRenderers. Called automatically by the engine when the local player
subsystem is torn down.