68 lines
1.7 KiB
C++
68 lines
1.7 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "GameFramework/Actor.h"
|
|
#include "LMItemDrop.generated.h"
|
|
|
|
class ALMPlayer;
|
|
class ULMDropData;
|
|
|
|
UCLASS()
|
|
class LEGUMEMIX_API ALMItemDrop : public AActor
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
protected:
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix)
|
|
float TimeBeforeDespawn = 30.f;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix)
|
|
float MoveRate = 0.1f;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix)
|
|
float MoveDuration = 1.f;
|
|
|
|
/** Distance curve from 0-1 to the player. */
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix, meta=(AllowPrivateAccess=true))
|
|
TObjectPtr<UCurveFloat> PositionAtTime;
|
|
|
|
FTimerHandle DespawnHandle;
|
|
FTimerHandle MoveHandle;
|
|
|
|
private:
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true))
|
|
TObjectPtr<USceneComponent> Root;
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true))
|
|
TObjectPtr<UStaticMeshComponent> StaticMeshComponent;
|
|
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true))
|
|
FVector SpawnLocation;
|
|
|
|
UPROPERTY()
|
|
TObjectPtr<AActor> Attractor;
|
|
|
|
float MoveTime = 0.f;
|
|
|
|
public:
|
|
ALMItemDrop();
|
|
virtual void BeginPlay() override;
|
|
|
|
void SetAttractor(AActor* Target);
|
|
UFUNCTION()
|
|
void DoMovingTowardsTarget();
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
virtual void ConsumePack(ALMPlayer* Player);
|
|
|
|
UFUNCTION(BlueprintImplementableEvent)
|
|
void OnPackConsumed();
|
|
|
|
FVector GetSpawnLocation() const { return SpawnLocation; }
|
|
|
|
protected:
|
|
UFUNCTION(BlueprintCallable)
|
|
void Despawn();
|
|
};
|