~leinnan/raylibGame unlisted

ddd470b75d684e58bb408450acbb62bd7a6a2128 — Leinnan 1 year, 4 months ago f3fe696
Fix runtime error, create preset base class
5 files changed, 44 insertions(+), 6 deletions(-)

M data/mod.ini
M src/main.cpp
A src/presets/Preset.hpp
A src/presets/Unit.hpp
M src/utils/JsonParser.cpp
M data/mod.ini => data/mod.ini +3 -3
@@ 1,10 1,10 @@
[game]
name = Arkona
firstJson = data/test.json
name = Arkona

[gfx]
width = 1024
height = 600
fullscreen = false
showLogo = true
msaa = true
\ No newline at end of file
showLogo = false
msaa = true

M src/main.cpp => src/main.cpp +2 -2
@@ 41,7 41,7 @@ int main(int argc, char **argv) {
        return 1;
    }
    const auto windowName = reader.Get("game", "name", "Raylib").c_str();
    const auto jsonFile = reader.Get("game","firstJson","data.json").c_str();
    const auto jsonFile = reader.Get("game","firstJson","data.json");

    int flags = FLAG_WINDOW_RESIZABLE;
    if(reader.GetBoolean("gfx","fullscreen",false))


@@ 57,7 57,7 @@ int main(int argc, char **argv) {
    collisionSystem.Init(registry);
    aiSystem.Init(registry);
    damageSystem.Init();
    Components::readFromFile(registry, jsonFile);
    Components::readFromFile(registry, jsonFile.c_str());

    camera = {0};
    camera.target = (Vector3){0.0f, 0.5f, 0.0f};

A src/presets/Preset.hpp => src/presets/Preset.hpp +17 -0
@@ 0,0 1,17 @@
#ifndef PRESET_HPP
#define PRESET_HPP
#include <entt/entt.hpp>

namespace Presets {

struct Preset {
public:
std::string type;

Preset(){};

virtual uint32_t CreateEntity(entt::registry<> &registry){};
};
}

#endif

A src/presets/Unit.hpp => src/presets/Unit.hpp +21 -0
@@ 0,0 1,21 @@
#ifndef UNIT_HPP
#define UNIT_HPP
#include <string>
#include "presets/Preset.hpp"

namespace Presets {

struct Unit : Preset {
public:
    std::string type = "Unit";

    float speed;
    bool isPlayer;
    std::string name;
    std::string modelPath;
    std::string diffusePath;

    Unit(){};
}

#endif

M src/utils/JsonParser.cpp => src/utils/JsonParser.cpp +1 -1
@@ 244,7 244,7 @@ void Components::readFromFile(entt::registry<> &registry, const char *filename) 

    for(nlohmann::json &object : jsonReader)
        createEntityFromJson(registry,object);
    }
}

    uint32_t Components::createEntityFromJson(entt::registry<> &registry, json &object)
    {