First pass for network hierarchy input processing

Signed-off-by: pereslav <pereslav@amazon.com>
This commit is contained in:
pereslav
2021-10-01 00:07:23 +01:00
parent bee4346df8
commit ef3552df69
5 changed files with 199 additions and 1 deletions
@@ -57,6 +57,8 @@ namespace Multiplayer
void BindNetworkHierarchyLeaveEventHandler(NetworkHierarchyLeaveEvent::Handler& handler) override;
//! @}
const AZStd::vector<AZ::Entity*>& GetHierarchicalEntitiesRef() const;
protected:
void SetTopLevelHierarchyRootEntity(AZ::Entity* hierarchyRoot);
@@ -97,4 +99,24 @@ namespace Multiplayer
//! Set to false when deactivating or otherwise not to be included in hierarchy considerations.
bool m_isHierarchyEnabled = true;
};
//! NetworkCharacterComponentController
//! This is the network controller for NetworkHierarchyRootComponent.
//! Class provides the ability to process input for hierarchies.
class NetworkHierarchyRootComponentController
: public NetworkHierarchyRootComponentControllerBase
{
public:
NetworkHierarchyRootComponentController(NetworkHierarchyRootComponent& parent);
// NetworkHierarchyRootComponentControllerBase
void OnActivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
void OnDeactivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
//! MultiplayerController interface
Multiplayer::MultiplayerController::InputPriorityOrder GetInputOrder() const override;
void CreateInput(Multiplayer::NetworkInput& input, float deltaTime) override;
void ProcessInput(Multiplayer::NetworkInput& input, float deltaTime) override;
};
}
@@ -29,6 +29,7 @@ namespace Multiplayer
friend class NetworkInputMigrationVector;
friend class NetworkInputHistory;
friend class NetworkInputChild;
friend class NetworkSubInput;
NetworkInput(const NetworkInput&);
NetworkInput& operator= (const NetworkInput&);
@@ -80,4 +81,28 @@ namespace Multiplayer
ConstNetworkEntityHandle m_owner;
bool m_wasAttached = false;
};
// Used by the NetworkHierarchyRootComponent. This component allows the gameplay programmer to specify dependent entities
// Since it is possible to for the Client/Server to disagree about the state of related entities, this input encodes the entity that
// is associated with it.
class NetworkSubInput final
{
public:
NetworkSubInput() = default;
NetworkSubInput(const NetworkSubInput&) = default;
NetworkSubInput(const ConstNetworkEntityHandle& entityHandle);
NetworkSubInput& operator=(const NetworkSubInput&) = default;
void Attach(const ConstNetworkEntityHandle& entityHandle);
const ConstNetworkEntityHandle& GetOwner() const;
NetworkInput& GetNetworkInput();
const NetworkInput& GetNetworkInput() const;
bool Serialize(AzNetworking::ISerializer& serializer);
private:
ConstNetworkEntityHandle m_owner;
NetworkInput m_networkInput;
};
}