20using json = nlohmann::json;
22#define LUA_USE_APICHECK
24#include <LuaBridge/LuaBridge.h>
32bool Get(
const json& j,
const std::string& name, T& t)
34 auto iter = j.find(name);
43 if (v.find(
"value") != v.end())
44 t = (v[
"value"]).get<T>();
49 catch (nlohmann::detail::exception& e)
51 dl::log_warn0(std::string(
"配置取值失败:") + name +
" " + e.what());
65 std::array<float, 2>
alpha = { 1, 0 };
66 std::array<float, 2>
angle = { 0, 360 };
77 std::array<float, 2>
speed = { 100, 200 };
82 std::array<float, 2>
offset = { 0, 0 };
86 std::array<float, 2>
size = { 100, 100 };
138 json& j_emitter = j[
"emitter"];
139 j_emitter[
"offset"] =
emitter.offset;
140 j_emitter[
"offset1"] =
emitter.offset1;
141 j_emitter[
"rate"] =
emitter.rate;
142 j_emitter[
"shape"] =
emitter.shape;
143 j_emitter[
"size"] =
emitter.size;
146 json& j_node = j[
"node"];
147 j_node[
"alpha"] =
node.alpha;
148 j_node[
"angle"] =
node.angle;
149 j_node[
"color_beg"] =
node.color_beg;
150 j_node[
"rotate_speed"] =
node.rotate_speed;
151 j_node[
"color_end"] =
node.color_end;
152 j_node[
"lifetime"] =
node.lifetime;
153 j_node[
"rotate_to_dir"] =
node.rotate_to_dir;
154 j_node[
"rotate_angle"] =
node.rotate_angle;
155 j_node[
"scale_x_beg"] =
node.scale_x_beg;
156 j_node[
"scale_x_end"] =
node.scale_x_end;
157 j_node[
"scale_y_beg"] =
node.scale_y_beg;
158 j_node[
"scale_y_end"] =
node.scale_y_end;
159 j_node[
"speed"] =
node.speed;
162 json& j_system = j[
"system"];
163 j_system[
"delay"] =
system.delay;
164 j_system[
"gravity"] =
system.gravity;
165 j_system[
"duration"] =
system.duration;
166 j_system[
"max_num"] =
system.max_num;
172 luabridge::getGlobalNamespace(
L)
173 .beginClass<
Emitter>(
"emitter")
174 .addConstructor<
void(*)()>()
182 luabridge::getGlobalNamespace(
L)
183 .beginClass<
Node>(
"node")
184 .addConstructor<
void(*)()>()
200 luabridge::getGlobalNamespace(
L)
201 .beginClass<
System>(
"system")
202 .addConstructor<
void(*)()>()
209 luabridge::getGlobalNamespace(
L)
211 .addConstructor<void(*)()>()
217 auto result = luabridge::push(
L,
this);
218 lua_setglobal(
L, lua_name.c_str());
bool Get(const json &j, const std::string &name, T &t)
从json返回值,不存在则返回false
void log_warn0(std::string_view str, DL_SOURCE_LOCATION)
std::array< float, 2 > size
发射区域类型 -> 发射区域类型(point、circle、box、line)
std::array< float, 2 > offset1
位置偏移 -> 位置偏移
std::array< float, 2 > offset
unsigned rate
位置偏移1,作为line模式的结束点 -> 位置偏移1,作为line模式的结束点
std::string shape
发射速率 -> 发射速率,每秒多少个
std::array< float, 2 > lifetime
结束颜色(RGB) -> 结束颜色(RGB)
std::array< float, 2 > rotate_speed
起始颜色(RGB) -> 起始颜色(RGB)
std::array< float, 2 > alpha
std::array< float, 3 > color_beg
方向角度(范围) -> 方向角度(范围)
std::array< float, 2 > scale_x_end
起始缩放比例x轴(范围) -> 起始缩放比例x轴(范围)
std::array< float, 2 > scale_y_end
起始缩放比例y轴(范围) -> 起始缩放比例y轴(范围)
std::array< float, 3 > color_end
旋转速度(范围) -> 旋转速度(范围)
std::array< float, 2 > scale_x_beg
初始旋转角度(范围) -> 初始旋转角度(范围)
std::array< float, 2 > angle
透明度(范围) -> 透明度(范围)
std::array< float, 2 > scale_y_beg
结束缩放比例x轴(范围) -> 结束缩放比例x轴(范围)
std::array< float, 2 > rotate_angle
旋转至运动方向 -> 旋转至运动方向(启用后,其他旋转控制失效)
std::array< float, 2 > speed
结束缩放比例y轴(范围) -> 结束缩放比例y轴(范围)
bool rotate_to_dir
存活时间(范围) -> 存活时间(范围)
float duration
重力方向和大小 -> 重力方向和大小
unsigned max_num
持续时间 -> 持续时间(单位秒)
std::array< float, 2 > gravity
启动延时 -> 启动延时
struct dl::ParticleConfig::Node node
struct dl::ParticleConfig::Emitter emitter
void RegisterLua(lua_State *L, const std::string &lua_name)
struct dl::ParticleConfig::System system