imgration 14/12/2025
This commit is contained in:
11
include/types/Interactable_resource.h
Normal file
11
include/types/Interactable_resource.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "type_base.hpp"
|
||||
|
||||
struct Interactable_Resource : public TypeBase
|
||||
{
|
||||
uint16_t ResourceID;
|
||||
|
||||
void Parse(const ryml::ConstNodeRef& node, ParseContext& context);
|
||||
void Link(const std::unordered_map<int64_t, TypeBase*>& assetsMap) {};
|
||||
};
|
||||
65
include/types/game_object.h
Normal file
65
include/types/game_object.h
Normal file
@@ -0,0 +1,65 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <bitset>
|
||||
|
||||
#include <ryml_std.hpp>
|
||||
|
||||
#include "type_base.hpp"
|
||||
#include "transform.h"
|
||||
|
||||
struct GameObject : public TypeBase
|
||||
{
|
||||
std::string name;
|
||||
uint8_t layer{ 0 };
|
||||
uint8_t namMeshLayer{ 0 };
|
||||
std::string tag;
|
||||
|
||||
Transform* transform{ nullptr };
|
||||
std::vector<TypeBase*> Components;
|
||||
|
||||
/**
|
||||
* ComponentMask is a bitset where each bit corresponds to a component type index.
|
||||
* This allows for extremely fast checking of whether a GameObject has specific components.
|
||||
* The bit is set during the Link() phase when components are resolved.
|
||||
* Max 64 different component types are supported.
|
||||
*/
|
||||
std::bitset<64> ComponentMask;
|
||||
|
||||
void Parse(const ryml::ConstNodeRef& node, ParseContext& context);
|
||||
void Link(const std::unordered_map<int64_t, TypeBase*>& assetsMap);
|
||||
|
||||
// Check if this GameObject has a specific component type
|
||||
template <typename T>
|
||||
bool HasComponent() const
|
||||
{
|
||||
// Type index must be set by the system
|
||||
for (auto* comp : Components)
|
||||
{
|
||||
if (comp && comp->TypeID >= 0 && comp->TypeID < 64)
|
||||
{
|
||||
if (ComponentMask.test(comp->TypeID))
|
||||
{
|
||||
// Additional runtime check could be added here
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get a component of a specific type
|
||||
template <typename T>
|
||||
T* GetComponent()
|
||||
{
|
||||
for (auto* comp : Components)
|
||||
{
|
||||
if (auto* typedComp = dynamic_cast<T*>(comp))
|
||||
{
|
||||
return typedComp;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
18
include/types/mesh_filter.h
Normal file
18
include/types/mesh_filter.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "type_base.hpp"
|
||||
|
||||
|
||||
struct GameObject;
|
||||
|
||||
struct MeshFilter : TypeBase
|
||||
{
|
||||
AssetGUID Mesh;
|
||||
GameObject* GameObject{ nullptr };
|
||||
|
||||
void Parse(const ryml::ConstNodeRef& node, ParseContext& context);
|
||||
void Link(const std::unordered_map<int64_t, TypeBase*>& assetsMap);
|
||||
};
|
||||
|
||||
13
include/types/prefab_instance.h
Normal file
13
include/types/prefab_instance.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "type_base.hpp"
|
||||
|
||||
struct PrefabInstance : public TypeBase
|
||||
{
|
||||
public:
|
||||
void Parse(const ryml::ConstNodeRef& node, ParseContext& context);
|
||||
void Link(const std::unordered_map<int64_t, TypeBase*>& assetsMap) {};
|
||||
|
||||
public:
|
||||
std::unordered_map<int64_t, ryml::Tree> Data;
|
||||
};
|
||||
27
include/types/transform.h
Normal file
27
include/types/transform.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
|
||||
#include "type_base.hpp"
|
||||
|
||||
struct GameObject;
|
||||
|
||||
struct Transform : public TypeBase
|
||||
{
|
||||
glm::quat Rotation;
|
||||
glm::vec3 Position;
|
||||
glm::vec3 Scale;
|
||||
|
||||
glm::mat4 GlobalMatrix;
|
||||
|
||||
GameObject* GameObject{ nullptr };
|
||||
std::vector<Transform*> Children;
|
||||
Transform* Parent{ nullptr };
|
||||
|
||||
void Parse(const ryml::ConstNodeRef& node, ParseContext& context);
|
||||
void Link(const std::unordered_map<int64_t, TypeBase*>& assetsMap);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user