AkGameObject.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*******************************************************************************
  2. The content of this file includes portions of the proprietary AUDIOKINETIC Wwise
  3. Technology released in source code form as part of the game integration package.
  4. The content of this file may not be used without valid licenses to the
  5. AUDIOKINETIC Wwise Technology.
  6. Note that the use of the game engine is subject to the Unreal(R) Engine End User
  7. License Agreement at https://www.unrealengine.com/en-US/eula/unreal
  8. License Usage
  9. Licensees holding valid licenses to the AUDIOKINETIC Wwise Technology may use
  10. this file in accordance with the end user license agreement provided with the
  11. software or, alternatively, in accordance with the terms contained
  12. in a written agreement between you and Audiokinetic Inc.
  13. Copyright (c) 2023 Audiokinetic Inc.
  14. *******************************************************************************/
  15. /*=============================================================================
  16. AkGameObject.h:
  17. =============================================================================*/
  18. #pragma once
  19. #include "AkAudioDevice.h"
  20. #include "AkGameplayTypes.h"
  21. #include "Components/SceneComponent.h"
  22. #include "AkGameObject.generated.h"
  23. UCLASS(ClassGroup=Audiokinetic, BlueprintType, Blueprintable, hidecategories=(Transform,Rendering,Mobility,LOD,Component,Activation), AutoExpandCategories=AkComponent, meta=(BlueprintSpawnableComponent))
  24. class AKAUDIO_API UAkGameObject: public USceneComponent
  25. {
  26. GENERATED_BODY()
  27. public:
  28. UAkGameObject(const class FObjectInitializer& ObjectInitializer);
  29. /** Associated Wwise Event to be posted on this game object */
  30. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="AkEvent")
  31. UAkAudioEvent* AkAudioEvent = nullptr;
  32. /** Associated Event name to be posted on this game object. Deprecation warning: You should always use the associated AkAudioEvent to ensure the assets are properly loaded. */
  33. UPROPERTY(EditAnywhere, BlueprintReadWrite, AdvancedDisplay, Category = "AkEvent")
  34. FString EventName;
  35. /**
  36. * Posts this game object's AkAudioEvent to Wwise, using this as the game object source
  37. */
  38. UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category="Audiokinetic|AkGameObject", meta = (AdvancedDisplay = "2", AutoCreateRefTerm = "PostEventCallback,ExternalSources"))
  39. virtual int32 PostAssociatedAkEvent(
  40. UPARAM(meta = (Bitmask, BitmaskEnum = "/Script/AkAudio.EAkCallbackType")) int32 CallbackMask,
  41. const FOnAkPostEventCallback& PostEventCallback);
  42. UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category = "Audiokinetic|AkGameObject", meta = (AutoCreateRefTerm = "PostEventCallback,ExternalSources", Latent, LatentInfo = "LatentInfo", WorldContext = "WorldContextObject"))
  43. virtual void PostAssociatedAkEventAsync(const UObject* WorldContextObject,
  44. UPARAM(meta = (Bitmask, BitmaskEnum = "/Script/AkAudio.EAkCallbackType")) int32 CallbackMask,
  45. const FOnAkPostEventCallback& PostEventCallback,
  46. FLatentActionInfo LatentInfo,
  47. int32& PlayingID);
  48. /**
  49. * Posts an event to Wwise, using this as the game object source
  50. *
  51. * @param AkEvent The event to post
  52. * @param CallbackMask Mask of desired callbacks
  53. * @param PostEventCallback Blueprint Event to execute on callback
  54. * @param InEventName Deprecated: If AkEvent is not set, this is used. You should ensure your AkEvent is always set.
  55. *
  56. */
  57. UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category = "Audiokinetic|AkGameObject", meta = (AdvancedDisplay = "1", AutoCreateRefTerm = "PostEventCallback,ExternalSources"))
  58. virtual int32 PostAkEvent(
  59. class UAkAudioEvent * AkEvent,
  60. UPARAM(meta = (Bitmask, BitmaskEnum = "/Script/AkAudio.EAkCallbackType")) int32 CallbackMask,
  61. const FOnAkPostEventCallback& PostEventCallback,
  62. const FString& InEventName
  63. );
  64. virtual AkPlayingID PostAkEvent(UAkAudioEvent* AkEvent, AkUInt32 Flags = 0, AkCallbackFunc UserCallback = nullptr, void* UserCookie = nullptr);
  65. /**
  66. * Posts an event to Wwise, using this as the game object source
  67. *
  68. * @param AkEvent The event to post
  69. * @param CallbackMask Mask of desired callbacks
  70. * @param PostEventCallback Blueprint Event to execute on callback
  71. *
  72. */
  73. UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category = "Audiokinetic|AkGameObject", meta = (AdvancedDisplay = "3", AutoCreateRefTerm = "PostEventCallback,ExternalSources", Latent, LatentInfo = "LatentInfo", WorldContext = "WorldContextObject"))
  74. virtual void PostAkEventAsync(const UObject* WorldContextObject,
  75. class UAkAudioEvent* AkEvent,
  76. int32& PlayingID,
  77. UPARAM(meta = (Bitmask, BitmaskEnum = "/Script/AkAudio.EAkCallbackType")) int32 CallbackMask,
  78. const FOnAkPostEventCallback& PostEventCallback,
  79. FLatentActionInfo LatentInfo
  80. );
  81. /**
  82. * Stops playback using this game object as the game object to stop
  83. */
  84. UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category = "Audiokinetic|AkComponent")
  85. virtual void Stop();
  86. /**
  87. * @warning Using EventName in this function is deprecated. Use \ref PostAkEvent.
  88. */
  89. AK_DEPRECATED(2022.1, "Use PostAkEvent.")
  90. virtual AkPlayingID PostAkEventByNameWithDelegate(
  91. UAkAudioEvent* AkEvent,
  92. const FString& InEventName,
  93. int32 CallbackMask,
  94. const FOnAkPostEventCallback& PostEventCallback);
  95. /**
  96. * @warning This function is deprecated. You are expected to use an UAkAudioEvent. Use \ref PostAkEvent.
  97. */
  98. AK_DEPRECATED(2022.1, "Use PostAkEvent.")
  99. virtual void PostAkEventAsyncByEvent(const UObject* WorldContextObject,
  100. class UAkAudioEvent* AkEvent,
  101. int32 CallbackMask,
  102. const FOnAkPostEventCallback& PostEventCallback,
  103. FLatentActionInfo LatentInfo,
  104. int32& PlayingID
  105. );
  106. /**
  107. * Sets an RTPC value, using this game object as the game object source
  108. *
  109. * @param RTPC The name of the RTPC to set
  110. * @param Value The value of the RTPC
  111. * @param InterpolationTimeMs - Duration during which the RTPC is interpolated towards Value (in ms)
  112. */
  113. UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category = "Audiokinetic|AkGameObject", meta = (AdvancedDisplay = "3"))
  114. void SetRTPCValue(class UAkRtpc const* RTPCValue, float Value, int32 InterpolationTimeMs, FString RTPC) const;
  115. /**
  116. * Gets an RTPC value that was set on this game object as the game object source
  117. *
  118. * @param RTPC The name of the RTPC to set
  119. * @param InputValueType The input value type
  120. * @param Value The value of the RTPC
  121. * @param OutputValueType The output value type
  122. * @param PlayingID The playing ID of the posted event (Set to zero to ignore)
  123. */
  124. UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category = "Audiokinetic|AkGameObject", meta = (AdvancedDisplay = "RTPC"))
  125. void GetRTPCValue(class UAkRtpc const* RTPCValue, ERTPCValueType InputValueType, float& Value, ERTPCValueType& OutputValueType, FString RTPC, int32 PlayingID = 0) const;
  126. AK_DEPRECATED(2019.1.3, "This function is deprecated and will be removed in future releases.")
  127. void GetRTPCValue(FString RTPC, int32 PlayingID, ERTPCValueType InputValueType, float& Value, ERTPCValueType& OutputValueType) const;
  128. #if CPP
  129. bool VerifyEventName(const FString& InEventName) const;
  130. bool AllowAudioPlayback() const;
  131. AkGameObjectID GetAkGameObjectID() const;
  132. virtual void UpdateObstructionAndOcclusion() {};
  133. bool HasActiveEvents() const;
  134. #endif
  135. bool HasBeenRegisteredWithWwise() const { return IsRegisteredWithWwise; }
  136. void EventPosted() {bEventPosted = true;}
  137. protected:
  138. // Whether an event was posted on the game object. Never reset to false.
  139. bool bEventPosted;
  140. bool IsRegisteredWithWwise = false;
  141. };