LEAP Documentation 40220
Documentation for the LEAP project
ProjectXAISpawner.h
Go to the documentation of this file.
1// Copyright Blue Isle Studios Inc 2017. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "GameFramework/Actor.h"
8#include "SpawnInterface.h"
9#include "ProjectXAISpawner.generated.h"
10
12class APlayerState;
13
14UCLASS()
15class PROJECTX_API AProjectXAISpawner : public AActor, public IReactsToMatchEvents, public ISpawnInterface
16{
17 GENERATED_BODY()
18
19public:
20 /*Execute this spawner immediately rather than on match start?*/
21 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spawn Config", meta=(EditCondition = "!bExecuteImmediately"))
22 bool bExecuteOnMatchStart = true;
23 /*Execute this spawner immediately rather than on match start?*/
24 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spawn Config")
25 bool bExecuteImmediately = false;
26 /*What Team should this AI spawn on?*/
27 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spawn Config")
28 int32 Team = 99;
29 /*Which AI would you like to spawn here?*/
30 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Spawn Config")
31 TSubclassOf<class AProjectXCharacter> AIToSpawn;
32 /*How long should the AI take to spawn once the game starts?*/
33 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spawn Config")
34 float SpawnDelay = 0.0f;
35 /*Once this AI spawns, how long does it stay alive? -1 means infinite duration. */
36 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spawn Config")
37 float LifeTime = -1.0f;
38 /*Should the AI respawn if killed?*/
39 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spawn Config")
40 bool bRespawn;
41 /*How long should the AI take to respawn?*/
42 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spawn Config", meta = (EditCondition = "bRespawn"))
43 float RespawnTime = 60.0f;
44 /*How many players must be playing for this AI to spawn? If the playercount falls below this threshold, the AI will despawn. -1 Will always spawn and never despawn. */
45 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spawn Config")
46 int32 RequiredPlayerCount = INDEX_NONE;
47 /*Should thie spawner auto destroy if possible once spawning is completed? Some things prevent auto-destruction such as lifetime and respawn settings */
48 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spawn Config")
49 bool bAutoDestroy = true;
50 /*Should we despawn the AI when stopspawning is called? */
51 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spawn Config")
52 bool bDespawnAIWhenStopSpawningCalled = false;
53 /*If the player count is specified, its associative multiplier will be used to increase or decrease spawned health */
54 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spawn Config")
55 TMap<int32, float> PlayerCountHealthMultipliers;
56
57 TWeakObjectPtr<AProjectXCharacter> SpawnedAI = nullptr;
58
59 FTimerHandle AIRespawnTimer;
60
62
63 UFUNCTION(BlueprintImplementableEvent)
64 void OnAISpawned(AProjectXCharacter* SpawnedActor);
65
66 virtual void BeginSpawning_Implementation() override;
67 virtual void StopSpawning_Implementation() override;
68 virtual bool ImplementsSpawnCompleteCallback() const override;
69 virtual void Despawn();
70 virtual void Cleanup();
71
72 FORCEINLINE bool ShouldDestroySpawnerOnceComplete() const { return bAutoDestroy && LifeTime == -1.0f && !bRespawn; }
73
74 virtual void BeginPlay() override;
75 virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
76 virtual void MatchStarted() override;
77 virtual void HandleSpawn();
78
79 UFUNCTION()
80 virtual void OnAIDeath(AActor* Victim, const float Damage, struct FDamageEvent const& DamageEvent, const AController* EventInstigator, const AActor* DamageCauser, const class APlayerState* InstigatorPlayerState);
81};
Definition: ProjectXAISpawner.h:16
Definition: ProjectXCharacter.h:128
Definition: ReactsToMatchEvents.h:16
Definition: SpawnInterface.h:24