Add ItemDrop glow
This commit is contained in:
parent
3990b196a2
commit
9af6bfe60e
@ -14,6 +14,7 @@ struct Drawable {
|
||||
struct LinePart {
|
||||
Line2F line;
|
||||
float width;
|
||||
Maybe<Color> endColor;
|
||||
};
|
||||
|
||||
struct PolyPart {
|
||||
|
@ -265,6 +265,32 @@ bool ItemDrop::shouldDestroy() const {
|
||||
}
|
||||
|
||||
void ItemDrop::render(RenderCallback* renderCallback) {
|
||||
if (m_mode.get() != Mode::Taken) {
|
||||
Color beamColor;
|
||||
switch (m_item->rarity()) {
|
||||
case Rarity::Uncommon:
|
||||
beamColor = Color::rgb(87, 255, 81);
|
||||
break;
|
||||
case Rarity::Rare:
|
||||
beamColor = Color::rgb(87, 220, 255);
|
||||
break;
|
||||
case Rarity::Legendary:
|
||||
beamColor = Color::rgb(176, 81, 255);
|
||||
break;
|
||||
case Rarity::Essential:
|
||||
beamColor = Color::rgb(255, 255, 81);
|
||||
break;
|
||||
default:
|
||||
beamColor = Color::White;
|
||||
}
|
||||
|
||||
beamColor.setAlphaF(0.8f);
|
||||
auto line = Drawable::makeLine({ Vec2F(), Vec2F(0.0f, 1.5f) }, 2.0f, beamColor, position());
|
||||
(line.linePart().endColor = beamColor)->setAlphaF(0.0f);
|
||||
line.fullbright = true;
|
||||
renderCallback->addDrawable(move(line), RenderLayerItemDrop);
|
||||
}
|
||||
|
||||
if (!m_drawables) {
|
||||
m_drawables = m_item->dropDrawables();
|
||||
if (Directives dropDirectives = m_config.getString("directives", "")) {
|
||||
@ -282,6 +308,15 @@ void ItemDrop::render(RenderCallback* renderCallback) {
|
||||
}
|
||||
}
|
||||
|
||||
void ItemDrop::renderLightSources(RenderCallback* renderCallback) {
|
||||
LightSource light;
|
||||
light.pointLight = false;
|
||||
light.color = Vec3B::filled(20);
|
||||
light.position = position();
|
||||
renderCallback->addLightSource(move(light));
|
||||
}
|
||||
|
||||
|
||||
ItemPtr ItemDrop::item() const {
|
||||
return m_item;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public:
|
||||
bool shouldDestroy() const override;
|
||||
|
||||
virtual void render(RenderCallback* renderCallback) override;
|
||||
|
||||
virtual void renderLightSources(RenderCallback* renderCallback) override;
|
||||
// The item that this drop contains
|
||||
ItemPtr item() const;
|
||||
|
||||
|
@ -17,12 +17,16 @@ void DrawablePainter::drawDrawable(Drawable const& drawable) {
|
||||
Vec2F left = Vec2F(vnorm(line.diff())).rot90() * linePart->width / 2.0f;
|
||||
|
||||
float fullbright = drawable.fullbright ? 0.0f : 1.0f;
|
||||
primitives.emplace_back(std::in_place_type_t<RenderQuad>(),
|
||||
auto& primitive = primitives.emplace_back(std::in_place_type_t<RenderQuad>(),
|
||||
line.min() + left,
|
||||
line.min() - left,
|
||||
line.max() - left,
|
||||
line.max() + left,
|
||||
color, fullbright);
|
||||
if (auto* endColor = linePart->endColor.ptr()) {
|
||||
RenderQuad& quad = primitive.get<RenderQuad>();
|
||||
quad.c.color = quad.d.color = endColor->toRgba();
|
||||
}
|
||||
} else if (auto polyPart = drawable.part.ptr<Drawable::PolyPart>()) {
|
||||
PolyF poly = polyPart->poly;
|
||||
poly.translate(drawable.position);
|
||||
|
Loading…
Reference in New Issue
Block a user