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

Classes

struct  Blueprint
 an entity blueprint More...
 
struct  ComponentEntry
 
struct  Template
 

Public Member Functions

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.
 

Static Public Member Functions

static ManagerAPI Create ()
 Create the singleton.
 
static void Destroy ()
 Destroy the singleton.
 
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 Member Functions

 __DeclareSingleton (BlueprintManager)
 
 BlueprintManager ()
 constructor
 
 ~BlueprintManager ()
 destructor
 
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 OnActivate ()
 called when attached to game server. Needs to be attached after categorymanager
 

Private Attributes

Util::Array< Templatetemplates
 
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
 

Constructor & Destructor Documentation

◆ BlueprintManager()

Game::BlueprintManager::BlueprintManager ( )
private

constructor

◆ ~BlueprintManager()

Game::BlueprintManager::~BlueprintManager ( )
private

destructor

Member Function Documentation

◆ __DeclareSingleton()

Game::BlueprintManager::__DeclareSingleton ( BlueprintManager )
private

◆ Create()

ManagerAPI Game::BlueprintManager::Create ( )
static

Create the singleton.

◆ CreateCategory()

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

create a table in the world db

Todo
this can be optimized

◆ Destroy()

void Game::BlueprintManager::Destroy ( )
static

Destroy the singleton.

◆ GetBlueprintId()

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

get a blueprint id

◆ GetTemplateId()

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

get a template id

◆ GetTemplateName()

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

get template name

◆ Instantiate() [1/2]

EntityMapping Game::BlueprintManager::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.

See also
Game::EntityManager
api.h

◆ Instantiate() [2/2]

EntityMapping Game::BlueprintManager::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.

See also
Game::EntityManager
api.h

◆ ListTemplates()

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

◆ LoadTemplateFolder()

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

load a template folder

◆ OnActivate()

void Game::BlueprintManager::OnActivate ( )
staticprivate

called when attached to game server. Needs to be attached after categorymanager

◆ 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 )
static

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: