Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-08-20 11:56:37 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-08-20 11:56:37 +1000
commit9af6bfe60e061a0d4c9a0267955ac0ab935dbf93 (patch)
tree7f51d773c8f3536e0a3af5474058fcfaea73ea8b /source
parent3990b196a22d7241f59448aeb7c36b9642127519 (diff)
Add ItemDrop glow
Diffstat (limited to 'source')
-rw-r--r--source/game/StarDrawable.hpp1
-rw-r--r--source/game/StarItemDrop.cpp35
-rw-r--r--source/game/StarItemDrop.hpp2
-rw-r--r--source/rendering/StarDrawablePainter.cpp6
4 files changed, 42 insertions, 2 deletions
diff --git a/source/game/StarDrawable.hpp b/source/game/StarDrawable.hpp
index f707eec..08dca1d 100644
--- a/source/game/StarDrawable.hpp
+++ b/source/game/StarDrawable.hpp
@@ -14,6 +14,7 @@ struct Drawable {
struct LinePart {
Line2F line;
float width;
+ Maybe<Color> endColor;
};
struct PolyPart {
diff --git a/source/game/StarItemDrop.cpp b/source/game/StarItemDrop.cpp
index 10ba8f5..d6c04f5 100644
--- a/source/game/StarItemDrop.cpp
+++ b/source/game/StarItemDrop.cpp
@@ -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;
}
diff --git a/source/game/StarItemDrop.hpp b/source/game/StarItemDrop.hpp
index 54114fb..a806209 100644
--- a/source/game/StarItemDrop.hpp
+++ b/source/game/StarItemDrop.hpp
@@ -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;
diff --git a/source/rendering/StarDrawablePainter.cpp b/source/rendering/StarDrawablePainter.cpp
index 8c50b2b..0ef1f31 100644
--- a/source/rendering/StarDrawablePainter.cpp
+++ b/source/rendering/StarDrawablePainter.cpp
@@ -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);