123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426 |
- #pragma once
- #include "Runtime/Launch/Resources/Version.h"
- #include "AkInclude.h"
- #include "AkGameplayTypes.h"
- #include "AkSettings.h"
- #include "Components/SceneComponent.h"
- #include "AkGameObject.h"
- #include "Wwise/AkComponentObstructionAndOcclusionService.h"
- #include "AkComponent.generated.h"
- UENUM(Meta = (Bitflags))
- enum class EReflectionFilterBits
- {
- Wall,
- Ceiling,
- Floor
- };
- static_assert(sizeof(AkPlayingID) == sizeof(int32), "AkPlayingID is not 32 bits anymore. Change return value of PostEvent functions!");
- struct AkReverbFadeControl
- {
- public:
- uint32 AuxBusId;
- bool bIsFadingOut;
- void* FadeControlUniqueId;
- private:
- float CurrentControlValue;
- float TargetControlValue;
- float FadeRate;
- float Priority;
- public:
- AkReverbFadeControl(const class UAkLateReverbComponent& LateReverbComponent);
- void UpdateValues(const class UAkLateReverbComponent& LateReverbComponent);
- bool Update(float DeltaTime);
- void ForceCurrentToTargetValue() { CurrentControlValue = TargetControlValue; }
- AkAuxSendValue ToAkAuxSendValue() const;
- static bool Prioritize(const AkReverbFadeControl& A, const AkReverbFadeControl& B);
- };
- UCLASS(ClassGroup=Audiokinetic, BlueprintType, Blueprintable, hidecategories=(Transform,Rendering,Mobility,LOD,Component,Activation), AutoExpandCategories=AkComponent, meta=(BlueprintSpawnableComponent))
- class AKAUDIO_API UAkComponent: public UAkGameObject
- {
- GENERATED_BODY()
- public:
- UAkComponent(const class FObjectInitializer& ObjectInitializer);
- UPROPERTY()
- bool bUseSpatialAudio_DEPRECATED = false;
- int32 ReflectionFilter_DEPRECATED;
-
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AkComponent|Obstruction Occlusion", meta = (DisplayName = "Collision Channel"))
- TEnumAsByte<EAkCollisionChannel> OcclusionCollisionChannel = { EAkCollisionChannel::EAKCC_UseIntegrationSettingsDefault };
-
- UFUNCTION(BlueprintCallable, Category="AkComponent|Obstruction Occlusion", meta = (DisplayName = "Get Collision Channel"))
- ECollisionChannel GetOcclusionCollisionChannel();
-
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AkComponent|Obstruction Occlusion", meta = (ClampMin = 0.f, DisplayName = "Refresh Interval"))
- float OcclusionRefreshInterval = .0f;
-
- UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "AkComponent|Spatial Audio")
- bool EnableSpotReflectors = false;
-
- UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "AkComponent|Spatial Audio|Radial Emitter", meta = (ClampMin = 0.0f) )
- float outerRadius = .0f;
-
- UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "AkComponent|Spatial Audio|Radial Emitter", meta = (ClampMin = 0.0f))
- float innerRadius = .0f;
- UFUNCTION(BlueprintCallable, Category = "Audiokinetic|AkComponent")
- void SetGameObjectRadius(float in_outerRadius, float in_innerRadius);
- UFUNCTION(BlueprintCallable, Category = "Audiokinetic|AkComponent")
- void SetEnableSpotReflectors(bool in_enable);
- private:
-
- UPROPERTY(EditAnywhere, Category = "AkComponent|Spatial Audio|Reflect")
- class UAkAuxBus * EarlyReflectionAuxBus = nullptr;
-
- UPROPERTY(EditAnywhere, Category = "AkComponent|Spatial Audio|Reflect")
- FString EarlyReflectionAuxBusName;
-
- UPROPERTY(EditAnywhere, Category = "AkComponent|Spatial Audio|Reflect", meta = (ClampMin = "0.0", ClampMax = "1.0"))
- float EarlyReflectionBusSendGain = .0f;
- public:
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AkComponent|Spatial Audio|Debug Draw")
- bool DrawFirstOrderReflections = false;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AkComponent|Spatial Audio|Debug Draw")
- bool DrawSecondOrderReflections = false;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AkComponent|Spatial Audio|Debug Draw")
- bool DrawHigherOrderReflections = false;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AkComponent|Spatial Audio|Debug Draw")
- bool DrawDiffraction = false;
-
- UPROPERTY()
- bool StopWhenOwnerDestroyed = false;
-
- UFUNCTION(BlueprintCallable, Category = "Audiokinetic|AkComponent", meta = (AdvancedDisplay = "0", Latent, LatentInfo = "LatentInfo"))
- int32 PostAssociatedAkEventAndWaitForEnd(FLatentActionInfo LatentInfo);
-
- UFUNCTION(BlueprintCallable, Category = "Audiokinetic|AkComponent", meta = (AdvancedDisplay = "1", Latent, LatentInfo = "LatentInfo"))
- int32 PostAkEventAndWaitForEnd(
- class UAkAudioEvent * AkEvent,
- FLatentActionInfo LatentInfo
- );
- int32 PostAkEvent(UAkAudioEvent* AkEvent, int32 CallbackMask, const FOnAkPostEventCallback& PostEventCallback) override;
- AkPlayingID PostAkEvent(UAkAudioEvent* AkEvent, AkUInt32 Flags = 0, AkCallbackFunc UserCallback = nullptr, void* UserCookie = nullptr) override;
-
- UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category="Audiokinetic|AkComponent", meta = (AdvancedDisplay = "1"))
- void PostTrigger(class UAkTrigger const* TriggerValue, FString Trigger);
-
-
- UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category="Audiokinetic|AkComponent", meta = (AdvancedDisplay = "1"))
- void SetSwitch(class UAkSwitchValue const* SwitchValue, FString SwitchGroup, FString SwitchState);
-
- UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category="Audiokinetic|AkComponent")
- void SetStopWhenOwnerDestroyed( bool bStopWhenOwnerDestroyed );
-
- UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category="Audiokinetic|AkComponent")
- void SetListeners( const TArray<UAkComponent*>& Listeners );
-
-
- UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category = "Audiokinetic|AkComponent")
- void SetEarlyReflectionsAuxBus(const FString& AuxBusName);
-
- UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category = "Audiokinetic|AkComponent")
- void SetEarlyReflectionsVolume(float SendVolume);
-
- UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category = "Audiokinetic|AkComponent")
- void SetOutputBusVolume(float BusVolume);
-
- UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="AkComponent")
- float AttenuationScalingFactor = .0f;
-
- UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category = "Audiokinetic|AkComponent")
- void SetAttenuationScalingFactor(float Value);
-
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AkComponent")
- bool bUseReverbVolumes = true;
-
- UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category="Audiokinetic|AkComponent")
- float GetAttenuationRadius() const;
- void UpdateGameObjectPosition();
- void GetAkGameObjectName(FString& Name) const;
- bool IsListener = false;
- bool IsDefaultListener = false;
- #if CPP
-
-
- virtual void OnRegister();
-
- virtual void OnUnregister();
-
- virtual void OnComponentDestroyed(bool bDestroyingHierarchy) override;
-
- virtual void ShutdownAfterError();
- virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override;
-
- virtual void BeginPlay() override;
- virtual void OnUpdateTransform(EUpdateTransformFlags UpdateTransformFlags, ETeleportType Teleport = ETeleportType::None) override;
-
-
- void UpdateAkLateReverbComponentList(FVector Loc);
-
- void UpdateSpatialAudioRoom(FVector Location);
- void SetAutoDestroy(bool in_AutoDestroy) { bAutoDestroy = in_AutoDestroy; }
- bool UseDefaultListeners() const { return bUseDefaultListeners; }
- void OnListenerUnregistered(UAkComponent* in_pListener)
- {
- FScopeLock Lock(&ListenerCriticalSection);
- Listeners.Remove(in_pListener);
- }
- void OnDefaultListenerAdded(UAkComponent* in_pListener)
- {
- if(bUseDefaultListeners)
- {
- FScopeLock Lock(&ListenerCriticalSection);
- Listeners.Add(in_pListener);
- }
- }
- static UAkComponent* GetAkComponent(AkGameObjectID GameObjectID);
- AkRoomID GetSpatialAudioRoomID() const;
- const UAkRoomComponent* GetSpatialAudioRoom() const { return CurrentRoom; }
- void UpdateObstructionAndOcclusion();
- FVector GetPosition() const;
- #if WITH_EDITOR
- virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
- #endif
- private:
-
- void RegisterGameObject();
-
- void UnregisterGameObject();
-
- virtual void PostRegisterGameObject();
-
- virtual void PostUnregisterGameObject();
-
-
- void ApplyAkReverbVolumeList(float DeltaTime);
- AkComponentObstructionAndOcclusionService ObstructionService;
-
- TArray<AkReverbFadeControl> ReverbFadeControls;
-
- TArray<AkAuxSendValue> CurrentAuxSendValues;
-
- bool NeedToUpdateAuxSends(const TArray<AkAuxSendValue>& NewValues);
-
- class UAkRoomComponent* CurrentRoom;
-
- bool bAutoDestroy;
-
- AkSoundPosition CurrentSoundPosition;
- bool HasMoved();
- #endif
- #if WITH_EDITORONLY_DATA
-
- void UpdateSpriteTexture();
- #endif
- bool bUseDefaultListeners;
- FCriticalSection ListenerCriticalSection;
- TSet<UAkComponent*> Listeners;
- void DebugDrawReflections() const;
- void _DebugDrawReflections(const AkVector64& akEmitterPos, const AkVector64& akListenerPos, const AkReflectionPathInfo* paths, AkUInt32 uNumPaths) const;
- void DebugDrawDiffraction() const;
- void _DebugDrawDiffraction(const AkVector64& akEmitterPos, const AkVector64& akListenerPos, const AkDiffractionPathInfo* paths, AkUInt32 uNumPaths) const;
- };
|