UnrealFightingFramework/Source/UnrealFightingEngine/State/FEState.h

106 lines
2.7 KiB
C
Raw Normal View History

2023-06-03 22:38:35 +00:00
// Unreal Fighting Engine by Kevin Poretti
#pragma once
2023-06-04 19:56:36 +00:00
// UE includes
#include "CoreMinimal.h"
2023-06-04 19:56:36 +00:00
#include "FEState.generated.h"
/**
2023-06-03 22:38:35 +00:00
* 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 UNREALFIGHTINGENGINE_API UFEState : public UObject
{
GENERATED_BODY()
2023-06-03 22:38:35 +00:00
public:
/**
* Initializes pointers to what owns this state and what avatar this state represents.
2023-06-04 19:56:36 +00:00
*
* @param InOwner Actor that owns this state machine.
* @param InAvatar Actor that this state machine represents.
2023-06-03 22:38:35 +00:00
*/
virtual void InitActorInfo(AActor* InOwner, AActor* InAvatar);
/** Name of this state */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="UFE|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;
/** How many ticks have elapsed since this state was entered */
UPROPERTY(BlueprintReadOnly, Category="UFE|State")
int32 TicksInState;
/**
* Called whenever this state is transitioned into.
*
* Resets TicksInState and calls appropriate Blueprint hooks
*/
void Enter();
/**
* Called whenever this state is transitioned out of into a new state.
*/
void Exit();
/**
* 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);
2023-06-03 22:38:35 +00:00
/**
* Blueprint hook that is called whenever this state is transitioned into
*/
UFUNCTION(BlueprintNativeEvent, Category="UFE|State|Events")
void OnEnter();
/**
* Blueprint hook that is called whenever this state is transitioned out of into a new state
*/
UFUNCTION(BlueprintNativeEvent, Category="UFE|State|Events")
void OnExit();
/**
* 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="UFE|State|Events")
void OnUpdate(float OneFrame);
2023-06-03 22:38:35 +00:00
// UObject interface
virtual UWorld* GetWorld() const override;
// End of UObject interface
protected:
/**
* Actor that owns this state.
* This will typically be a player controller that possesses the avatar.
*/
UPROPERTY(BlueprintReadOnly)
AActor* Owner;
/**
* The avatar is an actor that this state represents.
* This will typically be a pawn or character.
*/
UPROPERTY(BlueprintReadOnly)
AActor* Avatar;
};