You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
o3de/Gems/Multiplayer/Code/Tests/TestMultiplayerComponent.h

62 lines
2.2 KiB
C++

/*
* 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 <Tests/AutoGen/TestMultiplayerComponent.AutoComponent.h>
namespace MultiplayerTest
{
// Dummy class for satisfying "MultiplayerInputDriver" component dependency
class TestInputDriverComponent : public AZ::Component
{
public:
AZ_COMPONENT(TestInputDriverComponent, "{C3877905-3B61-45AE-A636-9845C3AAA39D}");
static void Reflect(AZ::ReflectContext* context);
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
provided.emplace_back(AZ_CRC_CE("MultiplayerInputDriver"));
}
void Activate() override {}
void Deactivate() override {}
};
// Test multiplayer component with ability to create and process network input
class TestMultiplayerComponent
: public TestMultiplayerComponentBase
{
public:
AZ_MULTIPLAYER_COMPONENT(MultiplayerTest::TestMultiplayerComponent, s_testMultiplayerComponentConcreteUuid, MultiplayerTest::TestMultiplayerComponentBase);
static void Reflect(AZ::ReflectContext* context);
void OnInit() override;
void OnActivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
void OnDeactivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
AZStd::function<void(Multiplayer::NetEntityId)> m_processInputCallback;
};
// Multiplayer controller for the test component
class TestMultiplayerComponentController
: public TestMultiplayerComponentControllerBase
{
public:
TestMultiplayerComponentController(TestMultiplayerComponent& parent);
//! TestMultiplayerComponentControllerBase
void OnActivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
void OnDeactivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
//! MultiplayerController interface
void CreateInput(Multiplayer::NetworkInput& input, float deltaTime) override;
void ProcessInput(Multiplayer::NetworkInput& input, float deltaTime) override;
};
}