Skip to content

Commit

Permalink
Initial project files commit
Browse files Browse the repository at this point in the history
Signed-off-by: AMZN-alexpete <26804013+AMZN-alexpete@users.noreply.github.com>
  • Loading branch information
AMZN-alexpete committed Jul 19, 2021
1 parent 467ecdf commit 2b21521
Show file tree
Hide file tree
Showing 163 changed files with 16,478 additions and 0 deletions.
23 changes: 23 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

if(NOT PROJECT_NAME)
cmake_minimum_required(VERSION 3.20)
project(Game
LANGUAGES C CXX
VERSION 1.0.0.0
)
include(EngineFinder.cmake OPTIONAL)
find_package(o3de REQUIRED)
o3de_initialize()
else()
# Add the project_name to global LY_PROJECTS_TARGET_NAME property
file(READ "${CMAKE_CURRENT_LIST_DIR}/project.json" project_json)

string(JSON project_target_name ERROR_VARIABLE json_error GET ${project_json} "project_name")
if(json_error)
message(FATAL_ERROR "Unable to read key 'project_name' from 'project.json'")
endif()

set_property(GLOBAL APPEND PROPERTY LY_PROJECTS_TARGET_NAME ${project_target_name})

add_subdirectory(Code)
endif()
106 changes: 106 additions & 0 deletions Code/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@

# Currently we are in the Game/Code folder: ${CMAKE_CURRENT_LIST_DIR}
# Get the platform specific folder ${pal_dir} for the current folder: ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME}
# Note: ly_get_list_relative_pal_filename will take care of the details for us, as this may be a restricted platform
# in which case it will see if that platform is present here or in the restricted folder.
# i.e. It could here : Game/Code/Platform/<platorm_name> or
# <restricted_folder>/<platform_name>/Game/Code
ly_get_list_relative_pal_filename(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME} ${o3de_project_restricted_path} ${o3de_project_path} ${o3de_project_name})

# Now that we have the platform abstraction layer (PAL) folder for this folder, thats where we will find the
# traits for this platform. Traits for a platform are defines for things like whether or not something in this project
# is supported by this platform.
include(${pal_dir}/PAL_${PAL_PLATFORM_NAME_LOWERCASE}.cmake)

# Now that we have loaded our project traits for this platform, see if this project is even supported on this platform.
# If its not supported we just return after including the unsupported.
if(NOT PAL_TRAIT_GAME_SUPPORTED)
return()
endif()

# We are on a supported platform, so add the Game target
# Note: We include the common files and the platform specific files which are set in game_files.cmake and
# in ${pal_dir}/game_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
ly_add_target(
NAME Game.Static STATIC
NAMESPACE Gem
FILES_CMAKE
game_files.cmake
${pal_dir}/game_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
INCLUDE_DIRECTORIES
PUBLIC
Include
BUILD_DEPENDENCIES
PRIVATE
AZ::AzGameFramework
Gem::Atom_AtomBridge.Static
)

ly_add_target(
NAME Game ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
NAMESPACE Gem
FILES_CMAKE
game_shared_files.cmake
${pal_dir}/game_shared_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
INCLUDE_DIRECTORIES
PUBLIC
Include
BUILD_DEPENDENCIES
PRIVATE
Gem::Game.Static
AZ::AzCore
)

# if enabled, Game is used by all kinds of applications
ly_create_alias(NAME Game.Builders NAMESPACE Gem TARGETS Gem::Game)
ly_create_alias(NAME Game.Tools NAMESPACE Gem TARGETS Gem::Game)
ly_create_alias(NAME Game.Clients NAMESPACE Gem TARGETS Gem::Game)
ly_create_alias(NAME Game.Servers NAMESPACE Gem TARGETS Gem::Game)

################################################################################
# Gem dependencies
################################################################################

# The GameLauncher uses "Clients" gem variants:
ly_enable_gems(
PROJECT_NAME Game GEM_FILE enabled_gems.cmake
TARGETS
Game.GameLauncher
VARIANTS
Clients)

if(PAL_TRAIT_BUILD_HOST_TOOLS)

# the builder type applications use the "Builders" variants of the enabled gems.
ly_enable_gems(
PROJECT_NAME Game GEM_FILE enabled_gems.cmake
TARGETS
AssetBuilder
AssetProcessor
AssetProcessorBatch
VARIANTS
Builders)

# the Editor applications use the "Tools" variants of the enabled gems.
ly_enable_gems(
PROJECT_NAME Game GEM_FILE enabled_gems.cmake
TARGETS
Editor
VARIANTS
Tools)
endif()

if(PAL_TRAIT_BUILD_SERVER_SUPPORTED)
# this property causes it to actually make a ServerLauncher.
# if you don't want a Server application, you can remove this and the
# following ly_enable_gems lines.
set_property(GLOBAL APPEND PROPERTY LY_LAUNCHER_SERVER_PROJECTS Game)

# The ServerLauncher uses the "Servers" variants of enabled gems:
ly_enable_gems(
PROJECT_NAME Game GEM_FILE enabled_gems.cmake
TARGETS
Game.ServerLauncher
VARIANTS
Servers)
endif()
31 changes: 31 additions & 0 deletions Code/Include/Game/GameBus.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

#pragma once

#include <AzCore/EBus/EBus.h>
#include <AzCore/Interface/Interface.h>

namespace Game
{
class GameRequests
{
public:
AZ_RTTI(GameRequests, "{98723945-f4c7-4380-976b-5a9068da35ff}");
virtual ~GameRequests() = default;
// Put your public methods here
};

class GameBusTraits
: public AZ::EBusTraits
{
public:
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
static constexpr AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
static constexpr AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
//////////////////////////////////////////////////////////////////////////
};

using GameRequestBus = AZ::EBus<GameRequests, GameBusTraits>;
using GameInterface = AZ::Interface<GameRequests>;

} // namespace Game
2 changes: 2 additions & 0 deletions Code/Platform/Android/PAL_android.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

