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{
33public:
34 struct Template
35 {
37 MemDb::RowId row; // row in blueprint table
39 };
40
42 static ManagerAPI Create();
44 static void Destroy();
46 static void SetBlueprintsFilename(const Util::String& name, const Util::String& folder);
50 static TemplateId const GetTemplateId(Util::StringAtom name);
52 static Util::StringAtom const GetTemplateName(TemplateId const templateId);
55
57 EntityMapping Instantiate(World* const world, BlueprintId blueprint);
59 EntityMapping Instantiate(World* const world, TemplateId templateId);
60
61private:
66
68 static void OnActivate();
69
71 bool ParseBlueprint(Util::String const& blueprintsPath);
73 bool LoadTemplateFolder(Util::String const& path);
75 bool ParseTemplate(Util::String const& templatePath);
77 void SetupBlueprints();
80
85
87 struct Blueprint
88 {
89 // this is setup when calling SetupCategories
92 // these are created by ParseBlueprints()
96 };
97
99
102
104
107
110
113};
114
115} // 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:179
__DeclareSingleton(BlueprintManager)
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:280
static Util::String templatesFolder
Definition blueprintmanager.h:112
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:423
MemDb::TableId CreateCategory(World *const world, BlueprintId bid)
create a table in the world db
Definition blueprintmanager.cc:474
BlueprintManager()
constructor
Definition blueprintmanager.cc:52
Ids::IdGenerationPool templateIdPool
Definition blueprintmanager.h:103
static Util::String blueprintFolder
Definition blueprintmanager.h:111
static void Destroy()
Destroy the singleton.
Definition blueprintmanager.cc:43
static Util::Array< Template > const & ListTemplates()
Definition blueprintmanager.cc:414
~BlueprintManager()
destructor
Definition blueprintmanager.cc:68
Util::HashTable< Util::StringAtom, TemplateId > templateMap
maps from template name to template id
Definition blueprintmanager.h:106
Util::Array< Template > templates
Definition blueprintmanager.h:98
bool LoadTemplateFolder(Util::String const &path)
load a template folder
Definition blueprintmanager.cc:154
static TemplateId const GetTemplateId(Util::StringAtom name)
get a template id
Definition blueprintmanager.cc:300
Util::Array< Blueprint > blueprints
contains all blueprints and their information.
Definition blueprintmanager.h:101
bool ParseBlueprint(Util::String const &blueprintsPath)
parse entity blueprints file
Definition blueprintmanager.cc:101
static void OnActivate()
called when attached to game server. Needs to be attached after categorymanager
Definition blueprintmanager.cc:77
static Util::StringAtom const GetTemplateName(TemplateId const templateId)
get template name
Definition blueprintmanager.cc:404
void SetupBlueprints()
setup blueprint database
Definition blueprintmanager.cc:318
static BlueprintId const GetBlueprintId(Util::StringAtom name)
get a blueprint id
Definition blueprintmanager.cc:290
Util::HashTable< Util::StringAtom, BlueprintId > blueprintMap
maps from blueprint name to blueprint id, which is the index in the blueprints array.
Definition blueprintmanager.h:109
static ManagerAPI Create()
Create the singleton.
Definition blueprintmanager.cc:29
Definition world.h:49
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
Definition orientation.h:7
Definition category.h:17
an entity blueprint
Definition blueprintmanager.h:88
Util::Array< ComponentEntry > components
contains all the components for this blueprint
Definition blueprintmanager.h:95
Util::StringAtom name
Definition blueprintmanager.h:93
MemDb::TableId tableId
The blueprint table. Contains all templates for the blueprint.
Definition blueprintmanager.h:91
Definition blueprintmanager.h:82
Util::StringAtom name
Definition blueprintmanager.h:83
Definition blueprintmanager.h:35
Util::StringAtom name
Definition blueprintmanager.h:38
MemDb::RowId row
Definition blueprintmanager.h:37
BlueprintId bid
Definition blueprintmanager.h:36
Maps an entity to a table and instance id.
Definition entity.h:81
A Manager is just a bundle of function pointers to static or global functions that is called by the G...
Definition manager.h:33
Definition category.h:18
row identifier
Definition tableid.h:18
Table identifier.
Definition tableid.h:14
Nebula's universal string class.
Definition String.cs:8