ezEngine  Milestone 9
ezWorldReader Class Reference

Reads a world description from a stream. Allows to instantiate that world multiple times in different locations and different ezWorld's. More...

#include <WorldReader.h>

Public Member Functions

void ReadWorldDescription (ezStreamReader &stream)
 Reads all information about the world from the given stream. More...
 
void InstantiateWorld (ezWorld &world, const ezUInt16 *pOverrideTeamID=nullptr)
 Creates one instance of the world that was previously read by ReadWorldDescription(). More...
 
void InstantiatePrefab (ezWorld &world, const ezTransform &rootTransform, ezGameObjectHandle hParent, ezHybridArray< ezGameObject *, 8 > *out_CreatedRootObjects, ezHybridArray< ezGameObject *, 8 > *out_CreatedChildObjects, const ezUInt16 *pOverrideTeamID)
 Creates one instance of the world that was previously read by ReadWorldDescription(). More...
 
ezStreamReaderGetStream () const
 Gives access to the stream of data. Use this inside component deserialization functions to read data.
 
ezGameObjectHandle ReadGameObjectHandle ()
 Used during component deserialization to read a handle to a game object.
 
void ReadComponentHandle (ezComponentHandle *out_hComponent)
 Used during component deserialization to read a handle to a component. More...
 
ezUInt32 GetComponentTypeVersion (const ezRTTI *pRtti) const
 Used during component deserialization to query the actual version number with which the given component type was written. The version number is given through the EZ_BEGIN_COMPONENT_TYPE macro. Whenever the serialization of a component changes, that number should be increased.
 
void ClearAndCompact ()
 Clears all data.
 
ezUInt64 GetHeapMemoryUsage () const
 Returns the amount of bytes that are currently allocated on the heap.
 

Detailed Description

Reads a world description from a stream. Allows to instantiate that world multiple times in different locations and different ezWorld's.

The reader will ignore unknown component types and skip them during instantiation.

Member Function Documentation

◆ InstantiatePrefab()

void ezWorldReader::InstantiatePrefab ( ezWorld world,
const ezTransform rootTransform,
ezGameObjectHandle  hParent,
ezHybridArray< ezGameObject *, 8 > *  out_CreatedRootObjects,
ezHybridArray< ezGameObject *, 8 > *  out_CreatedChildObjects,
const ezUInt16 *  pOverrideTeamID 
)

Creates one instance of the world that was previously read by ReadWorldDescription().

Parameters
rootTransformis an additional transform that is applied to all root objects.
hParentallows to attach the newly created objects immediately to a parent
out_CreatedRootObjectsIf this is valid, all pointers the to created root objects are stored in this array

If pOverrideTeamID is not null, every instantiated game object will get it passed in as its new value. This can be used to identify that the object belongs to a specific player or team.

◆ InstantiateWorld()

void ezWorldReader::InstantiateWorld ( ezWorld world,
const ezUInt16 *  pOverrideTeamID = nullptr 
)

Creates one instance of the world that was previously read by ReadWorldDescription().

This is identical to calling InstantiatePrefab() with identity values, however, it is a bit more efficient, as unnecessary computations are skipped.

If pOverrideTeamID is not null, every instantiated game object will get it passed in as its new value. This can be used to identify that the object belongs to a specific player or team.

◆ ReadComponentHandle()

void ezWorldReader::ReadComponentHandle ( ezComponentHandle out_hComponent)

Used during component deserialization to read a handle to a component.

The handle might not have been created at this point. Therefore all such reads are queued and fulfilled at the very end of the reading process. Therefore the ezComponentHandle pointer must stay valid throughout the deserialization process.

◆ ReadWorldDescription()

void ezWorldReader::ReadWorldDescription ( ezStreamReader stream)

Reads all information about the world from the given stream.

Call this once to populate ezWorldReader with information how to instantiate the world. Afterwards stream can be deleted. Call InstantiateWorld() or InstantiatePrefab() afterwards as often as you like to actually get an objects into an ezWorld.


The documentation for this class was generated from the following files: