Skip to content

Commit

Permalink
Merge pull request #145 from o3de/cgalvan/gitflow_220509_multiplayers…
Browse files Browse the repository at this point in the history
…ample_main

Merged `stabilization/2205` to `main`
  • Loading branch information
cgalvan authored May 12, 2022
2 parents 83f23a7 + 690a7a3 commit 50a9aed
Show file tree
Hide file tree
Showing 93 changed files with 5,000 additions and 1,036 deletions.
44 changes: 44 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
name: Bug report
about: Create a report to help us improve
title: 'Bug Report'
labels: 'needs-triage,kind/bug'

---

**Describe the bug**
A clear and concise description of what the bug is. Try to isolate the issue to help the community to reproduce it easily and increase chances for a fast fix.

**Steps to reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '...'
3. Select attached asset '...'
4. Scroll down to '...'
5. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Actual behavior**
A clear and concise description of what actually happened.

**Assets required**
Provide sample assets needed to reproduce the issue.

**Screenshots/Video**
If applicable, add screenshots and/or a video to help explain your problem.

**Found in Branch**
Name of or link to the branch where the issue occurs.

**Desktop/Device (please complete the following information):**
- Device: [e.g. PC, Mac, iPhone, Samsung]
- OS: [e.g. Windows, macOS, iOS, Android]
- Version [e.g. 10, Bug Sur, Oreo]
- CPU [e.g. Intel I9-9900k , Ryzen 5900x, ]
- GPU [AMD 6800 XT, NVidia RTX 3090]
- Memory [e.g. 16GB]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---

name: Feature request
about: Suggest an idea for this project
title: 'Feature Request'
labels: 'needs-triage,kind/feature'

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
15 changes: 2 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,17 @@
#
#

#! Adds the --project-path argument to the VS IDE debugger command arguments
function(add_vs_debugger_arguments)
# Inject the project root into the --project-path argument into the Visual Studio Debugger arguments by defaults
list(APPEND app_targets MultiplayerSample.GameLauncher MultiplayerSample.ServerLauncher)
list(APPEND app_targets AssetBuilder AssetProcessor AssetProcessorBatch Editor)
foreach(app_target IN LISTS app_targets)
if (TARGET ${app_target})
set_property(TARGET ${app_target} APPEND PROPERTY VS_DEBUGGER_COMMAND_ARGUMENTS "--project-path=\"${CMAKE_CURRENT_LIST_DIR}\"")
endif()
endforeach()
endfunction()

if(NOT PROJECT_NAME)
cmake_minimum_required(VERSION 3.19)
include(cmake/CompilerSettings.cmake)
project(MultiplayerSample
LANGUAGES C CXX
VERSION 1.0.0.0
)
include(EngineFinder.cmake OPTIONAL)
include(cmake/EngineFinder.cmake OPTIONAL)
find_package(o3de REQUIRED)
o3de_initialize()
add_vs_debugger_arguments()
else()
# Add the project_name to global LY_PROJECTS_TARGET_NAME property
file(READ "${CMAKE_CURRENT_LIST_DIR}/project.json" project_json)
Expand Down
4 changes: 4 additions & 0 deletions Gem/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@
#
#

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)

add_subdirectory(Code)
7 changes: 5 additions & 2 deletions Gem/Code/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#
# 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
#
#

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

