Start of input buffer and player controller
This commit is contained in:
parent
3090798d20
commit
ecd8b1ca3c
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
// This class does not need to be modified.
|
// This class does not need to be modified.
|
||||||
UINTERFACE(MinimalAPI)
|
UINTERFACE(MinimalAPI)
|
||||||
class UIFESystemInterface : public UInterface
|
class UFESystemInterface : public UInterface
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
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
|
* This ensures all gameplay effecting objects can be assumed to have certain properties that enable serialization, networking and
|
||||||
* some form of determinism.
|
* some form of determinism.
|
||||||
*/
|
*/
|
||||||
class UNREALFIGHTINGENGINE_API IIFESystemInterface
|
class UNREALFIGHTINGENGINE_API IFESystemInterface
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
// Unreal Fighting Engine by Kevin Poretti
|
||||||
|
|
||||||
|
#include "FEInputBufferComponent.h"
|
||||||
|
|
||||||
|
UFEInputBufferComponent::UFEInputBufferComponent()
|
||||||
|
{
|
||||||
|
PrimaryComponentTick.bCanEverTick = false;
|
||||||
|
}
|
18
Source/UnrealFightingEngine/Input/FEInputBufferComponent.h
Normal file
18
Source/UnrealFightingEngine/Input/FEInputBufferComponent.h
Normal 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();
|
||||||
|
};
|
20
Source/UnrealFightingEngine/Input/FEPlayerController.cpp
Normal file
20
Source/UnrealFightingEngine/Input/FEPlayerController.cpp
Normal 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();
|
||||||
|
}
|
40
Source/UnrealFightingEngine/Input/FEPlayerController.h
Normal file
40
Source/UnrealFightingEngine/Input/FEPlayerController.h
Normal 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;
|
||||||
|
};
|
@ -5,13 +5,13 @@
|
|||||||
// FE includes
|
// FE includes
|
||||||
#include "FEStateMachineComponent.h"
|
#include "FEStateMachineComponent.h"
|
||||||
|
|
||||||
|
|
||||||
void UFEState::InitActorInfo(AActor* InOwner, AActor* InAvatar)
|
void UFEState::InitActorInfo(AActor* InOwner, AActor* InAvatar)
|
||||||
{
|
{
|
||||||
Owner = InOwner;
|
Owner = InOwner;
|
||||||
Avatar = InAvatar;
|
Avatar = InAvatar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void UFEState::Enter()
|
void UFEState::Enter()
|
||||||
{
|
{
|
||||||
TicksInState = 0;
|
TicksInState = 0;
|
||||||
@ -19,16 +19,18 @@ void UFEState::Enter()
|
|||||||
OnEnter();
|
OnEnter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void UFEState::Exit()
|
void UFEState::Exit()
|
||||||
{
|
{
|
||||||
OnExit();
|
OnExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UFEState::FixedTick(float OneFrame)
|
|
||||||
|
void UFEState::Update(float OneFrame)
|
||||||
{
|
{
|
||||||
TicksInState++;
|
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
|
UWorld* UFEState::GetWorld() const
|
||||||
{
|
{
|
||||||
UFEStateMachineComponent* SMC = Cast<UFEStateMachineComponent>(GetOuter());
|
UFEStateMachineComponent* SMC = Cast<UFEStateMachineComponent>(GetOuter());
|
||||||
@ -55,4 +58,4 @@ UWorld* UFEState::GetWorld() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
@ -61,7 +61,7 @@ public:
|
|||||||
*
|
*
|
||||||
* @param OneFrame the time that elapses during one fixed tick
|
* @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
|
* 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
|
* @param OneFrame the time that elapses during one fixed tick
|
||||||
*/
|
*/
|
||||||
UFUNCTION(BlueprintNativeEvent, Category="UFE|State|Events")
|
UFUNCTION(BlueprintNativeEvent, Category="UFE|State|Events")
|
||||||
void OnFixedTick(float OneFrame);
|
void OnUpdate(float OneFrame);
|
||||||
|
|
||||||
// UObject interface
|
// UObject interface
|
||||||
virtual UWorld* GetWorld() const override;
|
virtual UWorld* GetWorld() const override;
|
||||||
|
@ -128,7 +128,7 @@ void UFEStateMachineComponent::FixedTick(float OneFrame)
|
|||||||
check(CurrentState);
|
check(CurrentState);
|
||||||
|
|
||||||
// Tick current state
|
// Tick current state
|
||||||
CurrentState->FixedTick(OneFrame);
|
CurrentState->Update(OneFrame);
|
||||||
|
|
||||||
// Debug
|
// Debug
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
* This component also calls the appropriate state logic when a state is changed or the component ticks.
|
* This component also calls the appropriate state logic when a state is changed or the component ticks.
|
||||||
*/
|
*/
|
||||||
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
|
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
|
||||||
class UNREALFIGHTINGENGINE_API UFEStateMachineComponent : public UActorComponent, public IIFESystemInterface
|
class UNREALFIGHTINGENGINE_API UFEStateMachineComponent : public UActorComponent, public IFESystemInterface
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
@ -74,9 +74,9 @@ public:
|
|||||||
UFUNCTION(BlueprintPure)
|
UFUNCTION(BlueprintPure)
|
||||||
FName GetCurrentStateName() const;
|
FName GetCurrentStateName() const;
|
||||||
|
|
||||||
// IIFESystemInterface interface
|
// IFESystemInterface interface
|
||||||
virtual void FixedTick(float OneFrame) override;
|
virtual void FixedTick(float OneFrame) override;
|
||||||
// End of IIFESystemInterface interface
|
// End of IFESystemInterface interface
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user