Fixed and Enhanced Input Binding Management #298

Merged
mushgunAX merged 9 commits from SP3-10-input-management into main 2023-01-01 12:35:50 +08:00
5 changed files with 59 additions and 7 deletions
Showing only changes of commit 775dcd5337 - Show all commits

View File

@ -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 };

View File

@ -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

View File

@ -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;
}
/*-----------------------------------------------------------------------------------*/

View File

@ -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
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);
}
}

View File

@ -133,11 +133,6 @@ namespace SHADE
void SHSceneNode::SetActive(bool newActiveState) noexcept
{
active = newActiveState;
for (auto* child : children)
{
child->SetActive(newActiveState);
}
}
} // namespace SHADE