Nebula
Loading...
Searching...
No Matches
Game::BlueprintManager Class Reference

#include <blueprintmanager.h>

Detailed Description

Loads the 'data:tables/blueprint.json' file and subsequently sets up categories based on the blueprints in the entity manager.

You can instantiate entities from blueprints via the entity interface.

See also
api.h
Game::EntityManager

Inherits Game::Manager.

Classes

struct  Blueprint
 an entity blueprint More...
 
struct  ComponentEntry
 

Private Member Functions

__DeclareClass(BlueprintManager) __DeclareSingleton(BlueprintManager) public BlueprintManager ()
 constructor
 
 ~BlueprintManager ()
 destructor
 
void OnActivate () override
 
void OnDeactivate () override
 called when removed from game server
 
EntityMapping Instantiate (World *const world, BlueprintId blueprint)
 create an instance from blueprint. Note that this does not tie it to an entity! It's not recommended to create entities this way.
 
EntityMapping Instantiate (World *const world, TemplateId templateId)
 create an instance from template. Note that this does not tie it to an entity! It's not recommended to create entities this way.
 
bool ParseBlueprint (Util::String const &blueprintsPath)
 parse entity blueprints file
 
bool LoadTemplateFolder (Util::String const &path)
 load a template folder
 
bool ParseTemplate (Util::String const &templatePath)
 parse blueprint template file
 
void SetupBlueprints ()
 setup blueprint database
 
MemDb::TableId CreateCategory (World *const world, BlueprintId bid)
 create a table in the world db
 

Static Private Member Functions

static void SetBlueprintsFilename (const Util::String &name, const Util::String &folder)
 set a optional blueprints.xml, which is used instead of standard blueprint.xml
 
static BlueprintId const GetBlueprintId (Util::StringAtom name)
 get a blueprint id
 
static TemplateId const GetTemplateId (Util::StringAtom name)
 get a template id
 
static Util::StringAtom const GetTemplateName (TemplateId const templateId)
 get template name
 
static Util::Array< Template > const & ListTemplates ()
 

Private Attributes

Util::Array< Template > templates
 
Util::Array< Blueprintblueprints
 contains all blueprints and their information.
 
Ids::IdGenerationPool templateIdPool
 
Util::HashTable< Util::StringAtom, TemplateIdtemplateMap
 maps from template name to template id
 
Util::HashTable< Util::StringAtom, BlueprintIdblueprintMap
 maps from blueprint name to blueprint id, which is the index in the blueprints array.
 

Static Private Attributes

static Util::String blueprintFolder
 
static Util::String templatesFolder
 

Additional Inherited Members

- 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
 
- Static Public Member Functions inherited from Core::RefCounted
static void DumpRefCountingLeaks ()
 dump refcounting leaks, call at end of application (NEBULA_DEBUG builds only!)
 
- Protected Member Functions inherited from Core::RefCounted
virtual ~RefCounted ()
 destructor (called when refcount reaches zero)
 

Constructor & Destructor Documentation

◆ BlueprintManager()

Game::BlueprintManager::BlueprintManager ( )
private

constructor

◆ ~BlueprintManager()

Game::BlueprintManager::~BlueprintManager ( )
private

destructor

Member Function Documentation

◆ CreateCategory()

MemDb::TableId Game::BlueprintManager::CreateCategory ( World *const world,
BlueprintId bid )
private

create a table in the world db

Todo
this can be optimized

◆ GetBlueprintId()

BlueprintId const Game::BlueprintManager::GetBlueprintId ( Util::StringAtom name)
staticprivate

get a blueprint id

◆ GetTemplateId()

TemplateId const Game::BlueprintManager::GetTemplateId ( Util::StringAtom name)
staticprivate

get a template id

◆ GetTemplateName()

Util::StringAtom const Game::BlueprintManager::GetTemplateName ( TemplateId const templateId)
staticprivate

get template name

◆ Instantiate() [1/2]

EntityMapping Game::BlueprintManager::Instantiate ( World *const world,
BlueprintId blueprint )
private

create an instance from blueprint. Note that this does not tie it to an entity! It's not recommended to create entities this way.

See also
Game::EntityManager
api.h

◆ Instantiate() [2/2]

EntityMapping Game::BlueprintManager::Instantiate ( World *const world,
TemplateId templateId )
private

create an instance from template. Note that this does not tie it to an entity! It's not recommended to create entities this way.

See also
Game::EntityManager
api.h

◆ ListTemplates()

Util::Array< BlueprintManager::Template > const & Game::BlueprintManager::ListTemplates ( )
staticprivate

◆ LoadTemplateFolder()

bool Game::BlueprintManager::LoadTemplateFolder ( Util::String const & path)
private

load a template folder

◆ OnActivate()

void Game::BlueprintManager::OnActivate ( )
overrideprivatevirtual

Reimplemented from Game::Manager.

◆ OnDeactivate()

void Game::BlueprintManager::OnDeactivate ( )
overrideprivatevirtual

called when removed from game server

Reimplemented from Game::Manager.

◆ ParseBlueprint()

bool Game::BlueprintManager::ParseBlueprint ( Util::String const & blueprintsPath)
private

parse entity blueprints file

This method parses the file data:tables/blueprints.json into the blueprints array.

◆ ParseTemplate()

bool Game::BlueprintManager::ParseTemplate ( Util::String const & templatePath)
private

parse blueprint template file

◆ SetBlueprintsFilename()

void Game::BlueprintManager::SetBlueprintsFilename ( const Util::String & name,
const Util::String & folder )
staticprivate

set a optional blueprints.xml, which is used instead of standard blueprint.xml

◆ SetupBlueprints()

void Game::BlueprintManager::SetupBlueprints ( )
private

setup blueprint database

Member Data Documentation

◆ blueprintFolder

Util::String Game::BlueprintManager::blueprintFolder
staticprivate

◆ blueprintMap

Util::HashTable<Util::StringAtom, BlueprintId> Game::BlueprintManager::blueprintMap
private

maps from blueprint name to blueprint id, which is the index in the blueprints array.

◆ blueprints

Util::Array<Blueprint> Game::BlueprintManager::blueprints
private

contains all blueprints and their information.

◆ templateIdPool

Ids::IdGenerationPool Game::BlueprintManager::templateIdPool
private

◆ templateMap

Util::HashTable<Util::StringAtom, TemplateId> Game::BlueprintManager::templateMap
private

maps from template name to template id

◆ templates

Util::Array<Template> Game::BlueprintManager::templates
private

◆ templatesFolder

Util::String Game::BlueprintManager::templatesFolder
staticprivate

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