Fixed edge cases for serialization and deserialization of scripts #218
|
@ -307,7 +307,7 @@ namespace SHADE
|
||||||
SHEventHandle SHScriptEngine::onEntityDestroyed(SHEventPtr eventPtr)
|
SHEventHandle SHScriptEngine::onEntityDestroyed(SHEventPtr eventPtr)
|
||||||
{
|
{
|
||||||
auto eventData = reinterpret_cast<const SHEventSpec<SHEntityDestroyedEvent>*>(eventPtr.get());
|
auto eventData = reinterpret_cast<const SHEventSpec<SHEntityDestroyedEvent>*>(eventPtr.get());
|
||||||
csScriptsRemoveAll(eventData->data->eid);
|
csScriptsRemoveAllImmediately(eventData->data->eid, true);
|
||||||
return eventData->handle;
|
return eventData->handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -402,8 +402,8 @@ namespace SHADE
|
||||||
System::Collections::Generic::List<Script^>^ scriptList = scripts[entity];
|
System::Collections::Generic::List<Script^>^ scriptList = scripts[entity];
|
||||||
for each (Script ^ script in scriptList)
|
for each (Script ^ script in scriptList)
|
||||||
{
|
{
|
||||||
// Call OnDestroy only if indicated and also in play mode
|
// Call OnDestroy only if indicated and also if the game has run
|
||||||
if (callOnDestroy)
|
if (callOnDestroy && Application::IsPlaying || Application::IsPaused)
|
||||||
{
|
{
|
||||||
script->OnDestroy();
|
script->OnDestroy();
|
||||||
}
|
}
|
||||||
|
@ -469,7 +469,7 @@ namespace SHADE
|
||||||
script->OnDestroy();
|
script->OnDestroy();
|
||||||
}
|
}
|
||||||
auto entity = script->Owner.GetEntity();
|
auto entity = script->Owner.GetEntity();
|
||||||
auto scriptList = scripts[script->Owner.GetEntity()];
|
auto scriptList = scripts[script->Owner.GetEntity()]; // Unable to find here
|
||||||
scriptList->Remove(script);
|
scriptList->Remove(script);
|
||||||
if (scriptList->Count <= 0)
|
if (scriptList->Count <= 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue