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

summaryrefslogtreecommitdiff
path: root/source/game/scripting/StarLuaAnimationComponent.hpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-07-03 08:51:42 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-07-03 08:51:42 +1000
commit398a5655f42378176a1e596af6d399a180ffb733 (patch)
tree88b5d6a9c389a55f5f10a5243188cdf5de7c553a /source/game/scripting/StarLuaAnimationComponent.hpp
parentd7ba1136883de9392bb929df5772dba7f8bf49df (diff)
Add Drawable <-> Lua conversion to LuaGameConverters
Diffstat (limited to 'source/game/scripting/StarLuaAnimationComponent.hpp')
-rw-r--r--source/game/scripting/StarLuaAnimationComponent.hpp28
1 files changed, 2 insertions, 26 deletions
diff --git a/source/game/scripting/StarLuaAnimationComponent.hpp b/source/game/scripting/StarLuaAnimationComponent.hpp
index 76c3f28..6d94466 100644
--- a/source/game/scripting/StarLuaAnimationComponent.hpp
+++ b/source/game/scripting/StarLuaAnimationComponent.hpp
@@ -61,36 +61,12 @@ LuaAnimationComponent<Base>::LuaAnimationComponent() {
animationCallbacks.registerCallback("clearDrawables", [this]() {
m_drawables.clear();
});
- animationCallbacks.registerCallback("addDrawable", [this](LuaTable const& drawableTable, Maybe<String> renderLayerName) {
+ animationCallbacks.registerCallback("addDrawable", [this](Drawable drawable, Maybe<String> renderLayerName) {
Maybe<EntityRenderLayer> renderLayer;
if (renderLayerName)
renderLayer = parseRenderLayer(*renderLayerName);
- Color color = drawableTable.get<Maybe<Color>>("color").value(Color::White);
-
- Drawable drawable;
- if (auto line = drawableTable.get<Maybe<Line2F>>("line"))
- drawable = Drawable::makeLine(line.take(), drawableTable.get<float>("width"), color);
- else if (auto poly = drawableTable.get<Maybe<PolyF>>("poly"))
- drawable = Drawable::makePoly(poly.take(), color);
- else if (auto image = drawableTable.get<Maybe<String>>("image"))
- drawable = Drawable::makeImage(image.take(), 1.0f / TilePixels, drawableTable.get<Maybe<bool>>("centered").value(true), Vec2F(), color);
- else
- throw LuaAnimationComponentException("Drawable table must have 'line', 'poly', or 'image'");
-
- if (auto transformation = drawableTable.get<Maybe<Mat3F>>("transformation"))
- drawable.transform(*transformation);
- if (auto rotation = drawableTable.get<Maybe<float>>("rotation"))
- drawable.rotate(*rotation);
- if (drawableTable.get<bool>("mirrored"))
- drawable.scale(Vec2F(-1, 1));
- if (auto scale = drawableTable.get<Maybe<float>>("scale"))
- drawable.scale(*scale);
- if (auto position = drawableTable.get<Maybe<Vec2F>>("position"))
- drawable.translate(*position);
-
- drawable.fullbright = drawableTable.get<bool>("fullbright");
-
+ drawable.scale(1.0f / TilePixels);
m_drawables.append({move(drawable), renderLayer});
});
animationCallbacks.registerCallback("clearLightSources", [this]() {