From 31a6a5d98e53d012a8752c563289db7b00b5e8bf Mon Sep 17 00:00:00 2001 From: PHILIP White Date: Mon, 20 Feb 2023 17:58:32 +0000 Subject: [PATCH] Added StatusEffect Stub for Multiple Status Effects --- .../Combat_UI/BP_TurnBaseCombatV2.uasset | 4 +- .../TurnBasedCombatV2/HoldToInitCombat.cpp | 5 --- .../TurnBasedCombatV2/StatusEffect.cpp | 11 +++++ .../TurnBasedCombatV2/StatusEffect.h | 27 +++++++++++ .../TurnBasedCombatV2/StatusSystem.cpp | 41 +++++++++++++++++ .../TurnBasedCombatV2/StatusSystem.h | 45 +++++++++++++++++++ the_twilight_abyss.uproject | 3 +- 7 files changed, 128 insertions(+), 8 deletions(-) create mode 100644 Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffect.cpp create mode 100644 Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffect.h create mode 100644 Source/the_twilight_abyss/TurnBasedCombatV2/StatusSystem.cpp create mode 100644 Source/the_twilight_abyss/TurnBasedCombatV2/StatusSystem.h diff --git a/Content/Blueprints/Combat_UI/BP_TurnBaseCombatV2.uasset b/Content/Blueprints/Combat_UI/BP_TurnBaseCombatV2.uasset index fc8c04d..a34d1da 100644 --- a/Content/Blueprints/Combat_UI/BP_TurnBaseCombatV2.uasset +++ b/Content/Blueprints/Combat_UI/BP_TurnBaseCombatV2.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:24c95fe7e7607ae47a17cd32db55c6169323a9bae5fc7cd908e27a75b4ad1a4d -size 19741 +oid sha256:48e4a20b8adf64276d188ae33021a81a3236291342f32f294642a371a00d87c9 +size 19781 diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/HoldToInitCombat.cpp b/Source/the_twilight_abyss/TurnBasedCombatV2/HoldToInitCombat.cpp index 8b2a14f..a4253a2 100644 --- a/Source/the_twilight_abyss/TurnBasedCombatV2/HoldToInitCombat.cpp +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/HoldToInitCombat.cpp @@ -30,9 +30,7 @@ void UHoldToInitCombat::BeginPlay() InitCombatWidget = CreateWidget(GetWorld(), InitCombatWidgetClass); UInputComponent* PlayerInputComponent = GetWorld()->GetFirstPlayerController()->InputComponent; - //Bind Right Mouse Button to the function OnRightClickDown PlayerInputComponent->BindAction("RightClick", IE_Pressed, this, &UHoldToInitCombat::OnRightClickDown); - //Bind Right Mouse Button to the function OnRightClickUp PlayerInputComponent->BindAction("RightClick", IE_Released, this, &UHoldToInitCombat::OnRightClickUp); } @@ -42,7 +40,6 @@ void UHoldToInitCombat::TickComponent(float DeltaTime, ELevelTick TickType, FAct { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); - // //If the player is holding down the right mouse button for 3 seconds, then the player will enter combat mode // if (bRightClickDown && RightClickDownTime < 0.1f) // { // RightClickDownTime += DeltaTime; @@ -73,9 +70,7 @@ void UHoldToInitCombat::OnRightClickDown() if (GunEffect) { - //Get Player Actor const AActor* PlayerActor = GetWorld()->GetFirstPlayerController()->GetPawn(); - //Get Static Mesh Location on the player actor const UStaticMeshComponent* GunComponent = Cast(PlayerActor->GetComponentsByTag(UPrimitiveComponent::StaticClass(), FName("Gun"))[0]); const FVector GunLocationOffset = GunComponent->GetSocketTransform("Muzzle").TransformPosition(FVector(-100, 0, 0)); UNiagaraFunctionLibrary::SpawnSystemAtLocation(GetWorld(), GunEffect, GunLocationOffset, PlayerActor->GetActorRotation()); diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffect.cpp b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffect.cpp new file mode 100644 index 0000000..2b69ad6 --- /dev/null +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffect.cpp @@ -0,0 +1,11 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "StatusEffect.h" + +void UStatusEffect::Invoke(ACharacter* Character) +{ + + + +} diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffect.h b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffect.h new file mode 100644 index 0000000..be3dcae --- /dev/null +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffect.h @@ -0,0 +1,27 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "UObject/NoExportTypes.h" +#include "StatusEffect.generated.h" + +/** + * + */ +UCLASS(Abstract) +class THE_TWILIGHT_ABYSS_API UStatusEffect : public UObject +{ + GENERATED_BODY() + +public: + UPROPERTY() + FString Name; + UPROPERTY() + FString Description; + UPROPERTY() + UStaticMesh* Icon; + + UFUNCTION() + virtual void Invoke(ACharacter* Character); +}; diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/StatusSystem.cpp b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusSystem.cpp new file mode 100644 index 0000000..58f10ab --- /dev/null +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusSystem.cpp @@ -0,0 +1,41 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "StatusSystem.h" +#include + +// Sets default values for this component's properties +UStatusSystem::UStatusSystem() +{ + // Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features + // off to improve performance if you don't need them. + PrimaryComponentTick.bCanEverTick = true; + + // ... +} + + +// Called when the game starts +void UStatusSystem::BeginPlay() +{ + Super::BeginPlay(); + + // ... + +} + + +// Called every frame +void UStatusSystem::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) +{ + Super::TickComponent(DeltaTime, TickType, ThisTickFunction); + + for (FActiveStatusEffect StatusEffect : ActiveStatusEffects) + { + if (StatusEffect.TimeTillExpiry > UGameplayStatics::GetRealTimeSeconds(GetWorld())) + { + //ActiveStatusEffects.RemoveAt(ActiveStatusEffects.Find(StatusEffect)); + } + } +} + diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/StatusSystem.h b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusSystem.h new file mode 100644 index 0000000..a1b65ea --- /dev/null +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusSystem.h @@ -0,0 +1,45 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Components/ActorComponent.h" +#include "StatusEffect.h" +#include "StatusSystem.generated.h" + +USTRUCT() +struct FActiveStatusEffect +{ + GENERATED_BODY() + + UPROPERTY() + float TimeInitiated; + UPROPERTY() + float TimeTillExpiry; + + UPROPERTY() + UStatusEffect* StatusEffect; +}; + +UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) +class THE_TWILIGHT_ABYSS_API UStatusSystem : public UActorComponent +{ + GENERATED_BODY() + +public: + // Sets default values for this component's properties + UStatusSystem(); + + UPROPERTY() + TArray ActiveStatusEffects; + +protected: + // Called when the game starts + virtual void BeginPlay() override; + +public: + // Called every frame + virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; + + +}; diff --git a/the_twilight_abyss.uproject b/the_twilight_abyss.uproject index 5d45481..97a9688 100644 --- a/the_twilight_abyss.uproject +++ b/the_twilight_abyss.uproject @@ -10,7 +10,8 @@ "LoadingPhase": "Default", "AdditionalDependencies": [ "Engine", - "UMG" + "UMG", + "CoreUObject" ] } ],