123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- /*
- * 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 <Source/AutoGen/AnimatedHitVolumesComponent.AutoComponent.h>
- #include <Multiplayer/Components/NetBindComponent.h>
- #include <Integration/ActorComponentBus.h>
- namespace Physics
- {
- class CharacterRequests;
- class CharacterHitDetectionConfiguration;
- }
- namespace MultiplayerSample
- {
- class AnimatedHitVolumesComponent
- : public AnimatedHitVolumesComponentBase
- , private EMotionFX::Integration::ActorComponentNotificationBus::Handler
- {
- public:
- struct AnimatedHitVolume final
- {
- AnimatedHitVolume
- (
- AzNetworking::ConnectionId connectionId,
- Physics::CharacterRequests* character,
- const char* hitVolumeName,
- const Physics::ColliderConfiguration* colliderConfig,
- const Physics::ShapeConfiguration* shapeConfig,
- const uint32_t jointIndex
- );
- ~AnimatedHitVolume() = default;
- void UpdateTransform(const AZ::Transform& transform);
- void SyncToCurrentTransform();
- Multiplayer::RewindableObject<AZ::Transform, Multiplayer::RewindHistorySize> m_transform;
- AZStd::shared_ptr<Physics::Shape> m_physicsShape;
- // Cached so we don't have to do subsequent lookups by name
- const Physics::ColliderConfiguration* m_colliderConfig = nullptr;
- const Physics::ShapeConfiguration* m_shapeConfig = nullptr;
- AZ::Transform m_colliderOffSetTransform;
- const AZ::u32 m_jointIndex = 0;
- };
- AZ_MULTIPLAYER_COMPONENT(MultiplayerSample::AnimatedHitVolumesComponent, s_animatedHitVolumesComponentConcreteUuid, MultiplayerSample::AnimatedHitVolumesComponentBase);
- static void Reflect(AZ::ReflectContext* context);
- AnimatedHitVolumesComponent();
- void OnInit() override;
- void OnActivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
- void OnDeactivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
- private:
- void OnPreRender(float deltaTime, float blendFactor);
- void OnTransformUpdate(const AZ::Transform& transform);
- void OnSyncRewind();
- void CreateHitVolumes();
- void DestroyHitVolumes();
- //! ActorComponentNotificationBus::Handler
- //! @{
- void OnActorInstanceCreated(EMotionFX::ActorInstance* actorInstance) override;
- void OnActorInstanceDestroyed(EMotionFX::ActorInstance* actorInstance) override;
- //! @}
- Physics::CharacterRequests* m_physicsCharacter = nullptr;
- EMotionFX::Integration::ActorComponentRequests* m_actorComponent = nullptr;
- const Physics::CharacterColliderConfiguration* m_hitDetectionConfig = nullptr;
- AZStd::vector<AnimatedHitVolume> m_animatedHitVolumes;
- Multiplayer::EntitySyncRewindEvent::Handler m_syncRewindHandler;
- Multiplayer::EntityPreRenderEvent::Handler m_preRenderHandler;
- };
- }
|