78 lines
1.7 KiB
C++
78 lines
1.7 KiB
C++
// 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::SetCurrentState(FGameplayTag NewState)
|
|
{
|
|
if (NewState != CurrentState)
|
|
{
|
|
OnStateEnd.Broadcast(CurrentState);
|
|
CurrentState = NewState;
|
|
OnStateBegin.Broadcast(CurrentState);
|
|
}
|
|
}
|
|
|
|
FGameplayTag UStateManagerComponent::GetCurrentState()
|
|
{
|
|
return CurrentState;
|
|
}
|
|
|
|
void UStateManagerComponent::ResetState()
|
|
{
|
|
CurrentState = FGameplayTag::EmptyTag;
|
|
}
|
|
|
|
bool UStateManagerComponent::IsCurrentStateEqualToAny(FGameplayTagContainer StatesToCheck)
|
|
{
|
|
return StatesToCheck.HasTagExact(CurrentState);
|
|
}
|
|
|
|
void UStateManagerComponent::SetCurrentAction(FGameplayTag NewAction)
|
|
{
|
|
if (CurrentAction != NewAction)
|
|
{
|
|
OnActionEnd.Broadcast(CurrentAction);
|
|
CurrentAction = NewAction;
|
|
OnActionBegin.Broadcast(CurrentAction);
|
|
}
|
|
}
|
|
|
|
FGameplayTag UStateManagerComponent::GetCurrentAction()
|
|
{
|
|
return CurrentAction;
|
|
}
|
|
|
|
bool UStateManagerComponent::IsCurrentActionEqualToAny(FGameplayTagContainer ActionToCheck)
|
|
{
|
|
return ActionToCheck.HasTagExact(CurrentAction);
|
|
} |