Draw Text System
Source: client/engine/systems/SystemsFunctions/Render/DrawTextSystem.cpp
Purpose: Render entities with a Text component while applying hierarchical transforms (position, rotation, scale) and respecting draw order via z_index.
Components used:
TransformText
Behavior
- Load the font from
Text::fontPathon first pass (InitializeText). - Compute the text origin via
GetOffsetFromTransformto align with theTransformorigin. - Apply local offsets (
offset), parent hierarchy transforms, and local rotation. - Apply cumulative scale (
CalculateCumulativeScale) and adjust opacity viaText::opacity. - Sort entities by
z_indexbefore drawing to guarantee order.
Main signature
void DrawTextRenderSystem(
Eng::registry ®,
GameWorld &game_world,
Eng::sparse_array<Com::Transform> const &transforms,
Eng::sparse_array<Com::Text> &texts);
Notes
InitializeTextsets the text size tocharacterSize * 10then applies cumulative scale divided by 10 to stay consistent with sprites.- If font loading fails, an error is logged to
std::cerrbutis_loadedflips totrueto avoid endless retries. - The
offsetfield lets you locally shift text relative to theTransformwithout changing hierarchy.