Skip to content

Commit 402e524

Browse files
Tool for prefab randomization during activation. (#114)
* Tool to randomize entity during activation. Signed-off-by: Michał Pełka <[email protected]> * Apply suggestions from code review Co-authored-by: Patryk Antosz <[email protected]> --------- Signed-off-by: Michał Pełka <[email protected]> Co-authored-by: Patryk Antosz <[email protected]>
1 parent 647f85d commit 402e524

38 files changed

+661
-0
lines changed

Gems/RandomizeUtils/.gitignore

Whitespace-only changes.

Gems/RandomizeUtils/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
o3de_gem_setup("RandomizeUtils")
3+
4+
ly_add_external_target_path(${CMAKE_CURRENT_SOURCE_DIR}/3rdParty)
5+
6+
add_subdirectory(Code)
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
2+
# Currently we are in the Code folder: ${CMAKE_CURRENT_LIST_DIR}
3+
# Get the platform specific folder ${pal_dir} for the current folder: ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME}
4+
# Note: o3de_pal_dir will take care of the details for us, as this may be a restricted platform
5+
# in which case it will see if that platform is present here or in the restricted folder.
6+
# i.e. It could here in our gem : Gems/RandomizeUtils/Code/Platform/<platorm_name> or
7+
# <restricted_folder>/<platform_name>/Gems/RandomizeUtils/Code
8+
o3de_pal_dir(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME} "${gem_restricted_path}" "${gem_path}" "${gem_parent_relative_path}")
9+
10+
# Now that we have the platform abstraction layer (PAL) folder for this folder, thats where we will find the
11+
# traits for this platform. Traits for a platform are defines for things like whether or not something in this gem
12+
# is supported by this platform.
13+
include(${pal_dir}/PAL_${PAL_PLATFORM_NAME_LOWERCASE}.cmake)
14+
15+
# Check to see if building the Gem Modules are supported for the current platform
16+
if(NOT PAL_TRAIT_RANDOMIZEUTILS_SUPPORTED)
17+
return()
18+
endif()
19+
20+
# The ${gem_name}.API target declares the common interface that users of this gem should depend on in their targets
21+
ly_add_target(
22+
NAME ${gem_name}.API INTERFACE
23+
NAMESPACE Gem
24+
FILES_CMAKE
25+
randomizeutils_api_files.cmake
26+
${pal_dir}/randomizeutils_api_files.cmake
27+
INCLUDE_DIRECTORIES
28+
INTERFACE
29+
Include
30+
BUILD_DEPENDENCIES
31+
INTERFACE
32+
AZ::AzCore
33+
)
34+
35+
# The ${gem_name}.Private.Object target is an internal target
36+
# It should not be used outside of this Gems CMakeLists.txt
37+
ly_add_target(
38+
NAME ${gem_name}.Private.Object STATIC
39+
NAMESPACE Gem
40+
FILES_CMAKE
41+
randomizeutils_private_files.cmake
42+
${pal_dir}/randomizeutils_private_files.cmake
43+
TARGET_PROPERTIES
44+
O3DE_PRIVATE_TARGET TRUE
45+
INCLUDE_DIRECTORIES
46+
PRIVATE
47+
Include
48+
Source
49+
BUILD_DEPENDENCIES
50+
PUBLIC
51+
AZ::AzCore
52+
AZ::AzFramework
53+
)
54+
55+
# Here add ${gem_name} target, it depends on the Private Object library and Public API interface
56+
ly_add_target(
57+
NAME ${gem_name} ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
58+
NAMESPACE Gem
59+
FILES_CMAKE
60+
randomizeutils_shared_files.cmake
61+
${pal_dir}/randomizeutils_shared_files.cmake
62+
INCLUDE_DIRECTORIES
63+
PUBLIC
64+
Include
65+
PRIVATE
66+
Source
67+
BUILD_DEPENDENCIES
68+
PUBLIC
69+
Gem::${gem_name}.API
70+
PRIVATE
71+
Gem::${gem_name}.Private.Object
72+
)
73+
74+
# Include the gem name into the Client Module source file
75+
# for use with the AZ_DECLARE_MODULE_CLASS macro
76+
# This is to allow renaming of the gem to also cause
77+
# the CreateModuleClass_Gem_<gem-name> function which
78+
# is used to bootstrap the gem in monolithic builds to link to the new gem name
79+
ly_add_source_properties(
80+
SOURCES
81+
Source/Clients/RandomizeUtilsModule.cpp
82+
PROPERTY COMPILE_DEFINITIONS
83+
VALUES
84+
O3DE_GEM_NAME=${gem_name}
85+
O3DE_GEM_VERSION=${gem_version})
86+
87+
# By default, we will specify that the above target ${gem_name} would be used by
88+
# Client and Server type targets when this gem is enabled. If you don't want it
89+
# active in Clients or Servers by default, delete one of both of the following lines:
90+
ly_create_alias(NAME ${gem_name}.Clients NAMESPACE Gem TARGETS Gem::${gem_name})
91+
ly_create_alias(NAME ${gem_name}.Servers NAMESPACE Gem TARGETS Gem::${gem_name})
92+
ly_create_alias(NAME ${gem_name}.Unified NAMESPACE Gem TARGETS Gem::${gem_name})
93+
94+
# For the Client and Server variants of ${gem_name} Gem, an alias to the ${gem_name}.API target will be made
95+
ly_create_alias(NAME ${gem_name}.Clients.API NAMESPACE Gem TARGETS Gem::${gem_name}.API)
96+
ly_create_alias(NAME ${gem_name}.Servers.API NAMESPACE Gem TARGETS Gem::${gem_name}.API)
97+
ly_create_alias(NAME ${gem_name}.Unified.API NAMESPACE Gem TARGETS Gem::${gem_name}.API)
98+
99+
# Add in CMake dependencies for each gem dependency listed in this gem's gem.json file
100+
# for the Clients, Servers, Unified gem variants
101+
o3de_add_variant_dependencies_for_gem_dependencies(GEM_NAME ${gem_name} VARIANTS Clients Servers Unified)
102+
103+
# If we are on a host platform, we want to add the host tools targets like the ${gem_name}.Editor MODULE target
104+
if(PAL_TRAIT_BUILD_HOST_TOOLS)
105+
# The ${gem_name}.Editor.API target can be used by other gems that want to interact with the ${gem_name}.Editor module
106+
ly_add_target(
107+
NAME ${gem_name}.Editor.API INTERFACE
108+
NAMESPACE Gem
109+
FILES_CMAKE
110+
randomizeutils_editor_api_files.cmake
111+
${pal_dir}/randomizeutils_editor_api_files.cmake
112+
INCLUDE_DIRECTORIES
113+
INTERFACE
114+
Include
115+
BUILD_DEPENDENCIES
116+
INTERFACE
117+
AZ::AzToolsFramework
118+
)
119+
120+
# The ${gem_name}.Editor.Private.Object target is an internal target
121+
# which is only to be used by this gems CMakeLists.txt and any subdirectories
122+
# Other gems should not use this target
123+
ly_add_target(
124+
NAME ${gem_name}.Editor.Private.Object STATIC
125+
NAMESPACE Gem
126+
FILES_CMAKE
127+
randomizeutils_editor_private_files.cmake
128+
TARGET_PROPERTIES
129+
O3DE_PRIVATE_TARGET TRUE
130+
INCLUDE_DIRECTORIES
131+
PRIVATE
132+
Include
133+
Source
134+
BUILD_DEPENDENCIES
135+
PUBLIC
136+
AZ::AzToolsFramework
137+
${gem_name}.Private.Object
138+
)
139+
140+
ly_add_target(
141+
NAME ${gem_name}.Editor GEM_MODULE
142+
NAMESPACE Gem
143+
AUTOMOC
144+
FILES_CMAKE
145+
randomizeutils_editor_shared_files.cmake
146+
INCLUDE_DIRECTORIES
147+
PRIVATE
148+
Source
149+
PUBLIC
150+
Include
151+
BUILD_DEPENDENCIES
152+
PUBLIC
153+
Gem::${gem_name}.Editor.API
154+
PRIVATE
155+
Gem::${gem_name}.Editor.Private.Object
156+
)
157+
158+
# Include the gem name into the Editor Module source file
159+
# for use with the AZ_DECLARE_MODULE_CLASS macro
160+
# This is to allow renaming of the gem to also cause
161+
# the CreateModuleClass_Gem_<gem-name> function which
162+
# is used to bootstrap the gem in monolithic builds to link to the new gem name
163+
ly_add_source_properties(
164+
SOURCES
165+
Source/Tools/RandomizeUtilsEditorModule.cpp
166+
PROPERTY COMPILE_DEFINITIONS
167+
VALUES
168+
O3DE_GEM_NAME=${gem_name}
169+
O3DE_GEM_VERSION=${gem_version})
170+
171+
# By default, we will specify that the above target ${gem_name} would be used by
172+
# Tool and Builder type targets when this gem is enabled. If you don't want it
173+
# active in Tools or Builders by default, delete one of both of the following lines:
174+
ly_create_alias(NAME ${gem_name}.Tools NAMESPACE Gem TARGETS Gem::${gem_name}.Editor)
175+
ly_create_alias(NAME ${gem_name}.Builders NAMESPACE Gem TARGETS Gem::${gem_name}.Editor)
176+
177+
# For the Tools and Builders variants of ${gem_name} Gem, an alias to the ${gem_name}.Editor API target will be made
178+
ly_create_alias(NAME ${gem_name}.Tools.API NAMESPACE Gem TARGETS Gem::${gem_name}.Editor.API)
179+
ly_create_alias(NAME ${gem_name}.Builders.API NAMESPACE Gem TARGETS Gem::${gem_name}.Editor.API)
180+
181+
# Add in CMake dependencies for each gem dependency listed in this gem's gem.json file
182+
# for the Tools and Builders gem variants
183+
o3de_add_variant_dependencies_for_gem_dependencies(GEM_NAME ${gem_name} VARIANTS Tools Builders)
184+
endif()
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
#pragma once
3+
4+
namespace RandomizeUtils
5+
{
6+
7+
// Module derived classes TypeIds
8+
inline constexpr const char* RandomizeUtilsModuleInterfaceTypeId = "{0C8DC567-4080-4647-9AFF-FD03E6593A27}";
9+
inline constexpr const char* RandomizeUtilsModuleTypeId = "{8D073235-A1A1-4EE6-9736-40E640F59BC7}";
10+
// The Editor Module by default is mutually exclusive with the Client Module
11+
// so they use the Same TypeId
12+
inline constexpr const char* RandomizeUtilsEditorModuleTypeId = RandomizeUtilsModuleTypeId;
13+
14+
inline constexpr const char* RandomizePoseComponentTypeId = "{4e990b5f-062b-4aaa-8e2a-440d3574ff1e}";
15+
} // namespace RandomizeUtils
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
set(PAL_TRAIT_RANDOMIZEUTILS_SUPPORTED TRUE)
3+
set(PAL_TRAIT_RANDOMIZEUTILS_TEST_SUPPORTED FALSE)
4+
set(PAL_TRAIT_RANDOMIZEUTILS_EDITOR_TEST_SUPPORTED FALSE)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
set(FILES
3+
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
set(FILES
3+
)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
# Platform specific files for Linux
3+
# i.e. ../Source/Linux/RandomizeUtilsLinux.cpp
4+
# ../Source/Linux/RandomizeUtilsLinux.h
5+
# ../Include/Linux/RandomizeUtilsLinux.h
6+
7+
set(FILES
8+
)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
# Platform specific files for Linux
3+
# i.e. ../Source/Linux/RandomizeUtilsLinux.cpp
4+
# ../Source/Linux/RandomizeUtilsLinux.h
5+
# ../Include/Linux/RandomizeUtilsLinux.h
6+
7+
set(FILES
8+
)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
set(PAL_TRAIT_RANDOMIZEUTILS_SUPPORTED TRUE)
3+
set(PAL_TRAIT_RANDOMIZEUTILS_TEST_SUPPORTED FALSE)
4+
set(PAL_TRAIT_RANDOMIZEUTILS_EDITOR_TEST_SUPPORTED FALSE)

0 commit comments

Comments
 (0)