AkGameObject.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. /**
  33. * Posts this game object's AkAudioEvent to Wwise, using this as the game object source
  34. */
  35. UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category="Audiokinetic|AkGameObject", meta = (AdvancedDisplay = "2", AutoCreateRefTerm = "PostEventCallback,ExternalSources"))
  36. virtual int32 PostAssociatedAkEvent(
  37. UPARAM(meta = (Bitmask, BitmaskEnum = "/Script/AkAudio.EAkCallbackType")) int32 CallbackMask,
  38. const FOnAkPostEventCallback& PostEventCallback);
  39. UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category = "Audiokinetic|AkGameObject", meta = (AutoCreateRefTerm = "PostEventCallback,ExternalSources", Latent, LatentInfo = "LatentInfo", WorldContext = "WorldContextObject"))
  40. virtual void PostAssociatedAkEventAsync(const UObject* WorldContextObject,
  41. UPARAM(meta = (Bitmask, BitmaskEnum = "/Script/AkAudio.EAkCallbackType")) int32 CallbackMask,
  42. const FOnAkPostEventCallback& PostEventCallback,
  43. FLatentActionInfo LatentInfo,
  44. int32& PlayingID);
  45. /**
  46. * Posts an event to Wwise, using this as the game object source
  47. *
  48. * @param AkEvent The event to post
  49. * @param CallbackMask Mask of desired callbacks
  50. * @param PostEventCallback Blueprint Event to execute on callback
  51. *
  52. */
  53. UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category = "Audiokinetic|AkGameObject", meta = (AdvancedDisplay = "1", AutoCreateRefTerm = "PostEventCallback,ExternalSources"))
  54. virtual int32 PostAkEvent(
  55. class UAkAudioEvent * AkEvent,
  56. UPARAM(meta = (Bitmask, BitmaskEnum = "/Script/AkAudio.EAkCallbackType")) int32 CallbackMask,
  57. const FOnAkPostEventCallback& PostEventCallback
  58. );
  59. virtual AkPlayingID PostAkEvent(UAkAudioEvent* AkEvent, AkUInt32 Flags = 0, AkCallbackFunc UserCallback = nullptr, void* UserCookie = nullptr);
  60. /**
  61. * Posts an event to Wwise, using this as the game object source
  62. *
  63. * @param AkEvent The event to post
  64. * @param CallbackMask Mask of desired callbacks
  65. * @param PostEventCallback Blueprint Event to execute on callback
  66. *
  67. */
  68. UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category = "Audiokinetic|AkGameObject", meta = (AdvancedDisplay = "3", AutoCreateRefTerm = "PostEventCallback,ExternalSources", Latent, LatentInfo = "LatentInfo", WorldContext = "WorldContextObject"))
  69. virtual void PostAkEventAsync(const UObject* WorldContextObject,
  70. class UAkAudioEvent* AkEvent,
  71. int32& PlayingID,
  72. UPARAM(meta = (Bitmask, BitmaskEnum = "/Script/AkAudio.EAkCallbackType")) int32 CallbackMask,
  73. const FOnAkPostEventCallback& PostEventCallback,
  74. FLatentActionInfo LatentInfo
  75. );
  76. /**
  77. * Stops playback using this game object as the game object to stop
  78. */
  79. UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category = "Audiokinetic|AkComponent")
  80. virtual void Stop();
  81. /**
  82. * Sets an RTPC value, using this game object as the game object source
  83. *
  84. * @param RTPC The name of the RTPC to set
  85. * @param Value The value of the RTPC
  86. * @param InterpolationTimeMs - Duration during which the RTPC is interpolated towards Value (in ms)
  87. */
  88. UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category = "Audiokinetic|AkGameObject", meta = (AdvancedDisplay = "3"))
  89. void SetRTPCValue(class UAkRtpc const* RTPCValue, float Value, int32 InterpolationTimeMs, FString RTPC) const;
  90. /**
  91. * Gets an RTPC value that was set on this game object as the game object source
  92. *
  93. * @param RTPC The name of the RTPC to set
  94. * @param InputValueType The input value type
  95. * @param Value The value of the RTPC
  96. * @param OutputValueType The output value type
  97. * @param PlayingID The playing ID of the posted event (Set to zero to ignore)
  98. */
  99. UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category = "Audiokinetic|AkGameObject", meta = (AdvancedDisplay = "RTPC"))
  100. void GetRTPCValue(class UAkRtpc const* RTPCValue, ERTPCValueType InputValueType, float& Value, ERTPCValueType& OutputValueType, FString RTPC, int32 PlayingID = 0) const;
  101. #if CPP
  102. bool VerifyEventName(const FString& InEventName) const;
  103. bool AllowAudioPlayback() const;
  104. AkGameObjectID GetAkGameObjectID() const;
  105. virtual void UpdateObstructionAndOcclusion() {};
  106. bool HasActiveEvents() const;
  107. #endif
  108. bool HasBeenRegisteredWithWwise() const { return IsRegisteredWithWwise; }
  109. void EventPosted() {bEventPosted = true;}
  110. protected:
  111. // Whether an event was posted on the game object. Never reset to false.
  112. bool bEventPosted;
  113. bool IsRegisteredWithWwise = false;
  114. };