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 "Kismet/GameplayStatics.h"
|
||||
#include "TurnBaseCombatV2.h"
|
||||
#include "Components/TextBlock.h"
|
||||
|
||||
void UStatusEffect::Invoke(AActor* Character, float TimeOfInit)
|
||||
@ -21,16 +22,23 @@ void UStatusEffect::OnExpiry(AActor* Character)
|
||||
StatusSystem->RemoveStatusEffect(this);
|
||||
}
|
||||
|
||||
void UStatusEffect::OnPlayerTurn(AActor* Character)
|
||||
void UStatusEffect::OnPlayerTurn(AActor* Character, AActor* Enemy)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void UStatusEffect::OnEnemyTurn(AActor* Character)
|
||||
void UStatusEffect::OnEnemyTurn(AActor* Enemy, AActor* Character)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (TimeOfExpiry <= UGameplayStatics::GetRealTimeSeconds(GetWorld())) OnExpiry(Character);
|
||||
|
@ -26,15 +26,16 @@ public:
|
||||
|
||||
UFUNCTION()
|
||||
virtual void Invoke(AActor* Character, float TimeOfExpiry);
|
||||
|
||||
UFUNCTION()
|
||||
virtual void OnExpiry(AActor* Character);
|
||||
|
||||
UFUNCTION()
|
||||
virtual void OnPlayerTurn(AActor* Character);
|
||||
virtual void OnPlayerTurn(AActor* Character, AActor* Enemy);
|
||||
UFUNCTION()
|
||||
virtual void OnEnemyTurn(AActor* Enemy, AActor* Character);
|
||||
|
||||
UFUNCTION()
|
||||
virtual void OnEnemyTurn(AActor* Character);
|
||||
virtual void OnStatusEffectAdd();
|
||||
|
||||
protected:
|
||||
UPROPERTY()
|
||||
|
@ -48,6 +48,7 @@ void UStatusSystem::AddStatusEffect(UStatusEffect* StatusEffect, const float Dur
|
||||
UImage* StatusIconImage = Cast<UImage>(NewStatusEffect.StatusIcon->GetWidgetFromName(TEXT("StatusIconImage")));
|
||||
StatusIconImage->SetBrushFromTexture(StatusEffect->Icon);
|
||||
StatusIconsBox->AddChild(NewStatusEffect.StatusIcon);
|
||||
NewStatusEffect.StatusEffect->OnStatusEffectAdd();
|
||||
if (Invoke) NewStatusEffect.StatusEffect->Invoke(GetOwner(), NewStatusEffect.TimeTillExpiry);
|
||||
|
||||
ActiveStatusEffects.Add(NewStatusEffect);
|
||||
|
Loading…
Reference in New Issue
Block a user