Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include "CoreMinimal.h"
- #include "Kismet/BlueprintFunctionLibrary.h"
- #include "GameID.h"
- #include "FormID.h"
- #include "Record.h"
- #include "Group.generated.h"
- // Represents a group (GRUP) in Bethesda file formats, containing FormIDs of records or subgroups.
- USTRUCT(BlueprintType)
- struct FGroup
- {
- GENERATED_BODY()
- // Array of FormIDs identifying records or subgroups within this group.
- UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Group", meta=(ToolTip="Array of FormIDs in the group."))
- TArray<FFormID> FormIds;
- // Group label, typically a string or integer identifier from the GRUP header.
- UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Group", meta=(ToolTip="Group label or identifier."))
- FString Label;
- // Default constructor, initializing to empty values.
- FGroup() : FormIds(), Label(TEXT("")) {}
- // Parameterized constructor for initializing with specific values.
- FGroup(const TArray<FFormID>& InFormIds, const FString& InLabel) : FormIds(InFormIds), Label(InLabel) {}
- // Equality operator to compare groups based on FormIDs and Label.
- bool operator==(const FGroup& Other) const { return FormIds == Other.FormIds && Label == Other.Label; }
- // Inequality operator, defined using equality operator.
- bool operator!=(const FGroup& Other) const { return !(*this == Other); }
- };
- // Hash function for FGroup, enabling use in TMap/TSet.
- FORCEINLINE uint32 GetTypeHash(const FGroup& Group)
- {
- return GetTypeHash(Group.FormIds) ^ GetTypeHash(Group.Label);
- }
- // Blueprint Function Library for group-related utilities.
- UCLASS()
- class UNREALCREATIONENGINE_API UGroupHelper : public UBlueprintFunctionLibrary
- {
- GENERATED_BODY()
- public:
- // Reads a group from a file with game-specific logic.
- UFUNCTION(BlueprintCallable, Category = "Group", meta=(ToolTip="Reads a group from a file."))
- static bool ReadGroupFromFile(FGroup& OutGroup, const FString& FilePath, EGameID GameID, bool bSkipSubrecords);
- // Reads a group from a byte array with game-specific logic.
- UFUNCTION(BlueprintCallable, Category = "Group", meta=(ToolTip="Reads a group from a byte array."))
- static bool ReadGroupFromBytes(FGroup& OutGroup, const TArray<uint8>& ByteArray, EGameID GameID, bool bSkipSubrecords);
- // Writes a group to a file with game-specific logic.
- UFUNCTION(BlueprintCallable, Category = "Group", meta=(ToolTip="Writes a group to a file."))
- static bool WriteGroupToFile(const FGroup& Group, const FString& FilePath, EGameID GameID);
- // Serializes a group to a byte array with game-specific logic.
- UFUNCTION(BlueprintCallable, Category = "Group", meta=(ToolTip="Serializes a group to a byte array."))
- static bool WriteGroupToBytes(const FGroup& Group, TArray<uint8>& OutByteArray, EGameID GameID);
- // Gets the FormIDs in the group.
- UFUNCTION(BlueprintPure, Category = "Group", meta=(ToolTip="Gets the FormIDs in the group."))
- static TArray<FFormID> GetFormIds(const FGroup& Group);
- // Gets the number of FormIDs in the group.
- UFUNCTION(BlueprintPure, Category = "Group", meta=(ToolTip="Gets the number of FormIDs."))
- static int32 GetFormIdCount(const FGroup& Group);
- // Checks if a specific FormID exists in the group.
- UFUNCTION(BlueprintPure, Category = "Group", meta=(ToolTip="Checks if a FormID exists in the group."))
- static bool HasFormId(const FGroup& Group, const FFormID& FormId);
- // Gets the group label.
- UFUNCTION(BlueprintPure, Category = "Group", meta=(ToolTip="Gets the group label."))
- static FString GetLabel(const FGroup& Group);
- // Adds a FormID to the group.
- UFUNCTION(BlueprintCallable, Category = "Group", meta=(ToolTip="Adds a FormID to the group."))
- static void AddFormId(FGroup& Group, const FFormID& FormId);
- // Removes a FormID from the group.
- UFUNCTION(BlueprintCallable, Category = "Group", meta=(ToolTip="Removes a FormID from the group."))
- static bool RemoveFormId(FGroup& Group, const FFormID& FormId);
- // Clears all FormIDs from the group.
- UFUNCTION(BlueprintCallable, Category = "Group", meta=(ToolTip="Clears all FormIDs from the group."))
- static void ClearFormIds(FGroup& Group);
- // Returns true if the group is valid (non-empty FormIDs, valid label).
- UFUNCTION(BlueprintPure, Category = "Group", meta=(ToolTip="Returns true if the group is valid."))
- static bool IsValidGroup(const FGroup& Group, EGameID GameID);
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement