feat: add new fancy reflection

This commit is contained in:
2026-11-01 23:12:00 +01:00
parent 08acd84404
commit 6a85d17899
58 changed files with 380 additions and 1055 deletions
@@ -2,6 +2,7 @@
#include "spdlog/spdlog.h"
#include <destrum/ObjectModel/GameObject.h>
#include <destrum/Serialization/Reflect.h>
TriggerLoggerComponent::TriggerLoggerComponent(GameObject& parent)
: Component(parent, "TriggerLoggerComponent") {}
@@ -28,18 +29,8 @@ void TriggerLoggerComponent::OnTriggerExit(GameObject* other) {
triggerExitCount);
}
nlohmann::json TriggerLoggerComponent::Serialize() const {
return {
{"triggerEnterCount", triggerEnterCount},
{"triggerExitCount", triggerExitCount}
};
void TriggerLoggerComponent::Reflect(FieldVisitor& v) {
v.Field("triggerEnterCount", triggerEnterCount, {.readOnly = true});
v.Field("triggerExitCount", triggerExitCount, {.readOnly = true});
v.Field("lastOtherName", lastOtherName, {.readOnly = true, .transient = true});
}
void TriggerLoggerComponent::Deserialize(const nlohmann::json& data) {
if (data.contains("triggerEnterCount")) {
triggerEnterCount = data.at("triggerEnterCount").get<int>();
}
if (data.contains("triggerExitCount")) {
triggerExitCount = data.at("triggerExitCount").get<int>();
}
}