Minor fixes

This commit is contained in:
Wojtek Figat
2023-10-01 10:56:30 +02:00
parent af3f6d0003
commit 075f40b93a
3 changed files with 52 additions and 47 deletions

View File

@@ -190,10 +190,10 @@ void Actor::OnDeleteObject()
#endif
for (int32 i = 0; i < Children.Count(); i++)
{
auto child = Children[i];
ASSERT(child->_parent == this);
child->_parent = nullptr;
child->DeleteObject();
auto e = Children[i];
ASSERT(e->_parent == this);
e->_parent = nullptr;
e->DeleteObject();
}
#if BUILD_DEBUG
ASSERT(callsCheck == Children.Count());
@@ -206,10 +206,10 @@ void Actor::OnDeleteObject()
#endif
for (int32 i = 0; i < Scripts.Count(); i++)
{
auto script = Scripts[i];
ASSERT(script->_parent == this);
script->_parent = nullptr;
script->DeleteObject();
auto e = Scripts[i];
ASSERT(e->_parent == this);
e->_parent = nullptr;
e->DeleteObject();
}
#if BUILD_DEBUG
ASSERT(callsCheck == Scripts.Count());
@@ -401,8 +401,9 @@ Actor* Actor::GetChild(const StringView& name) const
{
for (int32 i = 0; i < Children.Count(); i++)
{
if (Children[i]->GetName() == name)
return Children[i];
auto e = Children.Get()[i];
if (e->GetName() == name)
return e;
}
return nullptr;
}
@@ -852,15 +853,17 @@ void Actor::BeginPlay(SceneBeginData* data)
// Update scripts
for (int32 i = 0; i < Scripts.Count(); i++)
{
if (!Scripts[i]->IsDuringPlay())
Scripts[i]->BeginPlay(data);
auto e = Scripts.Get()[i];
if (!e->IsDuringPlay())
e->BeginPlay(data);
}
// Update children
for (int32 i = 0; i < Children.Count(); i++)
{
if (!Children[i]->IsDuringPlay())
Children[i]->BeginPlay(data);
auto e = Children.Get()[i];
if (!e->IsDuringPlay())
e->BeginPlay(data);
}
// Fire events for scripting
@@ -891,8 +894,9 @@ void Actor::EndPlay()
// Call event deeper
for (int32 i = 0; i < Children.Count(); i++)
{
if (Children[i]->IsDuringPlay())
Children[i]->EndPlay();
auto e = Children.Get()[i];
if (e->IsDuringPlay())
e->EndPlay();
}
// Fire event for scripting
@@ -907,8 +911,9 @@ void Actor::EndPlay()
// Inform attached scripts
for (int32 i = 0; i < Scripts.Count(); i++)
{
if (Scripts[i]->IsDuringPlay())
Scripts[i]->EndPlay();
auto e = Scripts.Get()[i];
if (e->IsDuringPlay())
e->EndPlay();
}
// Cleanup managed object