set(PAL_TRAIT_GAME_SUPPORTED TRUE)
4 changes: 4 additions & 0 deletions Code/Platform/Android/game_android_files.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

set(FILES
PAL_android.cmake
)
3 changes: 3 additions & 0 deletions Code/Platform/Android/game_shared_android_files.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

set(FILES
)
2 changes: 2 additions & 0 deletions Code/Platform/Linux/PAL_linux.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

set(PAL_TRAIT_GAME_SUPPORTED TRUE)
4 changes: 4 additions & 0 deletions Code/Platform/Linux/game_linux_files.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

set(FILES
PAL_linux.cmake
)
3 changes: 3 additions & 0 deletions Code/Platform/Linux/game_shared_linux_files.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

set(FILES
)
2 changes: 2 additions & 0 deletions Code/Platform/Mac/PAL_mac.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

set(PAL_TRAIT_GAME_SUPPORTED TRUE)
5 changes: 5 additions & 0 deletions Code/Platform/Mac/game_mac_files.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

set(FILES
../../../Resources/Platform/Mac/Info.plist
PAL_mac.cmake
)
4 changes: 4 additions & 0 deletions Code/Platform/Mac/game_shared_mac_files.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

set(FILES
../../../Resources/Platform/Mac/Info.plist
)
2 changes: 2 additions & 0 deletions Code/Platform/Windows/PAL_windows.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

set(PAL_TRAIT_GAME_SUPPORTED TRUE)
3 changes: 3 additions & 0 deletions Code/Platform/Windows/game_shared_windows_files.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

set(FILES
)
4 changes: 4 additions & 0 deletions Code/Platform/Windows/game_windows_files.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

set(FILES
PAL_windows.cmake
)
2 changes: 2 additions & 0 deletions Code/Platform/iOS/PAL_ios.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

set(PAL_TRAIT_GAME_SUPPORTED TRUE)
5 changes: 5 additions & 0 deletions Code/Platform/iOS/game_ios_files.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

set(FILES
../Resources/Platform/iOS/Info.plist
PAL_ios.cmake
)
3 changes: 3 additions & 0 deletions Code/Platform/iOS/game_shared_ios_files.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

set(FILES
)
37 changes: 37 additions & 0 deletions Code/Source/GameModule.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

#include <AzCore/Memory/SystemAllocator.h>
#include <AzCore/Module/Module.h>

#include "GameSystemComponent.h"

namespace Game
{
class GameModule
: public AZ::Module
{
public:
AZ_RTTI(GameModule, "{d05515ea-bc09-47e4-b933-8dcf87d2315b}", AZ::Module);
AZ_CLASS_ALLOCATOR(GameModule, AZ::SystemAllocator, 0);

GameModule()
: AZ::Module()
{
// Push results of [MyComponent]::CreateDescriptor() into m_descriptors here.
m_descriptors.insert(m_descriptors.end(), {
GameSystemComponent::CreateDescriptor(),
});
}

/**
* Add required SystemComponents to the SystemEntity.
*/
AZ::ComponentTypeList GetRequiredSystemComponents() const override
{
return AZ::ComponentTypeList{
azrtti_typeid<GameSystemComponent>(),
};
}
};
}// namespace Game

AZ_DECLARE_MODULE_CLASS(Gem_Game, Game::GameModule)
76 changes: 76 additions & 0 deletions Code/Source/GameSystemComponent.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@

#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Serialization/EditContextConstants.inl>

#include "GameSystemComponent.h"

namespace Game
{
void GameSystemComponent::Reflect(AZ::ReflectContext* context)
{
if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
{
serialize->Class<GameSystemComponent, AZ::Component>()
->Version(0)
;

if (AZ::EditContext* ec = serialize->GetEditContext())
{
ec->Class<GameSystemComponent>("Game", "[Description of functionality provided by this System Component]")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("System"))
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
;
}
}
}

void GameSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
provided.push_back(AZ_CRC("GameService"));
}

void GameSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
{
incompatible.push_back(AZ_CRC("GameService"));
}

void GameSystemComponent::GetRequiredServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& required)
{
}

void GameSystemComponent::GetDependentServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& dependent)
{
}

GameSystemComponent::GameSystemComponent()
{
if (GameInterface::Get() == nullptr)
{
GameInterface::Register(this);
}
}

GameSystemComponent::~GameSystemComponent()
{
if (GameInterface::Get() == this)
{
GameInterface::Unregister(this);
}
}

void GameSystemComponent::Init()
{
}

void GameSystemComponent::Activate()
{
GameRequestBus::Handler::BusConnect();
}

void GameSystemComponent::Deactivate()
{
GameRequestBus::Handler::BusDisconnect();
}
}
40 changes: 40 additions & 0 deletions Code/Source/GameSystemComponent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

#pragma once

#include <AzCore/Component/Component.h>

#include <Game/GameBus.h>

namespace Game
{
class GameSystemComponent
: public AZ::Component
, protected GameRequestBus::Handler
{
public:
AZ_COMPONENT(GameSystemComponent, "{f0dc2ecf-af62-48ad-9b2a-f28b1657129a}");

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);

GameSystemComponent();
~GameSystemComponent();

protected:
////////////////////////////////////////////////////////////////////////
// GameRequestBus interface implementation

////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////
// AZ::Component interface implementation
void Init() override;
void Activate() override;
void Deactivate() override;
////////////////////////////////////////////////////////////////////////
};
}
Loading

0 comments on commit 2b21521

Please sign in to comment.