mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-08 17:57:02 +08:00
- 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]]
37 lines
1011 B
C++
37 lines
1011 B
C++
#pragma once
|
|
#include "Cubed/gameplay/hitbox.hpp"
|
|
|
|
#include <tbb/concurrent_hash_map.h>
|
|
namespace Cubed {
|
|
class HitboxManager {
|
|
public:
|
|
struct Handle {
|
|
Hitbox box;
|
|
HitboxID id = 0;
|
|
};
|
|
HitboxManager();
|
|
~HitboxManager();
|
|
static HitboxManager& instance();
|
|
|
|
[[nodiscard]]
|
|
Handle get_hitbox(const std::string& key);
|
|
[[nodiscard]]
|
|
Handle get_hitbox(HitboxID id);
|
|
[[nodiscard]]
|
|
static Handle hitbox(const std::string& name);
|
|
[[nodiscard]]
|
|
static Handle hitbox(HitboxID id);
|
|
HitboxID get_hitbox_id(const std::string& name);
|
|
const std::string& get_hitbox_name(HitboxID id);
|
|
|
|
private:
|
|
using HitboxMap = tbb::concurrent_hash_map<HitboxID, Hitbox>;
|
|
using IDMap = tbb::concurrent_hash_map<std::string, HitboxID>;
|
|
using NameMap = tbb::concurrent_hash_map<HitboxID, std::string>;
|
|
HitboxID m_next = 0;
|
|
IDMap m_id_map;
|
|
NameMap m_name_map;
|
|
HitboxMap m_hitboxes;
|
|
Handle load(std::string_view name);
|
|
};
|
|
} // namespace Cubed
|