Advertisement
malice936

AsyncPluginLoader.h

Apr 17th, 2025
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.08 KB | Gaming | 0 0
  1. /*
  2. Warning! Experimental! No guarantees on functionality! Use at your own risk!!!!!
  3. (Not so much on this one. I have used it and it actually functions very well, but still potentially unstable.)
  4. */
  5. #pragma once
  6.  
  7. #include "FormID.h"
  8. #include "CoreMinimal.h"
  9. #include "Kismet/BlueprintFunctionLibrary.h"
  10. #include "AsyncPluginLoader.generated.h"
  11.  
  12. DECLARE_DYNAMIC_DELEGATE_TwoParams(FOnPluginFileLoaded, bool, bSuccess, const TArray<uint8>&, LoadedBytes);
  13.  
  14. USTRUCT(BlueprintType)
  15. struct FESMSubrecord
  16. {
  17.     GENERATED_BODY()
  18.     UPROPERTY(BlueprintReadOnly)
  19.     FString SubrecordType;
  20.     UPROPERTY(BlueprintReadOnly)
  21.     TArray<uint8> SubrecordData;
  22. };
  23.  
  24. USTRUCT(BlueprintType)
  25. struct FESMRecord
  26. {
  27.     GENERATED_BODY()
  28.     UPROPERTY(BlueprintReadOnly)
  29.     FString RecordType;
  30.     UPROPERTY(BlueprintReadOnly)
  31.     TArray<uint8> RecordData;
  32.     UPROPERTY(BlueprintReadOnly)
  33.     TArray<FFormID> FormIDs;
  34.     UPROPERTY(BlueprintReadOnly)
  35.     TArray<FESMSubrecord> Subrecords;
  36.     UPROPERTY(BlueprintReadOnly)
  37.     FString EditorID;
  38. };
  39.  
  40. USTRUCT(BlueprintType)
  41. struct FESMHeightData
  42. {
  43.     GENERATED_BODY()
  44.     UPROPERTY(BlueprintReadOnly)
  45.     float BaseHeight;
  46.     UPROPERTY(BlueprintReadOnly)
  47.     TArray<float> Heights; // 65x65 grid (4225 floats)
  48. };
  49.  
  50. UCLASS()
  51. class UAsyncPluginLoader : public UBlueprintFunctionLibrary
  52. {
  53.     GENERATED_BODY()
  54. public:
  55.     UFUNCTION(BlueprintCallable, Category = "File I/O")
  56.     static void LoadPluginFileAsync(const FString& FilePath, const FOnPluginFileLoaded& OnLoaded);
  57.  
  58.     UFUNCTION(BlueprintCallable, Category = "ESM Parsing")
  59.     static void ParseESMRecords(const TArray<uint8>& FileBytes, TArray<FESMRecord>& OutRecords);
  60.  
  61.     UFUNCTION(BlueprintCallable, Category = "ESM Parsing")
  62.     static void ParseESMSubrecords(const TArray<uint8>& RecordData, TArray<FESMSubrecord>& OutSubrecords, TArray<FFormID>& OutFormIDs, FESMRecord& CurrentRecord); // Added CurrentRecord parameter
  63.  
  64.     UFUNCTION(BlueprintCallable, Category = "ESM Parsing")
  65.     static bool ExtractHeightData(const FESMRecord& Record, FESMHeightData& OutHeightData);
  66. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement