Cogs.Core
HeightMapExtension.cpp
1#include <Context.h>
2#include <ExtensionRegistry.h>
3#include <Resources/ResourceStore.h>
4#include <ResourceManifest.h>
5#include <Serialization/EntityReader.h>
6
7#include "DataSet2DComponent.h"
8#include "HeightMapComponent.h"
9#include "HeightMapSystem.h"
10
11namespace Cogs::Core::HeightMap
12{
14 {
15 HeightMapExtension() { ExtensionRegistry::add(this, COGS_CORE_VERSION_STRING); }
16
17 bool initializeStatic() override;
18 bool initialize(Context* context) override;
19 const char* getExtensionKey() const override { return "HeightMap"; }
20
21 } HeightMapExtension;
22}
23
25{
26 DataSet2DComponent::registerType();
27 HeightMapComponent::registerType();
28 return true;
29}
30
32{
33 context->registerDynamicComponentType("DataSet2DComponent");
34
35 readEntityDefinition(R"(
36{ "name": "DataSet2D",
37 "components": [
38 "DataSet2DComponent"
39 ]
40})"
41, context->store);
42
43 readEntityDefinition(R"(
44{ "name": "HeightMap",
45 "components": [
46 "TransformComponent",
47 "SceneComponent",
48 "HeightMapComponent",
49 "MeshComponent",
50 "SubMeshRenderComponent",
51 "MaterialComponent"
52 ]
53})"
54, context->store);
55
56 ExtensionRegistry::registerExtensionSystem<HeightMapSystem>(context, SystemPriority::Geometry, 128);
57 return true;
58}
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Definition: Context.h:83
void registerDynamicComponentType(const StringView &typeName)
Register a dynamic component type with the given typeName.
Definition: Context.cpp:380
class EntityStore * store
Entity store.
Definition: Context.h:231
static void add(Extension *extension, StringView version)
Adds the given extension to the registry, ensuring the initialization methods are called at appropria...
Defines an extension to Cogs.Core and provides methods to override in order to initialize extension c...
bool initialize(Context *context) override
Initialize extension for the given context.
bool initializeStatic() override
Initialize extension statically.
const char * getExtensionKey() const override
Get the extensions unique key, used to check for extension presence and retrieve extension specific d...
@ Geometry
Run at the time geometry data is updated.
Definition: Engine.h:70