Plasma Engine  2.0
Loading...
Searching...
No Matches
WorldWriter.h
1#pragma once
2
3#include <Core/World/World.h>
4#include <Foundation/IO/Stream.h>
5#include <Foundation/Types/TagSet.h>
6
12class PL_CORE_DLL plWorldWriter
13{
14public:
18 void WriteWorld(plStreamWriter& inout_stream, plWorld& ref_world, const plTagSet* pExclude = nullptr);
19
21 void WriteObjects(plStreamWriter& inout_stream, const plDeque<const plGameObject*>& rootObjects);
22
24 void WriteObjects(plStreamWriter& inout_stream, plArrayPtr<const plGameObject*> rootObjects);
25
30 void WriteGameObjectHandle(const plGameObjectHandle& hObject);
31
36 void WriteComponentHandle(const plComponentHandle& hComponent);
37
40 plStreamWriter& GetStream() const { return *m_pStream; }
41
43 const plDeque<const plGameObject*>& GetAllWrittenRootObjects() const { return m_AllRootObjects; }
44
46 const plDeque<const plGameObject*>& GetAllWrittenChildObjects() const { return m_AllChildObjects; }
47
48private:
49 void Clear();
50 plResult WriteToStream();
51 void AssignGameObjectIndices();
52 void AssignComponentHandleIndices(const plMap<plString, const plRTTI*>& sortedTypes);
53 void IncludeAllComponentBaseTypes();
54 void IncludeAllComponentBaseTypes(const plRTTI* pRtti);
55 void Traverse(plGameObject* pObject);
56
57 plVisitorExecution::Enum ObjectTraverser(plGameObject* pObject);
58 void WriteGameObject(const plGameObject* pObject);
59 void WriteComponentTypeInfo(const plRTTI* pRtti);
60 void WriteComponentCreationData(const plDeque<const plComponent*>& components);
61 void WriteComponentSerializationData(const plDeque<const plComponent*>& components);
62
63 plStreamWriter* m_pStream = nullptr;
64 const plTagSet* m_pExclude = nullptr;
65
66 plDeque<const plGameObject*> m_AllRootObjects;
67 plDeque<const plGameObject*> m_AllChildObjects;
68 plMap<plGameObjectHandle, plUInt32> m_WrittenGameObjectHandles;
69
70 struct Components
71 {
72 plUInt16 m_uiSerializedTypeIndex = 0;
73 plDeque<const plComponent*> m_Components;
75 };
76
78};
This class encapsulates an array and it's size. It is recommended to use this class instead of plain ...
Definition ArrayPtr.h:37
Definition Deque.h:270
This class represents an object inside the world.
Definition GameObject.h:32
Definition HashTable.h:333
Definition Map.h:408
This class holds information about reflected types. Each instance represents one type that is known t...
Definition RTTI.h:30
Interface for binary out (write) streams.
Definition Stream.h:107
A dynamic collection of tags featuring fast lookups.
Definition TagSet.h:23
A world encapsulates a scene graph of game objects and various component managers and their component...
Definition World.h:22
Stores an entire plWorld in a stream.
Definition WorldWriter.h:13
const plDeque< const plGameObject * > & GetAllWrittenChildObjects() const
Returns an array containing all game object pointers that were written to the stream as child objects...
Definition WorldWriter.h:46
plStreamWriter & GetStream() const
Accesses the stream to which data is written. Use this in component serialization functions to write ...
Definition WorldWriter.h:40
const plDeque< const plGameObject * > & GetAllWrittenRootObjects() const
Returns an array containing all game object pointers that were written to the stream as root objects.
Definition WorldWriter.h:43
A handle to a component.
Definition Declarations.h:138
A handle to a game object.
Definition Declarations.h:76
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54
Enum
Definition Declarations.h:344