ly_add_target(
NAME MultiplayerSample.Static STATIC
Expand Down Expand Up @@ -77,3 +77,6 @@ ly_enable_gems(PROJECT_NAME MultiplayerSample GEM_FILE enabled_gems.cmake)
if(PAL_TRAIT_BUILD_SERVER_SUPPORTED)
set_property(GLOBAL APPEND PROPERTY LY_LAUNCHER_SERVER_PROJECTS MultiplayerSample)
endif()

set_property(TARGET MultiplayerSample APPEND PROPERTY GAMELAUNCHER_ADDITIONAL_VS_DEBUGGER_COMMAND_ARGUMENTS "--console-command-file=\"client.cfg\"")
set_property(TARGET MultiplayerSample APPEND PROPERTY SERVERLAUNCHER_ADDITIONAL_VS_DEBUGGER_COMMAND_ARGUMENTS "--console-command-file=\"server.cfg\"")
66 changes: 66 additions & 0 deletions Gem/Code/Include/NetworkPrefabSpawnerInterface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/

#pragma once

#include <AzCore/Math/Transform.h>
#include <AzFramework/Spawnable/SpawnableEntitiesInterface.h>

namespace MultiplayerSample
{
using PrefabSpawnCallbackBeforeActivation = AZStd::function<void(
AZStd::shared_ptr<AzFramework::EntitySpawnTicket>,
AzFramework::SpawnableEntityContainerView)>;

using PrefabSpawnCallback = AZStd::function<void(
AZStd::shared_ptr<AzFramework::EntitySpawnTicket>,
AzFramework::SpawnableConstEntityContainerView)>;

struct PrefabCallbacks
{
PrefabSpawnCallbackBeforeActivation m_beforeActivateCallback;
PrefabSpawnCallback m_onActivateCallback;
};

class NetworkPrefabSpawnerRequests
{
public:
AZ_RTTI(NetworkPrefabSpawnerRequests, "{82e5cfb5-6a1a-4bd1-b48d-cd817474d611}");
virtual ~NetworkPrefabSpawnerRequests() = default;

/**
* \brief Spawn a prefab given its asset path at a specified transform.
* \param worldTm Where to spawn the instance.
* \param assetPath Path to .spawnable asset to spawn from.
* \param callbacks Optional structure for pre-activate and post-activate callbacks.
*/
virtual void SpawnPrefab(const AZ::Transform& worldTm, const char* assetPath, PrefabCallbacks callbacks) = 0;

/**
* \brief Spawn a prefab from spawnable asset at a specified transform.
* \param worldTm Where to spawn the instance.
* \param asset .spawnable asset to spawn from.
* \param callbacks Optional structure for pre-activate and post-activate callbacks.
*/
virtual void SpawnPrefabAsset(const AZ::Transform& worldTm, const AZ::Data::Asset<AzFramework::Spawnable>& asset, PrefabCallbacks callbacks) = 0;

/**
* \brief Spawn a prefab instance from spawnable asset assigned in the spawner component. See @NetworkPrefabSpawnerComponent.
* \param worldTm Where to spawn the instance.
* \param callbacks Optional structure for pre-activate and post-activate callbacks.
*/
virtual void SpawnDefaultPrefab(const AZ::Transform& worldTm, PrefabCallbacks callbacks) = 0;
};

class NetworkPrefabSpawnerTraits
: public AZ::ComponentBus
{
};

using NetworkPrefabSpawnerRequestBus = AZ::EBus<NetworkPrefabSpawnerRequests, NetworkPrefabSpawnerTraits>;
using NetworkPrefabSpawnerInterface = AZ::Interface<NetworkPrefabSpawnerRequests>;
}
2 changes: 2 additions & 0 deletions Gem/Code/Source/AutoGen/NetworkAiComponent.AutoComponent.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<!-- Our "AI" is really just a chaos monkey. Every N ms, we choose a cardinal direction to move towards, -->
<!-- and flip coins to determine if we should shoot, or perform some other action. -->

<ComponentRelation Constraint="Required" HasController="true" Name="LocalPredictionPlayerInputComponent" Namespace="Multiplayer" Include="Multiplayer/Components/LocalPredictionPlayerInputComponent.h" />

<NetworkProperty Type="bool" Name="Enabled" Init="false" ReplicateFrom="Authority" ReplicateTo="Client" Container="Object" IsPublic="true" IsRewindable="false" IsPredictable="false" ExposeToEditor="true" ExposeToScript="false" GenerateEventBindings="false" Description="If enabled, this AI component overrides movement and camera components." />

<NetworkProperty Type="float" Name="remainingTimeMs" Init="0.f" ReplicateFrom="Authority" ReplicateTo="Server" Container="Object" IsPublic="true" IsRewindable="false" IsPredictable="false" ExposeToEditor="false" ExposeToScript="false" GenerateEventBindings="false" Description="" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<ComponentRelation Constraint="Required" HasController="true" Name="NetworkAnimationComponent" Namespace="MultiplayerSample" Include="Source/Components/NetworkAnimationComponent.h" />
<ComponentRelation Constraint="Required" HasController="true" Name="NetworkCharacterComponent" Namespace="Multiplayer" Include="Multiplayer/Components/NetworkCharacterComponent.h" />
<ComponentRelation Constraint="Required" HasController="true" Name="NetworkSimplePlayerCameraComponent" Namespace="MultiplayerSample" Include="Source/Components/NetworkSimplePlayerCameraComponent.h" />
<ComponentRelation Constraint="Weak" HasController="true" Name="NetworkAiComponent" Namespace="MultiplayerSample" Include="Source/Components/NetworkAiComponent.h" />

<Include File="Source/MultiplayerSampleTypes.h"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
<Component
Name="NetworkPlayerSpawnerComponent"
Namespace="MultiplayerSample"
OverrideComponent="false"
OverrideComponent="true"
OverrideController="false"
OverrideInclude="Source/Components/NetworkPlayerSpawnerComponent.h"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<Include File="AzCore/Asset/AssetSerializer.h"/>
<Include File="AzFramework/Spawnable/Spawnable.h"/>

<ComponentRelation Constraint="Weak" HasController="false" Name="TransformComponent" Namespace="AzFramework" Include="AzFramework/Components/TransformComponent.h" />

<ArchetypeProperty Type="bool" Name="SnapToGround" Init="false" ExposeToEditor="true" />
<ArchetypeProperty Type="AZ::Data::Asset&lt;AzFramework::Spawnable&gt;" Name="SpawnableAsset" Init="" ExposeToEditor="true" />
</Component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>

<Component
Name="NetworkRandomImpulseComponent"
Namespace="MultiplayerSample"
OverrideComponent="false"
OverrideController="true"
OverrideInclude="Source/Components/PerfTest/NetworkRandomImpulseComponent.h"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<ArchetypeProperty Type="bool" Name="EnableHopping" Init="true" ExposeToEditor="true" Description="Enables occasional hops." />
<ArchetypeProperty Type="float" Name="HopPeriod" Init="2.f" ExposeToEditor="true" Description="Number of seconds between vertical hopping." />
<ArchetypeProperty Type="float" Name="HopForce" Init="200.f" ExposeToEditor="true" Description="Force of a hop." />

</Component>
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
<Include File="Source/MultiplayerSampleTypes.h"/>

<NetworkProperty Type="AZ::Vector3" Name="AimAngles" Init="AZ::Vector3::CreateZero()" ReplicateFrom="Authority" ReplicateTo="Client" IsRewindable="true" IsPredictable="true" IsPublic="true" Container="Object" ExposeToEditor="false" ExposeToScript="false" GenerateEventBindings="true" Description="Current aim direction of this player"/>
<NetworkProperty Type="bool" Name="SyncAimImmediate" Init="false" ReplicateFrom="Authority" ReplicateTo="Client" IsRewindable="false" IsPredictable="true" IsPublic="true" Container="Object" ExposeToEditor="false" ExposeToScript="false" GenerateEventBindings="true" Description="Flag to force aim angles sync without interpolation"/>
</Component>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
OverrideInclude="Source/Components/NetworkStressTestComponent.h"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<ArchetypeProperty Type="AZ::TimeMs" Name="AutoSpawnIntervalMs" Init="0" ExposeToEditor="true" Description="If > 0, will autospawn an AI using the provided interval" />
<ArchetypeProperty Type="uint32_t" Name="MaxSpawns" Init="0" ExposeToEditor="true" Description="If > 0, will cap the total number of spawned AI to the provided value" />

<NetworkProperty Type="bool" Name="Enabled" Init="true" ReplicateFrom="Authority" ReplicateTo="Client" Container="Object" IsPublic="true" IsRewindable="false" IsPredictable="false" ExposeToEditor="true" ExposeToScript="false" GenerateEventBindings="false" Description="If enabled, this AI component overrides movement and camera components." />
<NetworkProperty Type="uint32_t" Name="SpawnCount" Init="0" ReplicateFrom="Authority" ReplicateTo="Server" Container="Object" IsPublic="true" IsRewindable="false" IsPredictable="false" ExposeToEditor="false" ExposeToScript="false" GenerateEventBindings="false" Description="Tracks the total number of spawns by this component." />

<RemoteProcedure Name="SpawnAIEntity" InvokeFrom="Autonomous" HandleOn="Authority" IsPublic="true" IsReliable="true" GenerateEventBindings="false" Description="Spawn AI Entity RPC">
<Param Type="float" Name="fireIntervalMinMs"/>
<Param Type="float" Name="fireIntervalMaxMs"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0"?>

<Component
Name="NetworkTestSpawnerComponent"
Namespace="MultiplayerSample"
OverrideComponent="false"
OverrideController="true"
OverrideInclude="Source/Components/PerfTest/NetworkTestSpawnerComponent.h"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<ComponentRelation Constraint="Required" HasController="true" Name="NetworkRandomComponent" Namespace="MultiplayerSample" Include="Source/Components/NetworkRandomComponent.h" />
<ComponentRelation Constraint="Required" HasController="false" Name="NetworkPrefabSpawnerComponent" Namespace="MultiplayerSample" Include="Source/Components/PerfTest/NetworkPrefabSpawnerComponent.h" />

<ArchetypeProperty Type="bool" Name="Enabled" Init="true" ExposeToEditor="true" Description="Enables spawning of test prefabs." />
<ArchetypeProperty Type="bool" Name="RespawnEnabled" Init="false" ExposeToEditor="true" Description="Deletes old instances and spawns new ones when at the maximum live count." />
<ArchetypeProperty Type="int" Name="MaxLiveCount" Init="100" ExposeToEditor="true" Description="Maximum objects to keep alive, will delete older objects when the count goes above this value." />
<ArchetypeProperty Type="int" Name="SpawnPerSecond" Init="10" ExposeToEditor="true" Description="How many prefabs to spawn per second." />

</Component>
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@

<ComponentRelation Constraint="Required" HasController="true" Name="NetworkAnimationComponent" Namespace="MultiplayerSample" Include="Source/Components/NetworkAnimationComponent.h" />
<ComponentRelation Constraint="Required" HasController="true" Name="NetworkSimplePlayerCameraComponent" Namespace="MultiplayerSample" Include="Source/Components/NetworkSimplePlayerCameraComponent.h" />
<ComponentRelation Constraint="Weak" HasController="true" Name="NetworkAiComponent" Namespace="MultiplayerSample" Include="Source/Components/NetworkAiComponent.h" />

<Include File="Source/Weapons/WeaponTypes.h" />

<NetworkInput Type="bool" Name="Draw" Init="false" />
<NetworkInput Type="WeaponActivationBitset" Name="Firing" Init="" />
<NetworkInput Type="AZ::Vector3" Name="ShotStartPosition" Init="" />

<NetworkProperty Type="FireParams" Name="ActivationParams" Init="" Container="Array" Count="MaxWeaponsPerComponent" ReplicateFrom="Authority" ReplicateTo="Client" IsPublic="false" IsRewindable="false" IsPredictable="false" ExposeToEditor="false" GenerateEventBindings="false" Description="Parameters for the current weapon activation" />
<NetworkProperty Type="uint8_t" Name="ActivationCounts" Init="0" Container="Array" Count="MaxWeaponsPerComponent" ReplicateFrom="Authority" ReplicateTo="Client" IsPublic="false" IsRewindable="false" IsPredictable="false" ExposeToEditor="false" GenerateEventBindings="true" Description="The number of activations" />
Expand Down
4 changes: 2 additions & 2 deletions Gem/Code/Source/Components/ExampleFilteredEntityComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ namespace MultiplayerSample

void ExampleFilteredEntityComponent::Activate()
{
Multiplayer::GetMultiplayer()->SetFilterEntityManager( this );
AZ::Interface<IFilterEntityManager>::Register(this);
}

void ExampleFilteredEntityComponent::Deactivate()
{
Multiplayer::GetMultiplayer()->SetFilterEntityManager( nullptr );
AZ::Interface<IFilterEntityManager>::Unregister(this);
}

bool ExampleFilteredEntityComponent::IsEntityFiltered(
Expand Down
10 changes: 2 additions & 8 deletions Gem/Code/Source/Components/NetworkAiComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ namespace MultiplayerSample
{
if (GetEnabled())
{
Multiplayer::LocalPredictionPlayerInputComponent* playerInputComponent = FindComponent<Multiplayer::LocalPredictionPlayerInputComponent>();
Multiplayer::LocalPredictionPlayerInputComponentController* playerInputController = (playerInputComponent != nullptr) ?
static_cast<Multiplayer::LocalPredictionPlayerInputComponentController*>(playerInputComponent->GetController()) : nullptr;

Multiplayer::LocalPredictionPlayerInputComponentController* playerInputController = GetLocalPredictionPlayerInputComponentController();
if (playerInputController != nullptr)
{
playerInputController->ForceEnableAutonomousUpdate();
Expand All @@ -42,10 +39,7 @@ namespace MultiplayerSample
{
if (GetEnabled())
{
Multiplayer::LocalPredictionPlayerInputComponent* playerInputComponent = FindComponent<Multiplayer::LocalPredictionPlayerInputComponent>();
Multiplayer::LocalPredictionPlayerInputComponentController* playerInputController = (playerInputComponent != nullptr) ?
static_cast<Multiplayer::LocalPredictionPlayerInputComponentController*>(playerInputComponent->GetController()) : nullptr;

Multiplayer::LocalPredictionPlayerInputComponentController* playerInputController = GetLocalPredictionPlayerInputComponentController();
if (playerInputController != nullptr)
{
playerInputController->ForceDisableAutonomousUpdate();
Expand Down
Loading

0 comments on commit 50a9aed

Please sign in to comment.