feat: add new fancy reflection
This commit is contained in:
@@ -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>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user