Updated the Default Project template to enable the "Standard" list of gems (#1325)

* Added a ModuleInterface class for sharing an AZ::Module implementation

The ModuleInterface class registers the SystemComponent that that comes
with the Client module and returns in it's GetRequiredSystemComponent
the Clients module SystemComponent

An EditorModule class has been added which inherits from the
ModuleInterface class and extends the registered SystemComponent
descriptors with it's SystemComponent.
It then overrides teh GetRequiredSystemComponent function and replaces
the required SystemComponent with it's Tools module SystemComponent

* Updated the DefaultProject list of Gems to match the decided Standard list of gems

* Updated the comment in the EditorModule constructor

The comment indicates that all component descriptors should be added to the m_descriptors list

* Added more detail to the ModuleInterface constructor about the registering the Component Descriptors
main
lumberyard-employee-dm 5 years ago committed by GitHub
parent 4014cacff8
commit b945e1689a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -10,5 +10,5 @@
# {END_LICENSE}
set(FILES
Source/${Name}Module.cpp
Source/${Name}EditorModule.cpp
)

@ -10,6 +10,8 @@
# {END_LICENSE}
set(FILES
Include/${Name}/${Name}Bus.h
Source/${Name}ModuleInterface.h
Source/${Name}SystemComponent.cpp
Source/${Name}SystemComponent.h
)

@ -22,7 +22,7 @@ namespace ${SanitizedCppName}
class ${SanitizedCppName}Requests
{
public:
AZ_RTTI(${SanitizedCppName}Requests, "${Random_Uuid}");
AZ_RTTI(${SanitizedCppName}Requests, "{${Random_Uuid}}");
virtual ~${SanitizedCppName}Requests() = default;
// Put your public methods here
};

@ -0,0 +1,51 @@
// {BEGIN_LICENSE}
/*
* 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.
*
*/
// {END_LICENSE}
#include <${Name}ModuleInterface.h>
#include <${Name}EditorSystemComponent.h>
namespace ${SanitizedCppName}
{
class ${SanitizedCppName}EditorModule
: public ${SanitizedCppName}ModuleInterface
{
public:
AZ_RTTI(${SanitizedCppName}EditorModule, "${ModuleClassId}", ${SanitizedCppName}ModuleInterface);
AZ_CLASS_ALLOCATOR(${SanitizedCppName}EditorModule, AZ::SystemAllocator, 0);
${SanitizedCppName}EditorModule()
{
// Push results of [MyComponent]::CreateDescriptor() into m_descriptors here.
// Add ALL components descriptors associated with this gem to m_descriptors.
// This will associate the AzTypeInfo information for the components with the the SerializeContext, BehaviorContext and EditContext.
// This happens through the [MyComponent]::Reflect() function.
m_descriptors.insert(m_descriptors.end(), {
${SanitizedCppName}EditorSystemComponent::CreateDescriptor(),
});
}
/**
* Add required SystemComponents to the SystemEntity.
* Non-SystemComponents should not be added here
*/
AZ::ComponentTypeList GetRequiredSystemComponents() const override
{
return AZ::ComponentTypeList {
azrtti_typeid<${SanitizedCppName}EditorSystemComponent>(),
};
}
};
}// namespace ${SanitizedCppName}
AZ_DECLARE_MODULE_CLASS(Gem_${SanitizedCppName}, ${SanitizedCppName}::${SanitizedCppName}EditorModule)

@ -21,34 +21,47 @@ namespace ${SanitizedCppName}
{
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<${SanitizedCppName}EditorSystemComponent, AZ::Component>()->Version(1);
serializeContext->Class<${SanitizedCppName}EditorSystemComponent, ${SanitizedCppName}SystemComponent>()
->Version(0);
}
}
${SanitizedCppName}EditorSystemComponent::${SanitizedCppName}EditorSystemComponent()
${SanitizedCppName}EditorSystemComponent::${SanitizedCppName}EditorSystemComponent() = default;
${SanitizedCppName}EditorSystemComponent::~${SanitizedCppName}EditorSystemComponent() = default;
void ${SanitizedCppName}EditorSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
if (${SanitizedCppName}Interface::Get() == nullptr)
{
${SanitizedCppName}Interface::Register(this);
}
BaseSystemComponent::GetProvidedServices(provided);
provided.push_back(AZ_CRC_CE("${SanitizedCppName}EditorService"));
}
${SanitizedCppName}EditorSystemComponent::~${SanitizedCppName}EditorSystemComponent()
void ${SanitizedCppName}EditorSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
{
if (${SanitizedCppName}Interface::Get() == this)
{
${SanitizedCppName}Interface::Unregister(this);
}
BaseSystemComponent::GetIncompatibleServices(incompatible);
incompatible.push_back(AZ_CRC_CE("${SanitizedCppName}EditorService"));
}
void ${SanitizedCppName}EditorSystemComponent::GetRequiredServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& required)
{
BaseSystemComponent::GetRequiredServices(required);
}
void ${SanitizedCppName}EditorSystemComponent::GetDependentServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& dependent)
{
BaseSystemComponent::GetDependentServices(dependent);
}
void ${SanitizedCppName}EditorSystemComponent::Activate()
{
${SanitizedCppName}SystemComponent::Activate();
AzToolsFramework::EditorEvents::Bus::Handler::BusConnect();
}
void ${SanitizedCppName}EditorSystemComponent::Deactivate()
{
AzToolsFramework::EditorEvents::Bus::Handler::BusDisconnect();
${SanitizedCppName}SystemComponent::Deactivate();
}
} // namespace ${SanitizedCppName}

