Call init when state is created by state machine and pass it state context
This commit is contained in:
parent
08d52a913f
commit
93ca460c8a
@ -10,9 +10,9 @@
|
|||||||
// UE includes
|
// UE includes
|
||||||
#include "Components/SkeletalMeshComponent.h"
|
#include "Components/SkeletalMeshComponent.h"
|
||||||
|
|
||||||
void UFFState::Init()
|
void UFFState::Init(const FFFStateContext& InStateContext)
|
||||||
{
|
{
|
||||||
OnInit();
|
OnInit(InStateContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UFFState::CanTransition(const FFFStateContext& InStateContext)
|
bool UFFState::CanTransition(const FFFStateContext& InStateContext)
|
||||||
@ -153,7 +153,7 @@ void UFFState::RegisterInputHandler(const FFFInputSequence& InRequiredSequence,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void UFFState::OnInit_Implementation()
|
void UFFState::OnInit_Implementation(const FFFStateContext& InStateContext)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,13 +164,6 @@ bool UFFState::OnCanTransition_Implementation(const FFFStateContext& InStateCont
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void UFFState::PostInitProperties()
|
|
||||||
{
|
|
||||||
UObject::PostInitProperties();
|
|
||||||
|
|
||||||
Init();
|
|
||||||
}
|
|
||||||
|
|
||||||
UWorld* UFFState::GetWorld() const
|
UWorld* UFFState::GetWorld() const
|
||||||
{
|
{
|
||||||
UFFStateMachineComponent* SMC = Cast<UFFStateMachineComponent>(GetOuter());
|
UFFStateMachineComponent* SMC = Cast<UFFStateMachineComponent>(GetOuter());
|
||||||
|
@ -76,7 +76,7 @@ public:
|
|||||||
* How long this state will be active before finishing if this state is not cancelled out of
|
* How long this state will be active before finishing if this state is not cancelled out of
|
||||||
* by other means.
|
* by other means.
|
||||||
*/
|
*/
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="UFF State Properties")
|
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category="UFF State Properties")
|
||||||
int64 StateDuration;
|
int64 StateDuration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -123,7 +123,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Called when state is first created.
|
* Called when state is first created.
|
||||||
*/
|
*/
|
||||||
virtual void Init();
|
virtual void Init(const FFFStateContext& InStateContext);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if Avatar's is in the correct stance AND
|
* Returns true if Avatar's is in the correct stance AND
|
||||||
@ -189,7 +189,7 @@ public:
|
|||||||
const FFFInputSequence& InRequiredSequence, FFFInputEventDelegate InDelegate);
|
const FFFInputSequence& InRequiredSequence, FFFInputEventDelegate InDelegate);
|
||||||
|
|
||||||
UFUNCTION(BlueprintNativeEvent, Category="UFF|State|Events")
|
UFUNCTION(BlueprintNativeEvent, Category="UFF|State|Events")
|
||||||
void OnInit();
|
void OnInit(const FFFStateContext& InStateContext);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Blueprint hook for overriding the CanTransition logic
|
* Blueprint hook for overriding the CanTransition logic
|
||||||
@ -232,8 +232,6 @@ public:
|
|||||||
void OnBlock(const FFFStateContext& InStateContext);
|
void OnBlock(const FFFStateContext& InStateContext);
|
||||||
|
|
||||||
// UObject interface
|
// UObject interface
|
||||||
virtual void PostInitProperties() override;
|
|
||||||
|
|
||||||
virtual UWorld* GetWorld() const override;
|
virtual UWorld* GetWorld() const override;
|
||||||
// End of UObject interface
|
// End of UObject interface
|
||||||
};
|
};
|
||||||
|
@ -56,6 +56,7 @@ UFFState* UFFStateMachineComponent::AddState(TSubclassOf<UFFState> StateClassToA
|
|||||||
if(!FindStateWithName(TempState->Name))
|
if(!FindStateWithName(TempState->Name))
|
||||||
{
|
{
|
||||||
States.Add(TempState);
|
States.Add(TempState);
|
||||||
|
TempState->Init(GetCurrentStateContext());
|
||||||
return TempState;
|
return TempState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user