Nebula
Loading...
Searching...
No Matches
blueprintmanager.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
17//------------------------------------------------------------------------------
18#include "core/refcounted.h"
19#include "core/singleton.h"
20#include "game/manager.h"
21#include "util/stringatom.h"
22#include "game/api.h"
24
25namespace Game
26{
27
28class World;
29
31{
34public:
35 struct Template
36 {
37 BlueprintId bid;
38 MemDb::RowId row; // row in blueprint table
40 };
41
46
47 void OnActivate() override;
48 void OnDeactivate() override;
50 static void SetBlueprintsFilename(const Util::String& name, const Util::String& folder);
54 static TemplateId const GetTemplateId(Util::StringAtom name);
56 static Util::StringAtom const GetTemplateName(TemplateId const templateId);
59
61 EntityMapping Instantiate(World* const world, BlueprintId blueprint);
63 EntityMapping Instantiate(World* const world, TemplateId templateId);
64
65private:
67 bool ParseBlueprint(Util::String const& blueprintsPath);
69 bool LoadTemplateFolder(Util::String const& path);
71 bool ParseTemplate(Util::String const& templatePath);
73 void SetupBlueprints();
76
81
83 struct Blueprint
84 {
85 // this is setup when calling SetupCategories
88 // these are created by ParseBlueprints()
92 };
93
95
98
100
103
106
109};
110
111} // namespace Game
The main programming interface for the Game Subsystem.
Loads the 'data:tables/blueprint.json' file and subsequently sets up categories based on the blueprin...
Definition blueprintmanager.h:31
bool ParseTemplate(Util::String const &templatePath)
parse blueprint template file
Definition blueprintmanager.cc:168
static void SetBlueprintsFilename(const Util::String &name, const Util::String &folder)
set a optional blueprints.xml, which is used instead of standard blueprint.xml
Definition blueprintmanager.cc:269
static Util::String templatesFolder
Definition blueprintmanager.h:108
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 ...
Definition blueprintmanager.cc:412
void OnActivate() override
Definition blueprintmanager.cc:29
MemDb::TableId CreateCategory(World *const world, BlueprintId bid)
create a table in the world db
Definition blueprintmanager.cc:463
__DeclareClass(BlueprintManager) __DeclareSingleton(BlueprintManager) public BlueprintManager()
constructor
Definition blueprintmanager.cc:61
Ids::IdGenerationPool templateIdPool
Definition blueprintmanager.h:99
static Util::String blueprintFolder
Definition blueprintmanager.h:107
static Util::Array< Template > const & ListTemplates()
Definition blueprintmanager.cc:403
~BlueprintManager()
destructor
Definition blueprintmanager.cc:79
Util::HashTable< Util::StringAtom, TemplateId > templateMap
maps from template name to template id
Definition blueprintmanager.h:102
Util::Array< Template > templates
Definition blueprintmanager.h:94
bool LoadTemplateFolder(Util::String const &path)
load a template folder
Definition blueprintmanager.cc:143
static TemplateId const GetTemplateId(Util::StringAtom name)
get a template id
Definition blueprintmanager.cc:289
void OnDeactivate() override
called when removed from game server
Definition blueprintmanager.cc:53
Util::Array< Blueprint > blueprints
contains all blueprints and their information.
Definition blueprintmanager.h:97
bool ParseBlueprint(Util::String const &blueprintsPath)
parse entity blueprints file
Definition blueprintmanager.cc:90
static Util::StringAtom const GetTemplateName(TemplateId const templateId)
get template name
Definition blueprintmanager.cc:393
void SetupBlueprints()
setup blueprint database
Definition blueprintmanager.cc:307
static BlueprintId const GetBlueprintId(Util::StringAtom name)
get a blueprint id
Definition blueprintmanager.cc:279
Util::HashTable< Util::StringAtom, BlueprintId > blueprintMap
maps from blueprint name to blueprint id, which is the index in the blueprints array.
Definition blueprintmanager.h:105
Definition manager.h:32
Definition world.h:50
Provides a system for creating array friendly id numbers with reuse and generations.
Definition idgenerationpool.h:43
Nebula's dynamic array class.
Definition array.h:60
Organizes key/value pairs by a hash code.
Definition hashtable.h:42
A StringAtom.
Definition stringatom.h:22
Game::EditorState.
Definition orientation.h:7
#define __DeclareSingleton(type)
Definition osxsingleton.h:24
#define __DeclareClass(type)
Definition category.h:17
an entity blueprint
Definition blueprintmanager.h:84
Util::Array< ComponentEntry > components
contains all the components for this blueprint
Definition blueprintmanager.h:91
Util::StringAtom name
Definition blueprintmanager.h:89
MemDb::TableId tableId
The blueprint table. Contains all templates for the blueprint.
Definition blueprintmanager.h:87
Definition blueprintmanager.h:78
Util::StringAtom name
Definition blueprintmanager.h:79
Maps an entity to a table and instance id.
Definition entity.h:87
Definition category.h:18
row identifier
Definition tableid.h:18
Table identifier.
Definition tableid.h:14
Nebula's universal string class.
Definition string.h:50