Change something??

This commit is contained in:
bailehuni 2024-04-29 18:51:52 +01:00
parent 4f8252476c
commit 119978774c
3 changed files with 14 additions and 6 deletions

View File

@ -108,6 +108,14 @@ class Scene {
ecs_systems_.emplace_back(hash, std::make_unique<T>(this));
}
/* Pushes old systems starting at 'index' along by 1 */
template <typename T>
void RegisterSystemAtIndex(size_t index)
{
size_t hash = typeid(T).hash_code();
ecs_systems_.emplace(ecs_systems_.begin() + index, hash, std::make_unique<T>(this));
}
template <typename T>
T* GetSystem()
{

View File

@ -26,11 +26,11 @@ Scene::Scene(Application* app) : app_(app) {
RegisterComponent<UIRenderableComponent>();
// Order here matters:
RegisterSystem<CustomBehaviourSystem>(); // potentially modifies transforms
RegisterSystem<TransformSystem>();
RegisterSystem<CollisionSystem>();
RegisterSystem<CustomBehaviourSystem>();
RegisterSystem<MeshRenderSystem>();
RegisterSystem<UIRenderSystem>();
RegisterSystem<CollisionSystem>(); // depends on transformed world matrix
RegisterSystem<MeshRenderSystem>(); // depends on transformed world matrix
RegisterSystem<UIRenderSystem>(); // does nothing as of now
}
Scene::~Scene() {}

View File

@ -68,7 +68,7 @@ void PlayGame(GameSettings settings)
//engine::Entity temple = engine::util::LoadGLTF(*start_scene, "C:/games/temple.glb", true);
start_scene->RegisterComponent<CameraControllerComponent>();
start_scene->RegisterSystem<CameraControllerSystem>();
start_scene->RegisterSystemAtIndex<CameraControllerSystem>(0);
start_scene->AddComponent<CameraControllerComponent>(camera)->noclip = true;
start_scene->GetPosition(camera).z += 10.0f;
}
@ -93,7 +93,7 @@ void PlayGame(GameSettings settings)
camera_transform->is_static = false;
main_scene->RegisterComponent<CameraControllerComponent>();
main_scene->RegisterSystem<CameraControllerSystem>();
main_scene->RegisterSystemAtIndex<CameraControllerSystem>(0);
main_scene->AddComponent<CameraControllerComponent>(camera);
/* floor */