// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "Components/ActorComponent.h" #include "GestureData.h" #include "GestureManagerComponent.generated.h" class AHandManager; UCLASS(ClassGroup = "Gesture", BlueprintType, Blueprintable, ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) class TABLE_API UGestureManagerComponent : public UActorComponent { GENERATED_BODY() public: // Sets default values for this component's properties UGestureManagerComponent(); protected: // Called when the game starts virtual void BeginPlay() override; public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Scale") float UEUnitsPerUnit = 100.f; // set via calibration rectangle UPROPERTY(BlueprintReadOnly) AHandManager* HandManager; UFUNCTION(BlueprintCallable, Category = "Gesture") void EvaluateHands(); UFUNCTION() void OnHandAdded(AHandActor* Hand); UFUNCTION() void OnHandRemoved(AHandActor* Hand); UPROPERTY(EditDefaultsOnly, Category = "Gesture") FString BindingConfigPath; // path to the per-game JSON // Loaded from JSON — gesture name -> definition object UPROPERTY(BlueprintReadOnly, Category = "Gesture") TArray GestureDefinitions; UPROPERTY(BlueprintReadOnly, Category = "Gesture") TArray ActiveGestureActions; // Populated on BeginPlay from JSON UPROPERTY(BlueprintReadOnly, Category = "Gesture") TArray GestureBindings; void LoadBindings(const FString& FilePath); void Initialize(UDataTable* InGestureTable, UDataTable* InActionTable); void BuildDefinitionMap(); void BuildActionMap(); // Populated on BeginPlay from the tables UPROPERTY(BlueprintReadOnly, Category = "Gesture") TMap DefinitionMap; UPROPERTY(BlueprintReadOnly, Category = "Gesture") TMap> ActionClassMap; private: // UPROPERTY(EditDefaultsOnly, Category = "Gesture") UDataTable* GestureDefinitionTable; UPROPERTY(EditDefaultsOnly, Category = "Gesture") UDataTable* GestureActionTable; void CheckGestureDefinitions(TArray& Hands); void TriggerAction(AHandActor* Hand); void UpdateOngoingActions(); AGestureAction* SpawnGestureAction(FName ActionName, AHandActor* Hand); bool TryExtendGestureAction(AHandActor* Hand); bool TryJoinExistingAction(AHandActor* Hand); bool TryCreateExtension(AHandActor* Hand); static constexpr int32 CandidateThreshold = 8; static constexpr int32 FailThreshold = 5; };