Modified TestScene space bar input to not destroy the object, only remove scripts
This commit is contained in:
parent
77cccd63be
commit
f8391d6c9e
|
@ -47,7 +47,7 @@ namespace Sandbox
|
||||||
renderable.SetMaterial(matInst);
|
renderable.SetMaterial(matInst);
|
||||||
|
|
||||||
SHADE::SHScriptEngine* scriptEngine = static_cast<SHADE::SHScriptEngine*>(SHADE::SHSystemManager::GetSystem<SHADE::SHScriptEngine>());
|
SHADE::SHScriptEngine* scriptEngine = static_cast<SHADE::SHScriptEngine*>(SHADE::SHSystemManager::GetSystem<SHADE::SHScriptEngine>());
|
||||||
scriptEngine->AddScript(*SHADE::SHEntityManager::GetEntityByID(testObj), "TestScript");
|
scriptEngine->AddScript(testObj, "TestScript");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SBTestScene::Update(float dt)
|
void SBTestScene::Update(float dt)
|
||||||
|
@ -61,7 +61,10 @@ namespace Sandbox
|
||||||
|
|
||||||
// Destroy entity if space is pressed
|
// Destroy entity if space is pressed
|
||||||
if (GetKeyState(VK_SPACE) & 0x8000)
|
if (GetKeyState(VK_SPACE) & 0x8000)
|
||||||
SHADE::SHEntityManager::DestroyEntity(testObj);
|
{
|
||||||
|
SHADE::SHScriptEngine* scriptEngine = static_cast<SHADE::SHScriptEngine*>(SHADE::SHSystemManager::GetSystem<SHADE::SHScriptEngine>());
|
||||||
|
scriptEngine->RemoveAllScripts(testObj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SBTestScene::Render()
|
void SBTestScene::Render()
|
||||||
|
|
|
@ -103,17 +103,17 @@ namespace SHADE
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
/* Script Manipulation Functions */
|
/* Script Manipulation Functions */
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
bool SHScriptEngine::AddScript(const SHEntity& entity, const std::string_view& scriptName)
|
bool SHScriptEngine::AddScript(EntityID entity, const std::string_view& scriptName)
|
||||||
{
|
{
|
||||||
return csScriptsAdd(entity.GetEID(), scriptName.data());
|
return csScriptsAdd(entity, scriptName.data());
|
||||||
}
|
}
|
||||||
void SHScriptEngine::RemoveAllScripts(const SHEntity& entity)
|
void SHScriptEngine::RemoveAllScripts(EntityID entity)
|
||||||
{
|
{
|
||||||
csScriptsRemoveAll(entity.GetEID());
|
csScriptsRemoveAll(entity);
|
||||||
}
|
}
|
||||||
void SHScriptEngine::RemoveAllScriptsImmediately(const SHEntity& entity, bool callOnDestroy)
|
void SHScriptEngine::RemoveAllScriptsImmediately(EntityID entity, bool callOnDestroy)
|
||||||
{
|
{
|
||||||
csScriptsRemoveAllImmediately(entity.GetEID(), callOnDestroy);
|
csScriptsRemoveAllImmediately(entity, callOnDestroy);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -116,14 +116,14 @@ namespace SHADE
|
||||||
/// True if successfully added. False otherwise with the error logged to the
|
/// True if successfully added. False otherwise with the error logged to the
|
||||||
/// console.
|
/// console.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
bool AddScript(const SHEntity& entity, const std::string_view& scriptName);
|
bool AddScript(EntityID entity, const std::string_view& scriptName);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Removes all Scripts attached to the specified Entity. Does not do anything
|
/// Removes all Scripts attached to the specified Entity. Does not do anything
|
||||||
/// if the specified Entity is invalid or does not have any Scripts
|
/// if the specified Entity is invalid or does not have any Scripts
|
||||||
/// attached.
|
/// attached.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="entity">The entity to remove the scripts from.</param>
|
/// <param name="entity">The entity to remove the scripts from.</param>
|
||||||
void RemoveAllScripts(const SHEntity& entity);
|
void RemoveAllScripts(EntityID entity);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Removes all Scripts attached to the specified Entity. Unlike
|
/// Removes all Scripts attached to the specified Entity. Unlike
|
||||||
/// RemoveAllScripts(), this removes all the scripts immediately.
|
/// RemoveAllScripts(), this removes all the scripts immediately.
|
||||||
|
@ -135,7 +135,7 @@ namespace SHADE
|
||||||
/// Whether or not to call OnDestroy on the scripts. This is ignored if not in
|
/// Whether or not to call OnDestroy on the scripts. This is ignored if not in
|
||||||
/// play mode.
|
/// play mode.
|
||||||
/// </param>
|
/// </param>
|
||||||
void RemoveAllScriptsImmediately(const SHEntity& entity, bool callOnDestroy);
|
void RemoveAllScriptsImmediately(EntityID entity, bool callOnDestroy);
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Script Serialisation Functions */
|
/* Script Serialisation Functions */
|
||||||
|
|
Loading…
Reference in New Issue