// entitat.hpp - Classe base abstracta per a totes les entitats del joc // © 2025 Orni Attack - Arquitectura d'entitats #pragma once #include #include #include "core/graphics/shape.hpp" #include "core/types.hpp" namespace Entities { class Entity { public: virtual ~Entity() = default; // Interfície principal (virtual pur) virtual void init() = 0; virtual void update(float delta_time) = 0; virtual void draw() const = 0; [[nodiscard]] virtual bool isActive() const = 0; // Interfície de col·lisió (override opcional) [[nodiscard]] virtual float getCollisionRadius() const { return 0.0F; } [[nodiscard]] virtual bool isCollidable() const { return false; } // Getters comuns (inline, sense overhead) [[nodiscard]] const Vec2& getCenter() const { return center_; } [[nodiscard]] float getAngle() const { return angle_; } [[nodiscard]] float getBrightness() const { return brightness_; } [[nodiscard]] const std::shared_ptr& getShape() const { return shape_; } protected: // Estat comú (accés directe, sense overhead) SDL_Renderer* renderer_; std::shared_ptr shape_; Vec2 center_; float angle_{0.0F}; float brightness_{1.0F}; // Constructor protegit (classe abstracta) Entity(SDL_Renderer* renderer = nullptr) : renderer_(renderer), center_({.x = 0.0F, .y = 0.0F}) {} }; } // namespace Entities