You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
o3de/Gems/LmbrCentral/Code/Source/Audio/EditorAudioTriggerComponent...

71 lines
4.2 KiB
C++

/*
* Copyright (c) Contributors to the Open 3D Engine Project
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "LmbrCentral_precompiled.h"
#include "EditorAudioTriggerComponent.h"
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Serialization/SerializeContext.h>
namespace LmbrCentral
{
//=========================================================================
void EditorAudioTriggerComponent::Reflect(AZ::ReflectContext* context)
{
auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<EditorAudioTriggerComponent, EditorComponentBase>()
->Version(1)
->Field("Play Trigger", &EditorAudioTriggerComponent::m_defaultPlayTrigger)
->Field("Stop Trigger", &EditorAudioTriggerComponent::m_defaultStopTrigger)
->Field("Obstruction Type", &EditorAudioTriggerComponent::m_obstructionType)
->Field("Plays Immediately", &EditorAudioTriggerComponent::m_playsImmediately)
->Field("Send Finished Event", &EditorAudioTriggerComponent::m_notifyWhenTriggerFinishes)
;
if (auto editContext = serializeContext->GetEditContext())
{
editContext->Enum<Audio::ObstructionType>("Obstruction Type", "The types of ray-casts available for obstruction and occlusion")
->Value("Ignore", Audio::ObstructionType::Ignore)
->Value("SingleRay", Audio::ObstructionType::SingleRay)
->Value("MultiRay", Audio::ObstructionType::MultiRay)
;
editContext->Class<EditorAudioTriggerComponent>("Audio Trigger", "The Audio Trigger component provides Audio Translation Layer (ATL) triggers for play/stop functionality and on-demand execution")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Category, "Audio")
->Attribute(AZ::Edit::Attributes::Icon, "Icons/Components/AudioTrigger.svg")
->Attribute(AZ::Edit::Attributes::ViewportIcon, "Icons/Components/Viewport/AudioTrigger.png")
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game", 0x232b318c))
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->Attribute(AZ::Edit::Attributes::HelpPageURL, "https://docs.o3de.org/docs/user-guide/components/reference/audio-trigger/")
->DataElement("AudioControl", &EditorAudioTriggerComponent::m_defaultPlayTrigger, "Default 'play' Trigger", "The default ATL Trigger control used by 'Play'")
->DataElement("AudioControl", &EditorAudioTriggerComponent::m_defaultStopTrigger, "Default 'stop' Trigger", "The default ATL Trigger control used by 'Stop'")
->DataElement(AZ::Edit::UIHandlers::ComboBox, &EditorAudioTriggerComponent::m_obstructionType, "Obstruction Type", "Ray-casts used in calculation of obstruction and occlusion")
->DataElement(AZ::Edit::UIHandlers::Default, &EditorAudioTriggerComponent::m_playsImmediately, "Plays immediately", "Play when this component is Activated")
->DataElement(AZ::Edit::UIHandlers::Default, &EditorAudioTriggerComponent::m_notifyWhenTriggerFinishes, "Send Finished Event", "Send a notification event when the trigger finishes")
;
}
}
}
//=========================================================================
EditorAudioTriggerComponent::EditorAudioTriggerComponent()
{
m_defaultPlayTrigger.m_propertyType = AzToolsFramework::AudioPropertyType::Trigger;
m_defaultStopTrigger.m_propertyType = AzToolsFramework::AudioPropertyType::Trigger;
}
//=========================================================================
void EditorAudioTriggerComponent::BuildGameEntity(AZ::Entity* gameEntity)
{
gameEntity->CreateComponent<AudioTriggerComponent>(m_defaultPlayTrigger.m_controlName, m_defaultStopTrigger.m_controlName, m_obstructionType, m_playsImmediately, m_notifyWhenTriggerFinishes);
}
} // namespace LmbrCentral