Added StatusEffect Stub for Multiple Status Effects

This commit is contained in:
Philip W 2023-02-20 17:58:32 +00:00
parent 5dae3b2691
commit 31a6a5d98e
7 changed files with 128 additions and 8 deletions

Binary file not shown.

View File

@ -30,9 +30,7 @@ void UHoldToInitCombat::BeginPlay()
InitCombatWidget = CreateWidget<UUserWidget>(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<UStaticMeshComponent>(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());

View File

@ -0,0 +1,11 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "StatusEffect.h"
void UStatusEffect::Invoke(ACharacter* Character)
{
}

View File

@ -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);
};

View File

@ -0,0 +1,41 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "StatusSystem.h"
#include <Runtime/Engine/Classes/Kismet/GameplayStatics.h>
// 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));
}
}
}

View File

@ -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<FActiveStatusEffect> 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;
};

View File

@ -10,7 +10,8 @@
"LoadingPhase": "Default",
"AdditionalDependencies": [
"Engine",
"UMG"
"UMG",
"CoreUObject"
]
}
],