@ -14,7 +14,7 @@
#pragma once
#include <AzCore/Component/Component.h>
#include <${Name}SystemComponent.h>
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
@ -22,26 +22,22 @@ namespace ${SanitizedCppName}
{
/// System component for ${SanitizedCppName} editor
class ${SanitizedCppName}EditorSystemComponent
: public AZ::Component
: public ${SanitizedCppName}SystemComponent
, private AzToolsFramework::EditorEvents::Bus::Handler
{
using BaseSystemComponent = ${SanitizedCppName}SystemComponent;
public:
AZ_COMPONENT(${SanitizedCppName}EditorSystemComponent, "${EditorSysCompClassId}");
AZ_COMPONENT(${SanitizedCppName}EditorSystemComponent, "${EditorSysCompClassId}", BaseSystemComponent);
static void Reflect(AZ::ReflectContext* context);
${SanitizedCppName}EditorSystemComponent();
~${SanitizedCppName}EditorSystemComponent();
private:
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
provided.push_back(AZ_CRC("${SanitizedCppName}EditorService"));
}
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
{
required.push_back(AZ_CRC("${SanitizedCppName}Service"));
}
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);
// AZ::Component
void Activate() override;

@ -12,38 +12,18 @@
*/
// {END_LICENSE}
#include <AzCore/Memory/SystemAllocator.h>
#include <AzCore/Module/Module.h>
#include <${Name}ModuleInterface.h>
#include <${Name}SystemComponent.h>
namespace ${SanitizedCppName}
{
class ${SanitizedCppName}Module
: public AZ::Module
: public ${SanitizedCppName}ModuleInterface
{
public:
AZ_RTTI(${SanitizedCppName}Module, "${ModuleClassId}", AZ::Module);
AZ_RTTI(${SanitizedCppName}Module, "${ModuleClassId}", ${SanitizedCppName}ModuleInterface);
AZ_CLASS_ALLOCATOR(${SanitizedCppName}Module, AZ::SystemAllocator, 0);
${SanitizedCppName}Module()
: AZ::Module()
{
// Push results of [MyComponent]::CreateDescriptor() into m_descriptors here.
m_descriptors.insert(m_descriptors.end(), {
${SanitizedCppName}SystemComponent::CreateDescriptor(),
});
}
/**
* Add required SystemComponents to the SystemEntity.
*/
AZ::ComponentTypeList GetRequiredSystemComponents() const override
{
return AZ::ComponentTypeList {
azrtti_typeid<${SanitizedCppName}SystemComponent>(),
};
}
};
}// namespace ${SanitizedCppName}

@ -0,0 +1,49 @@
// {BEGIN_LICENSE}
/*
* 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.
*
*/
// {END_LICENSE}
#include <AzCore/Memory/SystemAllocator.h>
#include <AzCore/Module/Module.h>
#include <${Name}SystemComponent.h>
namespace ${SanitizedCppName}
{
class ${SanitizedCppName}ModuleInterface
: public AZ::Module
{
public:
AZ_RTTI(${SanitizedCppName}ModuleInterface, "{${Random_Uuid}}", AZ::Module);
AZ_CLASS_ALLOCATOR(${SanitizedCppName}ModuleInterface, AZ::SystemAllocator, 0);
${SanitizedCppName}ModuleInterface()
{
// Push results of [MyComponent]::CreateDescriptor() into m_descriptors here.
// Add ALL components descriptors associated with this gem to m_descriptors.
// This will associate the AzTypeInfo information for the components with the the SerializeContext, BehaviorContext and EditContext.
// This happens through the [MyComponent]::Reflect() function.
m_descriptors.insert(m_descriptors.end(), {
${SanitizedCppName}SystemComponent::CreateDescriptor(),
});
}
/**
* Add required SystemComponents to the SystemEntity.
*/
AZ::ComponentTypeList GetRequiredSystemComponents() const override
{
return AZ::ComponentTypeList{
azrtti_typeid<${SanitizedCppName}SystemComponent>(),
};
}
};
}// namespace ${SanitizedCppName}

