Nebula
Loading...
Searching...
No Matches
levelextension.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
38//------------------------------------------------------------------------------
39#include "game/entity.h"
40#include "util/array.h"
41#include "util/dictionary.h"
42#include "util/string.h"
43#include "util/stringatom.h"
44
45namespace Game
46{
47
48//------------------------------------------------------------------------------
52{
53public:
58 using ApplyFunc = void(*)(Game::Entity, const char*);
59
65 using KeysFunc = void(*)(const char* text, Util::Array<Util::String>& out);
67 using MergeFunc = void(*)(const char* base, const char* over, Util::String& out);
71 using ResolveFunc = void(*)(const char* base, const Util::Array<Util::String>& keys, Util::String& out);
73 using RefContextFunc = void(*)(const char* pairs);
74
80 ApplyFunc apply = nullptr;
82 KeysFunc keys = nullptr;
83 MergeFunc merge = nullptr;
86};
87
88//------------------------------------------------------------------------------
115
116} // namespace Game
117//------------------------------------------------------------------------------
A feature's contribution to the level formats.
Definition levelextension.h:52
RefContextFunc refContext
Definition levelextension.h:85
void(*)(Game::Entity, Util::String &) CaptureFunc
Definition levelextension.h:54
MergeFunc merge
Definition levelextension.h:83
void(*)(Game::Entity, const Util::Array< Util::String > &keys, Util::String &out) CaptureKeysFunc
the text with only the named keys, which is what a linked entity writes and what a merge composes fro...
Definition levelextension.h:62
CaptureFunc capture
the text for one entity, produced from what the feature holds
Definition levelextension.h:78
void(*)(Game::Entity, const char *) ApplyFunc
the entity, put back from the text.
Definition levelextension.h:58
KeysFunc keys
Definition levelextension.h:82
void(*)(const char *base, const Util::Array< Util::String > &keys, Util::String &out) ResolveFunc
the text for the named keys, each value read from the given base text, or the field's default when th...
Definition levelextension.h:71
void(*)(const char *base, const char *over, Util::String &out) MergeFunc
what the base text gives when the keys the other text carries are put over it
Definition levelextension.h:67
void(*)(const char *pairs) RefContextFunc
the file's guid map as "guid:entityId" pairs, for the duration of one capture or apply
Definition levelextension.h:73
CaptureKeysFunc captureKeys
Definition levelextension.h:81
Util::StringAtom name
the node name the extension writes under an entity
Definition levelextension.h:76
ApplyFunc apply
one entity, put back from the text the file carried for it
Definition levelextension.h:80
ResolveFunc resolve
Definition levelextension.h:84
void(*)(const char *text, Util::Array< Util::String > &out) KeysFunc
the keys the given text carries.
Definition levelextension.h:65
Util::Dictionary< Util::StringAtom, IndexT > byName
Definition levelextension.h:113
LevelExtensionRegistry()
Definition levelextension.cc:47
static LevelExtensionRegistry * Instance()
The registry's constructor is called by the Instance() method, and nobody else.
Definition levelextension.cc:18
static void Destroy()
This static method is used to destroy the registry object and should be called right before the main ...
Definition levelextension.cc:35
static const LevelExtension * GetExtension(Util::StringAtom name)
the extension registered under a name, or null when there is none
Definition levelextension.cc:86
static void Register(const LevelExtension &extension)
register an extension. The name is what the formats use to find it again
Definition levelextension.cc:67
static const Util::Array< LevelExtension > & GetAllExtensions()
all extensions, in the order they were registered, which is the order the formats write them in
Definition levelextension.cc:101
static LevelExtensionRegistry * Singleton
Definition levelextension.h:110
Util::Array< LevelExtension > extensions
Definition levelextension.h:112
Nebula's dynamic array class.
Definition array.h:61
A collection of key/value pairs with quick value retrieval by key at roughly O(log n).
Definition dictionary.h:35
A StringAtom.
Definition stringatom.h:22
Nebula's universal string class.
Definition string.h:50
Game::EditorState.
Definition graphicsmanager.h:66
An entity is essentially just an Id with some utility functions attached.
Definition entity.h:35