Files
FLESH/Source/FLESHEditor/Public/FLESHGraph/FLESHCompiler.h
2025-04-23 01:18:06 +08:00

142 lines
3.7 KiB
C++

#pragma once
#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "NiagaraSystem.h"
#include "FLESHCompiler.generated.h"
class UFLESHGraphNode;
class UFLESHGraph;
/**
* FLESH node type enum
*/
UENUM(BlueprintType)
enum class EFLESHNodeType : uint8
{
None UMETA(DisplayName = "None"),
Cut UMETA(DisplayName = "Cut"),
BloodEffect UMETA(DisplayName = "Blood Effect"),
Physics UMETA(DisplayName = "Physics"),
Organ UMETA(DisplayName = "Organ"),
Wound UMETA(DisplayName = "Wound"),
BoneSelection UMETA(DisplayName = "Bone Selection")
};
/**
* FLESH node data structure
*/
USTRUCT(BlueprintType)
struct FFLESHNodeData
{
GENERATED_BODY()
// Node name
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "FLESH")
FName NodeName;
// Node type
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "FLESH")
EFLESHNodeType NodeType;
// Node parameters
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "FLESH")
TMap<FName, float> FloatParameters;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "FLESH")
TMap<FName, FVector> VectorParameters;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "FLESH")
TMap<FName, FRotator> RotatorParameters;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "FLESH")
TMap<FName, bool> BoolParameters;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "FLESH")
TMap<FName, FString> StringParameters;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "FLESH")
TMap<FName, TObjectPtr<UObject>> ObjectParameters;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "FLESH")
TMap<FName, FName> NameParameters;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "FLESH")
TMap<FName, FLinearColor> ColorParameters;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "FLESH")
TMap<FName, TObjectPtr<UNiagaraSystem>> NiagaraSystemParameters;
// Connected nodes
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "FLESH")
TArray<int32> ConnectedNodes;
};
/**
* FLESH compiler class
* Compiles FLESH graph into executable format
*/
UCLASS(BlueprintType)
class FLESHEDITOR_API UFLESHCompiler : public UObject
{
GENERATED_BODY()
public:
// Constructor
UFLESHCompiler();
// Initialize compiler with graph
UFUNCTION(BlueprintCallable, Category = "FLESH")
void Initialize(UFLESHGraph* InGraph);
// Compile graph
UFUNCTION(BlueprintCallable, Category = "FLESH")
bool Compile();
// Get compiled node data
UFUNCTION(BlueprintCallable, Category = "FLESH")
TArray<FFLESHNodeData> GetCompiledNodeData() const;
// Get execution order
UFUNCTION(BlueprintCallable, Category = "FLESH")
TArray<int32> GetExecutionOrder() const;
// Check if compilation was successful
UFUNCTION(BlueprintCallable, Category = "FLESH")
bool IsCompilationSuccessful() const;
// Get error message
UFUNCTION(BlueprintCallable, Category = "FLESH")
FString GetErrorMessage() const;
private:
// Source graph
UPROPERTY()
TObjectPtr<UFLESHGraph> SourceGraph;
// Compiled node data
UPROPERTY()
TArray<FFLESHNodeData> CompiledNodeData;
// Execution order
UPROPERTY()
TArray<int32> ExecutionOrder;
// Compilation status
UPROPERTY()
bool bCompilationSuccessful;
// Error message
UPROPERTY()
FString ErrorMessage;
// Process node
bool ProcessNode(UFLESHGraphNode* Node, int32 NodeIndex);
// Sort nodes in execution order
void SortNodes();
// Validate graph
bool ValidateGraph();
};