Hey there,
I’m working on a tile based game in Unreal where my maps is stored by an array of Ustructs. I’ve read online that USTRUCTS don’t get garbage collected so I need to implement a custom Destroy function. However the structs are very simple and currently look like this:
UENUM(BlueprintType)
enum class ETerrain : uint8
{
TE_Floors UMETA(DisplayName = "Floors"),
TE_Walls UMETA(DisplayName = "Walls"),
TE_Water UMETA(DisplayName = "Water"),
TE_ERROR UMETA(DisplayName = "Error handler")
};
USTRUCT()
struct FCell
{
GENERATED_USTRUCT_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cell Settings") int32 i;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cell Settings") int32 x;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cell Settings") int32 y;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cell Settings") ETerrain terrain;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cell Settings / pathfinding") int32 pathfinding_ParentIndex; // Previous step in Path
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cell Settings / pathfinding") float pathfinding_G; // Steps taken to get to this Cell
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cell Settings / pathfinding") float pathfinding_H; // Heuristics, distance to end in straight line
FCell()
{
i = 0;
}
~FCell()
{
}
FCell(int32 a_index, int32 a_x, int32 a_y) : i(a_index), x(a_x), y(a_y)
{
terrain = ETerrain::TE_Floors;
}
FCell(int32 a_index, int32 a_x, int32 a_y, int32 a_parent) : i(a_index), x(a_x), y(a_y), pathfinding_ParentIndex(a_parent), pathfinding_G(0), pathfinding_H(0)
{
terrain = ETerrain::TE_Floors;
}
};
What would I put in the Destroy function of this struct?