Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Gems/O3DEReflect/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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


o3de_gem_setup("O3DEReflect")

set(gem_path ${CMAKE_CURRENT_LIST_DIR})
set(gem_json ${gem_path}/gem.json)
o3de_restricted_path(${gem_json} gem_restricted_path gem_parent_relative_path)

o3de_pal_dir(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME} "${gem_restricted_path}" "${gem_path}" "${gem_parent_relative_path}")

ly_add_external_target_path(${CMAKE_CURRENT_LIST_DIR}/3rdParty)

add_subdirectory(Code)

55 changes: 55 additions & 0 deletions Gems/O3DEReflect/Code/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# 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

# O3DEReflect gem - no platform-specific code needed

ly_add_target(
NAME O3DEReflect.Static STATIC
NAMESPACE Gem
FILES_CMAKE
o3dereflect_files.cmake
INCLUDE_DIRECTORIES
PUBLIC
Include
Source
BUILD_DEPENDENCIES
PUBLIC
AZ::AzCore
AZ::AzFramework
)

ly_add_target(
NAME O3DEReflect ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
NAMESPACE Gem
FILES_CMAKE
o3dereflect_shared_files.cmake
INCLUDE_DIRECTORIES
PUBLIC
Include
PRIVATE
Source
BUILD_DEPENDENCIES
PRIVATE
Gem::O3DEReflect.Static
)

# Inject the gem name into the Module source file
ly_add_source_properties(
SOURCES
Source/O3DEReflectModule.cpp
PROPERTY COMPILE_DEFINITIONS
VALUES
O3DE_GEM_NAME=O3DEReflect
O3DE_GEM_VERSION=1.0.0
)

# Load the "Gem::O3DEReflect" module in all types of applications
ly_create_alias(NAME O3DEReflect.Servers NAMESPACE Gem TARGETS Gem::O3DEReflect)
ly_create_alias(NAME O3DEReflect.Unified NAMESPACE Gem TARGETS Gem::O3DEReflect)
ly_create_alias(NAME O3DEReflect.Clients NAMESPACE Gem TARGETS Gem::O3DEReflect)
ly_create_alias(NAME O3DEReflect.Tools NAMESPACE Gem TARGETS Gem::O3DEReflect)
ly_create_alias(NAME O3DEReflect.Builders NAMESPACE Gem TARGETS Gem::O3DEReflect)


49 changes: 49 additions & 0 deletions Gems/O3DEReflect/Code/Examples/AIState.O3DEReflect.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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

Example O3DEReflect Enum - AI State

This demonstrates how to define an enum using O3DEReflect XML.
Like Unreal's UENUM, this creates a scriptable, editor-visible enumeration.
-->
<Enum
Name="AIState"
Namespace="Example"
Category="AI"
Description="Possible states for an AI character"
ScriptType="true"
UnderlyingType="uint8_t">

<EnumValue Name="Idle" Value="0"
DisplayName="Standing Idle"
Tooltip="AI is idle and not doing anything"/>

<EnumValue Name="Patrol" Value="1"
DisplayName="Patrolling"
Tooltip="AI is following a patrol route"/>

<EnumValue Name="Alert" Value="2"
DisplayName="On Alert"
Tooltip="AI has detected something suspicious"/>

<EnumValue Name="Chase" Value="3"
DisplayName="Chasing Target"
Tooltip="AI is actively pursuing a target"/>

<EnumValue Name="Combat" Value="4"
DisplayName="In Combat"
Tooltip="AI is engaged in combat"/>

<EnumValue Name="Flee" Value="5"
DisplayName="Fleeing"
Tooltip="AI is running away from danger"/>

<EnumValue Name="Dead" Value="6"
DisplayName="Dead"
Tooltip="AI has been killed"/>

</Enum>
80 changes: 80 additions & 0 deletions Gems/O3DEReflect/Code/Examples/BeforeAfterComparison.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* 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
*
*/

#pragma once

#include <AzCore/Component/Component.h>
#include <AzCore/RTTI/RTTI.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Serialization/EditContextConstants.inl>
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/Math/Vector3.h>

