Space Plunder
Loading...
Searching...
No Matches
AISpawnLocation.h
Go to the documentation of this file.
1// Fill out your copyright notice in the Description page of Project Settings.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "Data/AIDataTypes.h"
7#include "GameFramework/Actor.h"
8#include "AISpawnLocation.generated.h"
9
10enum class EDeathType : uint8;
12DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnAISpawned, const AActor*, Actor, AAISpawnLocation*, SelfActor);
13// DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnAISpawnedDeath, AActor*, Actor);
14
15UCLASS()
16class AITOOLKIT_API AAISpawnLocation : public AActor
17{
18 GENERATED_BODY()
19
20public:
22
23 UPROPERTY(BlueprintAssignable, Category="AI Spawn")
24 FOnAISpawned OnAISpawned;
25 UPROPERTY(BlueprintAssignable, Category="AI Spawn")
26 FOnFinishedSpawning OnFinishedSpawning;
27 // UPROPERTY(BlueprintAssignable, Category="AI Spawn")
28 // FOnAISpawnedDeath OnAISpawnedDeath;
29
30
31
32 UFUNCTION(BlueprintCallable, Category="AI Spawn")
33 void AIDeath(AActor* OwningActor, EDeathType DeathType, AActor* DeathCauser, AController* DeathInstigator);
34 UFUNCTION(BlueprintCallable, Category="AI Spawn")
35 void SetSpawnLocationData(const FAISpawnLocationData Data){AISpawnLocationData = Data;};
36
37protected:
38 virtual void BeginPlay() override;
39 virtual void OnConstruction(const FTransform& Transform) override;
40
41
42 //- Components //
43 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="AI Tool Kit")
44 class USceneComponent* SceneRoot;
45 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="AI Tool Kit")
46 class UBillboardComponent* PreviewIcon;
47 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="AI Tool Kit")
48 class USphereComponent* TriggerAreaComponent;
49 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="AI Tool Kit")
50 class USphereComponent* SpawnAreaComponent;
51
52 //- Area the AI can spawn in //
53 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="AI Tool Kit|Spawner")
54 float SpawnRadius = 400.0f;
55 //- The distance between the player and the spawn point before the ai spawns. //
56 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="AI Tool Kit|Spawner")
57 float SpawnDistance = 2000.0f;
58 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="AI Tool Kit|Spawner")
59 FAISpawnLocationData AISpawnLocationData;
60 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="AI Tool Kit|Debugging")
61 bool bDebuggingMode = false;
62
63 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="AI Tool Kit|Characters")
64 TArray<APawn*> SpawnedAI;
65
66 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="AI Tool Kit|Spawner")
67 float SpawnDelayCheck = 2.0f;
68
69private:
70
71 FVector GetRandomSpawnLocation(TArray<FVector>& Locations);
72
73 FVector GetRandomSpawnLocationInArea(TArray<FVector>& Locations);
74
75 bool IsPointInsideSphere(const FVector& Point, const USphereComponent* Sphere);
76
77 void CheckAISpawnData();
78
79 void RemoveVisualizers() const;
80 void SetRandomNumber();
81 void CheckForSpawn();
82 void SpawnAI();
83 void SpawnAICharacter(FAISpawnLocationData& SpawnLocationData);
84
85 FTimerHandle InitialDelayTimerHandle;
86 FTimerHandle NextSpawnTimerHandle;
87 FTimerHandle DestroyTimerHandle;
88
89 int32 LastUsedLocationIndex = -1;
90
91};
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnFinishedSpawning, AAISpawnLocation *, SelfActor)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnAISpawned, const AActor *, Actor, AAISpawnLocation *, SelfActor)
EDeathType
Definition BaseData.h:53
UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent)) class CHATSYSTEM_API UChatSystemComponent
Definition ChatSystemComponent.h:13
Definition AISpawnLocation.h:17
Definition AIDataTypes.h:711