Updated StatusSystem to Bind Player/Enemy Turn Events
This commit is contained in:
parent
06deee7b0b
commit
6227b4952c
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "StatusSystem.h"
|
#include "StatusSystem.h"
|
||||||
#include "Kismet/GameplayStatics.h"
|
#include "Kismet/GameplayStatics.h"
|
||||||
|
#include "TurnBaseCombatV2.h"
|
||||||
#include "Components/TextBlock.h"
|
#include "Components/TextBlock.h"
|
||||||
|
|
||||||
void UStatusEffect::Invoke(AActor* Character, float TimeOfInit)
|
void UStatusEffect::Invoke(AActor* Character, float TimeOfInit)
|
||||||
@ -21,16 +22,23 @@ void UStatusEffect::OnExpiry(AActor* Character)
|
|||||||
StatusSystem->RemoveStatusEffect(this);
|
StatusSystem->RemoveStatusEffect(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UStatusEffect::OnPlayerTurn(AActor* Character)
|
void UStatusEffect::OnPlayerTurn(AActor* Character, AActor* Enemy)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UStatusEffect::OnEnemyTurn(AActor* Character)
|
void UStatusEffect::OnEnemyTurn(AActor* Enemy, AActor* Character)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UStatusEffect::OnStatusEffectAdd()
|
||||||
|
{
|
||||||
|
ATurnBaseCombatV2* CombatSystem = Cast<ATurnBaseCombatV2>(GetWorld()->GetGameState());
|
||||||
|
CombatSystem->OnPlayerTurn.AddUObject(this, &UStatusEffect::OnPlayerTurn);
|
||||||
|
CombatSystem->OnEnemyTurn.AddUObject(this, &UStatusEffect::OnEnemyTurn);
|
||||||
|
}
|
||||||
|
|
||||||
void UStatusEffect::CheckForExpiry(const float TimeOfExpiry, AActor* Character)
|
void UStatusEffect::CheckForExpiry(const float TimeOfExpiry, AActor* Character)
|
||||||
{
|
{
|
||||||
if (TimeOfExpiry <= UGameplayStatics::GetRealTimeSeconds(GetWorld())) OnExpiry(Character);
|
if (TimeOfExpiry <= UGameplayStatics::GetRealTimeSeconds(GetWorld())) OnExpiry(Character);
|
||||||
|
@ -26,15 +26,16 @@ public:
|
|||||||
|
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
virtual void Invoke(AActor* Character, float TimeOfExpiry);
|
virtual void Invoke(AActor* Character, float TimeOfExpiry);
|
||||||
|
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
virtual void OnExpiry(AActor* Character);
|
virtual void OnExpiry(AActor* Character);
|
||||||
|
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
virtual void OnPlayerTurn(AActor* Character);
|
virtual void OnPlayerTurn(AActor* Character, AActor* Enemy);
|
||||||
|
UFUNCTION()
|
||||||
|
virtual void OnEnemyTurn(AActor* Enemy, AActor* Character);
|
||||||
|
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
virtual void OnEnemyTurn(AActor* Character);
|
virtual void OnStatusEffectAdd();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
|
@ -48,6 +48,7 @@ void UStatusSystem::AddStatusEffect(UStatusEffect* StatusEffect, const float Dur
|
|||||||
UImage* StatusIconImage = Cast<UImage>(NewStatusEffect.StatusIcon->GetWidgetFromName(TEXT("StatusIconImage")));
|
UImage* StatusIconImage = Cast<UImage>(NewStatusEffect.StatusIcon->GetWidgetFromName(TEXT("StatusIconImage")));
|
||||||
StatusIconImage->SetBrushFromTexture(StatusEffect->Icon);
|
StatusIconImage->SetBrushFromTexture(StatusEffect->Icon);
|
||||||
StatusIconsBox->AddChild(NewStatusEffect.StatusIcon);
|
StatusIconsBox->AddChild(NewStatusEffect.StatusIcon);
|
||||||
|
NewStatusEffect.StatusEffect->OnStatusEffectAdd();
|
||||||
if (Invoke) NewStatusEffect.StatusEffect->Invoke(GetOwner(), NewStatusEffect.TimeTillExpiry);
|
if (Invoke) NewStatusEffect.StatusEffect->Invoke(GetOwner(), NewStatusEffect.TimeTillExpiry);
|
||||||
|
|
||||||
ActiveStatusEffects.Add(NewStatusEffect);
|
ActiveStatusEffects.Add(NewStatusEffect);
|
||||||
|
Loading…
Reference in New Issue
Block a user