MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / Draw

Method Draw

TombEngine/Game/Hud/TargetHighlighter.cpp:134–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132 }
133
134 void CrosshairData::Draw() const
135 {
136 constexpr auto SPRITE_SEQUENCE_OBJECT_ID = ID_CROSSHAIR_GRAPHICS;
137 constexpr auto STATIC_ELEMENT_SPRITE_ID = 0;
138 constexpr auto SEGMENT_ELEMENT_SPRITE_ID = 1;
139 constexpr auto PRIORITY = 0; // TODO: Check later. May interfere with Lua display sprites. -- Sezz 2023.10.06
140
141 if (!Position.has_value())
142 return;
143
144 auto pos0 = Vector2::Lerp(PrevPosition, *Position, g_Renderer.GetInterpolationFactor());
145 short orient0 = PrevOrientation + Geometry::GetShortestAngle(PrevOrientation, Orientation) * g_Renderer.GetInterpolationFactor();
146 float scale = Lerp(PrevScale, Scale, g_Renderer.GetInterpolationFactor());
147 auto color = Color::Lerp(PrevColor, Color, g_Renderer.GetInterpolationFactor());
148
149 // Draw main static element.
150 AddDisplaySprite(
151 SPRITE_SEQUENCE_OBJECT_ID, STATIC_ELEMENT_SPRITE_ID,
152 pos0, orient0, Vector2(scale), color,
153 PRIORITY, DisplaySpriteAlignMode::Center, DisplaySpriteScaleMode::Fill,
154 BlendMode::Additive, DisplaySpritePhase::Draw);
155
156 // Draw animated outer segment elements.
157 for (int i = 0; i < Segments.size(); i++)
158 {
159 const auto& segment = Segments[i];
160 const auto& prevSegment = PrevSegments[i];
161
162 auto pos1 = pos0 + Vector2::Lerp(prevSegment.PosOffset, segment.PosOffset, g_Renderer.GetInterpolationFactor());
163 short orient1 = orient0 + (prevSegment.OrientOffset + (Geometry::GetShortestAngle(prevSegment.OrientOffset, segment.OrientOffset) * g_Renderer.GetInterpolationFactor()));
164
165 AddDisplaySprite(
166 SPRITE_SEQUENCE_OBJECT_ID, SEGMENT_ELEMENT_SPRITE_ID,
167 pos1, orient1, Vector2(scale / 2), color,
168 PRIORITY, DisplaySpriteAlignMode::Center, DisplaySpriteScaleMode::Fill,
169 BlendMode::Additive, DisplaySpritePhase::Draw);
170 }
171 }
172
173 void TargetHighlighterController::Update(const ItemInfo& playerItem)
174 {

Callers

nothing calls this directly

Calls 8

LerpFunction · 0.85
GetShortestAngleFunction · 0.85
AddDisplaySpriteFunction · 0.85
Vector2Function · 0.50
has_valueMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected