#pragma once #include #include #include "CoreMath.h" #include // todo: Make this class AStaticMeshActor : public AActor class StaticMeshActor { public: std::string Name; FVector Pos; IRotator Rot; FVector Scale; std::string Model; int32_t* Collision; bool bPendingDestroy = false; StaticMeshActor(std::string name, FVector pos, IRotator rot, FVector scale, std::string model, int32_t* collision); nlohmann::json to_json() const { nlohmann::json j; // Serialize each field of the class j["Name"] = Name; j["Position"] = {Pos.x, Pos.y, Pos.z}; // Assuming FVector has x, y, z fields j["Rotation"] = {Rot.pitch, Rot.yaw, Rot.roll}; // Assuming IRotator has pitch, yaw, roll fields j["Scale"] = {Scale.x, Scale.y, Scale.z}; // Assuming FVector has x, y, z fields j["Model"] = Model; // If Collision is not null, serialize it if (Collision != nullptr) { j["Collision"] = *Collision; // Serialize the value that Collision points to } else { j["Collision"] = nullptr; // Handle the case where Collision is nullptr } return j; } void from_json(const nlohmann::json& j) { Name = j.at("Name").get(); Pos = FVector(j.at("Position")[0].get(), j.at("Position")[1].get(), j.at("Position")[2].get()); Rot.Set(j.at("Rotation")[0].get(), j.at("Rotation")[1].get(), j.at("Rotation")[2].get()); Scale = FVector(j.at("Scale")[0].get(), j.at("Scale")[1].get(), j.at("Scale")[2].get()); // Deserialize the Model string Model = j.at("Model").get(); // Check if Collision is present in the JSON and deserialize it //if (j.contains("Collision") && !j["Collision"].is_null()) { // If Collision is a valid value, allocate memory for it and assign the value // Collision = new int32_t(j.at("Collision").get()); //} else { // If Collision is not present or is null, set it to nullptr Collision = nullptr; //} } virtual void Draw(); virtual void Destroy(); };