- Combo manager connects to this subsystem entirely on its own when its owner is the player character.
60 lines
3.9 KiB
C++
60 lines
3.9 KiB
C++
// ©2022 Batty Bovine Productions, LLC. All Rights Reserved.
|
||
|
||
#pragma once
|
||
|
||
#include "CoreMinimal.h"
|
||
#include "EnhancedInputSubsystems.h"
|
||
|
||
#include "InputBufferLocalPlayerSubsystem.generated.h"
|
||
|
||
DECLARE_LOG_CATEGORY_EXTERN(LogInputBufferLocalPlayerSubsystem, Log, All);
|
||
|
||
DECLARE_DELEGATE_OneParam(FNewComboInput, const class UComboInputAsset*);
|
||
|
||
|
||
/**
|
||
* Subsystem that handles input buffering, and passing the resulting actions to the player's ComboManagerComponent.
|
||
*/
|
||
UCLASS()
|
||
class COMBOINPUT_API UInputBufferLocalPlayerSubsystem : public UEnhancedInputLocalPlayerSubsystem
|
||
{
|
||
GENERATED_BODY()
|
||
|
||
public:
|
||
virtual void Initialize(FSubsystemCollectionBase &Collection) override;
|
||
|
||
void AttachComboManager(class UComboManagerComponent *ComboManager, class UEnhancedInputComponent *InputComponent);
|
||
|
||
UFUNCTION(BlueprintCallable)
|
||
void UnlockComboInput(const class UComboInputAsset *Unlocked);
|
||
|
||
private:
|
||
void AddActionToBuffer(const FInputActionValue &Value, const class UInputAction *Action);
|
||
void ExpireAction(const FInputActionValue &Value, const class UInputAction *Action);
|
||
|
||
void ActivateComboInput(const class UComboInputAsset *ComboInput);
|
||
|
||
void ClearMultiPresses();
|
||
void ExpireBufferedActions();
|
||
|
||
TObjectPtr<class UEnhancedInputComponent> EnhancedInputComponent;
|
||
|
||
// Currently active combo input.
|
||
TObjectPtr<const class UComboInputAsset> InputBufferActive;
|
||
|
||
// Combo input held until the current input has expired.
|
||
TObjectPtr<const class UComboInputAsset> InputBufferHold;
|
||
|
||
// Set of currently locked actions; will not be activated until an unlock signal is received.
|
||
TSet<TObjectPtr<const class UComboInputAsset>> LockedComboInputs;
|
||
|
||
TSet<const class UInputAction*> MostRecentActions;
|
||
TSet<const class UInputAction*> ExpiringActions;
|
||
|
||
FNewComboInput NewComboInput;
|
||
|
||
FTimerHandle MultiPressTimerHandle;
|
||
FTimerHandle InputReleaseExpirationTimerHandle;
|
||
FTimerHandle ForceUnlockTimerHandle;
|
||
};
|