1#include "ExtensionRegistry.h"
2#include "EntityDefinitions.h"
5#include "Services/Services.h"
7#include "AudioSystem.h"
8#include "AudioListenerComponent.h"
10#include "SoundManager.h"
11#include "WaveSoundLoader.h"
13#include "Serialization/ResourceReader.h"
15#include "Services/Services.h"
17#include "AudioFunctions.h"
28 Reflection::TypeDatabase::createType<SoundHandle>();
30 AudioComponent::registerType();
31 AudioListenerComponent::registerType();
33 Reflection::TypeDatabase::createType<SoundManager>();
39 auto manager = std::make_unique<SoundManager>(context);
41 auto soundManager = manager.get();
42 context->
engine->addResourceManager(std::move(manager));
44 context->
services->registerServiceReference(soundManager);
51 readerExtension.readCallback = [=](
const StringView & name,
const Value & jsonValue)
53 for (
auto & m : jsonValue.GetObject()) {
54 auto key = toKey(m.name);
57 auto sound = soundManager->loadSound(toKey(m.value));
66 auto fieldValue = field->getPtr<
SoundHandle>(component);
68 *fieldValue = soundManager->loadSound(value.value);
71 registerExtensionReader(context,
"Sound", Reflection::TypeDatabase::getType<SoundHandle>(), readerExtension);
76 } audioExtensionInstance;
A Context instance contains all the services, systems and runtime components needed to use Cogs.
std::unique_ptr< class Services > services
Services.
void registerDynamicComponentType(const StringView &typeName)
Register a dynamic component type with the given typeName.
std::unique_ptr< class Engine > engine
Engine instance.
static void add(Extension *extension, StringView version)
Adds the given extension to the registry, ensuring the initialization methods are called at appropria...
Field definition describing a single data member of a data structure.
Provides a weakly referenced view over the contents of a string.
std::string to_string() const
String conversion method.
Contains all Cogs related functionality.
const char * getExtensionKey() const override
Get the extensions unique key, used to check for extension presence and retrieve extension specific d...
bool initialize(Context *context) override
Initialize extension for the given context.
bool initializeStatic() override
Initialize extension statically.
Defines an extension to Cogs.Core and provides methods to override in order to initialize extension c...
Defines a value to apply to a field.
@ PreTransform
Run before transformations are updated.