瀏覽代碼

Bug fixes, tweaks, and addressing code review feedback

Signed-off-by: kberg-amzn <[email protected]>
kberg-amzn 2 年之前
父節點
當前提交
a3a8d0a138

+ 0 - 1
Gem/Code/Source/AutoGen/EnergyBallComponent.AutoComponent.xml

@@ -18,7 +18,6 @@
     <ArchetypeProperty Type="HitEffect" Name="HitEffect" Init="" ExposeToEditor="true" Description="Specifies the damage effects to apply on hit" />
     <ArchetypeProperty Type="AZ::TimeMs" Name="LifetimeMs" Init="AZ::TimeMs{ 0 }" Container="Object" ExposeToEditor="true" Description="Specifies the duration in milliseconds that the projectile should live for" />
 
-    <NetworkProperty Type="Multiplayer::NetEntityId" Name="ShooterNetEntityId" Init="Multiplayer::InvalidNetEntityId" ReplicateFrom="Authority" ReplicateTo="Client" Container="Object" IsPublic="true" IsRewindable="true" IsPredictable="false" ExposeToScript="true" ExposeToEditor="false" GenerateEventBindings="true" Description="The net entityId of the entity that shot the energy ball" />
     <NetworkProperty Type="AZ::Vector3" Name="Velocity" Init="AZ::Vector3::CreateZero()" ReplicateFrom="Authority" ReplicateTo="Client" Container="Object" IsPublic="true" IsRewindable="true" IsPredictable="false" ExposeToScript="true" ExposeToEditor="false" GenerateEventBindings="true" Description="The energy balls current velocity" />
     <NetworkProperty Type="bool" Name="BallActive" Init="false" ReplicateFrom="Authority" ReplicateTo="Client" Container="Object" IsPublic="true" IsRewindable="true" IsPredictable="false" ExposeToScript="true" ExposeToEditor="false" GenerateEventBindings="true" Description="Track whether or not the energy ball is currently active" />
 

+ 1 - 0
Gem/Code/Source/AutoGen/EnergyCannonComponent.AutoComponent.xml

@@ -19,4 +19,5 @@
     <ArchetypeProperty Type="Multiplayer::NetworkSpawnable" Name="ProjectileSpawnable" ExposeToEditor="true" Description="The projectile asset to spawn." />
 
     <RemoteProcedure Name="RPC_TriggerBuildup" InvokeFrom="Authority" HandleOn="Client" IsPublic="true" IsReliable="true" GenerateEventBindings="true" Description="Triggered on clients to start the buildup event." />
+    <RemoteProcedure Name="RPC_StopBuildup" InvokeFrom="Authority" HandleOn="Client" IsPublic="true" IsReliable="true" GenerateEventBindings="true" Description="Triggered on clients to stop the buildup event." />
 </Component>

+ 20 - 14
Gem/Code/Source/Components/Multiplayer/EnergyBallComponent.cpp

@@ -6,12 +6,12 @@
  */
 
 #include <Source/Components/Multiplayer/EnergyBallComponent.h>
-#include <Source/Components/Multiplayer/EnergyCannonComponent.h>
 #include <Source/AutoGen/NetworkHealthComponent.AutoComponent.h>
 #include <Multiplayer/Components/NetworkTransformComponent.h>
 #include <Multiplayer/Components/NetworkRigidBodyComponent.h>
 #include <MultiplayerSampleTypes.h>
 #include <AzCore/Component/TransformBus.h>
+#include <AzCore/EBus/IEventScheduler.h>
 #include <AzFramework/Physics/Components/SimulatedBodyComponentBus.h>
 #include <AzFramework/Physics/RigidBodyBus.h>
 #include <WeaponNotificationBus.h>
@@ -69,16 +69,6 @@ namespace MultiplayerSample
 
             AZ_Error("EnergyBall", startSuccess, "Restart call for Energy Ball was unsuccessful.");
 
