Start of input buffer and player controller

This commit is contained in:
Kevin Poretti 2023-06-05 17:02:11 -04:00
parent 3090798d20
commit ecd8b1ca3c
9 changed files with 102 additions and 13 deletions

View File

@ -9,7 +9,7 @@
// This class does not need to be modified.
UINTERFACE(MinimalAPI)
class UIFESystemInterface : public UInterface
class UFESystemInterface : public UInterface
{
GENERATED_BODY()
};
@ -20,7 +20,7 @@ class UIFESystemInterface : public UInterface
* This ensures all gameplay effecting objects can be assumed to have certain properties that enable serialization, networking and
* some form of determinism.
*/
class UNREALFIGHTINGENGINE_API IIFESystemInterface
class UNREALFIGHTINGENGINE_API IFESystemInterface
{
GENERATED_BODY()

View File

@ -0,0 +1,8 @@
// Unreal Fighting Engine by Kevin Poretti
#include "FEInputBufferComponent.h"
UFEInputBufferComponent::UFEInputBufferComponent()
{
PrimaryComponentTick.bCanEverTick = false;
}

View File

@ -0,0 +1,18 @@
// Unreal Fighting Engine by Kevin Poretti
#pragma once
// UE includes
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "FEInputBufferComponent.generated.h"
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class UNREALFIGHTINGENGINE_API UFEInputBufferComponent : public UActorComponent
{
GENERATED_BODY()
public:
UFEInputBufferComponent();
};

View File

@ -0,0 +1,20 @@
// Unreal Fighting Engine by Kevin Poretti
#include "FEPlayerController.h"
// FE includes
#include "FEInputBufferComponent.h"
AFEPlayerController::AFEPlayerController()
{
InputBuffer = CreateDefaultSubobject<UFEInputBufferComponent>(TEXT("InputBuffer"));
}
void AFEPlayerController::SendInputsToRemote() const
{
}
void AFEPlayerController::SetupInputComponent()
{
Super::SetupInputComponent();
}

View File

@ -0,0 +1,40 @@
// Unreal Fighting Engine by Kevin Poretti
#pragma once
// UE includes
#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "FEPlayerController.generated.h"
/**
* A class that collects player inputs, stores them in an input buffer, and sends a rolling window of
* unacknowledged inputs to a remote client or server for processing.
*/
UCLASS()
class UNREALFIGHTINGENGINE_API AFEPlayerController : public APlayerController
{
GENERATED_BODY()
public:
AFEPlayerController();
/**
* Sends all unacknowledged inputs to the remote
*/
void SendInputsToRemote() const;
// APlayerController interface
virtual void SetupInputComponent() override;
// End of APlayerController interface
protected:
/** Input Buffer component */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "UFE|Input", meta = (AllowPrivateAccess = "true"))
UFEInputBufferComponent* InputBuffer;
int32 Inputs;
TArray<int32> UnacknowledgedInputs;
};

View File

@ -5,13 +5,13 @@
// FE includes
#include "FEStateMachineComponent.h"
void UFEState::InitActorInfo(AActor* InOwner, AActor* InAvatar)
{
Owner = InOwner;
Avatar = InAvatar;
}
void UFEState::Enter()
{
TicksInState = 0;
@ -19,16 +19,18 @@ void UFEState::Enter()
OnEnter();
}
void UFEState::Exit()
{
OnExit();
}
void UFEState::FixedTick(float OneFrame)
void UFEState::Update(float OneFrame)
{
TicksInState++;
OnFixedTick(OneFrame);
OnUpdate(OneFrame);
}
@ -42,10 +44,11 @@ void UFEState::OnExit_Implementation()
}
void UFEState::OnFixedTick_Implementation(float OneFrame)
void UFEState::OnUpdate_Implementation(float OneFrame)
{
}
UWorld* UFEState::GetWorld() const
{
UFEStateMachineComponent* SMC = Cast<UFEStateMachineComponent>(GetOuter());
@ -55,4 +58,4 @@ UWorld* UFEState::GetWorld() const
}
return nullptr;
}
}

View File

@ -61,7 +61,7 @@ public:
*
* @param OneFrame the time that elapses during one fixed tick
*/
void FixedTick(float OneFrame);
void Update(float OneFrame);
/**
* Blueprint hook that is called whenever this state is transitioned into
@ -81,7 +81,7 @@ public:
* @param OneFrame the time that elapses during one fixed tick
*/
UFUNCTION(BlueprintNativeEvent, Category="UFE|State|Events")
void OnFixedTick(float OneFrame);
void OnUpdate(float OneFrame);
// UObject interface
virtual UWorld* GetWorld() const override;

View File

@ -128,7 +128,7 @@ void UFEStateMachineComponent::FixedTick(float OneFrame)
check(CurrentState);
// Tick current state
CurrentState->FixedTick(OneFrame);
CurrentState->Update(OneFrame);
// Debug
}

View File

@ -18,7 +18,7 @@
* This component also calls the appropriate state logic when a state is changed or the component ticks.
*/
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class UNREALFIGHTINGENGINE_API UFEStateMachineComponent : public UActorComponent, public IIFESystemInterface
class UNREALFIGHTINGENGINE_API UFEStateMachineComponent : public UActorComponent, public IFESystemInterface
{
GENERATED_BODY()
@ -74,9 +74,9 @@ public:
UFUNCTION(BlueprintPure)
FName GetCurrentStateName() const;
// IIFESystemInterface interface
// IFESystemInterface interface
virtual void FixedTick(float OneFrame) override;
// End of IIFESystemInterface interface
// End of IFESystemInterface interface
protected:
/**