Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
@@ -0,0 +1,111 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "precompiled.h"
#include <ScriptEvents/ScriptEventsGem.h>
#include <Source/Editor/ScriptEventsSystemEditorComponent.h>
#include <ScriptEvents/Components/ScriptEventReferencesComponent.h>
#include <Builder/ScriptEventsBuilderComponent.h>
#include <ScriptEvents/ScriptEventsBus.h>
#if defined(SCRIPTEVENTS_EDITOR)
namespace ScriptEvents
{
class ScriptEventsSystemComponentEditorImpl
: public ScriptEventsSystemComponentImpl
{
public:
~ScriptEventsSystemComponentEditorImpl() override
{
}
void RegisterAssetHandler() override
{
AZ::Data::AssetType assetType(azrtti_typeid<ScriptEvents::ScriptEventsAsset>());
if (AZ::Data::AssetManager::Instance().GetHandler(assetType))
{
return; // Asset Type already handled
}
m_assetHandler = AZStd::make_unique<ScriptEventsEditor::ScriptEventAssetHandler>(
ScriptEvents::ScriptEventsAsset::GetDisplayName(),
ScriptEvents::ScriptEventsAsset::GetGroup(),
ScriptEvents::ScriptEventsAsset::GetFileExtension(),
AZ::AzTypeInfo<ScriptEventsEditor::ScriptEventEditorSystemComponent>::Uuid());
AZ::Data::AssetManager::Instance().RegisterHandler(m_assetHandler.get(), assetType);
// Use AssetCatalog service to register ScriptEvent asset type and extension
AZ::Data::AssetCatalogRequestBus::Broadcast(&AZ::Data::AssetCatalogRequests::AddAssetType, assetType);
AZ::Data::AssetCatalogRequestBus::Broadcast(&AZ::Data::AssetCatalogRequests::EnableCatalogForAsset, assetType);
AZ::Data::AssetCatalogRequestBus::Broadcast(&AZ::Data::AssetCatalogRequests::AddExtension,
ScriptEvents::ScriptEventsAsset::GetFileExtension());
}
void UnregisterAssetHandler() override
{
if (m_assetHandler)
{
AZ::Data::AssetManager::Instance().UnregisterHandler(m_assetHandler.get());
m_assetHandler.reset();
}
}
AZStd::unique_ptr<AzFramework::GenericAssetHandler<ScriptEvents::ScriptEventsAsset>> m_assetHandler;
};
ScriptEventsModule::ScriptEventsModule()
: AZ::Module()
, m_systemImpl(nullptr)
{
ScriptEvents::ScriptEventModuleConfigurationRequestBus::Handler::BusConnect();
m_descriptors.insert(m_descriptors.end(), {
ScriptEventsEditor::ScriptEventEditorSystemComponent::CreateDescriptor(),
ScriptEvents::Components::ScriptEventReferencesComponent::CreateDescriptor(),
ScriptEventsBuilder::ScriptEventsBuilderComponent::CreateDescriptor(),
});
}
ScriptEventsSystemComponentImpl* ScriptEventsModule::GetSystemComponentImpl()
{
if (!m_systemImpl)
{
m_systemImpl = aznew ScriptEventsSystemComponentEditorImpl();
}
return m_systemImpl;
}
/**
* Add required SystemComponents to the SystemEntity.
*/
AZ::ComponentTypeList ScriptEventsModule::GetRequiredSystemComponents() const
{
return AZ::ComponentTypeList{
azrtti_typeid<ScriptEventsEditor::ScriptEventEditorSystemComponent >(),
};
}
}
AZ_DECLARE_MODULE_CLASS(Gem_ScriptEvents, ScriptEvents::ScriptEventsModule)
#endif
@@ -0,0 +1,248 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "precompiled.h"
#include "ScriptEventsSystemEditorComponent.h"
#include <ScriptEvents/Internal/VersionedProperty.h>
#include <AzToolsFramework/UI/PropertyEditor/GenericComboBoxCtrl.h>
#include <ScriptEvents/ScriptEventDefinition.h>
#include <ScriptEvents/ScriptEvent.h>
#include <AzCore/Component/TickBus.h>
#include <ScriptEvents/ScriptEventsBus.h>
#include <ScriptEvents/ScriptEventSystem.h>
#if defined(SCRIPTEVENTS_EDITOR)
namespace ScriptEventsEditor
{
////////////////////////////
// ScriptEventAssetHandler
////////////////////////////
ScriptEventAssetHandler::ScriptEventAssetHandler(const char* displayName, const char* group, const char* extension, const AZ::Uuid& componentTypeId, AZ::SerializeContext* serializeContext)
: AzFramework::GenericAssetHandler<ScriptEvents::ScriptEventsAsset>(displayName, group, extension, componentTypeId, serializeContext)
{
}
AZ::Data::AssetPtr ScriptEventAssetHandler::CreateAsset(const AZ::Data::AssetId& id, const AZ::Data::AssetType& type)
{
if (type != azrtti_typeid<ScriptEvents::ScriptEventsAsset>())
{
return nullptr;
}
AZ::Data::AssetPtr assetPtr = AzFramework::GenericAssetHandler<ScriptEvents::ScriptEventsAsset>::CreateAsset(id, type);
if (!AzToolsFramework::AssetEditor::AssetEditorValidationRequestBus::MultiHandler::BusIsConnectedId(id))
{
AzToolsFramework::AssetEditor::AssetEditorValidationRequestBus::MultiHandler::BusConnect(id);
}
return assetPtr;
}
AZ::Data::AssetHandler::LoadResult ScriptEventAssetHandler::LoadAssetData(
const AZ::Data::Asset<AZ::Data::AssetData>& asset,
AZStd::shared_ptr<AZ::Data::AssetDataStream> stream,
const AZ::Data::AssetFilterCB& assetLoadFilterCB)
{
AZ::Data::AssetHandler::LoadResult loadedData =
AzFramework::GenericAssetHandler<ScriptEvents::ScriptEventsAsset>::LoadAssetData(asset, stream, assetLoadFilterCB);
if (loadedData == AZ::Data::AssetHandler::LoadResult::LoadComplete)
{
ScriptEvents::ScriptEventsAsset* assetData = asset.GetAs<ScriptEvents::ScriptEventsAsset>();
if (assetData)
{
auto busIter = m_previousEbusNames.find(asset.GetId());
bool registerBus = true;
if (busIter != m_previousEbusNames.end())
{
if (busIter->second.m_version < assetData->m_definition.GetVersion())
{
ScriptEvents::Internal::Utils::DestroyScriptEventBehaviorEBus(busIter->second.m_previousName);
m_previousEbusNames.erase(busIter);
}
else
{
registerBus = false;
}
}
if (registerBus)
{
// LoadAssetData is being called from an Asset system thread,
// we need to complete registering with the BehaviorContext in the main thread
auto registerBusFn = [this, assetData, asset]()
{
if (ScriptEvents::Internal::Utils::ConstructAndRegisterScriptEventBehaviorEBus(assetData->m_definition))
{
PreviousNameSettings previousSettings;
previousSettings.m_previousName = assetData->m_definition.GetName().c_str();
previousSettings.m_version = assetData->m_definition.GetVersion();
m_previousEbusNames[asset.GetId()] = previousSettings;
}
};
AZ::TickBus::QueueFunction(registerBusFn);
}
}
}
return loadedData;
}
bool ScriptEventAssetHandler::SaveAssetData(const AZ::Data::Asset<AZ::Data::AssetData>& asset, AZ::IO::GenericStream* stream)
{
AZ_TracePrintf("ScriptEvent", "Trying to save Asset with ID: %s - SCRIPTEVENT", asset.Get()->GetId().ToString<AZStd::string>().c_str());
// Attempt to Save the data to a temporary stream in order to see if any
AZ::Outcome<bool, AZStd::string> outcome = AZ::Failure(AZStd::string::format("AssetEditorValidationRequests is not connected ID: %s", asset.Get()->GetId().ToString<AZStd::string>().c_str()));
// Verify that the asset is in a valid state that can be saved.
AzToolsFramework::AssetEditor::AssetEditorValidationRequestBus::EventResult(outcome, asset.Get()->GetId(), &AzToolsFramework::AssetEditor::AssetEditorValidationRequests::IsAssetDataValid, asset);
if (!outcome.IsSuccess())
{
AZ_Error("Asset Editor", false, "%s", outcome.GetError().c_str());
return false;
}
ScriptEvents::ScriptEventsAsset* assetData = asset.GetAs<ScriptEvents::ScriptEventsAsset>();
AZ_Assert(assetData, "Asset is of the wrong type.");
if (assetData && m_serializeContext)
{
return AZ::Utils::SaveObjectToStream<ScriptEvents::ScriptEventsAsset>(*stream,
m_saveAsBinary ? AZ::ObjectStream::ST_BINARY : AZ::ObjectStream::ST_XML,
assetData,
m_serializeContext);
}
return false;
}
AZ::Outcome<bool, AZStd::string> ScriptEventAssetHandler::IsAssetDataValid(const AZ::Data::Asset<AZ::Data::AssetData>& asset)
{
ScriptEvents::ScriptEventsAsset* assetData = asset.GetAs<ScriptEvents::ScriptEventsAsset>();
if (!assetData)
{
return AZ::Failure(AZStd::string::format("Unable to validate asset with id: %s it has not been registered with the Script Event system component.", asset.GetId().ToString<AZStd::string>().c_str()));
}
const ScriptEvents::ScriptEvent* definition = &assetData->m_definition;
AZ_Assert(definition, "The AssetData should have a valid definition");
return definition->Validate();
}
void ScriptEventAssetHandler::PreAssetSave(AZ::Data::Asset<AZ::Data::AssetData> asset)
{
ScriptEvents::ScriptEventsAsset* scriptEventAsset = asset.GetAs<ScriptEvents::ScriptEventsAsset>();
scriptEventAsset->m_definition.IncreaseVersion();
}
void ScriptEventAssetHandler::BeforePropertyEdit(AzToolsFramework::InstanceDataNode* node, AZ::Data::Asset<AZ::Data::AssetData> asset)
{
ScriptEventData::VersionedProperty* property = nullptr;
AzToolsFramework::InstanceDataNode* parent = node;
while (parent)
{
if (parent->GetClassMetadata()->m_typeId == azrtti_typeid<ScriptEventData::VersionedProperty>())
{
property = static_cast<ScriptEventData::VersionedProperty*>(parent->GetInstance(0));
break;
}
parent = parent->GetParent();
}
if (property)
{
property->OnPropertyChange();
}
}
void ScriptEventEditorSystemComponent::Reflect(AZ::ReflectContext* context)
{
if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
{
serialize->Class<ScriptEventEditorSystemComponent, AZ::Component>()
->Version(3)
->Attribute(AZ::Edit::Attributes::SystemComponentTags, AZStd::vector<AZ::Crc32>({ AZ_CRC("AssetBuilder", 0xc739c7d7) }));
;
}
using namespace ScriptEvents;
ScriptEventData::VersionedProperty::Reflect(context);
Parameter::Reflect(context);
Method::Reflect(context);
ScriptEvent::Reflect(context);
ScriptEventsAsset::Reflect(context);
ScriptEventsAssetRef::Reflect(context);
ScriptEventsAssetPtr::Reflect(context);
}
void ScriptEventEditorSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
provided.push_back(AZ_CRC("ScriptEventsService", 0x6897c23b));
}
void ScriptEventEditorSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
{
incompatible.push_back(AZ_CRC("ScriptEventsService", 0x6897c23b));
}
////////////////////
// SystemComponent
////////////////////
void ScriptEventEditorSystemComponent::Activate()
{
using namespace ScriptEvents;
ScriptEventsSystemComponentImpl* moduleConfiguration = nullptr;
ScriptEventModuleConfigurationRequestBus::BroadcastResult(moduleConfiguration, &ScriptEventModuleConfigurationRequests::GetSystemComponentImpl);
if (moduleConfiguration)
{
moduleConfiguration->RegisterAssetHandler();
}
m_propertyHandlers.emplace_back(AzToolsFramework::RegisterGenericComboBoxHandler<ScriptEventData::VersionedProperty>());
}
void ScriptEventEditorSystemComponent::Deactivate()
{
for (auto&& propertyHandler : m_propertyHandlers)
{
AzToolsFramework::PropertyTypeRegistrationMessages::Bus::Broadcast(&AzToolsFramework::PropertyTypeRegistrationMessages::UnregisterPropertyType, propertyHandler.get());
}
m_propertyHandlers.clear();
using namespace ScriptEvents;
ScriptEventsSystemComponentImpl* moduleConfiguration = nullptr;
ScriptEventModuleConfigurationRequestBus::BroadcastResult(moduleConfiguration, &ScriptEventModuleConfigurationRequests::GetSystemComponentImpl);
if (moduleConfiguration)
{
moduleConfiguration->UnregisterAssetHandler();
}
}
}
#endif
@@ -0,0 +1,100 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include "ScriptEventsSystemComponent.h"
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
#include <AzToolsFramework/AssetEditor/AssetEditorBus.h>
#include <ScriptEvents/ScriptEventsAsset.h>
#include <AzToolsFramework/AssetEditor/AssetEditorBus.h>
#include <ScriptEvents/ScriptEventsAssetRef.h>
namespace AzToolsFramework { class PropertyHandlerBase; }
#if defined(SCRIPTEVENTS_EDITOR)
namespace ScriptEventsEditor
{
// This is the ScriptEvent asset handler used by the Asset Editor, it does additional validation that is not
// needed when saving the asset through the builder
class ScriptEventAssetHandler
: public AzFramework::GenericAssetHandler<ScriptEvents::ScriptEventsAsset>
, AzToolsFramework::AssetEditor::AssetEditorValidationRequestBus::MultiHandler
{
public:
AZ_RTTI(ScriptEventAssetHandler, "{D81DE7D5-5ED0-4D70-8364-AA986E9C490E}", AzFramework::GenericAssetHandler<ScriptEvents::ScriptEventsAsset>);
ScriptEventAssetHandler(const char* displayName, const char* group, const char* extension, const AZ::Uuid& componentTypeId = AZ::Uuid::CreateNull(), AZ::SerializeContext* serializeContext = nullptr);
AZ::Data::AssetPtr CreateAsset(const AZ::Data::AssetId& id, const AZ::Data::AssetType& type) override;
AZ::Data::AssetHandler::LoadResult LoadAssetData(
const AZ::Data::Asset<AZ::Data::AssetData>& asset,
AZStd::shared_ptr<AZ::Data::AssetDataStream> stream,
const AZ::Data::AssetFilterCB& assetLoadFilterCB) override;
bool SaveAssetData(const AZ::Data::Asset<AZ::Data::AssetData>& asset, AZ::IO::GenericStream* stream) override;
// AssetEditorValidationRequestBus::Handler
AZ::Outcome<bool, AZStd::string> IsAssetDataValid(const AZ::Data::Asset<AZ::Data::AssetData>& asset) override;
void PreAssetSave(AZ::Data::Asset<AZ::Data::AssetData> asset);
void BeforePropertyEdit(AzToolsFramework::InstanceDataNode* node, AZ::Data::Asset<AZ::Data::AssetData> asset) override;
void SetSaveAsBinary(bool saveAsBinary) { m_saveAsBinary = saveAsBinary; }
private:
struct PreviousNameSettings
{
AZStd::string m_previousName;
AZ::u32 m_version;
};
AZStd::unordered_map< AZ::Data::AssetId, PreviousNameSettings > m_previousEbusNames;
bool m_saveAsBinary;
};
class ScriptEventEditorSystemComponent
: public AZ::Component
{
public:
AZ_COMPONENT(ScriptEventEditorSystemComponent, "{8BAD5292-56C3-4657-99F2-515A2BDE23C1}");
ScriptEventEditorSystemComponent() = default;
ScriptEventEditorSystemComponent(const ScriptEventEditorSystemComponent&) = delete;
protected:
static void Reflect(AZ::ReflectContext* context);
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
////////////////////////////////////////////////////////////////////////
// AZ::Component interface implementation
void Init() override {}
void Activate() override;
void Deactivate() override;
////////////////////////////////////////////////////////////////////////
AZStd::vector<AZStd::unique_ptr<AzToolsFramework::PropertyHandlerBase>> m_propertyHandlers;
// Script Event Assets
AZStd::unordered_map<ScriptEvents::ScriptEventKey, AZStd::intrusive_ptr<ScriptEvents::Internal::ScriptEvent>> m_scriptEvents;
};
}
#endif
@@ -0,0 +1,57 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "precompiled.h"
#include "ScriptEventsSystemComponent.h"
#include <AzCore/Memory/SystemAllocator.h>
#include <ScriptEvents/ScriptEventsGem.h>
#include <ScriptEvents/Components/ScriptEventReferencesComponent.h>
namespace ScriptEvents
{
ScriptEventsModule::ScriptEventsModule()
: AZ::Module()
, m_systemImpl(nullptr)
{
ScriptEventModuleConfigurationRequestBus::Handler::BusConnect();
m_descriptors.insert(m_descriptors.end(), {
ScriptEvents::ScriptEventsSystemComponent::CreateDescriptor(),
ScriptEvents::Components::ScriptEventReferencesComponent::CreateDescriptor(),
});
}
ScriptEventsSystemComponentImpl* ScriptEventsModule::GetSystemComponentImpl()
{
if (!m_systemImpl)
{
m_systemImpl = aznew ScriptEventsSystemComponentRuntimeImpl();
}
return m_systemImpl;
}
/**
* Add required SystemComponents to the SystemEntity.
*/
AZ::ComponentTypeList ScriptEventsModule::GetRequiredSystemComponents() const
{
return AZ::ComponentTypeList{
azrtti_typeid<ScriptEvents::ScriptEventsSystemComponent>(),
};
}
}
AZ_DECLARE_MODULE_CLASS(Gem_ScriptEvents, ScriptEvents::ScriptEventsModule)
@@ -0,0 +1,138 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "precompiled.h"
#include "ScriptEventsSystemComponent.h"
#include <AzCore/Component/ComponentApplicationBus.h>
#include <AzCore/Component/EntityId.h>
#include <AzCore/EBus/EBus.h>
#include <AzCore/Math/Color.h>
#include <AzCore/RTTI/TypeInfo.h>
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/std/smart_ptr/make_shared.h>
#include <AzCore/std/string/string.h>
#include <AzCore/std/sort.h>
#include <AzFramework/Asset/GenericAssetHandler.h>
#include <ScriptEvents/ScriptEventsAssetRef.h>
#include <ScriptEvents/ScriptEventDefinition.h>
#include <ScriptEvents/ScriptEventFundamentalTypes.h>
namespace ScriptEvents
{
void ScriptEventsSystemComponent::Reflect(AZ::ReflectContext* context)
{
using namespace ScriptEvents;
if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
{
serialize->Class<ScriptEventsSystemComponent, AZ::Component>()
->Version(1)
// ScriptEvents avoids a use dependency on the AssetBuilderSDK. Therefore the Crc is used directly to register this component with the Gem builder
->Attribute(AZ::Edit::Attributes::SystemComponentTags, AZStd::vector<AZ::Crc32>({ AZ_CRC("AssetBuilder", 0xc739c7d7) }));
;
}
ScriptEventData::VersionedProperty::Reflect(context);
Parameter::Reflect(context);
Method::Reflect(context);
ScriptEvent::Reflect(context);
ScriptEvents::ScriptEventsAsset::Reflect(context);
ScriptEvents::ScriptEventsAssetRef::Reflect(context);
ScriptEvents::ScriptEventsAssetPtr::Reflect(context);
}
void ScriptEventsSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
provided.push_back(AZ_CRC("ScriptEventsService", 0x6897c23b));
}
void ScriptEventsSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
{
incompatible.push_back(AZ_CRC("ScriptEventsService", 0x6897c23b));
}
void ScriptEventsSystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
{
required.push_back(AZ_CRC("AssetDatabaseService", 0x3abf5601));
}
void ScriptEventsSystemComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
{
AZ_UNUSED(dependent);
}
void ScriptEventsSystemComponent::Init()
{
}
void ScriptEventsSystemComponent::Activate()
{
ScriptEventsSystemComponentImpl* moduleConfiguration = nullptr;
ScriptEventModuleConfigurationRequestBus::BroadcastResult(moduleConfiguration, &ScriptEventModuleConfigurationRequests::GetSystemComponentImpl);
if (moduleConfiguration)
{
moduleConfiguration->RegisterAssetHandler();
}
}
void ScriptEventsSystemComponent::Deactivate()
{
for (auto& asset : m_scriptEvents)
{
asset.second.reset();
}
m_scriptEvents.clear();
ScriptEventsSystemComponentImpl* moduleConfiguration = nullptr;
ScriptEventModuleConfigurationRequestBus::BroadcastResult(moduleConfiguration, &ScriptEventModuleConfigurationRequests::GetSystemComponentImpl);
if (moduleConfiguration)
{
moduleConfiguration->UnregisterAssetHandler();
}
}
void ScriptEventsSystemComponentRuntimeImpl::RegisterAssetHandler()
{
AZ::Data::AssetType assetType(azrtti_typeid<ScriptEvents::ScriptEventsAsset>());
if (AZ::Data::AssetManager::Instance().GetHandler(assetType))
{
return; // Asset Type already handled
}
m_assetHandler = AZStd::make_unique<ScriptEventAssetRuntimeHandler>(ScriptEvents::ScriptEventsAsset::GetDisplayName(),
ScriptEvents::ScriptEventsAsset::GetGroup(), ScriptEvents::ScriptEventsAsset::GetFileExtension(),
AZ::AzTypeInfo<ScriptEvents::ScriptEventsSystemComponent>::Uuid());
AZ::Data::AssetManager::Instance().RegisterHandler(m_assetHandler.get(), assetType);
// Use AssetCatalog service to register ScriptCanvas asset type and extension
AZ::Data::AssetCatalogRequestBus::Broadcast(&AZ::Data::AssetCatalogRequests::AddAssetType, assetType);
AZ::Data::AssetCatalogRequestBus::Broadcast(&AZ::Data::AssetCatalogRequests::EnableCatalogForAsset, assetType);
AZ::Data::AssetCatalogRequestBus::Broadcast(&AZ::Data::AssetCatalogRequests::AddExtension,
ScriptEvents::ScriptEventsAsset::GetFileExtension());
}
void ScriptEventsSystemComponentRuntimeImpl::UnregisterAssetHandler()
{
AZ::Data::AssetManager::Instance().UnregisterHandler(m_assetHandler.get());
m_assetHandler.reset();
}
}
@@ -0,0 +1,71 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/Component/Component.h>
#include <AzCore/std/string/string.h>
#include <AzCore/Asset/AssetCommon.h>
#include <AzCore/std/smart_ptr/unique_ptr.h>
#include <AzCore/std/smart_ptr/intrusive_ptr.h>
#include <ScriptEvents/ScriptEvent.h>
#include <ScriptEvents/ScriptEventsBus.h>
#include <ScriptEvents/ScriptEventsAsset.h>
#include <ScriptEvents/ScriptEventDefinition.h>
#include <ScriptEvents/ScriptEventSystem.h>
namespace ScriptEvents
{
class ScriptEventsSystemComponent
: public AZ::Component
{
public:
AZ_COMPONENT(ScriptEventsSystemComponent, "{43068F27-B171-4DF4-B583-57CEF3F2AC6C}");
static void Reflect(AZ::ReflectContext* context);
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
protected:
////////////////////////////////////////////////////////////////////////
// AZ::Component interface implementation
void Init() override;
void Activate() override;
void Deactivate() override;
////////////////////////////////////////////////////////////////////////
// Script Event Assets
AZStd::unordered_map<ScriptEventKey, AZStd::intrusive_ptr<ScriptEvents::Internal::ScriptEvent>> m_scriptEvents;
};
class ScriptEventsSystemComponentRuntimeImpl
: public ScriptEventsSystemComponentImpl
{
public:
void RegisterAssetHandler() override;
void UnregisterAssetHandler() override;
AZStd::unique_ptr<ScriptEventAssetRuntimeHandler> m_assetHandler;
};
}
@@ -0,0 +1,13 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "precompiled.h"
@@ -0,0 +1,16 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/Serialization/EditContext.h>