-            const Multiplayer::ConstNetworkEntityHandle cannonHandle = Multiplayer::GetNetworkEntityManager()->GetEntity(GetShooterNetEntityId());
-            if (cannonHandle.Exists())
-            {
-                const EnergyCannonComponent* cannonComponent = cannonHandle.FindComponent<EnergyCannonComponent>();
-                if (cannonComponent != nullptr)
-                {
-                    cannonComponent->KillBuildupEffect();
-                }
-            }
-
             if (cl_EnergyBallDebugDraw)
             {
                 m_debugDrawEvent.Enqueue(AZ::TimeMs{ 0 }, true);
@@ -105,7 +95,10 @@ namespace MultiplayerSample
 
     void EnergyBallComponent::HandleRPC_BallExplosion([[maybe_unused]] AzNetworking::IConnection* invokingConnection, const HitEvent& hitEvent)
     {
-        // Notify every entity that was hit that they've received a weapon impact.
+        // Create an explosion effect at our current location.
+        m_effect.TriggerEffect(GetEntity()->GetTransform()->GetWorldTM());
+
+        // Notify every entity that was hit that they've received a weapon impact, this allows for blast decals.
         for (const HitEntity& hitEntity : hitEvent.m_hitEntities)
         {
             const AZ::Transform hitTransform = AZ::Transform::CreateLookAt(hitEntity.m_hitPosition, hitEntity.m_hitPosition + hitEntity.m_hitNormal, AZ::Transform::Axis::ZPositive);
@@ -190,7 +183,6 @@ namespace MultiplayerSample
 
         m_collisionCheckEvent.Enqueue(AZ::TimeMs{ 10 }, true);
 
-        SetShooterNetEntityId(owningNetEntityId);
         SetBallActive(true);
         SetVelocity(direction * GetGatherParams().m_travelSpeed);
 
@@ -282,7 +274,21 @@ namespace MultiplayerSample
 
         RPC_BallExplosion(m_hitEvent);
 
-        Multiplayer::GetNetworkEntityManager()->MarkForRemoval(GetNetBindComponent()->GetEntityHandle());
+        // Wait 5 seconds before cleaning up the entity so that the explosion effect has a chance to play out
+        // Capture just the netEntityId in case we have a level change or some other operation that clears out entities before our lamda triggers
+        const Multiplayer::NetEntityId netEntityId = GetNetEntityId();
+        AZ::Interface<AZ::IEventScheduler>::Get()->AddCallback([netEntityId]
+            {
+                // Fetch the entity handle, ensure its still valid
+                const Multiplayer::ConstNetworkEntityHandle entityHandle = Multiplayer::GetNetworkEntityManager()->GetEntity(netEntityId);
+                if (entityHandle.Exists())
+                {
+                    Multiplayer::GetNetworkEntityManager()->MarkForRemoval(entityHandle);
+                }
+            },
+            AZ::Name("Cleanup"),
+            AZ::TimeMs{ 5000 }
+        );
     }
 #endif
 }

+ 3 - 2
Gem/Code/Source/Components/Multiplayer/EnergyCannonComponent.cpp

@@ -12,7 +12,6 @@
 #include <AzCore/Settings/SettingsRegistry.h>
 #include <Source/Components/Multiplayer/EnergyBallComponent.h>
 #include <Source/Components/Multiplayer/EnergyCannonComponent.h>
-#include <Components/PerfTest/NetworkPrefabSpawnerComponent.h>
 
 namespace MultiplayerSample
 {
@@ -43,7 +42,7 @@ namespace MultiplayerSample
         m_effect.TriggerEffect(GetEntity()->GetTransform()->GetWorldTM());
     }
 
-    void EnergyCannonComponent::KillBuildupEffect() const
+    void EnergyCannonComponent::HandleRPC_StopBuildup([[maybe_unused]] AzNetworking::IConnection* invokingConnection)
     {
         m_effect.StopEffect();
     }
@@ -81,6 +80,8 @@ namespace MultiplayerSample
 
     void EnergyCannonComponentController::OnFireEnergyBall()
     {
+        RPC_StopBuildup();
+
         const AZ::Transform& cannonTm = GetEntity()->GetTransform()->GetWorldTM();
         const AZ::Vector3 effectOffset = GetFiringEffect().GetEffectOffset();
         const AZ::Vector3 ballPosition = cannonTm.TransformPoint(effectOffset);

+ 1 - 3
Gem/Code/Source/Components/Multiplayer/EnergyCannonComponent.h

@@ -24,11 +24,9 @@ namespace MultiplayerSample
 
 #if AZ_TRAIT_CLIENT
         void HandleRPC_TriggerBuildup(AzNetworking::IConnection* invokingConnection) override;
+        void HandleRPC_StopBuildup(AzNetworking::IConnection* invokingConnection) override;
 #endif
 
-        // Invoked directly by the energy ball projectile component on the client
-        void KillBuildupEffect() const;
-
     private:
         GameEffect m_effect;
     };

+ 7 - 4
Gem/Code/Source/Effects/GameEffect.cpp

@@ -12,7 +12,7 @@
 #if AZ_TRAIT_CLIENT
 #   include <PopcornFX/PopcornFXBus.h>
 #endif
-
+#pragma optimize("", off)
 namespace MultiplayerSample
 {
     AZ_CVAR(bool, cl_KillEffectOnRestart, false, nullptr, AZ::ConsoleFunctorFlags::Null, "Controls whether or not to kill current effects on restart");
@@ -188,14 +188,16 @@ namespace MultiplayerSample
     {
 #if AZ_TRAIT_CLIENT
         const AZ::Vector3 offsetPosition = transform.TransformPoint(m_effectOffset);
-        AZ::Transform transformOffset = transform;
-        transformOffset.SetTranslation(offsetPosition);
+
         if (m_emitter != nullptr)
         {
             if (PopcornFX::PopcornFXRequests* popcornFx = PopcornFX::PopcornFXRequestBus::FindFirstHandler())
             {
                 if (m_popcornFx->IsEffectAlive(m_emitter))
                 {
+                    AZ::Transform transformOffset = transform;
+                    transformOffset.SetTranslation(offsetPosition);
+
                     popcornFx->EffectSetTransform(m_emitter, transformOffset);
                     popcornFx->EffectSetTeleportThisFrame(m_emitter);
                     popcornFx->EffectRestart(m_emitter, cl_KillEffectOnRestart);
@@ -224,7 +226,7 @@ namespace MultiplayerSample
             {
                 if (m_popcornFx->IsEffectAlive(m_emitter))
                 {
-                    m_popcornFx->DestroyEffect(m_emitter);
+                    m_popcornFx->EffectKill(m_emitter);
                 }
             }
         }
@@ -236,3 +238,4 @@ namespace MultiplayerSample
         return m_effectOffset;
     }
 }
+#pragma optimize("", on)

+ 7 - 7
Prefabs/BubbleCannon.prefab

@@ -195,7 +195,7 @@
                         "MaterialSlots": {
                             "Slots": [
                                 {
-                                    "Name": "base_MAT"
+                                    "Name": "opaque_MAT"
                                 }
                             ]
                         }
@@ -204,19 +204,19 @@
                         "PhysicsAsset": {
                             "Asset": {
                                 "assetId": {
-                                    "guid": "{251F7A49-FA34-57EC-919D-399EAF8F9770}",
-                                    "subId": 1397975047
+                                    "guid": "{98F0A4B8-3708-5D15-BFB4-FA4AA377F084}",
+                                    "subId": 421091912
                                 },
-                                "assetHint": "spacecannon/spacecannon.pxmesh"
+                                "assetHint": "defenceturret/defenceturret.pxmesh"
                             },
                             "Configuration": {
                                 "PhysicsAsset": {
                                     "assetId": {
-                                        "guid": "{251F7A49-FA34-57EC-919D-399EAF8F9770}",
-                                        "subId": 1397975047
+                                        "guid": "{98F0A4B8-3708-5D15-BFB4-FA4AA377F084}",
+                                        "subId": 421091912
                                     },
                                     "loadBehavior": "QueueLoad",
-                                    "assetHint": "spacecannon/spacecannon.pxmesh"
+                                    "assetHint": "defenceturret/defenceturret.pxmesh"
                                 }
                             }
                         }

+ 5 - 5
Prefabs/Energy_Ball.prefab

@@ -162,14 +162,14 @@
                     "Id": 17042691414245108129,
                     "configuration": {
                         "sourceHandle": {
-                            "id": "{44094FA1-1EC7-5F96-A693-495E5AF6167D}",
-                            "path": "scriptcanvas/LinearEneryBall.scriptcanvas"
+                            "id": "{3AA3C08F-9E46-559E-8D4A-E7B628625E16}",
+                            "path": "scriptcanvas/LinearEnergyBall.scriptcanvas"
                         },
-                        "sourceName": "LinearEneryBall.scriptcanvas",
+                        "sourceName": "LinearEnergyBall.scriptcanvas",
                         "propertyOverrides": {
                             "source": {
-                                "id": "{44094FA1-1EC7-5F96-A693-495E5AF6167D}",
-                                "path": "scriptcanvas/LinearEneryBall.scriptcanvas"
+                                "id": "{3AA3C08F-9E46-559E-8D4A-E7B628625E16}",
+                                "path": "scriptcanvas/LinearEnergyBall.scriptcanvas"
                             }
                         }
                     }

+ 0 - 0
scriptcanvas/LinearEneryBall.scriptcanvas → scriptcanvas/LinearEnergyBall.scriptcanvas


文件差異過大導致無法顯示
+ 549 - 284
scriptcanvas/PlayerSeekingBubbleBall.scriptcanvas


部分文件因文件數量過多而無法顯示