Merge branch 'main' into SP3-10-input-management
This commit is contained in:
commit
775dcd5337
|
@ -18,4 +18,8 @@ constexpr SHEventIdentifier SH_PHYSICS_COLLIDER_REMOVED_EVENT { 9 };
|
|||
constexpr SHEventIdentifier SH_EDITOR_ON_PLAY_EVENT { 10 };
|
||||
constexpr SHEventIdentifier SH_EDITOR_ON_PAUSE_EVENT { 11 };
|
||||
constexpr SHEventIdentifier SH_EDITOR_ON_STOP_EVENT { 12 };
|
||||
constexpr SHEventIdentifier SH_SCENE_INIT_PRE { 13 };
|
||||
constexpr SHEventIdentifier SH_SCENE_INIT_POST { 14 };
|
||||
constexpr SHEventIdentifier SH_SCENE_EXIT_PRE { 15 };
|
||||
constexpr SHEventIdentifier SH_SCENE_EXIT_POST { 16 };
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
// Project Headers
|
||||
#include "SHSceneNode.h"
|
||||
#include "Assets/SHAssetMacros.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
|
@ -38,4 +39,10 @@ namespace SHADE
|
|||
SHSceneNode* childRemoved = nullptr;
|
||||
};
|
||||
|
||||
|
||||
struct SHSceneInitExitEvent
|
||||
{
|
||||
AssetID sceneAssetID;
|
||||
};
|
||||
|
||||
} // namespace SHADE
|
|
@ -204,7 +204,24 @@ namespace SHADE
|
|||
}
|
||||
////////////////////////////////////////
|
||||
|
||||
return NODE_ITER->second->IsActive();
|
||||
// Recurse up the tree until the root. If any parent is inactive, this node is inactive in the hierarchy.
|
||||
const SHSceneNode* PARENT_NODE = NODE_ITER->second->parent;
|
||||
|
||||
while (PARENT_NODE->GetEntityID() != root->GetEntityID())
|
||||
{
|
||||
if (!PARENT_NODE->IsActive())
|
||||
return false;
|
||||
|
||||
if (!PARENT_NODE->parent)
|
||||
{
|
||||
SHLOGV_ERROR("Entity {}'s node that is not the root has no parent!", PARENT_NODE->GetEntityID())
|
||||
return false;
|
||||
}
|
||||
|
||||
PARENT_NODE = PARENT_NODE->parent;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
//#include "Rendering/Window/SHRenderingWindow.h"
|
||||
#include "ECS_Base/Managers/SHEntityManager.h"
|
||||
#include "ECS_Base/Managers/SHSystemManager.h"
|
||||
#include "SHSceneEvents.h"
|
||||
#include "Events/SHEventManager.hpp"
|
||||
//#include "FRC/SHFrameRateController.h"
|
||||
//#include "ECS_Base/System/SHApplication.h"
|
||||
|
||||
|
@ -54,9 +56,15 @@ namespace SHADE
|
|||
{
|
||||
if (currentScene)
|
||||
{
|
||||
SHSceneInitExitEvent exitEvent;
|
||||
exitEvent.sceneAssetID = currentScene->sceneAssetID;
|
||||
SHEventManager::BroadcastEvent<SHSceneInitExitEvent>(exitEvent, SH_SCENE_EXIT_PRE);
|
||||
|
||||
currentScene->Free();
|
||||
currentScene->Unload();
|
||||
SHEntityManager::DestroyAllEntity();
|
||||
|
||||
SHEventManager::BroadcastEvent<SHSceneInitExitEvent>(exitEvent, SH_SCENE_EXIT_POST);
|
||||
delete currentScene;
|
||||
|
||||
}
|
||||
|
@ -82,27 +90,48 @@ namespace SHADE
|
|||
nextSceneID = UINT32_MAX;
|
||||
if (currentScene != nullptr)
|
||||
{
|
||||
|
||||
currentScene->Load();
|
||||
|
||||
SHSceneInitExitEvent initEvent;
|
||||
initEvent.sceneAssetID = currentScene->sceneAssetID;
|
||||
|
||||
SHEventManager::BroadcastEvent<SHSceneInitExitEvent>(initEvent, SH_SCENE_INIT_PRE);
|
||||
currentScene->Init();
|
||||
SHEventManager::BroadcastEvent<SHSceneInitExitEvent>(initEvent, SH_SCENE_INIT_POST);
|
||||
}
|
||||
}
|
||||
else // restarting scene
|
||||
{
|
||||
nextSceneID = UINT32_MAX;
|
||||
|
||||
SHSceneInitExitEvent exitEvent;
|
||||
exitEvent.sceneAssetID = currentScene->sceneAssetID;
|
||||
SHEventManager::BroadcastEvent<SHSceneInitExitEvent>(exitEvent, SH_SCENE_EXIT_PRE);
|
||||
|
||||
currentScene->Free();
|
||||
if (cleanReload == true)
|
||||
{
|
||||
cleanReload = false;
|
||||
currentScene->Unload();
|
||||
SHEntityManager::DestroyAllEntity();
|
||||
SHEventManager::BroadcastEvent<SHSceneInitExitEvent>(exitEvent, SH_SCENE_EXIT_POST);
|
||||
currentScene->sceneName = newSceneName;
|
||||
currentScene->Load();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
SHEntityManager::DestroyAllEntity();
|
||||
SHEventManager::BroadcastEvent<SHSceneInitExitEvent>(exitEvent, SH_SCENE_EXIT_POST);
|
||||
}
|
||||
|
||||
SHSceneInitExitEvent initEvent;
|
||||
initEvent.sceneAssetID = currentScene->sceneAssetID;
|
||||
SHEventManager::BroadcastEvent<SHSceneInitExitEvent>(initEvent, SH_SCENE_INIT_PRE);
|
||||
|
||||
currentScene->Init();
|
||||
SHEventManager::BroadcastEvent<SHSceneInitExitEvent>(initEvent, SH_SCENE_INIT_POST);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -133,11 +133,6 @@ namespace SHADE
|
|||
void SHSceneNode::SetActive(bool newActiveState) noexcept
|
||||
{
|
||||
active = newActiveState;
|
||||
|
||||
for (auto* child : children)
|
||||
{
|
||||
child->SetActive(newActiveState);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace SHADE
|
Loading…
Reference in New Issue