1#include "AudioFunctions.h"
4#include "Bridge/FieldSetter.h"
5#include "ExtensionRegistry.h"
6#include "Services/Services.h"
8#include "AudioSystem.h"
10#include "SoundManager.h"
14ResourceId loadSound(BridgeContext * ctx,
const char * resourceName,
int )
16 auto context =
static_cast<Context*
>(ctx);
21 loadInfo.
handle = soundManager->create();
25 static_cast<void>(soundManager->loadResource(&loadInfo));
30void setSoundField(BridgeContext * ctx, EntityId entityId,
const ComponentId componentId,
const FieldId fieldId,
const ResourceId resourceId)
32 auto context =
static_cast<Context*
>(ctx);
35 auto sound = soundManager->
getHandle(resourceId);
37 auto field = Cogs::getField<SoundHandle>(context, entityId, componentId, fieldId);
42void playSound(BridgeContext * ctx, EntityId entityId,
const ComponentId )
44 auto context =
static_cast<Context*
>(ctx);
45 const Entity* entity = context->store->getEntityPtr(entityId);
55 AudioSystem* audioSystem = ExtensionRegistry::getExtensionSystem<AudioSystem>(context);
59 if (data.state == AudioState::Playing || data.state == AudioState::Stopped) {
60 data.state = AudioState::StartPlaying;
Container for components, providing composition of dynamic entities.
T * getComponent() const
Get a pointer to the first component implementing the given type in the entity.
A Context instance contains all the services, systems and runtime components needed to use Cogs.
std::unique_ptr< class Services > services
Services.
ResourceId getNextResourceId() override
Get the next unique resource id.
ResourceHandle getHandle(const ResourceId id) const
Get a resource handle to the resource with the given id.
Contains the Engine, Renderer, resource managers and other systems needed to run Cogs....
std::string resourcePath
Resource path. Used to locate resource.
ResourceId resourceId
Unique resource identifier. Must be unique among resources of the same kind.
ResourceHandleBase handle
Handle to resource structure for holding actual resource data.