212 lines
6.4 KiB
C++
212 lines
6.4 KiB
C++
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "UObject/NoExportTypes.h"
|
|
#include "DismembermentCompiler.generated.h"
|
|
|
|
class UDismembermentGraphNode;
|
|
class UDismembermentGraph;
|
|
|
|
/**
|
|
* Compiled node data structure
|
|
*/
|
|
USTRUCT()
|
|
struct FCompiledNodeData
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
// Node reference
|
|
UPROPERTY()
|
|
TObjectPtr<UDismembermentGraphNode> Node;
|
|
|
|
// Input nodes
|
|
UPROPERTY()
|
|
TArray<int32> InputNodeIndices;
|
|
|
|
// Output nodes
|
|
UPROPERTY()
|
|
TArray<int32> OutputNodeIndices;
|
|
|
|
// Execution order index
|
|
int32 ExecutionOrder;
|
|
|
|
// Constructor
|
|
FCompiledNodeData()
|
|
: Node(nullptr)
|
|
, ExecutionOrder(-1)
|
|
{
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Dismemberment compiler class
|
|
* Compiles a dismemberment graph into executable logic
|
|
*/
|
|
UCLASS()
|
|
class FLESHEDITOR_API UDismembermentCompiler : public UObject
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
// Constructor
|
|
UDismembermentCompiler();
|
|
|
|
/**
|
|
* Compile a dismemberment graph
|
|
* @param InGraph - The graph to compile
|
|
* @return True if compilation was successful
|
|
*/
|
|
bool CompileGraph(UDismembermentGraph* InGraph);
|
|
|
|
/**
|
|
* Get the compiled node data
|
|
* @return Array of compiled node data
|
|
*/
|
|
const TArray<FCompiledNodeData>& GetCompiledNodeData() const { return CompiledNodeData; }
|
|
|
|
/**
|
|
* Get the execution order
|
|
* @return Array of node indices in execution order
|
|
*/
|
|
const TArray<int32>& GetExecutionOrder() const { return ExecutionOrder; }
|
|
|
|
/**
|
|
* Add a bone selection
|
|
* @param BoneName - Name of the bone to select
|
|
*/
|
|
void AddBoneSelection(const FName& BoneName);
|
|
|
|
/**
|
|
* Add a cut operation
|
|
* @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
|
|
*/
|
|
void AddCutOperation(const FVector& Location, const FVector& Direction, float Width, float Depth, UMaterialInterface* Material);
|
|
|
|
/**
|
|
* Add 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
|
|
*/
|
|
void AddBloodEffect(const FVector& Location, UNiagaraSystem* BloodEffect, float BloodAmount, float BloodPressure, bool CreateBloodPool, float BloodPoolSize, UMaterialInterface* BloodPoolMaterial);
|
|
|
|
/**
|
|
* Add a 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
|
|
*/
|
|
void AddPhysicsSimulation(float Mass, float LinearDamping, float AngularDamping, bool EnableGravity, bool SimulatePhysics, bool GenerateOverlapEvents, UPhysicalMaterial* PhysicalMaterial, float ImpulseForce, float ImpulseRadius);
|
|
|
|
/**
|
|
* Add 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
|
|
*/
|
|
void AddOrgan(UStaticMesh* OrganMesh, UMaterialInterface* OrganMaterial, const FName& AttachBoneName, const FVector& RelativeLocation, const FRotator& RelativeRotation, const FVector& RelativeScale, bool SimulatePhysics, float DamageMultiplier, bool IsCriticalOrgan, float BloodAmount);
|
|
|
|
/**
|
|
* Add 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
|
|
*/
|
|
void AddWoundEffect(float WoundSize, float WoundDepth, UMaterialInterface* WoundMaterial, UNiagaraSystem* WoundEffect, bool CreateDecal, UMaterialInterface* DecalMaterial, float DecalSize, float DecalLifetime, bool AffectBoneHealth, float BoneDamage);
|
|
|
|
private:
|
|
// The graph being compiled
|
|
UPROPERTY()
|
|
TObjectPtr<UDismembermentGraph> Graph;
|
|
|
|
// Compiled node data
|
|
UPROPERTY()
|
|
TArray<FCompiledNodeData> CompiledNodeData;
|
|
|
|
// Execution order
|
|
UPROPERTY()
|
|
TArray<int32> ExecutionOrder;
|
|
|
|
// Bone selections
|
|
UPROPERTY()
|
|
TArray<FName> BoneSelections;
|
|
|
|
// Cut operations
|
|
UPROPERTY()
|
|
TArray<FTransform> CutOperations;
|
|
|
|
// Cut materials
|
|
UPROPERTY()
|
|
TArray<TObjectPtr<UMaterialInterface>> CutMaterials;
|
|
|
|
// Cut widths
|
|
UPROPERTY()
|
|
TArray<float> CutWidths;
|
|
|
|
// Cut depths
|
|
UPROPERTY()
|
|
TArray<float> CutDepths;
|
|
|
|
// Blood effects
|
|
UPROPERTY()
|
|
TArray<FTransform> BloodEffectTransforms;
|
|
|
|
// Blood effect systems
|
|
UPROPERTY()
|
|
TArray<TObjectPtr<UNiagaraSystem>> BloodEffectSystems;
|
|
|
|
// Blood amounts
|
|
UPROPERTY()
|
|
TArray<float> BloodAmounts;
|
|
|
|
// Blood pressures
|
|
UPROPERTY()
|
|
TArray<float> BloodPressures;
|
|
|
|
// Create blood pools
|
|
UPROPERTY()
|
|
TArray<bool> CreateBloodPools;
|
|
|
|
// Blood pool sizes
|
|
UPROPERTY()
|
|
TArray<float> BloodPoolSizes;
|
|
|
|
// Blood pool materials
|
|
UPROPERTY()
|
|
TArray<TObjectPtr<UMaterialInterface>> BloodPoolMaterials;
|
|
|
|
// Topological sort the nodes
|
|
bool TopologicalSort();
|
|
|
|
// Visit node for topological sort
|
|
void VisitNode(int32 NodeIndex, TArray<bool>& Visited, TArray<bool>& TempMark, TArray<int32>& SortedNodes, bool& bHasCycle);
|
|
};
|