#pragma once #include "CoreMinimal.h" #include "EdGraph/EdGraphSchema.h" #include "DismembermentGraphSchema.generated.h" class UDismembermentGraphNode; /** * Connection response */ USTRUCT() struct FDismembermentGraphConnectionResponse { GENERATED_BODY() // Response type UPROPERTY() int32 Response; // Response text UPROPERTY() FText Message; // Pin names that would be broken UPROPERTY() TArray BreakingPins; // Constructor FDismembermentGraphConnectionResponse() : Response(0) { } }; /** * Connection response types */ struct FDismembermentGraphConnectionResponse_K2 { enum Type { // No error OK = 0, // Generic error ERROR_INCOMPATIBLE = 1, // Disallowed pin connection ERROR_DISALLOWED = 2, // Self-connection not allowed ERROR_SELF_CONNECTION = 3, // Cycle not allowed ERROR_CYCLE = 4 }; }; /** * Pin type */ USTRUCT() struct FDismembermentGraphPinType { GENERATED_BODY() // Pin category UPROPERTY() FName PinCategory; // Constructor FDismembermentGraphPinType() { } // Constructor with category FDismembermentGraphPinType(const FName& InPinCategory) : PinCategory(InPinCategory) { } // Equality operator bool operator==(const FDismembermentGraphPinType& Other) const { return PinCategory == Other.PinCategory; } // Inequality operator bool operator!=(const FDismembermentGraphPinType& Other) const { return !(*this == Other); } }; /** * Dismemberment graph schema */ UCLASS() class FLESHEDITOR_API UDismembermentGraphSchema : public UEdGraphSchema { GENERATED_BODY() public: // Pin categories static const FName PC_Exec; static const FName PC_Bone; static const FName PC_Cut; static const FName PC_Blood; static const FName PC_Physics; static const FName PC_Organ; static const FName PC_Wound; // UEdGraphSchema interface virtual void GetGraphContextActions(FGraphContextMenuBuilder& ContextMenuBuilder) const override; virtual void GetContextMenuActions(UToolMenu* Menu, UGraphNodeContextMenuContext* Context) const override; virtual const FPinConnectionResponse CanCreateConnection(const UEdGraphPin* A, const UEdGraphPin* B) const override; virtual bool TryCreateConnection(UEdGraphPin* A, UEdGraphPin* B) const override; virtual bool ShouldHidePinDefaultValue(UEdGraphPin* Pin) const override; virtual FLinearColor GetPinTypeColor(const FEdGraphPinType& PinType) const override; virtual void BreakNodeLinks(UEdGraphNode& TargetNode) const override; virtual void BreakPinLinks(UEdGraphPin& TargetPin, bool bSendsNodeNotification) const override; virtual void BreakSinglePinLink(UEdGraphPin* SourcePin, UEdGraphPin* TargetPin) const override; virtual void DroppedAssetsOnGraph(const TArray& Assets, const FVector2D& GraphPosition, UEdGraph* Graph) const override; virtual void DroppedAssetsOnNode(const TArray& Assets, const FVector2D& GraphPosition, UEdGraphNode* Node) const override; virtual void DroppedAssetsOnPin(const TArray& Assets, const FVector2D& GraphPosition, UEdGraphPin* Pin) const override; virtual void GetAssetsNodeHoverMessage(const TArray& Assets, const UEdGraphNode* HoverNode, FString& OutTooltipText, bool& OutOkIcon) const override; virtual void GetAssetsPinHoverMessage(const TArray& Assets, const UEdGraphPin* HoverPin, FString& OutTooltipText, bool& OutOkIcon) const override; // End of UEdGraphSchema interface /** * Check if two pins can be connected * @param PinA - First pin * @param PinB - Second pin * @param OutResponse - Connection response * @return True if the pins can be connected */ bool CanConnectPins(const UEdGraphPin* PinA, const UEdGraphPin* PinB, FDismembermentGraphConnectionResponse& OutResponse) const; /** * Check if connecting two pins would create a cycle * @param PinA - First pin * @param PinB - Second pin * @return True if connecting the pins would create a cycle */ bool WouldCreateCycle(const UEdGraphPin* PinA, const UEdGraphPin* PinB) const; /** * Get the pin type from a pin * @param Pin - The pin to get the type from * @return The pin type */ static FDismembermentGraphPinType GetPinType(const UEdGraphPin* Pin); /** * Get the pin type color * @param PinType - The pin type * @return The pin color */ static FLinearColor GetPinTypeColor(const FDismembermentGraphPinType& PinType); /** * Create a new node * @param NodeClass - Class of the node to create * @param ParentGraph - Graph to create the node in * @param NodePosX - X position of the node * @param NodePosY - Y position of the node * @param bSelectNewNode - Whether to select the new node * @return The created node */ static UDismembermentGraphNode* CreateNode(TSubclassOf NodeClass, UEdGraph* ParentGraph, float NodePosX, float NodePosY, bool bSelectNewNode = true); };