fix: api updates
This commit is contained in:
+25
-18
@@ -21,17 +21,36 @@ Scene::Scene(const std::string& name) : m_name(name) {
|
||||
|
||||
Scene::~Scene() = default;
|
||||
|
||||
void Scene::Add(std::shared_ptr<GameObject> object) {
|
||||
// m_objects.emplace_back(std::move(object));
|
||||
m_pendingAdditions.emplace_back(std::move(object));
|
||||
// void Scene::Add(std::shared_ptr<GameObject> object) {
|
||||
// // m_objects.emplace_back(std::move(object));
|
||||
// m_pendingAdditions.emplace_back(std::move(object));
|
||||
// }
|
||||
|
||||
GameObject* Scene::CreateGameObject(std::string name)
|
||||
{
|
||||
auto obj = std::make_shared<GameObject>(std::move(name));
|
||||
|
||||
GameObject* rawPtr = obj.get();
|
||||
|
||||
// obj->SetScene(this);
|
||||
m_pendingAdditions.emplace_back(std::move(obj));
|
||||
|
||||
return rawPtr;
|
||||
}
|
||||
|
||||
void Scene::Remove(const std::shared_ptr<GameObject>& object) {
|
||||
std::erase(m_objects, object);
|
||||
void Scene::Remove(GameObject* object) {
|
||||
std::erase_if(m_objects, [object](const std::shared_ptr<GameObject>& obj) {
|
||||
return obj.get() == object;
|
||||
});
|
||||
|
||||
std::erase_if(m_pendingAdditions, [object](const std::shared_ptr<GameObject>& obj) {
|
||||
return obj.get() == object;
|
||||
});
|
||||
}
|
||||
|
||||
void Scene::RemoveAll() {
|
||||
m_objects.clear();
|
||||
m_pendingAdditions.clear();
|
||||
}
|
||||
|
||||
void Scene::Load() {
|
||||
@@ -80,18 +99,6 @@ void Scene::Render(const RenderContext& ctx) const {
|
||||
object->Render(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
// int width, height;
|
||||
// SDL_GetWindowSize(Renderer::GetInstance().GetSDLWindow(), &width, &height);
|
||||
//
|
||||
// Renderer::GetInstance().RenderLine(
|
||||
// static_cast<float>(width / 2), 0,
|
||||
// static_cast<float>(width / 2), static_cast<float>(height), SDL_Color(255, 0, 0, 255) // Red vertical line
|
||||
// );
|
||||
//
|
||||
// Renderer::GetInstance().RenderLine(
|
||||
// 0, static_cast<float>(height / 2), static_cast<float>(width), static_cast<float>(height / 2), SDL_Color(0, 255, 0, 255) // Green horizontal line
|
||||
// );
|
||||
}
|
||||
|
||||
void Scene::RenderImgui() {
|
||||
@@ -145,6 +152,6 @@ void Scene::DestroyGameObjects() {
|
||||
gameObject->Destroy();
|
||||
}
|
||||
} else {
|
||||
assert(true && "Scene is being cleared but not unloaded? Wierd");
|
||||
assert(m_BeingUnloaded && "Scene is being cleared but not unloaded? Weird");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user