Minor - Enhances ECS component functionality - V13.5.0

Adds serialization/deserialization to components,
allowing saving and loading of entity states.
Provides ImGui widgets for editing component properties,
improving editor usability.
Passes the D3D device and context to entities and
components enabling resource creation within components.
This commit is contained in:
2025-09-16 18:26:33 +02:00
parent f875580197
commit de05631608
8 changed files with 346 additions and 16 deletions

View File

@@ -3,6 +3,7 @@
#include <vector>
#include <unordered_map>
#include <queue>
#include <d3d11.h>
namespace ecs {
@@ -33,6 +34,8 @@ public:
auto entity = std::make_shared<Entity>(id);
entity->SetCamera(camera_);
entity->SetSoundSystem(sound_system_);
entity->SetDevice(device);
entity->SetContext(context);
m_Entities[id] = entity;
return entity;
@@ -146,18 +149,42 @@ public:
}
/**
* Set the main camera that will be propagate to the entity when creating a new entity.
* @param camera Pointer to the camera_class instance.
*/
void SetCamera(camera_class* camera) { camera_ = camera; }
/**
* Get the main camera used by entities.
* @return Pointer to the camera_class instance.
*/
camera_class* GetCamera() const { return camera_; }
/**
* Set the FMOD sound system that will be propagate to the entity when creating a new entity.
* @param sound_system Pointer to the FMOD::System instance.
*/
void SetSoundSystem(FMOD::System* sound_system) { sound_system_ = sound_system; }
/**
* Get the FMOD sound system used by entities.
* @return Pointer to the FMOD::System instance.
*/
FMOD::System* GetSoundSystem() const { return sound_system_; }
void SetDevice (ID3D11Device* dev) { device = dev; }
void SetContext(ID3D11DeviceContext* ctx) { context = ctx; }
ID3D11Device* GetDevice() const { return device; }
ID3D11DeviceContext* GetContext() const { return context; }
private:
EntityID m_NextEntityID;
std::unordered_map<EntityID, std::shared_ptr<Entity>> m_Entities;
std::queue<EntityID> m_FreeIDs; // IDs <20> r<>utiliser
camera_class* camera_ = nullptr;
FMOD::System* sound_system_ = nullptr;
ID3D11Device* device;
ID3D11DeviceContext* context;
};
} // namespace ecs