// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "GameFramework/Actor.h" #include "LyraWeaponSpawner.generated.h" #define UE_API LYRAGAME_API namespace EEndPlayReason { enum Type : int; } class APawn; class UCapsuleComponent; class ULyraInventoryItemDefinition; class ULyraWeaponPickupDefinition; class UObject; class UPrimitiveComponent; class UStaticMeshComponent; struct FFrame; struct FGameplayTag; struct FHitResult; UCLASS(MinimalAPI, Blueprintable,BlueprintType) class ALyraWeaponSpawner : public AActor { GENERATED_BODY() public: // Sets default values for this actor's properties UE_API ALyraWeaponSpawner(); protected: // Called when the game starts or when spawned UE_API virtual void BeginPlay() override; UE_API virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override; public: // Called every frame UE_API virtual void Tick(float DeltaTime) override; UE_API void OnConstruction(const FTransform& Transform) override; protected: //Data asset used to configure a Weapon Spawner UPROPERTY(EditInstanceOnly, BlueprintReadOnly, Category = "Lyra|WeaponPickup") TObjectPtr WeaponDefinition; 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") TObjectPtr CollisionVolume; UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Lyra|WeaponPickup") TObjectPtr PadMesh; UPROPERTY(BlueprintReadOnly, Category = "Lyra|WeaponPickup") TObjectPtr WeaponMesh; UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Lyra|WeaponPickup") float WeaponMeshRotationSpeed; FTimerHandle CoolDownTimerHandle; FTimerHandle CheckOverlapsDelayTimerHandle; UFUNCTION() UE_API 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. UE_API void CheckForExistingOverlaps(); UFUNCTION(BlueprintNativeEvent) UE_API void AttemptPickUpWeapon(APawn* Pawn); UFUNCTION(BlueprintImplementableEvent, Category = "Lyra|WeaponPickup") UE_API bool GiveWeapon(TSubclassOf WeaponItemClass, APawn* ReceivingPawn); UE_API void StartCoolDown(); UFUNCTION(BlueprintCallable, Category = "Lyra|WeaponPickup") UE_API void ResetCoolDown(); UFUNCTION() UE_API void OnCoolDownTimerComplete(); UE_API void SetWeaponPickupVisibility(bool bShouldBeVisible); UFUNCTION(BlueprintNativeEvent, Category = "Lyra|WeaponPickup") UE_API void PlayPickupEffects(); UFUNCTION(BlueprintNativeEvent, Category = "Lyra|WeaponPickup") UE_API void PlayRespawnEffects(); UFUNCTION() UE_API 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 UE_API int32 GetDefaultStatFromItemDef(const TSubclassOf WeaponItemClass, FGameplayTag StatTag); }; #undef UE_API