// Project Lab - NHTV Igad

#pragma once

#include "SpawnerBase.h"
#include "CreatureSpawn.generated.h"

UCLASS()
class ACreatureSpawn : public ASpawnerBase
{
	GENERATED_BODY()
	
public:
	ACreatureSpawn();

	virtual void BeginPlay() override;
	virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;

	virtual void Tick(float DeltaTime) override;

	UPROPERTY(EditAnywhere, Category = "Switch Components")
	TArray<class ANetworkDoor*> doorsToOpen;

	UPROPERTY(EditAnywhere)
	float respawnTime;

	UPROPERTY(EditAnywhere, Category = "Switch Components")
	class USphereComponent* spawnTrigger;

	UPROPERTY(EditAnywhere, Category = "Gamestate Components")
	bool isBoss;
	UPROPERTY(EditAnywhere, Category = "Gamestate Components")
	bool spawnContinuous;

	UFUNCTION()
	void OnOverlapBegin(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
	UFUNCTION()
	void OnOverlapEnd(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);

	virtual int32 OnMobDie(class ANPCBase* mob) override;
	virtual void GetNewTarget(class ANPCBase* mob) override;
	void SpawnMobs();

protected:
	virtual void m_RespawnMobs();
private:
	TArray<FVector> m_resetPoints;
	float m_respawnTimer;

	class AModifier* m_invulnerableModifier;

	void m_DespawnMobs();

};
