-
Notifications
You must be signed in to change notification settings - Fork 0
/
SpawnVolume.h
55 lines (45 loc) · 1.74 KB
/
SpawnVolume.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Components/BoxComponent.h"
#include "SpawnVolume.generated.h"
UCLASS()
class BATTERYCOLLECTOR_API ASpawnVolume : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ASpawnVolume();
// Called every frame
virtual void Tick(float DeltaTime) override;
//returns the wheretospawn object
FORCEINLINE class UBoxComponent* GetWhereToSpawn() const { return WhereToSpawn; }
//find a random point in box component
UFUNCTION(BlueprintPure, Category = "Spawning")
FVector GetRandomPointInVolume();
// this functions toggles whether or not the spawn volume spawns pickups
UFUNCTION(BlueprintCallable, Category = "Spawning")
void SetSpawningActive(bool bShouldSpawn);
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
//the pickup to spawn
UPROPERTY(EditAnywhere, Category = "Spawning")//UPROPERTY macro allows to manipulate vars in Blueprint dynamically
TSubclassOf<class APickup> WhatToSpawn;
FTimerHandle SpawnTimer;
//minimum spawn delay
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spawning")
float SpawnDelayRangeLow;
//maximum spawn delay
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spawning")
float SpawnDelayRangeHigh;
private:
//Box Component to specify where pickups should spawn
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Spawning", meta = (AllowPrivateAccess = "true"))
class UBoxComponent* WhereToSpawn;
//handle spawning a new pickup
void SpawnPickup();
//the current spawn delay
float SpawnDelay;
};