UAssetDataSource.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. #pragma once
  16. #include "CoreMinimal.h"
  17. #include "WwiseItemType.h"
  18. #include "GenericPlatform/GenericPlatform.h"
  19. #include "Templates/TypeHash.h"
  20. struct UAssetDataSourceId
  21. {
  22. FGuid ItemId;
  23. uint32 ShortId = 0;
  24. FName Name;
  25. inline const bool operator==(const UAssetDataSourceId& other) const
  26. {
  27. if (other.ItemId == ItemId && ItemId.IsValid())
  28. {
  29. return true;
  30. }
  31. if (ShortId == other.ShortId && ShortId > 0)
  32. {
  33. return true;
  34. }
  35. return Name == other.Name;
  36. }
  37. };
  38. struct UAssetDataSourceInformation
  39. {
  40. EWwiseItemType::Type Type;
  41. UAssetDataSourceId Id;
  42. TArray<FAssetData> AssetsData;
  43. FName AssetName;
  44. inline const bool operator==(const UAssetDataSourceId& other) const
  45. {
  46. return Id == other;
  47. }
  48. inline const bool operator==(const UAssetDataSourceInformation& other) const
  49. {
  50. return Id == other.Id;
  51. }
  52. };
  53. class FUAssetDataSource
  54. {
  55. TMap<FGuid, UAssetDataSourceInformation> OrphanedItems;
  56. TMap<FGuid, UAssetDataSourceInformation> UsedItems;
  57. //UAssets with invalid Guid will use the ShortId to sync with the Project Database.
  58. TMap<uint32, UAssetDataSourceInformation> UAssetWithoutGuid;
  59. //UAssets with invalid Guid and ShortId will use the AssetName to sync with the Project Database.
  60. TMap<FName, UAssetDataSourceInformation> UAssetWithoutShortId;
  61. UAssetDataSourceInformation CreateUAssetInfo(const UAssetDataSourceId& Id, const FAssetData& Asset);
  62. bool GuidExistsInProjectDatabase(const FGuid ItemId, EWwiseItemType::Type Type);
  63. public:
  64. void ConstructItems();
  65. void GetAssetsInfo(FGuid ItemId, uint32 ShortId, FString Name, EWwiseItemType::Type& ItemType, FName& AssetName, TArray<FAssetData>& Assets);
  66. void GetOrphanAssets(TArray<UAssetDataSourceInformation>& OrphanAssets) const;
  67. };