#pragma once #include "raylib.h" #include "raymath.h" #include "entt.hpp" #include #include // ECSTransform component - position, rotation, scale, and cached local matrix struct ECSTransform { Vector3 position; Vector3 rotation; // Euler rotation (radians) Vector3 scale; Matrix localMatrix; ECSTransform() : position{0.0f, 0.0f, 0.0f} , rotation{0.0f, 0.0f, 0.0f} , scale{1.0f, 1.0f, 1.0f} , localMatrix(MatrixIdentity()) {} ECSTransform(Vector3 pos, Vector3 scl, Vector3 rot) : position(pos), rotation(rot), scale(scl), localMatrix(MatrixIdentity()) {} ECSTransform(Vector3 pos, Vector3 scl = {1.0f, 1.0f, 1.0f}, float rotY = 0.0f) : position(pos) , rotation{0.0f, rotY, 0.0f} , scale(scl) , localMatrix(MatrixIdentity()) {} }; // Velocity component - for movement struct Velocity { Vector3 linear; // Linear velocity (units per second) float angular; // Angular velocity (radians per second) Velocity() : linear{0.0f, 0.0f, 0.0f} , angular(0.0f) {} Velocity(Vector3 lin, float ang = 0.0f) : linear(lin), angular(ang) {} }; // ModelRenderer component - 3D model rendering data struct ModelRenderer { size_t modelId; // Index into models array Color color; // Tint color float outlineSize; // Outline thickness unsigned int shaderId; // Shader to use (0 = no shader) ModelRenderer() : modelId(0) , color(WHITE) , outlineSize(0.0f) , shaderId(0) {} ModelRenderer(int model, Color col = WHITE, float outline = 0.0f, unsigned int shader = 0) : modelId(model), color(col), outlineSize(outline), shaderId(shader) {} }; // Texture component - material texture reference struct TextureComponent { unsigned int textureId; TextureComponent() : textureId(0) {} TextureComponent(unsigned int id) : textureId(id) {} }; // UV transform component - tiling and offset for texture sampling struct UVTransform { Vector2 scale; Vector2 offset; float rotation; UVTransform() : scale{1.0f, 1.0f} , offset{0.0f, 0.0f} , rotation(0.0f) {} UVTransform(Vector2 s, Vector2 o = {0.0f, 0.0f}, float r = 0.0f) : scale(s), offset(o), rotation(r) {} }; // Tag component - simple string identifier struct Tag { std::string name; Tag() : name("") {} Tag(const std::string& n) : name(n) {} }; // ScriptComponent - per-entity script reference struct ScriptComponent { std::string scriptPath; bool enabled = true; bool started = false; // Optional: name of the script class to instantiate. If empty, engine // will attempt to pick a reasonable object type from the module. std::string className; // Opaque pointer to the script object instance (asIScriptObject*). void* scriptInstance = nullptr; // Persisted overrides for editable script fields (name -> raw value string). std::unordered_map scriptOverrides; }; // SceneEntity component - marks entities owned by the scene struct SceneEntity { bool persistent = false; std::string id; }; // Hierarchy component - parent/child links using EnTT-friendly linked list struct Hierarchy { entt::entity parent{entt::null}; entt::entity first{entt::null}; entt::entity prev{entt::null}; entt::entity next{entt::null}; }; // WorldTransform component - computed from hierarchy + local transform struct WorldTransform { Vector3 position; Vector3 rotation; // Euler rotation (radians) Vector3 scale; Matrix worldMatrix; WorldTransform() : position{0.0f, 0.0f, 0.0f} , rotation{0.0f, 0.0f, 0.0f} , scale{1.0f, 1.0f, 1.0f} , worldMatrix(MatrixIdentity()) {} }; // Camera3D component - camera settings struct Camera3DComponent { Vector3 position; Vector3 target; Vector3 up; float fovy; int projection; // 0 = CAMERA_PERSPECTIVE, 1 = CAMERA_ORTHOGRAPHIC Camera3DComponent() : position{0.0f, 10.0f, 10.0f} , target{0.0f, 0.0f, 0.0f} , up{0.0f, 1.0f, 0.0f} , fovy(45.0f) , projection(0) {} }; // Light component - directional light struct LightComponent { Vector3 direction; Color color; float intensity; LightComponent() : direction{0.5f, 0.7f, 0.3f} , color(WHITE) , intensity(1.0f) {} }; // Material component - references shader and material managers struct MaterialComponent { unsigned int materialId; // ID in MaterialManager MaterialComponent() : materialId(0) {} MaterialComponent(unsigned int id) : materialId(id) {} }; // RenderPass component - controls rendering order and properties struct RenderPassComponent { int order; // Render order (lower = earlier) bool depthTest; // Enable depth testing bool depthWrite; // Enable depth writing unsigned int shaderId; // Override shader for this pass (0 = use material shader) RenderPassComponent() : order(0) , depthTest(true) , depthWrite(true) , shaderId(0) {} };