Made scenes, items and components a lot cleaner, asset manager also cleans up properly.

This commit is contained in:
2024-12-02 16:19:25 -06:00
parent 2af55041c8
commit 9fd4c2399f
18 changed files with 191 additions and 213 deletions

View File

@ -7,26 +7,30 @@
#include "dawn.hpp"
namespace Dawn {
typedef uint_fast32_t flag_t;
class Flag final {
public:
template<typename T>
static void turnOn(T &flag, const T check) {
flag |= check;
template<typename T, typename J>
static void turnOn(T &flag, const J check) {
flag |= (T)check;
}
template<typename T>
static void turnOff(T &flag, const T check) {
flag &= ~check;
template<typename T, typename J>
static void turnOff(T &flag, const J check) {
flag &= ~((T)check);
}
template<typename T>
static bool_t isOn(const T flag, const T check) {
return (flag & check) == check;
template<typename T, typename J>
static bool_t isOn(const T flag, const J check) {
return (flag & (T)check) == (T)check;
}
template<typename T>
static bool_t isOff(const T flag, const T check) {
return (flag & check) == 0;
template<typename T, typename J>
static bool_t isOff(const T flag, const J check) {
return (flag & (T)check) == 0;
}
};
#define FLAG(i) ((flag_t)1 << (flag_t)i)
}

View File

@ -21,9 +21,10 @@ glm::vec3 JSON::vec3(const json &j) {
j["y"].get<float_t>(),
j["z"].get<float_t>()
);
} else {
assertUnreachable("Invalid JSON type for vec3");
}
assertUnreachable("Invalid JSON type for vec3");
return glm::vec3(0.0f);
}
struct Color JSON::color(const json &j) {
@ -71,7 +72,8 @@ struct Color JSON::color(const json &j) {
return { r, g, b, a };
} else if(j.type() == json::value_t::string) {
return Color::fromString(j.get<std::string>());
} else {
assertUnreachable("Invalid JSON type for color");
}
assertUnreachable("Invalid JSON type for color");
return COLOR_WHITE;
}