Add callback for when movement mode on character is changed
This commit is contained in:
parent
93ca460c8a
commit
bd195c7ee8
@ -126,6 +126,19 @@ void UFFState::Landed(const FHitResult& Hit, const FFFStateContext& InStateConte
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UFFState::MovementModeChanged(EMovementMode PrevMovementMode, uint8 PreviousCustomMode,
|
||||||
|
EMovementMode NewMovementMode, uint8 NewCustomMode, const FFFStateContext& InStateContext)
|
||||||
|
{
|
||||||
|
OnMovementModeChanged(PrevMovementMode, PreviousCustomMode,
|
||||||
|
NewMovementMode, NewCustomMode, InStateContext);
|
||||||
|
|
||||||
|
if(NewMovementMode != ReqMovementMode || ((ReqMovementMode == MOVE_Custom) && NewCustomMode != RequiredCustomMode))
|
||||||
|
{
|
||||||
|
Finish(InStateContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void UFFState::Hit(const FFFStateContext& InStateContext)
|
void UFFState::Hit(const FFFStateContext& InStateContext)
|
||||||
{
|
{
|
||||||
OnHit(InStateContext);
|
OnHit(InStateContext);
|
||||||
|
@ -108,6 +108,12 @@ public:
|
|||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="UFF State Properties")
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="UFF State Properties")
|
||||||
bool bCanTransitionToSelf = false;
|
bool bCanTransitionToSelf = false;
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="UFF State Properties")
|
||||||
|
TEnumAsByte<EMovementMode> ReqMovementMode;
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="UFF State Properties")
|
||||||
|
uint8 RequiredCustomMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Animation to begin playing when this state is entered
|
* Animation to begin playing when this state is entered
|
||||||
*/
|
*/
|
||||||
@ -159,6 +165,10 @@ public:
|
|||||||
// TODO: document
|
// TODO: document
|
||||||
virtual void Landed(const FHitResult& Hit, const FFFStateContext& InStateContext);
|
virtual void Landed(const FHitResult& Hit, const FFFStateContext& InStateContext);
|
||||||
|
|
||||||
|
// TODO: document
|
||||||
|
virtual void MovementModeChanged(EMovementMode PrevMovementMode, uint8 PreviousCustomMode,
|
||||||
|
EMovementMode NewMovementMode, uint8 NewCustomMode, const FFFStateContext& InStateContext);
|
||||||
|
|
||||||
// TODO: document
|
// TODO: document
|
||||||
// TODO: pass in hitdata struct as well
|
// TODO: pass in hitdata struct as well
|
||||||
virtual void Hit(const FFFStateContext& InStateContext);
|
virtual void Hit(const FFFStateContext& InStateContext);
|
||||||
@ -188,6 +198,7 @@ public:
|
|||||||
virtual void RegisterInputHandler(
|
virtual void RegisterInputHandler(
|
||||||
const FFFInputSequence& InRequiredSequence, FFFInputEventDelegate InDelegate);
|
const FFFInputSequence& InRequiredSequence, FFFInputEventDelegate InDelegate);
|
||||||
|
|
||||||
|
// TODO: document
|
||||||
UFUNCTION(BlueprintNativeEvent, Category="UFF|State|Events")
|
UFUNCTION(BlueprintNativeEvent, Category="UFF|State|Events")
|
||||||
void OnInit(const FFFStateContext& InStateContext);
|
void OnInit(const FFFStateContext& InStateContext);
|
||||||
|
|
||||||
@ -221,6 +232,11 @@ public:
|
|||||||
UFUNCTION(BlueprintImplementableEvent, Category="UFF|State|Events")
|
UFUNCTION(BlueprintImplementableEvent, Category="UFF|State|Events")
|
||||||
void OnLanded(const FHitResult& Hit, const FFFStateContext& InStateContext);
|
void OnLanded(const FHitResult& Hit, const FFFStateContext& InStateContext);
|
||||||
|
|
||||||
|
// TODO: document
|
||||||
|
UFUNCTION(BlueprintImplementableEvent, Category="UFF|State|Events")
|
||||||
|
void OnMovementModeChanged(EMovementMode PrevMovementMode, uint8 PreviousCustomMode,
|
||||||
|
EMovementMode NewMovementMode, uint8 NewCustomMode, const FFFStateContext& InStateContext);
|
||||||
|
|
||||||
// TODO: document
|
// TODO: document
|
||||||
// TODO: pass in hitdata struct as well
|
// TODO: pass in hitdata struct as well
|
||||||
UFUNCTION(BlueprintImplementableEvent, Category="UFF|State|Events")
|
UFUNCTION(BlueprintImplementableEvent, Category="UFF|State|Events")
|
||||||
|
@ -160,6 +160,25 @@ void UFFStateMachineComponent::Landed(const FHitResult& Hit)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UFFStateMachineComponent::MovementModeChanged(EMovementMode PrevMovementMode, uint8 PreviousCustomMode,
|
||||||
|
EMovementMode NewMovementMode, uint8 NewCustomMode)
|
||||||
|
{
|
||||||
|
// TODO: this check should be valid but isn't right now.
|
||||||
|
// Movement mode changed seems to be called whenever the character is first created but before
|
||||||
|
// any states are created and entered.
|
||||||
|
// For now just check if CurrentState is null and don't call the MovementModeChanged callback if
|
||||||
|
// so
|
||||||
|
//check(CurrentState)
|
||||||
|
if(!CurrentState)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CurrentState->MovementModeChanged(PrevMovementMode, PreviousCustomMode,
|
||||||
|
NewMovementMode, NewCustomMode, GetCurrentStateContext());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void UFFStateMachineComponent::FixedTick(float OneFrame)
|
void UFFStateMachineComponent::FixedTick(float OneFrame)
|
||||||
{
|
{
|
||||||
// CurrentState should never be null
|
// CurrentState should never be null
|
||||||
|
@ -104,6 +104,9 @@ public:
|
|||||||
// Events
|
// Events
|
||||||
virtual void Landed(const FHitResult& Hit);
|
virtual void Landed(const FHitResult& Hit);
|
||||||
|
|
||||||
|
virtual void MovementModeChanged(EMovementMode PrevMovementMode, uint8 PreviousCustomMode,
|
||||||
|
EMovementMode NewMovementMode, uint8 NewCustomMode);
|
||||||
|
|
||||||
// IFFSystemInterface interface
|
// IFFSystemInterface interface
|
||||||
virtual void FixedTick(float OneFrame) override;
|
virtual void FixedTick(float OneFrame) override;
|
||||||
// End of IFFSystemInterface interface
|
// End of IFFSystemInterface interface
|
||||||
|
Loading…
Reference in New Issue
Block a user