Interface for modifying raw inputs
This commit is contained in:
		
							parent
							
								
									eb735db17a
								
							
						
					
					
						commit
						a85a9a7005
					
				| @ -12,7 +12,7 @@ void UFFInputBufferComponent::AddInput(const FFFInputState& InputState) | |||||||
| 	InputBuffer.ForcePush(InputState); | 	InputBuffer.ForcePush(InputState); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool UFFInputBufferComponent::CheckInputSequence(const FFFInputSequence& InputSequence) | bool UFFInputBufferComponent::CheckInputSequence(const FFFInputCondition& InputCondition) | ||||||
| { | { | ||||||
|     for(int InpIdx = 0; InpIdx < InputBuffer.Num(); InpIdx++) |     for(int InpIdx = 0; InpIdx < InputBuffer.Num(); InpIdx++) | ||||||
|     { |     { | ||||||
|  | |||||||
| @ -21,14 +21,21 @@ struct FFFInputState | |||||||
| 
 | 
 | ||||||
| 	FVector2D	MoveAxes; | 	FVector2D	MoveAxes; | ||||||
| 	FVector2D	LookAxes; | 	FVector2D	LookAxes; | ||||||
|  | 
 | ||||||
|  | 	UPROPERTY(EditAnywhere, Meta = (Bitmask)) | ||||||
| 	int32		Buttons; | 	int32		Buttons; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| USTRUCT() | USTRUCT(BlueprintType) | ||||||
| struct FFFInputSequence | struct FFFInputCondition | ||||||
| { | { | ||||||
|     GENERATED_BODY() |     GENERATED_BODY() | ||||||
| 
 | 
 | ||||||
|  |     UPROPERTY(EditAnywhere) | ||||||
|  | 	TArray<FFFInputState> Sequence; | ||||||
|  | 
 | ||||||
|  | 	UPROPERTY(EditAnywhere) | ||||||
|  | 	int32 Lenience; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) | UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) | ||||||
| @ -41,7 +48,7 @@ public: | |||||||
| 
 | 
 | ||||||
| 	void AddInput(const FFFInputState& InputState); | 	void AddInput(const FFFInputState& InputState); | ||||||
| 
 | 
 | ||||||
| 	bool CheckInputSequence(const FFFInputSequence& InputSequence); | 	bool CheckInputSequence(const FFFInputCondition& InputCondition); | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	/** The underlying buffer data structure for holding past input states */ | 	/** The underlying buffer data structure for holding past input states */ | ||||||
|  | |||||||
| @ -19,10 +19,16 @@ void AFFPlayerController::SendInputsToRemote() const | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | void AFFPlayerController::ModifyRawInput() | ||||||
|  | { | ||||||
|  |     ModifiedInput = RawInput; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| void AFFPlayerController::FixedTick(float OneFrame) | void AFFPlayerController::FixedTick(float OneFrame) | ||||||
| { | { | ||||||
|     //UnacknowledgedInputs.Push(CurrInput);
 |     //UnacknowledgedInputs.Push(RawInput);
 | ||||||
|     InputBuffer->AddInput(CurrInput); |     InputBuffer->AddInput(ModifiedInput); | ||||||
| 
 | 
 | ||||||
|     //SendInputsToRemote();
 |     //SendInputsToRemote();
 | ||||||
| } | } | ||||||
|  | |||||||
| @ -31,7 +31,20 @@ public: | |||||||
| 	 */ | 	 */ | ||||||
| 	virtual void SendInputsToRemote() const; | 	virtual void SendInputsToRemote() const; | ||||||
| 
 | 
 | ||||||
| 	virtual FFFInputState GetCurrInput() { return CurrInput; }; |     /**
 | ||||||
|  |      * @brief Gets the current input after cleaning/modifying the raw input state | ||||||
|  |      * @return the current input | ||||||
|  |      */ | ||||||
|  |     virtual FFFInputState GetModifiedInput() const { return ModifiedInput; }; | ||||||
|  | 
 | ||||||
|  |     /**
 | ||||||
|  |      * @brief Function called before inputs are passed to the game logic to update the game state. | ||||||
|  |      * This is a chance for the application to mutate inputs before the game uses them to update game state. | ||||||
|  |      * Examples would include treating opposite directional inputs being held cancelling each other out or setting | ||||||
|  |      * a "neutral input" flag when no directional inputs are being held. | ||||||
|  |      * For stick/axis values this can be clamping those values or normalizing the Move and Look direction vectors. | ||||||
|  |      */ | ||||||
|  |     virtual void ModifyRawInput(); | ||||||
| 
 | 
 | ||||||
| 	// IFFSystemInterface interface
 | 	// IFFSystemInterface interface
 | ||||||
| 	virtual void FixedTick(float OneFrame) override; | 	virtual void FixedTick(float OneFrame) override; | ||||||
| @ -51,7 +64,10 @@ protected: | |||||||
| 	UFFInputBufferComponent* InputBuffer; | 	UFFInputBufferComponent* InputBuffer; | ||||||
| 
 | 
 | ||||||
| 	/** Current state of the player's inputs */ | 	/** Current state of the player's inputs */ | ||||||
| 	FFFInputState CurrInput; | 	FFFInputState RawInput; | ||||||
|  | 
 | ||||||
|  | 	/** Current state of the player's inputs after performing cleaning and modifications */ | ||||||
|  | 	FFFInputState ModifiedInput; | ||||||
| 
 | 
 | ||||||
| 	/**
 | 	/**
 | ||||||
| 	 *	Rolling window of the player's past inputs that have yet to be | 	 *	Rolling window of the player's past inputs that have yet to be | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user