2022-07-28 20:42:57 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "natives.hpp"
|
|
|
|
|
|
|
|
namespace big
|
|
|
|
{
|
|
|
|
struct model_attachment
|
|
|
|
{
|
|
|
|
Hash model_hash;
|
|
|
|
Vector3 position;
|
|
|
|
Vector3 rotation;
|
2022-10-18 15:08:05 -04:00
|
|
|
bool has_collision;
|
|
|
|
bool is_visible;
|
|
|
|
bool is_invincible;
|
|
|
|
|
2022-07-28 20:42:57 +02:00
|
|
|
};
|
2022-10-20 00:50:24 +02:00
|
|
|
|
|
|
|
static void to_json(nlohmann::json& j, const model_attachment& attachment)
|
|
|
|
{
|
2022-07-28 20:42:57 +02:00
|
|
|
|
|
|
|
j = nlohmann::json{ {"model_hash", attachment.model_hash},
|
|
|
|
{"position_x", attachment.position.x}, {"position_y", attachment.position.y}, {"position_z", attachment.position.z},
|
2022-10-18 15:08:05 -04:00
|
|
|
{"rotation_x", attachment.rotation.x}, {"rotation_y", attachment.rotation.y}, {"rotation_z", attachment.rotation.z},
|
|
|
|
{"has_collision", attachment.has_collision},
|
|
|
|
{"is_visible", attachment.is_visible},
|
|
|
|
{"is_invincible", attachment.is_invincible}
|
2022-07-28 20:42:57 +02:00
|
|
|
|
2022-10-18 15:08:05 -04:00
|
|
|
};
|
|
|
|
};
|
2022-10-20 00:50:24 +02:00
|
|
|
|
|
|
|
template <typename ValueType>
|
|
|
|
static void set_from_key_or_default(const nlohmann::json& j, const char* key, ValueType& value, ValueType default_value = {})
|
|
|
|
{
|
|
|
|
if (j.contains(key))
|
|
|
|
{
|
|
|
|
j.at(key).get_to(value);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
value = default_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void from_json(const nlohmann::json& j, model_attachment& attachment)
|
|
|
|
{
|
|
|
|
set_from_key_or_default(j, "model_hash", attachment.model_hash);
|
|
|
|
|
|
|
|
set_from_key_or_default(j, "position_x", attachment.position.x);
|
|
|
|
set_from_key_or_default(j, "position_y", attachment.position.y);
|
|
|
|
set_from_key_or_default(j, "position_z", attachment.position.z);
|
|
|
|
|
|
|
|
set_from_key_or_default(j, "rotation_x", attachment.rotation.x);
|
|
|
|
set_from_key_or_default(j, "rotation_y", attachment.rotation.y);
|
|
|
|
set_from_key_or_default(j, "rotation_z", attachment.rotation.z);
|
|
|
|
|
|
|
|
set_from_key_or_default(j, "has_collision", attachment.has_collision);
|
|
|
|
set_from_key_or_default(j, "is_visible", attachment.is_visible, true);
|
|
|
|
set_from_key_or_default(j, "is_invincible", attachment.is_invincible);
|
2022-07-28 20:42:57 +02:00
|
|
|
}
|
2022-10-20 00:50:24 +02:00
|
|
|
};
|