[박치영] 4챕터 포팅 중

pcyoung 2023-08-05 16:07:40 +09:00
parent 174f64b96c
commit 1f829698a0
2 changed files with 102 additions and 0 deletions

View File

@ -0,0 +1,58 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Components/StateManagerComponent.h"
// Sets default values for this component's properties
UStateManagerComponent::UStateManagerComponent()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don't need them.
PrimaryComponentTick.bCanEverTick = true;
// ...
}
// Called when the game starts
void UStateManagerComponent::BeginPlay()
{
Super::BeginPlay();
// ...
}
// Called every frame
void UStateManagerComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
// ...
}
void UStateManagerComponent::SetState(ECharacterState NewState)
{
if (NewState != CurrentState)
{
//TODO : Delegate ÇÔ¼ö È£Ãâ (Call on State End)
CurrentState = NewState;
//TODO : Delegate ÇÔ¼ö È£Ãâ (Call on State Begin)
}
}
ECharacterState UStateManagerComponent::GetCurrentState()
{
return CurrentState;
}
void UStateManagerComponent::ResetState()
{
CurrentState = ECharacterState::Nothing;
}
bool UStateManagerComponent::IsCurrentStateEqualToAny(TArray<ECharacterState> StatesToCheck)
{
return StatesToCheck.Contains(CurrentState);
}

View File

@ -0,0 +1,44 @@
// 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")
};
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 SetState(ECharacterState NewState);
ECharacterState GetCurrentState();
void ResetState();
bool IsCurrentStateEqualToAny(TArray<ECharacterState> StatesToCheck);
private:
ECharacterState CurrentState;
};