RealtimeStyleTransferRuntime/Source/LyraGame/Weapons/LyraWeaponSpawner.h

119 lines
3.9 KiB
C
Raw Normal View History

2022-05-23 18:41:30 +00:00
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
2022-09-13 07:18:28 +00:00
#include "Engine/EngineTypes.h"
2022-05-23 18:41:30 +00:00
#include "GameFramework/Actor.h"
#include "GameplayTagContainer.h"
2022-09-13 07:18:28 +00:00
#include "HAL/Platform.h"
#include "Math/Transform.h"
#include "Templates/SubclassOf.h"
#include "UObject/UObjectGlobals.h"
2022-05-23 18:41:30 +00:00
#include "LyraWeaponSpawner.generated.h"
2022-09-13 07:18:28 +00:00
class APawn;
class UCapsuleComponent;
2022-05-23 18:41:30 +00:00
class ULyraInventoryItemDefinition;
class ULyraWeaponPickupDefinition;
2022-09-13 07:18:28 +00:00
class UObject;
class UPrimitiveComponent;
2022-05-23 18:41:30 +00:00
class UStaticMeshComponent;
2022-09-13 07:18:28 +00:00
struct FFrame;
struct FGameplayTag;
struct FHitResult;
2022-05-23 18:41:30 +00:00
UCLASS(Blueprintable,BlueprintType)
class LYRAGAME_API ALyraWeaponSpawner : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ALyraWeaponSpawner();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
void OnConstruction(const FTransform& Transform) override;
protected:
//Data asset used to configure a Weapon Spawner
UPROPERTY(EditInstanceOnly, BlueprintReadOnly, Category = "Lyra|WeaponPickup")
2022-09-13 07:18:28 +00:00
TObjectPtr<ULyraWeaponPickupDefinition> WeaponDefinition;
2022-05-23 18:41:30 +00:00
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, ReplicatedUsing = OnRep_WeaponAvailability, Category = "Lyra|WeaponPickup")
bool bIsWeaponAvailable;
//The amount of time between weapon pickup and weapon spawning in seconds
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Lyra|WeaponPickup")
float CoolDownTime;
//Delay between when the weapon is made available and when we check for a pawn standing in the spawner. Used to give the bIsWeaponAvailable OnRep time to fire and play FX.
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Lyra|WeaponPickup")
float CheckExistingOverlapDelay;
//Used to drive weapon respawn time indicators 0-1
UPROPERTY(BlueprintReadOnly, Transient, Category = "Lyra|WeaponPickup")
float CoolDownPercentage;
public:
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Lyra|WeaponPickup")
2022-09-13 07:18:28 +00:00
TObjectPtr<UCapsuleComponent> CollisionVolume;
2022-05-23 18:41:30 +00:00
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Lyra|WeaponPickup")
2022-09-13 07:18:28 +00:00
TObjectPtr<UStaticMeshComponent> PadMesh;
2022-05-23 18:41:30 +00:00
UPROPERTY(BlueprintReadOnly, Category = "Lyra|WeaponPickup")
2022-09-13 07:18:28 +00:00
TObjectPtr<UStaticMeshComponent> WeaponMesh;
2022-05-23 18:41:30 +00:00
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Lyra|WeaponPickup")
float WeaponMeshRotationSpeed;
FTimerHandle CoolDownTimerHandle;
FTimerHandle CheckOverlapsDelayTimerHandle;
UFUNCTION()
void OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepHitResult);
//Check for pawns standing on pad when the weapon is spawned.
void CheckForExistingOverlaps();
UFUNCTION(BlueprintNativeEvent)
void AttemptPickUpWeapon(APawn* Pawn);
UFUNCTION(BlueprintImplementableEvent, Category = "Lyra|WeaponPickup")
bool GiveWeapon(TSubclassOf<ULyraInventoryItemDefinition> WeaponItemClass, APawn* ReceivingPawn);
void StartCoolDown();
UFUNCTION(BlueprintCallable, Category = "Lyra|WeaponPickup")
void ResetCoolDown();
UFUNCTION()
void OnCoolDownTimerComplete();
void SetWeaponPickupVisibility(bool bShouldBeVisible);
UFUNCTION(BlueprintNativeEvent, Category = "Lyra|WeaponPickup")
void PlayPickupEffects();
UFUNCTION(BlueprintNativeEvent, Category = "Lyra|WeaponPickup")
void PlayRespawnEffects();
UFUNCTION()
void OnRep_WeaponAvailability();
/** Searches an item definition type for a matching stat and returns the value, or 0 if not found */
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Lyra|WeaponPickup")
static int32 GetDefaultStatFromItemDef(const TSubclassOf<ULyraInventoryItemDefinition> WeaponItemClass, FGameplayTag StatTag);
};