shadow-over-bishkek001/src/items/GameObjectLoader.h
2026-04-11 15:30:29 +06:00

83 lines
2.0 KiB
C++

#pragma once
#include <string>
#include <vector>
#include <memory>
#include <unordered_map>
#include "external/nlohmann/json.hpp"
#include "TextModel.h"
#include "InteractiveObject.h"
#include "Character.h"
namespace ZL {
struct Texture;
struct VertexRenderStruct;
class Renderer;
class Character;
struct GameObjectData {
std::string name;
std::string texturePath;
std::string meshPath;
float rotationX = 0.0f;
float rotationY = 0.0f;
float rotationZ = 0.0f;
float positionX = 0.0f;
float positionY = 0.0f;
float positionZ = 0.0f;
float scale = 1.0f;
bool interactive = false;
std::string itemId;
std::string itemName;
std::string itemDescription;
std::string itemIcon;
float interactionRadius = 2.0f;
};
struct NpcData {
std::string id;
std::string name;
std::string texturePath;
std::string animationIdlePath;
std::string animationWalkPath;
float positionX = 0.0f;
float positionY = 0.0f;
float positionZ = 0.0f;
float walkSpeed = 1.5f;
float rotationSpeed = 8.0f;
float modelScale = 0.01f;
float modelCorrectionRotX = 0.0f;
float modelCorrectionRotY = 0.0f;
float modelCorrectionRotZ = 0.0f;
};
struct LoadedGameObject {
std::shared_ptr<Texture> texture;
VertexRenderStruct mesh;
std::string name;
};
class GameObjectLoader {
public:
static std::vector<GameObjectData> loadFromJson(const std::string& jsonPath, const std::string& zipPath = "");
static std::unordered_map<std::string, LoadedGameObject> loadAndCreateGameObjects(
const std::string& jsonPath,
Renderer& renderer,
const std::string& zipPath = ""
);
static std::vector<InteractiveObject> loadAndCreateInteractiveObjects(
const std::string& jsonPath,
Renderer& renderer,
const std::string& zipPath = ""
);
static std::vector<std::unique_ptr<Character>> loadAndCreateNpcs(
const std::string& jsonPath,
const std::string& zipPath = ""
);
static std::vector<NpcData> loadNpcsFromJson(const std::string& jsonPath, const std::string& zipPath = "");
};
} // namespace ZL