Nebula
Loading...
Searching...
No Matches
BaseGameFeature::LevelParser Class Reference

#include <levelparser.h>

Detailed Description

Base class for level parsing.

Entity format is defined as:

{
"level": {
"version": "100"
"entities": {
"[GUID]": {
"name": String,
"components": {
"ComponentName1": VALUE,
"ComponentName2": {
"FieldName1": VALUE,
"FieldName2": VALUE
}
},
},
"[GUID]": {
...
}
}
}
}
Todo
This class is a (working) mess right now, and should be refactored. An idea is to first load the json into an intermediate format/struct that contains all the loaded entities, not as actual entities but as smaller objects with kvp properties. This would require us to rewrite serialization somewhat, but we might gain quite a bit of flexibility from it if we move away from the json reader directly. This would be similar to how we parse and use gltfs. This would also make it easier to load subscenes, as they would be parsed directly into this structure/format.

(C) 2024 Individual contributors, see AUTHORS file

Inherits Core::RefCounted.

Public Member Functions

 LevelParser ()
 constructor
 
virtual ~LevelParser ()
 destructor
 
void SetWorld (Game::World *world)
 Set the world that we want to load the levels into.
 
Util::Array< Game::EntityLoadJsonLevel (const Ptr< IO::JsonReader > &reader)
 Loads a level from a json file in work:levels.
 
- Public Member Functions inherited from Core::RefCounted
 RefCounted ()
 constructor
 
int GetRefCount () const
 get the current refcount
 
void AddRef ()
 increment refcount by one
 
void Release ()
 decrement refcount and destroy object if refcount is zero
 
bool IsInstanceOf (const Rtti &rtti) const
 return true if this object is instance of given class
 
bool IsInstanceOf (const Util::String &className) const
 return true if this object is instance of given class by string
 
bool IsInstanceOf (const Util::FourCC &classFourCC) const
 return true if this object is instance of given class by fourcc
 
bool IsA (const Rtti &rtti) const
 return true if this object is instance of given class, or a derived class
 
bool IsA (const Util::String &rttiName) const
 return true if this object is instance of given class, or a derived class, by string
 
bool IsA (const Util::FourCC &rttiFourCC) const
 return true if this object is instance of given class, or a derived class, by fourcc
 
const Util::StringGetClassName () const
 get the class name
 
Util::FourCC GetClassFourCC () const
 get the class FourCC code
 

Protected Member Functions

Game::Entity LoadEntity (const Ptr< IO::JsonReader > &reader)
 parse a single object
 
void LoadComponents (const Ptr< IO::JsonReader > &reader, Game::Entity entity)
 parse all components for an entity
 
virtual void BeginLoad ()
 called at beginning of load
 
virtual void AddEntity (Game::Entity entity, Util::Guid const &guid)
 add entity
 
virtual void SetName (Game::Entity entity, const Util::String &name)
 set entity name
 
virtual void CommitEntity (Game::Entity entity)
 entity loaded completely
 
virtual void CommitLevel ()
 parsing done
 
- Protected Member Functions inherited from Core::RefCounted
virtual ~RefCounted ()
 destructor (called when refcount reaches zero)
 

Private Member Functions

 __DeclareClass (LevelParser)
 

Private Attributes

Util::Array< Util::StringinvalidAttrs
 
Util::HashTable< Util::Guid, Game::EntityguidToEntity
 
Game::Worldworld
 

Additional Inherited Members

- Static Public Member Functions inherited from Core::RefCounted
static void DumpRefCountingLeaks ()
 dump refcounting leaks, call at end of application (NEBULA_DEBUG builds only!)
 

Constructor & Destructor Documentation

◆ LevelParser()

BaseGameFeature::LevelParser::LevelParser ( )

constructor

◆ ~LevelParser()

BaseGameFeature::LevelParser::~LevelParser ( )
virtual

destructor

Member Function Documentation

◆ __DeclareClass()

BaseGameFeature::LevelParser::__DeclareClass ( LevelParser )
private

◆ AddEntity()

virtual void BaseGameFeature::LevelParser::AddEntity ( Game::Entity entity,
Util::Guid const & guid )
inlineprotectedvirtual

add entity

◆ BeginLoad()

virtual void BaseGameFeature::LevelParser::BeginLoad ( )
inlineprotectedvirtual

called at beginning of load

◆ CommitEntity()

virtual void BaseGameFeature::LevelParser::CommitEntity ( Game::Entity entity)
inlineprotectedvirtual

entity loaded completely

◆ CommitLevel()

virtual void BaseGameFeature::LevelParser::CommitLevel ( )
inlineprotectedvirtual

parsing done

◆ LoadComponents()

void BaseGameFeature::LevelParser::LoadComponents ( const Ptr< IO::JsonReader > & reader,
Game::Entity entity )
protected

parse all components for an entity

◆ LoadEntity()

Game::Entity BaseGameFeature::LevelParser::LoadEntity ( const Ptr< IO::JsonReader > & reader)
protected

parse a single object

◆ LoadJsonLevel()

Util::Array< Game::Entity > BaseGameFeature::LevelParser::LoadJsonLevel ( const Ptr< IO::JsonReader > & reader)

Loads a level from a json file in work:levels.

◆ SetName()

virtual void BaseGameFeature::LevelParser::SetName ( Game::Entity entity,
const Util::String & name )
inlineprotectedvirtual

set entity name

◆ SetWorld()

void BaseGameFeature::LevelParser::SetWorld ( Game::World * world)

Set the world that we want to load the levels into.

Member Data Documentation

◆ guidToEntity

Util::HashTable<Util::Guid, Game::Entity> BaseGameFeature::LevelParser::guidToEntity
private

◆ invalidAttrs

Util::Array<Util::String> BaseGameFeature::LevelParser::invalidAttrs
private

◆ world

Game::World* BaseGameFeature::LevelParser::world
private

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