Added initial Behavior API

Allows for arbitrary behaviors to be attached to Actors in a way that doesn't require the use of Inventory tokens. This list can't be freely modified nor can it have duplicates meaning it has far better deterministic behavior than using Inventory items for this purpose.
This commit is contained in:
Boondorl 2025-01-23 10:01:11 -05:00 committed by Ricardo Luís Vaz Silva
commit bd60fd7546
6 changed files with 308 additions and 1 deletions

View file

@ -226,6 +226,33 @@ FSerializer& FDoomSerializer::StatePointer(const char* key, void* ptraddr, bool
}
FSerializer& Serialize(FSerializer& arc, const char* key, TMap<FName, DObject*>& value, TMap<FName, DObject*>* def)
{
if (!arc.BeginObject(key))
return arc;
if (arc.isWriting())
{
TMap<FName, DObject*>::Iterator it = { value };
TMap<FName, DObject*>::Pair* pair = nullptr;
while (it.NextPair(pair))
arc(pair->Key.GetChars(), pair->Value);
}
else
{
const char* k = nullptr;
while ((k = arc.GetKey()) != nullptr)
{
DObject* obj = nullptr;
arc(k, obj);
value[k] = obj;
}
}
arc.EndObject();
return arc;
}
template<> FSerializer &Serialize(FSerializer &ar, const char *key, FPolyObj *&value, FPolyObj **defval)
{