@ -41,22 +41,20 @@ namespace ${SanitizedCppName}
void ${SanitizedCppName}SystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
provided.push_back(AZ_CRC("${SanitizedCppName}Service"));
provided.push_back(AZ_CRC_CE("${SanitizedCppName}Service"));
}
void ${SanitizedCppName}SystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
{
incompatible.push_back(AZ_CRC("${SanitizedCppName}Service"));
incompatible.push_back(AZ_CRC_CE("${SanitizedCppName}Service"));
}
void ${SanitizedCppName}SystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
void ${SanitizedCppName}SystemComponent::GetRequiredServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& required)
{
AZ_UNUSED(required);
}
void ${SanitizedCppName}SystemComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
void ${SanitizedCppName}SystemComponent::GetDependentServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& dependent)
{
AZ_UNUSED(dependent);
}
${SanitizedCppName}SystemComponent::${SanitizedCppName}SystemComponent()
@ -91,9 +89,8 @@ namespace ${SanitizedCppName}
${SanitizedCppName}RequestBus::Handler::BusDisconnect();
}
void ${SanitizedCppName}SystemComponent::OnTick(float /*deltaTime*/, AZ::ScriptTimePoint /*time*/)
void ${SanitizedCppName}SystemComponent::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time)
{
}
} // namespace ${SanitizedCppName}

@ -14,24 +14,4 @@
#include <AzTest/AzTest.h>
class ${SanitizedCppName}EditorTest
: public ::testing::Test
{
protected:
void SetUp() override
{
}
void TearDown() override
{
}
};
TEST_F(${SanitizedCppName}EditorTest, SanityTest)
{
ASSERT_TRUE(true);
}
AZ_UNIT_TEST_HOOK(DEFAULT_UNIT_TEST_ENV);

@ -14,24 +14,4 @@
#include <AzTest/AzTest.h>
class ${SanitizedCppName}Test
: public ::testing::Test
{
protected:
void SetUp() override
{
}
void TearDown() override
{
}
};
TEST_F(${SanitizedCppName}Test, SanityTest)
{
ASSERT_TRUE(true);
}
AZ_UNIT_TEST_HOOK(DEFAULT_UNIT_TEST_ENV);

@ -156,6 +156,12 @@
"isTemplated": true,
"isOptional": false
},
{
"file": "Code/Source/${Name}EditorModule.cpp",
"origin": "Code/Source/${Name}EditorModule.cpp",
"isTemplated": true,
"isOptional": false
},
{
"file": "Code/Source/${Name}EditorSystemComponent.cpp",
"origin": "Code/Source/${Name}EditorSystemComponent.cpp",
@ -174,6 +180,12 @@
"isTemplated": true,
"isOptional": false
},
{
"file": "Code/Source/${Name}ModuleInterface.h",
"origin": "Code/Source/${Name}ModuleInterface.h",
"isTemplated": true,
"isOptional": false
},
{
"file": "Code/Source/${Name}SystemComponent.cpp",
"origin": "Code/Source/${Name}SystemComponent.cpp",

@ -49,14 +49,12 @@ namespace ${SanitizedCppName}
incompatible.push_back(AZ_CRC("${SanitizedCppName}Service"));
}
void ${SanitizedCppName}SystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
void ${SanitizedCppName}SystemComponent::GetRequiredServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& required)
{
AZ_UNUSED(required);
}
void ${SanitizedCppName}SystemComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
void ${SanitizedCppName}SystemComponent::GetDependentServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& dependent)
{
AZ_UNUSED(dependent);
}
${SanitizedCppName}SystemComponent::${SanitizedCppName}SystemComponent()

@ -12,17 +12,22 @@
set(ENABLED_GEMS
${Name}
Atom_AtomBridge
Camera
AudioSystem
AWSCore
CameraFramework
DebugDraw
EditorPythonBindings
EMotionFX
GradientSignal
GameState
ImGui
LmbrCentral
LandscapeCanvas
LyShine
Maestro
NvCloth
SceneProcessing
Multiplayer
PhysX
SaveData
ScriptCanvasPhysics
ScriptEvents
StartingPointInput
TextureAtlas
WhiteBox
)

Loading…
Cancel
Save