f648cb1fd8
* Update the FileIOAlias naming to make the cache, project root and engine root paths more clear The alias of `@root@`, `@assets@`, and `@projectplatformcache@` has been collapsed to `@projectproductassets@` The alias of `@devroot@` and `@engroot@` has been collapsed to `@engroot@` The alias of `@devassets@` and `@projectroot@` has been collapsed to `@projectroot@` Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Updated use of devassets and devroot properties in python Those properties now use projectroot and engroot Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Updating the alias @engroot@ alias path comment in each platform specific LocalFileIO_*.cpp file Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Removed hardcoded size of 9 for the product asset alias. The ResolvePath function now just appends the @projectproductassets@ alias with the input path Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Remove duplicate @projectproductassets@ check in ProcessFileTreeRequest Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Fix for typos in Hydra python test Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Updated LocalFileIO::Copy call on Windows to use the Unicode aware CopyFileW API Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Updated the AWSMetreicsGemAllocatorFixture to properly suppress asset cache write errors for Test file creation. Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Removed unneeded call to set the @projectproductasstes@ alias at the bottom of the AssetSeedManagerTest SetUp Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Added a deprecated alias map to the FileIO System When a deprecated alias is accessed, the FileIO System logs an AZ_Error and indicates the alias that should be used Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Updated python test scripts to use the projectroot binding Retrieving the AutomatedTesting project path based on "<devroot>/AutomatedTesting" has been removed. Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Updated references to devroot and devgame within the codebase The GetAbsoluteDevGameFolderPath functions has been replaced with direct call to AZ::Utils::GetProjectPath The GetAbsoluteDevRootFolderPath functions has been replaced with direct calls to AZ::Utils::GetEnginePath Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Updated <engroot>/AutomatedTesting references to projectroot Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Replaced references that assumes the project path is <engroot>/AutomatedTesting with <projectroot> in the AutomatedTesting python test Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Correct casing in emfxworkspace file Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Removed newly added AppendPathParts function Removed the Path constructors which accepts a PathIterable instance The PathIterable isn't safe to return to a user of the Path class as it might be referencing temporary paths supplied via PathView arguments Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Fixed unused parameter warning Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Undid change to the LexicallyProximate function to set the path result to the base path. It needs to return the *this path if the pathResult is empty Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Moved the LocalFileIO ConvertToAbsolutePath implementations to AZ::Utils Fixed the ConvertToAbsolutePath implementation for Unix platforms to use a buffer that is size PATH_MAX(4096 on all our supported Unix platforms). Because the buffer before was AZ::IO::MaxPathLength which as a size of 1024, this was resulting in the Unix `realpath` function smashing the stack when it converts a path to an absolute path that is longer than 1024 characters Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Updated the EditorCore.Tests to attach the AZ Environment to the EditorCore shared library that is statically loaded on launch. Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Fixed for DeprecatedAlaisesKeyVisitor Visit function causing the non string_view overloads being hidden causing a hidden base class function warning Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Changed the AWSMetricsGemMock to use a temporary for writing test assets Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Updated the LocalFileIO::ResolvePath function to use HasRootPath to determine if a path starts with a root path such as "D:", "D:/" or "/" IsAbsolute was not the corect check as the path of "D:" is a relative path. To be absolute according to the Windows the path must have a root directory. i.e "D:/" or "D:\" Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Removed absolute path comment from LocalFile_UnixLike.cpp and LocalFile_Android.cpp FindFiles implementations Updated the ConvertToAlias to supply an AZ::IO::FixedMaxPath Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Replaced usage of the @projectproductassets@ alias with @engroot@ when referring to the LmbrCentral source folder in the CopyDependencyBuilderTest and the SeedBuilderTests Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Updated the ScriptCanvas Upgrade Tool to output backed up files to the Project User Path instead of the engine root Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Fixed whitespacing issues in Application.cpp Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Remove unnecessary creation of a FixedMaxPath in the UpgradeTool.cpp Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Modified testSeedFolder variable in the SeedBuilderTests to use the @engroot@ alias instead of @projectproductassets@/.. alias when referring to the LmbrCentral Gem source path Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Updated references to the Project Asset Cache in the PythonTests. Those tests no longer use the logic `azlmbr.paths.projectroot / "Cache" / "pc"` to retrieve a path to the cache root but instead the `azlmbr.paths.projectproductassets` constant Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Fixed the FileIO Deprecated Alias test on Windows Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Removing @projectsourceassets@ alias, as it is only used once. Updated the PhysX EditorSystemComponent.cpp to query the ProjectPath form the SettingsRegistry. Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Replaced @projectproductassets@ alias with @products@ Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Rollback changes to the PhysX EditorSystemComponent.cpp The changes to use the ProjectPath from the SettingsRegistry has been implemented in PR #4497 Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
503 lines
22 KiB
C++
503 lines
22 KiB
C++
/*
|
|
* Copyright (c) Contributors to the Open 3D Engine Project.
|
|
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
*
|
|
*/
|
|
#include "LmbrCentral.h"
|
|
|
|
#include <AzCore/Component/Entity.h>
|
|
#include <AzCore/Serialization/SerializeContext.h>
|
|
#include <AzCore/RTTI/BehaviorContext.h>
|
|
#include <AzCore/std/containers/list.h>
|
|
#include <AzCore/Memory/AllocatorScope.h>
|
|
#include <AzFramework/API/ApplicationAPI.h>
|
|
#include <AzFramework/Asset/AssetCatalogBus.h>
|
|
#include <AzFramework/Metrics/MetricsPlainTextNameRegistration.h>
|
|
|
|
// Component descriptors
|
|
#include "Audio/AudioAreaEnvironmentComponent.h"
|
|
#include "Audio/AudioEnvironmentComponent.h"
|
|
#include "Audio/AudioListenerComponent.h"
|
|
#include "Audio/AudioMultiPositionComponent.h"
|
|
#include "Audio/AudioPreloadComponent.h"
|
|
#include "Audio/AudioProxyComponent.h"
|
|
#include "Audio/AudioRtpcComponent.h"
|
|
#include "Audio/AudioSwitchComponent.h"
|
|
#include "Audio/AudioSystemComponent.h"
|
|
#include "Audio/AudioTriggerComponent.h"
|
|
#include "Bundling/BundlingSystemComponent.h"
|
|
#include "Ai/NavigationComponent.h"
|
|
#include "Scripting/TagComponent.h"
|
|
#include "Scripting/SimpleStateComponent.h"
|
|
#include "Scripting/SpawnerComponent.h"
|
|
#include "Scripting/LookAtComponent.h"
|
|
#include "Scripting/RandomTimedSpawnerComponent.h"
|
|
#include "Ai/NavigationSystemComponent.h"
|
|
#include "Geometry/GeometrySystemComponent.h"
|
|
#include <Asset/AssetSystemDebugComponent.h>
|
|
|
|
// Unhandled asset types
|
|
// Material
|
|
#include "Unhandled/Material/MaterialAssetTypeInfo.h"
|
|
// Other
|
|
#include "Unhandled/Other/AudioAssetTypeInfo.h"
|
|
#include "Unhandled/Other/CharacterPhysicsAssetTypeInfo.h"
|
|
#include "Unhandled/Other/GroupAssetTypeInfo.h"
|
|
#include "Unhandled/Other/PrefabsLibraryAssetTypeInfo.h"
|
|
#include "Unhandled/Other/GameTokenAssetTypeInfo.h"
|
|
#include "Unhandled/Other/EntityPrototypeLibraryAssetTypeInfo.h"
|
|
|
|
// Texture
|
|
#include "Unhandled/Texture/SubstanceAssetTypeInfo.h"
|
|
#include "Unhandled/Texture/TextureAssetTypeInfo.h"
|
|
// Hidden
|
|
#include "Unhandled/Hidden/TextureMipmapAssetTypeInfo.h"
|
|
//UI
|
|
#include <Unhandled/UI/EntityIconAssetTypeInfo.h>
|
|
#include "Unhandled/UI/FontAssetTypeInfo.h"
|
|
#include "Unhandled/UI/UICanvasAssetTypeInfo.h"
|
|
|
|
// Asset types
|
|
#include <AzCore/Slice/SliceAsset.h>
|
|
#include <AzCore/Script/ScriptAsset.h>
|
|
#include <LmbrCentral/Rendering/MaterialAsset.h>
|
|
#include <LmbrCentral/Rendering/MeshAsset.h>
|
|
#include <LmbrCentral/Rendering/MaterialHandle.h>
|
|
|
|
// Scriptable Ebus Registration
|
|
#include "Events/ReflectScriptableEvents.h"
|
|
|
|
// Shape components
|
|
#include "Shape/SphereShapeComponent.h"
|
|
#include "Shape/DiskShapeComponent.h"
|
|
#include "Shape/AxisAlignedBoxShapeComponent.h"
|
|
#include "Shape/BoxShapeComponent.h"
|
|
#include "Shape/QuadShapeComponent.h"
|
|
#include "Shape/CylinderShapeComponent.h"
|
|
#include "Shape/CapsuleShapeComponent.h"
|
|
#include "Shape/TubeShapeComponent.h"
|
|
#include "Shape/CompoundShapeComponent.h"
|
|
#include "Shape/SplineComponent.h"
|
|
#include "Shape/PolygonPrismShapeComponent.h"
|
|
|
|
namespace LmbrCentral
|
|
{
|
|
static const char* s_assetCatalogFilename = "assetcatalog.xml";
|
|
|
|
using LmbrCentralAllocatorScope = AZ::AllocatorScope<AZ::LegacyAllocator>;
|
|
|
|
// This component boots the required allocators for LmbrCentral everywhere but AssetBuilders
|
|
class LmbrCentralAllocatorComponent
|
|
: public AZ::Component
|
|
, protected LmbrCentralAllocatorScope
|
|
{
|
|
public:
|
|
AZ_COMPONENT(LmbrCentralAllocatorComponent, "{B0512A75-AC4A-423A-BB55-C3355C0B186A}", AZ::Component);
|
|
|
|
LmbrCentralAllocatorComponent() = default;
|
|
~LmbrCentralAllocatorComponent() override = default;
|
|
|
|
void Activate() override
|
|
{
|
|
LmbrCentralAllocatorScope::ActivateAllocators();
|
|
}
|
|
|
|
void Deactivate() override
|
|
{
|
|
LmbrCentralAllocatorScope::DeactivateAllocators();
|
|
}
|
|
|
|
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
|
|
{
|
|
provided.push_back(AZ_CRC("MemoryAllocators", 0xd59acbcc));
|
|
}
|
|
|
|
static void Reflect(AZ::ReflectContext* context)
|
|
{
|
|
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
|
|
if (serializeContext)
|
|
{
|
|
serializeContext->Class<LmbrCentralAllocatorComponent, AZ::Component>()->Version(1);
|
|
|
|
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
|
|
{
|
|
editContext->Class<LmbrCentralAllocatorComponent>(
|
|
"LmbrCentral Allocator Component", "Manages initialization of memory allocators required by LmbrCentral")
|
|
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
|
->Attribute(AZ::Edit::Attributes::Category, "Engine")
|
|
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("System", 0xc94d118b))
|
|
;
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
// This component is opted in to AssetBuilders
|
|
class LmbrCentralAssetBuilderAllocatorComponent
|
|
: public LmbrCentralAllocatorComponent
|
|
{
|
|
public:
|
|
AZ_COMPONENT(LmbrCentralAssetBuilderAllocatorComponent, "{030B63DE-7DC1-4E08-9AAF-1D089D3D0C46}", LmbrCentralAllocatorComponent);
|
|
|
|
LmbrCentralAssetBuilderAllocatorComponent() = default;
|
|
~LmbrCentralAssetBuilderAllocatorComponent() override = default;
|
|
|
|
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
|
|
{
|
|
provided.push_back(AZ_CRC("MemoryAllocators", 0xd59acbcc));
|
|
}
|
|
|
|
static void Reflect(AZ::ReflectContext* context)
|
|
{
|
|
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
|
|
if (serializeContext)
|
|
{
|
|
serializeContext->Class<LmbrCentralAssetBuilderAllocatorComponent, LmbrCentralAllocatorComponent>()->Version(1)
|
|
->Attribute(AZ::Edit::Attributes::SystemComponentTags, AZStd::vector<AZ::Crc32>({ AZ_CRC("AssetBuilder", 0xc739c7d7) }));
|
|
|
|
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
|
|
{
|
|
editContext->Class<LmbrCentralAssetBuilderAllocatorComponent>(
|
|
"LmbrCentral Asset Builder Allocator Component", "Manages initialization of memory allocators required by LmbrCentral during asset building")
|
|
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
|
->Attribute(AZ::Edit::Attributes::Category, "Engine")
|
|
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("System", 0xc94d118b))
|
|
;
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
// LmbrCentral::LmbrCentralModule
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
//! Create ComponentDescriptors and add them to the list.
|
|
//! The descriptors will be registered at the appropriate time.
|
|
//! The descriptors will be destroyed (and thus unregistered) at the appropriate time.
|
|
LmbrCentralModule::LmbrCentralModule()
|
|
: AZ::Module()
|
|
{
|
|
m_descriptors.insert(m_descriptors.end(), {
|
|
AudioAreaEnvironmentComponent::CreateDescriptor(),
|
|
AudioEnvironmentComponent::CreateDescriptor(),
|
|
AudioListenerComponent::CreateDescriptor(),
|
|
AudioMultiPositionComponent::CreateDescriptor(),
|
|
AudioPreloadComponent::CreateDescriptor(),
|
|
AudioProxyComponent::CreateDescriptor(),
|
|
AudioRtpcComponent::CreateDescriptor(),
|
|
AudioSwitchComponent::CreateDescriptor(),
|
|
AudioSystemComponent::CreateDescriptor(),
|
|
AudioTriggerComponent::CreateDescriptor(),
|
|
BundlingSystemComponent::CreateDescriptor(),
|
|
LmbrCentralAllocatorComponent::CreateDescriptor(),
|
|
LmbrCentralAssetBuilderAllocatorComponent::CreateDescriptor(),
|
|
LmbrCentralSystemComponent::CreateDescriptor(),
|
|
NavigationComponent::CreateDescriptor(),
|
|
SimpleStateComponent::CreateDescriptor(),
|
|
SpawnerComponent::CreateDescriptor(),
|
|
LookAtComponent::CreateDescriptor(),
|
|
TagComponent::CreateDescriptor(),
|
|
SphereShapeComponent::CreateDescriptor(),
|
|
DiskShapeComponent::CreateDescriptor(),
|
|
BoxShapeComponent::CreateDescriptor(),
|
|
AxisAlignedBoxShapeComponent::CreateDescriptor(),
|
|
QuadShapeComponent::CreateDescriptor(),
|
|
CylinderShapeComponent::CreateDescriptor(),
|
|
CapsuleShapeComponent::CreateDescriptor(),
|
|
TubeShapeComponent::CreateDescriptor(),
|
|
CompoundShapeComponent::CreateDescriptor(),
|
|
SplineComponent::CreateDescriptor(),
|
|
PolygonPrismShapeComponent::CreateDescriptor(),
|
|
NavigationSystemComponent::CreateDescriptor(),
|
|
GeometrySystemComponent::CreateDescriptor(),
|
|
RandomTimedSpawnerComponent::CreateDescriptor(),
|
|
SphereShapeDebugDisplayComponent::CreateDescriptor(),
|
|
DiskShapeDebugDisplayComponent::CreateDescriptor(),
|
|
BoxShapeDebugDisplayComponent::CreateDescriptor(),
|
|
AxisAlignedBoxShapeDebugDisplayComponent::CreateDescriptor(),
|
|
QuadShapeDebugDisplayComponent::CreateDescriptor(),
|
|
CapsuleShapeDebugDisplayComponent::CreateDescriptor(),
|
|
CylinderShapeDebugDisplayComponent::CreateDescriptor(),
|
|
PolygonPrismShapeDebugDisplayComponent::CreateDescriptor(),
|
|
TubeShapeDebugDisplayComponent::CreateDescriptor(),
|
|
AssetSystemDebugComponent::CreateDescriptor(),
|
|
#if AZ_LOADSCREENCOMPONENT_ENABLED
|
|
LoadScreenComponent::CreateDescriptor(),
|
|
#endif // if AZ_LOADSCREENCOMPONENT_ENABLED
|
|
});
|
|
|
|
// This is an internal Amazon gem, so register it's components for metrics tracking, otherwise the name of the component won't get sent back.
|
|
// IF YOU ARE A THIRDPARTY WRITING A GEM, DO NOT REGISTER YOUR COMPONENTS WITH EditorMetricsComponentRegistrationBus
|
|
AZStd::vector<AZ::Uuid> typeIds;
|
|
typeIds.reserve(m_descriptors.size());
|
|
for (AZ::ComponentDescriptor* descriptor : m_descriptors)
|
|
{
|
|
typeIds.emplace_back(descriptor->GetUuid());
|
|
}
|
|
EBUS_EVENT(AzFramework::MetricsPlainTextNameRegistrationBus, RegisterForNameSending, typeIds);
|
|
}
|
|
|
|
//! Request system components on the system entity.
|
|
//! These components' memory is owned by the system entity.
|
|
AZ::ComponentTypeList LmbrCentralModule::GetRequiredSystemComponents() const
|
|
{
|
|
return {
|
|
azrtti_typeid<LmbrCentralAllocatorComponent>(),
|
|
azrtti_typeid<LmbrCentralAssetBuilderAllocatorComponent>(),
|
|
azrtti_typeid<LmbrCentralSystemComponent>(),
|
|
azrtti_typeid<NavigationSystemComponent>(),
|
|
azrtti_typeid<GeometrySystemComponent>(),
|
|
azrtti_typeid<AudioSystemComponent>(),
|
|
azrtti_typeid<BundlingSystemComponent>(),
|
|
azrtti_typeid<AssetSystemDebugComponent>(),
|
|
#if AZ_LOADSCREENCOMPONENT_ENABLED
|
|
azrtti_typeid<LoadScreenComponent>(),
|
|
#endif // if AZ_LOADSCREENCOMPONENT_ENABLED
|
|
};
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
// LmbrCentralSystemComponent
|
|
|
|
void LmbrCentralSystemComponent::Reflect(AZ::ReflectContext* context)
|
|
{
|
|
if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
|
{
|
|
// Allow loading of Material and Texture Assets which explicitly specialized AzTypeInfo instead of using
|
|
// the AZ_RTTI Uuid from SimpleAssetReference<T>
|
|
serializeContext->ClassDeprecate("SimpleAssetReference_MaterialAsset", "{B7B8ECC7-FF89-4A76-A50E-4C6CA2B6E6B4}",
|
|
[](AZ::SerializeContext& context, AZ::SerializeContext::DataElementNode& rootElement)
|
|
{
|
|
AZStd::vector<AZ::SerializeContext::DataElementNode> childNodeElements;
|
|
for (int index = 0; index < rootElement.GetNumSubElements(); ++index)
|
|
{
|
|
childNodeElements.push_back(rootElement.GetSubElement(index));
|
|
}
|
|
// Convert the rootElement now, the existing child DataElmentNodes are now removed
|
|
rootElement.Convert<AzFramework::SimpleAssetReference<MaterialAsset>>(context);
|
|
for (AZ::SerializeContext::DataElementNode& childNodeElement : childNodeElements)
|
|
{
|
|
rootElement.AddElement(AZStd::move(childNodeElement));
|
|
}
|
|
return true;
|
|
});
|
|
serializeContext->ClassDeprecate("SimpleAssetReference_TextureAsset", "{68E92460-5C0C-4031-9620-6F1A08763243}",
|
|
[](AZ::SerializeContext& context, AZ::SerializeContext::DataElementNode& rootElement)
|
|
{
|
|
AZStd::vector<AZ::SerializeContext::DataElementNode> childNodeElements;
|
|
for (int index = 0; index < rootElement.GetNumSubElements(); ++index)
|
|
{
|
|
childNodeElements.push_back(rootElement.GetSubElement(index));
|
|
}
|
|
// Convert the rootElement now, the existing child DataElmentNodes are now removed
|
|
rootElement.Convert<AzFramework::SimpleAssetReference<TextureAsset>>(context);
|
|
for (AZ::SerializeContext::DataElementNode& childNodeElement : childNodeElements)
|
|
{
|
|
rootElement.AddElement(AZStd::move(childNodeElement));
|
|
}
|
|
return true;
|
|
});
|
|
AzFramework::SimpleAssetReference<MaterialAsset>::Register(*serializeContext);
|
|
AzFramework::SimpleAssetReference<TextureAsset>::Register(*serializeContext);
|
|
|
|
serializeContext->Class<LmbrCentralSystemComponent, AZ::Component>()
|
|
->Version(1)
|
|
;
|
|
|
|
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
|
|
{
|
|
editContext->Class<LmbrCentralSystemComponent>(
|
|
"LmbrCentral", "Coordinates initialization of systems within LmbrCentral")
|
|
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
|
->Attribute(AZ::Edit::Attributes::Category, "Game")
|
|
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("System", 0xc94d118b))
|
|
;
|
|
}
|
|
}
|
|
|
|
ReflectScriptableEvents::Reflect(context);
|
|
}
|
|
|
|
void LmbrCentralSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
|
|
{
|
|
provided.push_back(AZ_CRC("LmbrCentralService", 0xc3a02410));
|
|
}
|
|
|
|
void LmbrCentralSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
|
|
{
|
|
incompatible.push_back(AZ_CRC("LmbrCentralService", 0xc3a02410));
|
|
}
|
|
|
|
void LmbrCentralSystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
|
|
{
|
|
required.push_back(AZ_CRC("AssetDatabaseService", 0x3abf5601));
|
|
}
|
|
|
|
void LmbrCentralSystemComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
|
|
{
|
|
dependent.push_back(AZ_CRC("MemoryAllocators", 0xd59acbcc));
|
|
dependent.push_back(AZ_CRC("AssetCatalogService", 0xc68ffc57));
|
|
}
|
|
|
|
void LmbrCentralSystemComponent::Activate()
|
|
{
|
|
if (!AZ::AllocatorInstance<AZ::LegacyAllocator>::IsReady())
|
|
{
|
|
AZ::AllocatorInstance<AZ::LegacyAllocator>::Create();
|
|
m_allocatorShutdowns.push_back([]() { AZ::AllocatorInstance<AZ::LegacyAllocator>::Destroy(); });
|
|
}
|
|
|
|
// Register asset handlers. Requires "AssetDatabaseService"
|
|
AZ_Assert(AZ::Data::AssetManager::IsReady(), "Asset manager isn't ready!");
|
|
|
|
// Add asset types and extensions to AssetCatalog. Uses "AssetCatalogService".
|
|
auto assetCatalog = AZ::Data::AssetCatalogRequestBus::FindFirstHandler();
|
|
if (assetCatalog)
|
|
{
|
|
assetCatalog->EnableCatalogForAsset(AZ::AzTypeInfo<AZ::ScriptAsset>::Uuid());
|
|
assetCatalog->EnableCatalogForAsset(AZ::AzTypeInfo<MaterialAsset>::Uuid());
|
|
assetCatalog->EnableCatalogForAsset(AZ::AzTypeInfo<DccMaterialAsset>::Uuid());
|
|
assetCatalog->EnableCatalogForAsset(AZ::AzTypeInfo<MeshAsset>::Uuid());
|
|
assetCatalog->EnableCatalogForAsset(AZ::AzTypeInfo<CharacterDefinitionAsset>::Uuid());
|
|
|
|
assetCatalog->AddExtension("cgf");
|
|
assetCatalog->AddExtension("chr");
|
|
assetCatalog->AddExtension("cdf");
|
|
assetCatalog->AddExtension("dds");
|
|
assetCatalog->AddExtension("caf");
|
|
assetCatalog->AddExtension("xml");
|
|
assetCatalog->AddExtension("mtl");
|
|
assetCatalog->AddExtension("dccmtl");
|
|
assetCatalog->AddExtension("lua");
|
|
assetCatalog->AddExtension("sprite");
|
|
assetCatalog->AddExtension("cax");
|
|
}
|
|
|
|
CrySystemEventBus::Handler::BusConnect();
|
|
AZ::Data::AssetManagerNotificationBus::Handler::BusConnect();
|
|
|
|
|
|
// Register unhandled asset type info
|
|
// Material
|
|
auto materialAssetTypeInfo = aznew MaterialAssetTypeInfo();
|
|
materialAssetTypeInfo->Register();
|
|
m_unhandledAssetInfo.emplace_back(materialAssetTypeInfo);
|
|
// DCC Material
|
|
auto dccMaterialAssetTypeInfo = aznew DccMaterialAssetTypeInfo();
|
|
dccMaterialAssetTypeInfo->Register();
|
|
m_unhandledAssetInfo.emplace_back(dccMaterialAssetTypeInfo);
|
|
// Other
|
|
auto audioAssetTypeInfo = aznew AudioAssetTypeInfo();
|
|
audioAssetTypeInfo->Register();
|
|
m_unhandledAssetInfo.emplace_back(audioAssetTypeInfo);
|
|
|
|
auto characterPhysicsAssetTypeInfo = aznew CharacterPhysicsAssetTypeInfo();
|
|
characterPhysicsAssetTypeInfo->Register();
|
|
m_unhandledAssetInfo.emplace_back(characterPhysicsAssetTypeInfo);
|
|
|
|
auto groupAssetTypeInfo = aznew GroupAssetTypeInfo();
|
|
groupAssetTypeInfo->Register();
|
|
m_unhandledAssetInfo.emplace_back(groupAssetTypeInfo);
|
|
|
|
auto prefabsLibraryAssetTypeInfo = aznew PrefabsLibraryAssetTypeInfo();
|
|
prefabsLibraryAssetTypeInfo->Register();
|
|
m_unhandledAssetInfo.emplace_back(prefabsLibraryAssetTypeInfo);
|
|
|
|
auto entityPrototypeAssetTypeInfo = aznew EntityPrototypeLibraryAssetTypeInfo();
|
|
entityPrototypeAssetTypeInfo->Register();
|
|
m_unhandledAssetInfo.emplace_back(entityPrototypeAssetTypeInfo);
|
|
|
|
auto gameTokenAssetTypeInfo = aznew GameTokenAssetTypeInfo();
|
|
gameTokenAssetTypeInfo->Register();
|
|
m_unhandledAssetInfo.emplace_back(gameTokenAssetTypeInfo);
|
|
|
|
// Texture
|
|
auto substanceAssetTypeInfo = aznew SubstanceAssetTypeInfo();
|
|
substanceAssetTypeInfo->Register();
|
|
m_unhandledAssetInfo.emplace_back(substanceAssetTypeInfo);
|
|
|
|
auto textureAssetTypeInfo = aznew TextureAssetTypeInfo();
|
|
textureAssetTypeInfo->Register();
|
|
m_unhandledAssetInfo.emplace_back(textureAssetTypeInfo);
|
|
|
|
// Hidden
|
|
auto textureMipmapAssetTypeInfo = aznew TextureMipmapAssetTypeInfo();
|
|
textureMipmapAssetTypeInfo->Register();
|
|
m_unhandledAssetInfo.emplace_back(textureMipmapAssetTypeInfo);
|
|
|
|
// UI
|
|
auto fontAssetTypeInfo = aznew FontAssetTypeInfo();
|
|
fontAssetTypeInfo->Register();
|
|
m_unhandledAssetInfo.emplace_back(fontAssetTypeInfo);
|
|
|
|
auto uiCanvasAssetTypeInfo = aznew UICanvasAssetTypeInfo();
|
|
uiCanvasAssetTypeInfo->Register();
|
|
m_unhandledAssetInfo.emplace_back(uiCanvasAssetTypeInfo);
|
|
|
|
auto entityIconAssetTypeInfo = aznew EntityIconAssetTypeInfo();
|
|
entityIconAssetTypeInfo->Register();
|
|
m_unhandledAssetInfo.emplace_back(entityIconAssetTypeInfo);
|
|
}
|
|
|
|
void LmbrCentralSystemComponent::Deactivate()
|
|
{
|
|
// AssetTypeInfo's destructor calls Unregister()
|
|
m_unhandledAssetInfo.clear();
|
|
|
|
AZ::Data::AssetManagerNotificationBus::Handler::BusDisconnect();
|
|
CrySystemEventBus::Handler::BusDisconnect();
|
|
|
|
// AssetHandler's destructor calls Unregister()
|
|
m_assetHandlers.clear();
|
|
|
|
for (auto allocatorIt = m_allocatorShutdowns.rbegin(); allocatorIt != m_allocatorShutdowns.rend(); ++allocatorIt)
|
|
{
|
|
(*allocatorIt)();
|
|
}
|
|
m_allocatorShutdowns.clear();
|
|
}
|
|
|
|
void LmbrCentralSystemComponent::OnCrySystemPreInitialize([[maybe_unused]] ISystem& system, [[maybe_unused]] const SSystemInitParams& systemInitParams)
|
|
{
|
|
EBUS_EVENT(AZ::Data::AssetCatalogRequestBus, StartMonitoringAssets);
|
|
}
|
|
|
|
void LmbrCentralSystemComponent::OnCrySystemInitialized(ISystem& system, const SSystemInitParams& systemInitParams)
|
|
{
|
|
#if !defined(AZ_MONOLITHIC_BUILD)
|
|
// When module is linked dynamically, we must set our gEnv pointer.
|
|
// When module is linked statically, we'll share the application's gEnv pointer.
|
|
gEnv = system.GetGlobalEnvironment();
|
|
#endif
|
|
|
|
// Enable catalog now that application's asset root is set.
|
|
if (system.GetGlobalEnvironment()->IsEditor())
|
|
{
|
|
// In the editor, we build the catalog by scanning the disk.
|
|
if (systemInitParams.pUserCallback)
|
|
{
|
|
systemInitParams.pUserCallback->OnInitProgress("Refreshing asset catalog...");
|
|
}
|
|
}
|
|
|
|
// load the catalog from disk (supported over VFS).
|
|
EBUS_EVENT(AZ::Data::AssetCatalogRequestBus, LoadCatalog, AZStd::string::format("@products@/%s", s_assetCatalogFilename).c_str());
|
|
}
|
|
|
|
void LmbrCentralSystemComponent::OnCrySystemShutdown([[maybe_unused]] ISystem& system)
|
|
{
|
|
EBUS_EVENT(AZ::Data::AssetCatalogRequestBus, StopMonitoringAssets);
|
|
|
|
#if !defined(AZ_MONOLITHIC_BUILD)
|
|
gEnv = nullptr;
|
|
#endif
|
|
}
|
|
} // namespace LmbrCentral
|
|
|
|
#if !defined(LMBR_CENTRAL_EDITOR)
|
|
AZ_DECLARE_MODULE_CLASS(Gem_LmbrCentral, LmbrCentral::LmbrCentralModule)
|
|
#endif
|