Exposing NetworkCharacterComponent::TryMoveWithVelocity to script. Updating Multiplayer AutoComponent baseclass behavior context to Reflect itself instead of its derived (human made) component. This is so the derived class can also create behaviorcontext classes of its own if needed. Misc copyright header edit.

Signed-off-by: Gene Walters <genewalt@amazon.com>
This commit is contained in:
Gene Walters
2021-09-23 09:46:55 -07:00
parent d7e29c00c7
commit c2c18f094b
5 changed files with 48 additions and 7 deletions
@@ -83,7 +83,7 @@ namespace Multiplayer
return physx::PxQueryHitType::eNONE;
}
void NetworkCharacterComponent::NetworkCharacterComponent::Reflect(AZ::ReflectContext* context)
void NetworkCharacterComponent::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (serializeContext)
@@ -92,6 +92,7 @@ namespace Multiplayer
->Version(1);
}
NetworkCharacterComponentBase::Reflect(context);
NetworkCharacterComponentController::Reflect(context);
}
NetworkCharacterComponent::NetworkCharacterComponent()
@@ -161,6 +162,18 @@ namespace Multiplayer
return state.touchedActor != nullptr || (state.collisionFlags & physx::PxControllerCollisionFlag::eCOLLISION_DOWN) != 0;
}
void NetworkCharacterComponentController::Reflect(AZ::ReflectContext* context)
{
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
{
behaviorContext->EBus<NetworkCharacterRequestBus>("NetworkCharacterRequestBus")
->Event("TryMoveWithVelocity", &NetworkCharacterRequestBus::Events::TryMoveWithVelocity);
behaviorContext->Class<NetworkCharacterComponentController>("NetworkCharacterComponentController")
->RequestBus("NetworkCharacterRequestBus");
}
}
NetworkCharacterComponentController::NetworkCharacterComponentController(NetworkCharacterComponent& parent)
: NetworkCharacterComponentControllerBase(parent)
{
@@ -169,12 +182,12 @@ namespace Multiplayer
void NetworkCharacterComponentController::OnActivate([[maybe_unused]] Multiplayer::EntityIsMigrating entityIsMigrating)
{
;
NetworkCharacterRequestBus::Handler::BusConnect(GetEntity()->GetId());
}
void NetworkCharacterComponentController::OnDeactivate([[maybe_unused]] Multiplayer::EntityIsMigrating entityIsMigrating)
{
;
NetworkCharacterRequestBus::Handler::BusDisconnect(GetEntity()->GetId());
}
AZ::Vector3 NetworkCharacterComponentController::TryMoveWithVelocity(const AZ::Vector3& velocity, [[maybe_unused]] float deltaTime)