Files
FLESH/Source/FLESHEditor/Public/DismembermentGraph/DismembermentExecutor.h
2025-04-21 08:17:52 +08:00

162 lines
5.9 KiB
C++

#pragma once
#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "DismembermentCompiler.h"
#include "NiagaraSystem.h"
#include "BooleanCutTool.h"
#include "DismembermentExecutor.generated.h"
class AActor;
class USkeletalMeshComponent;
class UDismembermentCompiler;
/**
* Dismemberment executor class
* Executes a compiled dismemberment graph
*/
UCLASS()
class FLESHEDITOR_API UDismembermentExecutor : public UObject
{
GENERATED_BODY()
public:
// Constructor
UDismembermentExecutor();
/**
* Initialize the executor with a compiler
* @param InCompiler - The compiler containing the compiled graph
*/
void Initialize(UDismembermentCompiler* InCompiler);
/**
* Execute the compiled graph on a target actor
* @param TargetActor - The actor to apply the dismemberment effects to
* @return True if execution was successful
*/
bool Execute(AActor* TargetActor);
/**
* Get the target actor
* @return The target actor
*/
AActor* GetTargetActor() const { return TargetActor; }
/**
* Get the target skeletal mesh component
* @return The target skeletal mesh component
*/
USkeletalMeshComponent* GetTargetSkeletalMesh() const { return TargetSkeletalMesh; }
/**
* Get the selected bones
* @return Array of selected bone names
*/
const TArray<FName>& GetSelectedBones() const { return SelectedBones; }
/**
* Add a bone to the selection
* @param BoneName - Name of the bone to add
*/
void AddSelectedBone(const FName& BoneName);
/**
* Apply a cut to the target
* @param Location - Location of the cut
* @param Direction - Direction of the cut
* @param Width - Width of the cut
* @param Depth - Depth of the cut
* @param Material - Material to use for the cut surface
* @return True if the cut was successful
*/
bool ApplyCut(const FVector& Location, const FVector& Direction, float Width, float Depth, UMaterialInterface* Material);
/**
* Spawn a blood effect
* @param Location - Location of the blood effect
* @param BloodEffect - Niagara system for the blood effect
* @param BloodAmount - Amount of blood
* @param BloodPressure - Blood pressure
* @param CreateBloodPool - Whether to create a blood pool
* @param BloodPoolSize - Size of the blood pool
* @param BloodPoolMaterial - Material for the blood pool
* @return True if the blood effect was created successfully
*/
bool SpawnBloodEffect(const FVector& Location, UNiagaraSystem* BloodEffect, float BloodAmount, float BloodPressure, bool CreateBloodPool, float BloodPoolSize, UMaterialInterface* BloodPoolMaterial);
/**
* Apply physics simulation
* @param Mass - Mass of the object
* @param LinearDamping - Linear damping
* @param AngularDamping - Angular damping
* @param EnableGravity - Whether to enable gravity
* @param SimulatePhysics - Whether to simulate physics
* @param GenerateOverlapEvents - Whether to generate overlap events
* @param PhysicalMaterial - Physical material to use
* @param ImpulseForce - Force of the impulse
* @param ImpulseRadius - Radius of the impulse
* @return True if the physics simulation was applied successfully
*/
bool ApplyPhysics(float Mass, float LinearDamping, float AngularDamping, bool EnableGravity, bool SimulatePhysics, bool GenerateOverlapEvents, UPhysicalMaterial* PhysicalMaterial, float ImpulseForce, float ImpulseRadius);
/**
* Spawn an organ
* @param OrganMesh - Mesh for the organ
* @param OrganMaterial - Material for the organ
* @param AttachBoneName - Name of the bone to attach to
* @param RelativeLocation - Relative location
* @param RelativeRotation - Relative rotation
* @param RelativeScale - Relative scale
* @param SimulatePhysics - Whether to simulate physics
* @param DamageMultiplier - Damage multiplier
* @param IsCriticalOrgan - Whether this is a critical organ
* @param BloodAmount - Amount of blood
* @return True if the organ was spawned successfully
*/
bool SpawnOrgan(UStaticMesh* OrganMesh, UMaterialInterface* OrganMaterial, const FName& AttachBoneName, const FVector& RelativeLocation, const FRotator& RelativeRotation, const FVector& RelativeScale, bool SimulatePhysics, float DamageMultiplier, bool IsCriticalOrgan, float BloodAmount);
/**
* Apply a wound effect
* @param WoundSize - Size of the wound
* @param WoundDepth - Depth of the wound
* @param WoundMaterial - Material for the wound
* @param WoundEffect - Effect for the wound
* @param CreateDecal - Whether to create a decal
* @param DecalMaterial - Material for the decal
* @param DecalSize - Size of the decal
* @param DecalLifetime - Lifetime of the decal
* @param AffectBoneHealth - Whether to affect bone health
* @param BoneDamage - Amount of bone damage
* @return True if the wound effect was applied successfully
*/
bool ApplyWoundEffect(float WoundSize, float WoundDepth, UMaterialInterface* WoundMaterial, UNiagaraSystem* WoundEffect, bool CreateDecal, UMaterialInterface* DecalMaterial, float DecalSize, float DecalLifetime, bool AffectBoneHealth, float BoneDamage);
private:
// The compiler containing the compiled graph
UPROPERTY()
TObjectPtr<UDismembermentCompiler> Compiler;
// The target actor
UPROPERTY()
TObjectPtr<AActor> TargetActor;
// The target skeletal mesh component
UPROPERTY()
TObjectPtr<USkeletalMeshComponent> TargetSkeletalMesh;
// Selected bones
UPROPERTY()
TArray<FName> SelectedBones;
// Boolean cut tool for mesh cutting operations
UPROPERTY()
TObjectPtr<UBooleanCutTool> CutTool;
// Find the target skeletal mesh component
bool FindTargetSkeletalMesh();
// Execute a node
bool ExecuteNode(int32 NodeIndex);
};