UnrealFightingFramework/Source/UnrealFightingFramework/State/FFState.h

123 lines
3.5 KiB
C++

// Unreal Fighting Framework by Kevin Poretti
#pragma once
// UE includes
#include "CoreMinimal.h"
#include "FFState.generated.h"
USTRUCT(BlueprintType)
struct FFFStateData
{
GENERATED_BODY()
/** Name of this state */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="UFF|State")
FName Name;
/** Conditions that need to be met in order for this state to be transitioned into */
UPROPERTY(EditAnywhere)
TArray<uint8> EntryConditions;
/** What is this state's category. Used for determining what types of state can prematurely cancel this one. */
UPROPERTY(EditAnywhere)
uint8 StateType;
};
USTRUCT(BlueprintType)
struct FFFStateContext
{
GENERATED_BODY()
/** Actor that owns the avatar. Typically a player controller. */
AActor* Owner;
/**
* Actor that represents the player's avatar or an object associated with the player's avatar.
* This is typically a character or a weapon.
*/
AActor* Avatar;
/**
* Data associated with this state.
* For example this can be new movement values or data about the hitboxes if this state represents an attack.
*/
FFFStateData StateData;
};
/**
* A state is an object that provides rules and conditions for when a state can be transitioned into
* and logic to run when the state is entered, exited, and active.
*/
UCLASS()
class UNREALFIGHTINGFRAMEWORK_API UFFStateBehavior : public UObject
{
GENERATED_BODY()
public:
/** Name of this state behavior */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="UFF|State")
FName Name;
// TODO: since state's are now purely behavioral can we remove these function calls?
// They are basically redundant with OnEnter, OnUpdate, OnExit, etc.
/**
* Called whenever this state is transitioned into.
*
* Resets TicksInState and calls appropriate Blueprint hooks
*/
void Enter(const FFFStateContext& InStateContext);
/**
* Called whenever this state is transitioned out of into a new state.
*/
void Exit(const FFFStateContext& InStateContext);
/**
* Called whenever this state is active and the game logic ticks.
*
* Increments TicksInState and calls appropriate Blueprint hooks.
*
* @param OneFrame the time that elapses during one fixed tick
*/
void Update(float OneFrame, const FFFStateContext& InStateContext);
/**
* Blueprint hook that is called whenever this state is transitioned into
*/
UFUNCTION(BlueprintNativeEvent, Category="UFF|State|Events")
void OnEnter(const FFFStateContext& InStateContext);
/**
* Blueprint hook that is called whenever this state is transitioned out of into a new state
*/
UFUNCTION(BlueprintNativeEvent, Category="UFF|State|Events")
void OnExit(const FFFStateContext& InStateContext);
/**
* Blueprint hook that is called whenever this state is active and the game logic ticks
*
* @param OneFrame the time that elapses during one fixed tick
*/
UFUNCTION(BlueprintNativeEvent, Category="UFF|State|Events")
void OnUpdate(float OneFrame, const FFFStateContext& InStateContext);
UFUNCTION(BlueprintNativeEvent, Category="UFF|State|Events")
void OnLanded(const FFFStateContext& InStateContext);
UFUNCTION(BlueprintNativeEvent, Category="UFF|State|Events")
void OnHit(const FFFStateContext& InStateContext);
UFUNCTION(BlueprintNativeEvent, Category="UFF|State|Events")
void OnBlock(const FFFStateContext& InStateContext);
UFUNCTION(BlueprintNativeEvent, Category="UFF|State|Events")
void OnInputEvent(const FFFStateContext& InStateContext);
// UObject interface
virtual UWorld* GetWorld() const override;
// End of UObject interface
};