Major refactoring for game objects
This commit is contained in:
1 parent
efb85f7328
commit
2cae9998a0
18 files changed
+547
-716
No files matched your search
@@ -23,20 +23,12 @@ namespace ZL {
|
||||
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;
|
||||
std::string activateFunctionName;
|
||||
};
|
||||
|
||||
struct GiftData {
|
||||
std::string id;
|
||||
std::string name;
|
||||
std::string description;
|
||||
std::string icon;
|
||||
struct InteractiveObjectData {
|
||||
GameObjectData base;
|
||||
float interactionRadius = 2.0f;
|
||||
std::string activateFunctionName;
|
||||
};
|
||||
|
||||
struct NpcData {
|
||||
@@ -66,20 +58,11 @@ namespace ZL {
|
||||
float hp = 100.0f;
|
||||
bool canAttack = false;
|
||||
bool enabled = true;
|
||||
GiftData gift;
|
||||
float interactionRadius = 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,
|
||||
@@ -98,7 +81,12 @@ namespace ZL {
|
||||
);
|
||||
|
||||
static std::vector<NpcData> loadNpcsFromJson(const std::string& jsonPath, const std::string& zipPath = "");
|
||||
|
||||
private:
|
||||
static nlohmann::json loadJson(const std::string& jsonPath, const std::string& zipPath);
|
||||
static std::vector<GameObjectData> loadFromJson(const std::string& jsonPath, const std::string& zipPath);
|
||||
static std::vector<InteractiveObjectData> loadInteractiveFromJson(const std::string& jsonPath, const std::string& zipPath);
|
||||
static LoadedGameObject buildLoadedObject(const GameObjectData& data, Renderer& renderer, const std::string& zipPath);
|
||||
};
|
||||
|
||||
} // namespace ZL
|
||||
|
||||
Reference in new issue
Block a user