ComboInput/Source/ComboInput/Public/InputBufferLocalPlayerSubsystem.h
Jamie Greunbaum cd4708449f - Buffered inputs are no longer handled by a component on the PlayerController, but by a LocalPlayerSubsystem instead.
- Combo manager connects to this subsystem entirely on its own when its owner is the player character.
2023-09-10 01:47:21 -04:00

60 lines
3.9 KiB
C++
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// ©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;
};