Files
simian/include/ECSComponents.h
T
nick 4116678556
CI / build-and-test (push) Has been cancelled
fix: shaders work again now
2026-03-08 11:08:12 +13:00

107 lines
2.9 KiB
C++

#pragma once
#include "raylib.h"
#include <string>
// ECSTransform component - position, rotation, and scale
struct ECSTransform {
Vector3 position;
Vector3 scale;
float rotation; // Rotation around Y axis in radians
ECSTransform()
: position{0.0f, 0.0f, 0.0f}
, scale{1.0f, 1.0f, 1.0f}
, rotation(0.0f) {}
ECSTransform(Vector3 pos, Vector3 scl = {1.0f, 1.0f, 1.0f}, float rot = 0.0f)
: position(pos), scale(scl), rotation(rot) {}
};
// 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) {}
};
// Sprite component - visual representation
struct Sprite {
size_t modelId; // Index into models array
Color color; // Tint color
float outlineSize; // Outline thickness
unsigned int shaderId; // Shader to use (0 = no shader)
Sprite()
: modelId(0)
, color(WHITE)
, outlineSize(0.0f)
, shaderId(0) {}
Sprite(int model, Color col = WHITE, float outline = 0.0f, unsigned int shader = 0)
: modelId(model), color(col), outlineSize(outline), shaderId(shader) {}
};
// Tag component - simple string identifier
struct Tag {
std::string name;
Tag() : name("") {}
Tag(const std::string& n) : name(n) {}
};
// 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) {}
};