123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488 |
- #pragma once
- #include "Runtime/Launch/Resources/Version.h"
- #include "AkInclude.h"
- #include "AkGameplayTypes.h"
- #include "AkSettings.h"
- #include "Components/SceneComponent.h"
- #include "ObstructionAndOcclusionService/AkComponentObstructionAndOcclusionService.h"
- #include "AkGameObject.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|Occlusion")
- TEnumAsByte<EAkCollisionChannel> OcclusionCollisionChannel = { EAkCollisionChannel::EAKCC_UseIntegrationSettingsDefault };
- UFUNCTION(BlueprintCallable, Category="AkComponent|Occlusion")
- ECollisionChannel GetOcclusionCollisionChannel();
-
- 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(VisibleAnywhere, Category = "AkComponent|Spatial Audio|Reflect (DEPRECATED)", meta = (ClampMin = "0", ClampMax = "4"))
- int EarlyReflectionOrder = 0;
-
- UPROPERTY(EditAnywhere, Category = "AkComponent|Spatial Audio|Reflect", meta = (ClampMin = "0.0", ClampMax = "1.0"))
- float EarlyReflectionBusSendGain = .0f;
-
- UPROPERTY(VisibleAnywhere, Category = "AkComponent|Spatial Audio|Reflect (DEPRECATED)", meta = (ClampMin = "0.0"))
- float EarlyReflectionMaxPathLength = .0f;
-
- UPROPERTY(VisibleAnywhere, Category = "AkComponent|Spatial Audio|Room (DEPRECATED)", meta = (ClampMin = "0.0", ClampMax = "1.0"))
- float roomReverbAuxBusGain = .0f;
-
- UPROPERTY(VisibleAnywhere, Category = "AkComponent|Spatial Audio|Geometric Diffraction (DEPRECATED)", meta = (ClampMin = "0"))
- int diffractionMaxEdges = .0f;
-
- UPROPERTY(VisibleAnywhere, Category = "AkComponent|Spatial Audio|Geometric Diffraction (DEPRECATED)", meta = (ClampMin = "0"))
- int diffractionMaxPaths = .0f;
-
- UPROPERTY(VisibleAnywhere, Category = "AkComponent|Spatial Audio|Geometric Diffraction (DEPRECATED)", meta = (ClampMin = "0.0"))
- float diffractionMaxPathLength = .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", DeprecatedFunction, DeprecationMessage = "Use \"PostAssociatedAkEventAndWaitForEnd\"."))
- void PostAssociatedAkEventAndWaitForEndAsync(int32& PlayingID, FLatentActionInfo LatentInfo);
-
- UFUNCTION(BlueprintCallable, Category = "Audiokinetic|AkComponent", meta = (AdvancedDisplay = "1", Latent, LatentInfo = "LatentInfo"))
- int32 PostAkEventAndWaitForEnd(
- class UAkAudioEvent * AkEvent,
- const FString& in_EventName,
- FLatentActionInfo LatentInfo
- );
-
- UFUNCTION(BlueprintCallable, Category = "Audiokinetic|AkComponent", meta = (AdvancedDisplay = "2", Latent, LatentInfo = "LatentInfo", DeprecatedFunction, DeprecationMessage = "Use \"PostAkEventAndWaitForEnd\"."))
- void PostAkEventAndWaitForEndAsync(
- class UAkAudioEvent* AkEvent,
- int32& PlayingID,
- FLatentActionInfo LatentInfo
- );
- int32 PostAkEvent(UAkAudioEvent* AkEvent, int32 CallbackMask, const FOnAkPostEventCallback& PostEventCallback, const FString& InEventName) override;
- AkPlayingID PostAkEvent(UAkAudioEvent* AkEvent, AkUInt32 Flags = 0, AkCallbackFunc UserCallback = nullptr, void* UserCookie = nullptr) override;
-
- AK_DEPRECATED(2022.1, "Use PostAkEvent.")
- AkPlayingID PostAkEventByNameWithDelegate(UAkAudioEvent* AkEvent, const FString& in_EventName, int32 CallbackMask, const FOnAkPostEventCallback& PostEventCallback) override;
-
-
- AK_DEPRECATED(2022.1, "Use PostAkEvent.")
- AkPlayingID PostAkEventByIdWithCallback(const AkUInt32 EventShortID, AkUInt32 Flags = 0, AkCallbackFunc UserCallback = NULL, void * UserCookie = NULL, const TArray<AkExternalSourceInfo>& ExternalSources = TArray<AkExternalSourceInfo>());
-
- 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", meta = (DeprecatedFunction, DeprecationMessage = "Use the \"UseReverbVolume\" property", ScriptName="DEPRECATED_UseReverbVolumes"))
- void UseReverbVolumes(bool inUseReverbVolumes);
- UFUNCTION(BlueprintCallable, Category = "Audiokinetic|AkComponent", meta = (AdvancedDisplay = "5", DeprecatedFunction, DeprecationMessage = "This function is deprecated and will be removed in future releases."))
- void UseEarlyReflections(class UAkAuxBus* AuxBus, int Order = 1, float BusSendGain = 1.f, float MaxPathLength = 100000.f, bool SpotReflectors = false, const FString& AuxBusName = FString(""));
-
- 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|Occlusion")
- float OcclusionRefreshInterval = .0f;
-
- 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 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)
- {
- Listeners.Remove(in_pListener);
- }
- void OnDefaultListenerAdded(UAkComponent* in_pListener)
- {
- check(bUseDefaultListeners);
- Listeners.Add(in_pListener);
- }
- const TSet<UAkComponent*>& GetEmitters();
- static UAkComponent* GetAkComponent(AkGameObjectID GameObjectID);
- AkRoomID GetSpatialAudioRoom() const;
- void UpdateObstructionAndOcclusion() { ObstructionService.UpdateObstructionAndOcclusion(Listeners, GetPosition(), GetOwner(), GetSpatialAudioRoom(), GetOcclusionCollisionChannel(), OcclusionRefreshInterval); }
- 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;
- TSet<UAkComponent*> Listeners;
-
- TSet<UAkComponent*> Emitters;
- void CheckEmitterListenerConsistancy();
- 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;
- };
|