namespace TraditionalExample
{
// HEADER FILE - PlayerMovementComponent.h
// ========================================

class PlayerMovementComponent
: public AZ::Component
{
public:
AZ_COMPONENT(PlayerMovementComponent, "{A1B2C3D4-E5F6-7890-ABCD-123456789ABC}");

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

PlayerMovementComponent() = default;
~PlayerMovementComponent() override = default;

// Getters and Setters - MUST WRITE MANUALLY
float GetMoveSpeed() const { return m_moveSpeed; }
void SetMoveSpeed(float value) { m_moveSpeed = value; }

float GetSprintMultiplier() const { return m_sprintMultiplier; }
void SetSprintMultiplier(float value) { m_sprintMultiplier = value; }

float GetJumpForce() const { return m_jumpForce; }
void SetJumpForce(float value) { m_jumpForce = value; }

int GetMaxJumps() const { return m_maxJumps; }
void SetMaxJumps(int value) { m_maxJumps = value; }

bool GetIsGrounded() const { return m_isGrounded; }
const AZ::Vector3& GetCurrentVelocity() const { return m_currentVelocity; }

void Jump();
void Move(const AZ::Vector3& direction, float deltaTime);
void SetSprinting(bool sprinting);
float GetCurrentSpeed() const;
void Teleport(const AZ::Vector3& position);

protected:
void Init() override;
void Activate() override;
void Deactivate() override;

private:
// MUST MANUALLY DECLARE ALL MEMBERS
float m_moveSpeed = 5.0f;
float m_sprintMultiplier = 2.0f;
float m_jumpForce = 400.0f;
int m_maxJumps = 2;
float m_gravityMultiplier = 1.0f;
bool m_isGrounded = false;
AZ::Vector3 m_currentVelocity = AZ::Vector3::CreateZero();
};

} // namespace TraditionalExample


58 changes: 58 additions & 0 deletions Gems/O3DEReflect/Code/Examples/DamageFlags.O3DEReflect.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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

Example O3DEReflect Flags Enum - Damage Flags

This demonstrates how to define a bitfield/flags enum using O3DEReflect XML.
Setting Flags="true" automatically generates bitwise operators and flag values.
-->
<Enum
Name="DamageFlags"
Namespace="Example"
Category="Combat"
Description="Flags that modify damage behavior"
ScriptType="true"
Flags="true"
UnderlyingType="uint32_t">

<EnumValue Name="None" Value="0"
DisplayName="No Flags"
Tooltip="No special damage flags"/>

<EnumValue Name="IgnoreArmor"
DisplayName="Ignore Armor"
Tooltip="Damage bypasses armor/shields"/>

<EnumValue Name="CanCrit"
DisplayName="Can Critical Hit"
Tooltip="Damage has a chance to be a critical hit"/>

<EnumValue Name="ApplyKnockback"
DisplayName="Apply Knockback"
Tooltip="Damage applies knockback force"/>

<EnumValue Name="ApplyStun"
DisplayName="Apply Stun"
Tooltip="Damage has a chance to stun the target"/>

<EnumValue Name="ApplyBurn"
DisplayName="Apply Burn"
Tooltip="Damage applies a burning damage-over-time effect"/>

<EnumValue Name="ApplyFreeze"
DisplayName="Apply Freeze"
Tooltip="Damage has a chance to freeze the target"/>

<EnumValue Name="Unblockable"
DisplayName="Unblockable"
Tooltip="Damage cannot be blocked or parried"/>

<EnumValue Name="FriendlyFire"
DisplayName="Friendly Fire"
Tooltip="Damage affects allies as well as enemies"/>

</Enum>
60 changes: 60 additions & 0 deletions Gems/O3DEReflect/Code/Examples/DamageInfo.O3DEReflect.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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

Example O3DEReflect Struct - Damage Info

This demonstrates how to define a data struct using O3DEReflect XML.
Like Unreal's USTRUCT, this creates a serializable, scriptable data type.
-->
<Struct
Name="DamageInfo"
Namespace="Example"
Category="Combat"
Description="Information about damage dealt to an entity"
ScriptType="true">

<Include File="AzCore/Component/EntityId.h"/>
<Include File="AzCore/Math/Vector3.h"/>

<Property Name="damageAmount" Type="float" Default="0.0f"
Tooltip="Amount of damage dealt"
Min="0.0"
EditAnywhere="true"
ScriptReadWrite="true"/>

<Property Name="damageType" Type="AZ::Crc32" Default="AZ_CRC_CE(&quot;Physical&quot;)"
Tooltip="Type of damage (Physical, Fire, Ice, etc.)"
EditAnywhere="true"
ScriptReadWrite="true"/>

<Property Name="instigator" Type="AZ::EntityId" Default="AZ::EntityId()"
Tooltip="Entity that caused the damage"
EditAnywhere="true"
ScriptReadWrite="true"/>

<Property Name="hitLocation" Type="AZ::Vector3" Default="AZ::Vector3::CreateZero()"
Tooltip="World position where damage was applied"
EditAnywhere="true"
ScriptReadWrite="true"/>

<Property Name="hitNormal" Type="AZ::Vector3" Default="AZ::Vector3::CreateAxisZ()"
Tooltip="Surface normal at hit point"
EditAnywhere="true"
ScriptReadWrite="true"/>

<Property Name="isCritical" Type="bool" Default="false"
Tooltip="Whether this was a critical hit"
EditAnywhere="true"
ScriptReadWrite="true"/>

<Property Name="criticalMultiplier" Type="float" Default="2.0f"
Tooltip="Damage multiplier for critical hits"
Min="1.0" Max="10.0"
EditAnywhere="true"
ScriptReadWrite="true"/>

</Struct>
Loading