mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-09 02:07:04 +08:00
refactor(gameplay): integrate model and hitbox ID system into Entity
- Introduce HitboxID, EntityID, and ModelID types for safer ID-based lookups - Replace AABB struct with Hitbox (includes HitboxID) - Convert ModelManager and HitboxManager to singletons with Handle structs - Update Entity to store IDs for model and hitbox, removing direct references - Reorganize creature model assets into subdirectories per entity type - Add player model (player.glb) and collision data for pig - Remove ModelManager dependency from App and Renderer - Add namespace parsing utility for asset paths - Mark sparse_vector::insert() with [[nodiscard]]
This commit is contained in:
@@ -1,6 +1,18 @@
|
||||
#include "Cubed/gameplay/entity.hpp"
|
||||
|
||||
#include "Cubed/gameplay/hitbox_manager.hpp"
|
||||
#include "Cubed/render/model_manager.hpp"
|
||||
namespace Cubed {
|
||||
|
||||
Entity::Entity(EntityID id, const std::string& name) {
|
||||
m_info.id = id;
|
||||
m_info.name = name;
|
||||
auto h = ModelManager::model(name);
|
||||
m_info.model = h.id;
|
||||
auto b = HitboxManager::hitbox(name);
|
||||
m_info.hitbox = b.id;
|
||||
}
|
||||
|
||||
glm::vec3& Entity::max_speed() { return m_velocity.max; }
|
||||
float& Entity::acceleration() { return m_movement.acceleration; }
|
||||
float& Entity::deceleration() { return m_movement.deceleration; }
|
||||
@@ -20,6 +32,7 @@ Movement& Entity::movement() { return m_movement; }
|
||||
Gravity& Entity::gravity() { return m_gravity; }
|
||||
MoveState& Entity::move_state() { return m_move_state; }
|
||||
Direction& Entity::direction() { return m_direction; }
|
||||
EntityInfo& Entity::info() { return m_info; }
|
||||
|
||||
const Velocity& Entity::velocity() const { return m_velocity; }
|
||||
const Position& Entity::pos() const { return m_pos; }
|
||||
@@ -29,5 +42,6 @@ const Movement& Entity::movement() const { return m_movement; }
|
||||
const Gravity& Entity::gravity() const { return m_gravity; }
|
||||
const MoveState& Entity::move_state() const { return m_move_state; }
|
||||
const Direction& Entity::direction() const { return m_direction; }
|
||||
const EntityInfo& Entity::info() const { return m_info; }
|
||||
|
||||
} // namespace Cubed
|
||||
Reference in New Issue
Block a user