add particles.stop(...)
This commit is contained in:
parent
0cd5136fdb
commit
3ecb7b447f
@ -1,6 +1,6 @@
|
|||||||
function on_block_broken(id, x, y, z, playerid)
|
function on_block_broken(id, x, y, z, playerid)
|
||||||
particles.emit({x+0.5, y+0.5, z+0.5}, 100, {
|
particles.emit({x+0.5, y+0.5, z+0.5}, 64, {
|
||||||
lifetime=2.0,
|
lifetime=1.0,
|
||||||
spawn_interval=0.0001,
|
spawn_interval=0.0001,
|
||||||
explosion={4, 4, 4},
|
explosion={4, 4, 4},
|
||||||
texture="blocks:"..block.get_textures(id)[1],
|
texture="blocks:"..block.get_textures(id)[1],
|
||||||
|
|||||||
@ -535,10 +535,6 @@ void WorldRenderer::drawBorders(
|
|||||||
lineBatch->flush();
|
lineBatch->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldRenderer::addEmitter(std::unique_ptr<Emitter> emitter) {
|
|
||||||
particles->add(std::move(emitter));
|
|
||||||
}
|
|
||||||
|
|
||||||
void WorldRenderer::clear() {
|
void WorldRenderer::clear() {
|
||||||
renderer->clear();
|
renderer->clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
|
#include "typedefs.hpp"
|
||||||
|
|
||||||
class Level;
|
class Level;
|
||||||
class Player;
|
class Player;
|
||||||
class Camera;
|
class Camera;
|
||||||
@ -42,7 +44,6 @@ class WorldRenderer {
|
|||||||
std::unique_ptr<Skybox> skybox;
|
std::unique_ptr<Skybox> skybox;
|
||||||
std::unique_ptr<Batch3D> batch3d;
|
std::unique_ptr<Batch3D> batch3d;
|
||||||
std::unique_ptr<ModelBatch> modelBatch;
|
std::unique_ptr<ModelBatch> modelBatch;
|
||||||
std::unique_ptr<ParticlesRenderer> particles;
|
|
||||||
|
|
||||||
float timer = 0.0f;
|
float timer = 0.0f;
|
||||||
|
|
||||||
@ -80,6 +81,8 @@ class WorldRenderer {
|
|||||||
float fogFactor
|
float fogFactor
|
||||||
);
|
);
|
||||||
public:
|
public:
|
||||||
|
std::unique_ptr<ParticlesRenderer> particles;
|
||||||
|
|
||||||
static bool showChunkBorders;
|
static bool showChunkBorders;
|
||||||
static bool showEntitiesDebug;
|
static bool showEntitiesDebug;
|
||||||
|
|
||||||
@ -108,7 +111,5 @@ public:
|
|||||||
bool pause
|
bool pause
|
||||||
);
|
);
|
||||||
|
|
||||||
void addEmitter(std::unique_ptr<Emitter> emitter);
|
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
};
|
};
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "logic/scripting/scripting_hud.hpp"
|
#include "logic/scripting/scripting_hud.hpp"
|
||||||
#include "graphics/render/WorldRenderer.hpp"
|
#include "graphics/render/WorldRenderer.hpp"
|
||||||
|
#include "graphics/render/ParticlesRenderer.hpp"
|
||||||
#include "graphics/render/Emitter.hpp"
|
#include "graphics/render/Emitter.hpp"
|
||||||
#include "assets/assets_util.hpp"
|
#include "assets/assets_util.hpp"
|
||||||
#include "engine.hpp"
|
#include "engine.hpp"
|
||||||
@ -34,11 +35,19 @@ static int l_emit(lua::State* L) {
|
|||||||
region.region,
|
region.region,
|
||||||
count
|
count
|
||||||
);
|
);
|
||||||
renderer->addEmitter(std::move(emitter));
|
return lua::pushinteger(L, renderer->particles->add(std::move(emitter)));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int l_stop(lua::State* L) {
|
||||||
|
u64id_t id = lua::touinteger(L, 1);
|
||||||
|
if (auto emitter = renderer->particles->getEmitter(id)) {
|
||||||
|
emitter->stop();
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const luaL_Reg particleslib[] = {
|
const luaL_Reg particleslib[] = {
|
||||||
{"emit", lua::wrap<l_emit>},
|
{"emit", lua::wrap<l_emit>},
|
||||||
|
{"stop", lua::wrap<l_stop>},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user