// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "Components/ActorComponent.h" #include "StateManagerComponent.generated.h" UENUM(BlueprintType) enum class ECharacterState : uint8 { Nothing UMETA(DisplayName = "Nothing"), Attacking UMETA(DisplayName = "Attacking"), Dodging UMETA(DisplayName = "Dodging"), GeneralActionState UMETA(DisplayName = "GeneralActionState"), Dead UMETA(DisplayName = "Dead"), Disable UMETA(DisplayName = "Disable") }; UENUM(BlueprintType) enum class ECharacterAction : uint8 { Nothing UMETA(DisplayName = "Nothing"), GeneralAction UMETA(DisplayName = "GeneralAction"), LightAttack UMETA(DisplayName = "LightAttack"), HeavyAttack UMETA(DisplayName = "HeavyAttack"), ChargedAttack UMETA(DisplayName = "ChargedAttack"), FallingAttack UMETA(DisplayName = "FallingAttack"), SprintAttack UMETA(DisplayName = "SprintAttack"), Dodge UMETA(DisplayName = "Dodge"), EnterCombat UMETA(DisplayName = "EnterCombat"), ExitCombat UMETA(DisplayName = "ExitCombat"), }; DECLARE_MULTICAST_DELEGATE_OneParam(FStateBegin, ECharacterState); DECLARE_MULTICAST_DELEGATE_OneParam(FStateEnd, ECharacterState); DECLARE_MULTICAST_DELEGATE_OneParam(FActionBegin, ECharacterAction); DECLARE_MULTICAST_DELEGATE_OneParam(FActionEnd, ECharacterAction); UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) class D1_API UStateManagerComponent : public UActorComponent { GENERATED_BODY() public: // Sets default values for this component's properties UStateManagerComponent(); protected: // Called when the game starts virtual void BeginPlay() override; public: // Called every frame virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; public: void SetCurrentState(ECharacterState NewState); ECharacterState GetCurrentState(); void ResetState(); bool IsCurrentStateEqualToAny(TArray StatesToCheck); void SetCurrentAction(ECharacterAction NewAction); ECharacterAction GetCurrentAction(); bool IsCurrentActionEqualToAny(TArray ActionToCheck); public: //Delegate FStateBegin OnStateBegin; FStateEnd OnStateEnd; FActionBegin OnActionBegin; FActionEnd OnActionEnd; private: ECharacterState CurrentState; ECharacterAction CurrentAction; };