Browse Source

Update macro naming

Signed-off-by: puvvadar <[email protected]>
puvvadar 2 năm trước cách đây
mục cha
commit
a47b560110

+ 1 - 1
Gem/Code/Source/Components/NetworkAiComponent.cpp

@@ -23,7 +23,7 @@ namespace MultiplayerSample
     {
     }
 
-#if AZ_TRAIT_SERVER_ENABLED
+#if AZ_TRAIT_SERVER
     void NetworkAiComponentController::TickMovement(NetworkPlayerMovementComponentController& movementController, float deltaTime)
     {
         // TODO: Execute this tick only if this component is owned by this endpoint (currently ticks on server only)

+ 2 - 2
Gem/Code/Source/Components/NetworkAiComponent.h

@@ -27,7 +27,7 @@ namespace MultiplayerSample
         void OnActivate([[maybe_unused]] Multiplayer::EntityIsMigrating entityIsMigrating) override {};
         void OnDeactivate([[maybe_unused]] Multiplayer::EntityIsMigrating entityIsMigrating) override {};
 
-#if AZ_TRAIT_SERVER_ENABLED
+#if AZ_TRAIT_SERVER
         void TickMovement(NetworkPlayerMovementComponentController& movementController, float deltaTime);
         void TickWeapons(NetworkWeaponsComponentController& weaponsController, float deltaTime);
 #endif
@@ -35,7 +35,7 @@ namespace MultiplayerSample
     private:
         friend class NetworkStressTestComponentController;
 
-#if AZ_TRAIT_SERVER_ENABLED
+#if AZ_TRAIT_SERVER
         void ConfigureAi(
             float fireIntervalMinMs, float fireIntervalMaxMs, float actionIntervalMinMs, float actionIntervalMaxMs, uint64_t seed);
 

+ 1 - 1
Gem/Code/Source/Components/NetworkHealthComponent.cpp

@@ -24,7 +24,7 @@ namespace MultiplayerSample
         ;
     }
 
-#if AZ_TRAIT_SERVER_ENABLED
+#if AZ_TRAIT_SERVER
     void NetworkHealthComponentController::HandleSendHealthDelta([[maybe_unused]] AzNetworking::IConnection* invokingConnection, const float& healthDelta)
     {
         float health = GetHealth();

+ 1 - 1
Gem/Code/Source/Components/NetworkHealthComponent.h

@@ -20,7 +20,7 @@ namespace MultiplayerSample
         void OnActivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
         void OnDeactivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
 
-#if AZ_TRAIT_SERVER_ENABLED
+#if AZ_TRAIT_SERVER
         void HandleSendHealthDelta(AzNetworking::IConnection* invokingConnection, const float& healthDelta) override;
 #endif
     };

+ 1 - 1
Gem/Code/Source/Components/NetworkPlayerMovementComponent.cpp

