Clean up for Behavior API
Use TObjPtr to improve null checking. Add option to clear only specific kinds of Behaviors. Fixed removal checks while ticking. Don't stop at now-null behaviors when iterating.
This commit is contained in:
parent
1e05bb2a55
commit
7efd301810
6 changed files with 88 additions and 75 deletions
|
|
@ -226,17 +226,21 @@ FSerializer& FDoomSerializer::StatePointer(const char* key, void* ptraddr, bool
|
|||
}
|
||||
|
||||
|
||||
FSerializer& Serialize(FSerializer& arc, const char* key, TMap<FName, DBehavior*>& value, TMap<FName, DBehavior*>* def)
|
||||
FSerializer& Serialize(FSerializer& arc, const char* key, TMap<FName, TObjPtr<DBehavior*>>& value, TMap<FName, TObjPtr<DBehavior*>>* def)
|
||||
{
|
||||
if (!arc.BeginObject(key))
|
||||
return arc;
|
||||
|
||||
if (arc.isWriting())
|
||||
{
|
||||
TMap<FName, DBehavior*>::Iterator it = { value };
|
||||
TMap<FName, DBehavior*>::Pair* pair = nullptr;
|
||||
TMap<FName, TObjPtr<DBehavior*>>::Iterator it = { value };
|
||||
TMap<FName, TObjPtr<DBehavior*>>::Pair* pair = nullptr;
|
||||
while (it.NextPair(pair))
|
||||
arc(pair->Key.GetChars(), pair->Value);
|
||||
{
|
||||
auto b = pair->Value.Get();
|
||||
if (b != nullptr)
|
||||
arc(pair->Key.GetChars(), b);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue