Compare commits
No commits in common. "ec6daa06fb67fdbad2eb2d62de1908216a96156e" and "e38379586c13a5689b421c222f219d25c08c8203" have entirely different histories.
ec6daa06fb
...
e38379586c
@ -6,17 +6,3 @@ UFFInputBufferComponent::UFFInputBufferComponent()
|
||||
{
|
||||
PrimaryComponentTick.bCanEverTick = false;
|
||||
}
|
||||
|
||||
void UFFInputBufferComponent::Initialize(int32 BufferSize)
|
||||
{
|
||||
Buffer.Reserve(BufferSize);
|
||||
}
|
||||
|
||||
void UFFInputBufferComponent::AddInput(const FFFInputState& InputState)
|
||||
{
|
||||
}
|
||||
|
||||
bool UFFInputBufferComponent::CheckInputSequence(const FFFInputSequence& InputSequence)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -5,19 +5,9 @@
|
||||
// UE includes
|
||||
#include "CoreMinimal.h"
|
||||
#include "Components/ActorComponent.h"
|
||||
#include "Containers/RingBuffer.h"
|
||||
|
||||
#include "FFInputBufferComponent.generated.h"
|
||||
|
||||
struct FFFInputState;
|
||||
|
||||
USTRUCT()
|
||||
struct FFFInputSequence
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
};
|
||||
|
||||
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
|
||||
class UNREALFIGHTINGFRAMEWORK_API UFFInputBufferComponent : public UActorComponent
|
||||
{
|
||||
@ -25,14 +15,4 @@ class UNREALFIGHTINGFRAMEWORK_API UFFInputBufferComponent : public UActorCompone
|
||||
|
||||
public:
|
||||
UFFInputBufferComponent();
|
||||
|
||||
void Initialize(int32 BufferSize = 120);
|
||||
|
||||
void AddInput(const FFFInputState& InputState);
|
||||
|
||||
bool CheckInputSequence(const FFFInputSequence& InputSequence);
|
||||
|
||||
protected:
|
||||
/** The underlying buffer data structure for holding past input states */
|
||||
TRingBuffer<FFFInputState> Buffer;
|
||||
};
|
||||
|
@ -5,41 +5,16 @@
|
||||
// FF includes
|
||||
#include "FFInputBufferComponent.h"
|
||||
|
||||
// UE includes
|
||||
#include "EnhancedInputSubsystems.h"
|
||||
|
||||
AFFPlayerController::AFFPlayerController()
|
||||
{
|
||||
InputBuffer = CreateDefaultSubobject<UFFInputBufferComponent>(TEXT("InputBuffer"));
|
||||
}
|
||||
|
||||
|
||||
void AFFPlayerController::SendInputsToRemote() const
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void AFFPlayerController::FixedTick(float OneFrame)
|
||||
{
|
||||
UnacknowledgedInputs.Add(CurrInput);
|
||||
InputBuffer->AddInput(CurrInput);
|
||||
|
||||
SendInputsToRemote();
|
||||
}
|
||||
|
||||
|
||||
void AFFPlayerController::SetupInputComponent()
|
||||
{
|
||||
Super::SetupInputComponent();
|
||||
|
||||
if (ULocalPlayer* LocalPlayer = Cast<ULocalPlayer>(Player))
|
||||
{
|
||||
if (UEnhancedInputLocalPlayerSubsystem* InputSystem = LocalPlayer->GetSubsystem<UEnhancedInputLocalPlayerSubsystem>())
|
||||
{
|
||||
if (!DefaultInputMapping.IsNull())
|
||||
{
|
||||
InputSystem->AddMappingContext(DefaultInputMapping.LoadSynchronous(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,37 +2,18 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
// FF includes
|
||||
#include "FFInputBufferComponent.h"
|
||||
#include "UnrealFightingFramework/IFFSystemInterface.h"
|
||||
|
||||
// UE includes
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/PlayerController.h"
|
||||
#include "InputMappingContext.h"
|
||||
#include "Containers/RingBuffer.h"
|
||||
|
||||
#include "FFPlayerController.generated.h"
|
||||
|
||||
/**
|
||||
* Struct representing the state of a player's inputs for one frame
|
||||
*/
|
||||
USTRUCT()
|
||||
struct FFFInputState
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
FVector2D MoveAxes;
|
||||
FVector2D LookAxes;
|
||||
int32 Buttons;
|
||||
};
|
||||
|
||||
/**
|
||||
* 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 UNREALFIGHTINGFRAMEWORK_API AFFPlayerController : public APlayerController, public IFFSystemInterface
|
||||
class UNREALFIGHTINGFRAMEWORK_API AFFPlayerController : public APlayerController
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
@ -42,11 +23,7 @@ public:
|
||||
/**
|
||||
* Sends all unacknowledged inputs to the remote
|
||||
*/
|
||||
virtual void SendInputsToRemote() const;
|
||||
|
||||
// IFFSystemInterface interface
|
||||
virtual void FixedTick(float OneFrame) override;
|
||||
// End of IFFSystemInterface
|
||||
void SendInputsToRemote() const;
|
||||
|
||||
// APlayerController interface
|
||||
virtual void SetupInputComponent() override;
|
||||
@ -55,22 +32,13 @@ public:
|
||||
protected:
|
||||
/** MappingContext */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "UFF|Input", meta = (AllowPrivateAccess = "true"))
|
||||
TSoftObjectPtr<UInputMappingContext> DefaultInputMapping;
|
||||
class UInputMappingContext* DefaultMappingContext;
|
||||
|
||||
/** Input Buffer component */
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "UFF|Input", meta = (AllowPrivateAccess = "true"))
|
||||
UFFInputBufferComponent* InputBuffer;
|
||||
|
||||
/** Current state of the player's inputs */
|
||||
FFFInputState CurrInput;
|
||||
int32 Inputs;
|
||||
|
||||
/**
|
||||
* Rolling window of the player's past inputs that have yet to be
|
||||
* acknowledged and simulated by the remote machine
|
||||
*
|
||||
* This ring buffer should be initialized to be the size of the past X frames
|
||||
* you want the remote machine to re-simulate, where X is the oldest input you want to
|
||||
* allow to be re-simulated.
|
||||
*/
|
||||
TRingBuffer<FFFInputState> UnacknowledgedInputs;
|
||||
TArray<int32> UnacknowledgedInputs;
|
||||
};
|
||||
|
@ -10,14 +10,14 @@ public class UnrealFightingFramework : ModuleRules
|
||||
|
||||
PublicIncludePaths.AddRange(
|
||||
new string[] {
|
||||
"UnrealFightingFramework"
|
||||
// ... add public include paths required here ...
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PrivateIncludePaths.AddRange(
|
||||
new string[] {
|
||||
"UnrealFightingFramework"
|
||||
// ... add other private include paths required here ...
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -1,11 +0,0 @@
|
||||
// Unreal Fighting Framework by Kevin Poretti
|
||||
|
||||
#include "Utils/TCircleBuffer.h"
|
||||
|
||||
TCircleBuffer::TCircleBuffer()
|
||||
{
|
||||
}
|
||||
|
||||
TCircleBuffer::~TCircleBuffer()
|
||||
{
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
// Unreal Fighting Framework by Kevin Poretti
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class UNREALFIGHTINGFRAMEWORK_API TCircleBuffer
|
||||
{
|
||||
public:
|
||||
TCircleBuffer();
|
||||
~TCircleBuffer();
|
||||
};
|
Loading…
Reference in New Issue
Block a user