@@ -305,7 +305,7 @@ namespace MultiplayerSample
 
     void NetworkPlayerMovementComponentController::UpdateAI()
     {
-#if AZ_TRAIT_SERVER_ENABLED
+#if AZ_TRAIT_SERVER
         float deltaTime = static_cast<float>(m_updateAI.TimeInQueueMs()) / 1000.f;
         if (m_networkAiComponentController != nullptr)
         {

+ 1 - 1
Gem/Code/Source/Components/NetworkRandomComponent.cpp

@@ -41,7 +41,7 @@ namespace MultiplayerSample
     NetworkRandomComponentController::NetworkRandomComponentController(NetworkRandomComponent& parent)
         : NetworkRandomComponentControllerBase(parent)
     {
-#if AZ_TRAIT_SERVER_ENABLED
+#if AZ_TRAIT_SERVER
         if (IsNetEntityRoleAuthority())
         {
             // Setup seed on authority for proxies to pull

+ 6 - 6
Gem/Code/Source/Components/NetworkStressTestComponent.cpp

@@ -38,7 +38,7 @@ namespace MultiplayerSample
 
     NetworkStressTestComponentController::NetworkStressTestComponentController(NetworkStressTestComponent& owner)
         : NetworkStressTestComponentControllerBase(owner)
-#if AZ_TRAIT_SERVER_ENABLED
+#if AZ_TRAIT_SERVER
         , m_autoSpawnTimer([this]() { HandleSpawnAiEntity(); }, AZ::Name("StressTestSpawner Event"))
 #endif
     {
@@ -63,7 +63,7 @@ namespace MultiplayerSample
             break;
         }
 
-#if AZ_TRAIT_SERVER_ENABLED
+#if AZ_TRAIT_SERVER
         if (GetAutoSpawnIntervalMs() > AZ::Time::ZeroTimeMs)
         {
             m_autoSpawnTimer.Enqueue(GetAutoSpawnIntervalMs(), true);
@@ -78,7 +78,7 @@ namespace MultiplayerSample
 #endif
     }
 
-#if AZ_TRAIT_SERVER_ENABLED
+#if AZ_TRAIT_SERVER
     void NetworkStressTestComponentController::HandleSpawnAiEntity()
     {
         const uint64_t seed = m_seed == 0 ? static_cast<uint64_t>(AZ::Interface<AZ::ITime>::Get()->GetElapsedTimeMs()) : m_seed;
@@ -127,7 +127,7 @@ namespace MultiplayerSample
             {
                 if (m_isServer)
                 {
-#if AZ_TRAIT_SERVER_ENABLED
+#if AZ_TRAIT_SERVER
                     HandleSpawnAIEntity(
                         nullptr,
                         m_fireIntervalMinMs,
@@ -140,7 +140,7 @@ namespace MultiplayerSample
                 }
                 else
                 {
-#if AZ_TRAIT_CLIENT_ENABLED
+#if AZ_TRAIT_CLIENT
                     SpawnAIEntity(
                         m_fireIntervalMinMs,
                         m_fireIntervalMaxMs,
@@ -163,7 +163,7 @@ namespace MultiplayerSample
     {
     }
 
-#if AZ_TRAIT_SERVER_ENABLED
+#if AZ_TRAIT_SERVER
     void NetworkStressTestComponentController::HandleSpawnAIEntity(
         AzNetworking::IConnection* invokingConnection,
         const float& fireIntervalMinMs,

+ 2 - 2
Gem/Code/Source/Components/NetworkStressTestComponent.h

@@ -44,7 +44,7 @@ namespace MultiplayerSample
         void OnActivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
         void OnDeactivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
 
-#if AZ_TRAIT_SERVER_ENABLED
+#if AZ_TRAIT_SERVER
         void HandleSpawnAiEntity();
 
         void HandleSpawnAIEntity(
@@ -77,7 +77,7 @@ namespace MultiplayerSample
         uint64_t m_seed = 0;
         int m_teamID = 0;
 
-#if AZ_TRAIT_SERVER_ENABLED
+#if AZ_TRAIT_SERVER
         AZ::ScheduledEvent m_autoSpawnTimer;
 #endif
     };

+ 10 - 10
Gem/Code/Source/Components/NetworkWeaponsComponent.cpp

@@ -15,7 +15,7 @@
 #include <Source/Weapons/BaseWeapon.h>
 #include <AzCore/Component/TransformBus.h>
 
-#if AZ_TRAIT_CLIENT_ENABLED
+#if AZ_TRAIT_CLIENT
 #include <DebugDraw/DebugDrawBus.h>
 #endif
 
@@ -69,7 +69,7 @@ namespace MultiplayerSample
             ActivationCountsAddEvent(m_activationCountHandler);
         }
 
-#if AZ_TRAIT_CLIENT_ENABLED
+#if AZ_TRAIT_CLIENT
         if (m_debugDraw == nullptr)
         {
             m_debugDraw = DebugDraw::DebugDrawRequestBus::FindFirstHandler();
@@ -82,7 +82,7 @@ namespace MultiplayerSample
         ;
     }
 
-#if AZ_TRAIT_CLIENT_ENABLED
+#if AZ_TRAIT_CLIENT
     void NetworkWeaponsComponent::HandleSendConfirmHit([[maybe_unused]] AzNetworking::IConnection* invokingConnection, const WeaponIndex& weaponIndex, const HitEvent& hitEvent)
     {
         if (GetWeapon(weaponIndex) == nullptr)
@@ -121,7 +121,7 @@ namespace MultiplayerSample
             return;
         }
 
-#if AZ_TRAIT_CLIENT_ENABLED
+#if AZ_TRAIT_CLIENT
         if (cl_WeaponsDrawDebug && m_debugDraw)
         {
             m_debugDraw->DrawSphereAtLocation
@@ -147,7 +147,7 @@ namespace MultiplayerSample
     {
         if (IsNetEntityRoleAuthority())
         {
-#if AZ_TRAIT_SERVER_ENABLED
+#if AZ_TRAIT_SERVER
             OnWeaponConfirmHit(hitInfo);
             static_cast<NetworkWeaponsComponentController*>(GetController())->SendConfirmHit(hitInfo.m_weapon.GetWeaponIndex(), hitInfo.m_hitEvent);
 #endif
@@ -170,7 +170,7 @@ namespace MultiplayerSample
         {
             const HitEntity& hitEntity = hitInfo.m_hitEvent.m_hitEntities[i];
 
-#if AZ_TRAIT_CLIENT_ENABLED
+#if AZ_TRAIT_CLIENT
             if (cl_WeaponsDrawDebug && m_debugDraw)
             {
                 m_debugDraw->DrawSphereAtLocation
@@ -198,7 +198,7 @@ namespace MultiplayerSample
     void NetworkWeaponsComponent::OnWeaponConfirmHit(const WeaponHitInfo& hitInfo)
     {
 
-#if AZ_TRAIT_SERVER_ENABLED
+#if AZ_TRAIT_SERVER
         if (IsNetEntityRoleAuthority())
         {
             for (const HitEntity& hitEntity : hitInfo.m_hitEvent.m_hitEntities)
@@ -244,7 +244,7 @@ namespace MultiplayerSample
         {
             const HitEntity& hitEntity = hitInfo.m_hitEvent.m_hitEntities[i];
 
-#if AZ_TRAIT_CLIENT_ENABLED
+#if AZ_TRAIT_CLIENT
             if (cl_WeaponsDrawDebug && m_debugDraw)
             {
                 m_debugDraw->DrawSphereAtLocation
@@ -427,7 +427,7 @@ namespace MultiplayerSample
                 GetParent().ActivateWeaponWithParams(
                     aznumeric_cast<WeaponIndex>(weaponIndexInt), weaponState, fireParams, validateActivations);
 
-#if AZ_TRAIT_SERVER_ENABLED
+#if AZ_TRAIT_SERVER
                 if (IsNetEntityRoleAuthority())
                 {
                     SetActivationParams(weaponIndexInt, fireParams);
@@ -511,7 +511,7 @@ namespace MultiplayerSample
 
     void NetworkWeaponsComponentController::UpdateAI()
     {
-#if AZ_TRAIT_SERVER_ENABLED
+#if AZ_TRAIT_SERVER
         float deltaTime = static_cast<float>(m_updateAI.TimeInQueueMs()) / 1000.f;
         if (m_networkAiComponentController != nullptr)
         {

+ 1 - 1
Gem/Code/Source/Components/NetworkWeaponsComponent.h

@@ -39,7 +39,7 @@ namespace MultiplayerSample
         void OnActivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
         void OnDeactivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
 
-#if AZ_TRAIT_CLIENT_ENABLED
+#if AZ_TRAIT_CLIENT
         void HandleSendConfirmHit(AzNetworking::IConnection* invokingConnection, const WeaponIndex& weaponIndex, const HitEvent& hitEvent) override;
 #endif
         void ActivateWeaponWithParams(WeaponIndex weaponIndex, WeaponState& weaponState, const FireParams& fireParams, bool validateActivations);

+ 23 - 5
Gem/Code/Source/Components/RpcTesterComponent.cpp

@@ -6,9 +6,12 @@
  */
 
 #include <AtomLyIntegration/CommonFeatures/Material/MaterialComponentBus.h>
-#include <DebugDraw/DebugDrawBus.h>
 #include <Source/Components/RpcTesterComponent.h>
 
+#if AZ_TRAIT_CLIENT
+#include <DebugDraw/DebugDrawBus.h>
+#endif
+
 namespace MultiplayerSample
 {
     void RpcTesterComponent::Reflect(AZ::ReflectContext* context)
@@ -42,8 +45,10 @@ namespace MultiplayerSample
             testType = "Auth->Client";
         }
 
+#if AZ_TRAIT_CLIENT
         DebugDraw::DebugDrawRequestBus::Broadcast(&DebugDraw::DebugDrawRequestBus::Events::DrawTextOnEntity,
             GetEntityId(), testType, AZ::Colors::White, -1.f);
+#endif
 
         if (AZ::Render::MaterialComponentRequests* material =
             AZ::Render::MaterialComponentRequestBus::FindFirstHandler(GetEntityId()))
@@ -57,6 +62,7 @@ namespace MultiplayerSample
         m_delayTestRun.RemoveFromQueue();
     }
 
+#if AZ_TRAIT_CLIENT
     void RpcTesterComponent::HandleRPC_TestPassed([[maybe_unused]] AzNetworking::IConnection* invokingConnection)
     {
         if (AZ::Render::MaterialComponentRequests* material =
@@ -65,17 +71,24 @@ namespace MultiplayerSample
             material->SetMaterialAssetIdOnDefaultSlot(GetTestPassedMaterial().GetId());
         }
     }
+#endif
 
     void RpcTesterComponent::RunTests()
     {
         if (GetController())
         {
             auto controller = static_cast<RpcTesterComponentController*>(GetController());
+            
+#if AZ_TRAIT_CLIENT
             if (GetTestAutoToAuthorityRPC())
             {
                 controller->RPC_AutonomousToAuthority();
+                return;
             }
-            else if (GetTestServerToAuthorityRPC())
+#endif
+
+#if AZ_TRAIT_SERVER
+            if (GetTestServerToAuthorityRPC())
             {
                 RPC_ServerToAuthority();
             }
@@ -87,6 +100,7 @@ namespace MultiplayerSample
             {
                 controller->RPC_TestPassed();
             }
+#endif
         }
     }
 
@@ -105,12 +119,15 @@ namespace MultiplayerSample
     {
     }
 
-    void RpcTesterComponentController::HandleRPC_AutonomousToAuthority([[maybe_unused]] AzNetworking::IConnection* invokingConnection)
+#if AZ_TRAIT_CLIENT
+    void RpcTesterComponentController::HandleRPC_AuthorityToAutonomous([[maybe_unused]] AzNetworking::IConnection* invokingConnection)
     {
-        RPC_TestPassed();
+        ;
     }
+#endif
 
-    void RpcTesterComponentController::HandleRPC_AuthorityToAutonomous([[maybe_unused]] AzNetworking::IConnection* invokingConnection)
+#if AZ_TRAIT_SERVER
+    void RpcTesterComponentController::HandleRPC_AutonomousToAuthority([[maybe_unused]] AzNetworking::IConnection* invokingConnection)
     {
         RPC_TestPassed();
     }
@@ -119,4 +136,5 @@ namespace MultiplayerSample
     {
         RPC_TestPassed();
     }
+#endif
 }

+ 8 - 1
Gem/Code/Source/Components/RpcTesterComponent.h

@@ -29,7 +29,9 @@ namespace MultiplayerSample
         void OnActivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
         void OnDeactivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
 
+#if AZ_TRAIT_CLIENT
         void HandleRPC_TestPassed(AzNetworking::IConnection* invokingConnection) override;
+#endif
 
     private:
         void RunTests();
@@ -49,8 +51,13 @@ namespace MultiplayerSample
         void OnActivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
         void OnDeactivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
 
-        void HandleRPC_AutonomousToAuthority(AzNetworking::IConnection* invokingConnection) override;
+#if AZ_TRAIT_CLIENT
         void HandleRPC_AuthorityToAutonomous(AzNetworking::IConnection* invokingConnection) override;
+#endif
+
+#if AZ_TRAIT_SERVER
+        void HandleRPC_AutonomousToAuthority(AzNetworking::IConnection* invokingConnection) override;
         void HandleRPC_ServerToAuthority(AzNetworking::IConnection* invokingConnection) override;
+#endif
     };
 }

+ 3 - 3
Gem/Code/Source/Weapons/WeaponGathers.cpp

@@ -12,7 +12,7 @@
 #include <AzCore/Console/ILogger.h>
 #include <Source/Weapons/SceneQuery.h>
 
-#if AZ_TRAIT_CLIENT_ENABLED
+#if AZ_TRAIT_CLIENT
 #include <DebugDraw/DebugDrawBus.h>
 #endif
 
@@ -64,7 +64,7 @@ namespace MultiplayerSample
             collisionGroup, filteredNetEntityIds, gatherParams.GetCurrentShapeConfiguration());
         SceneQuery::WorldIntersect(intersectShape, filter, outResults);
 
-#if AZ_TRAIT_CLIENT_ENABLED
+#if AZ_TRAIT_CLIENT
         if (bg_DrawPhysicsRaycasts)
         {
             DebugDraw::DebugDrawRequestBus::Broadcast
@@ -127,7 +127,7 @@ namespace MultiplayerSample
                 hitMultiple, collisionGroup, filteredNetEntityIds, gatherParams.GetCurrentShapeConfiguration());
             SceneQuery::WorldIntersect(gatherParams.m_gatherShape, filter, outResults);
 
-#if AZ_TRAIT_CLIENT_ENABLED
+#if AZ_TRAIT_CLIENT
             if (bg_DrawPhysicsRaycasts)
             {
                 DebugDraw::DebugDrawRequestBus::Broadcast