// Fill out your copyright notice in the Description page of Project Settings.


#include "FayeCameraManager.h"

#include "EngineUtils.h"
#include "GameFramework/Character.h"
#include "Kismet/GameplayStatics.h"
#include "Camera/CameraComponent.h"
#include "GameFramework/SpringArmComponent.h"

void AFayeCameraManager::ToggleClassRendering(UClass* Class, bool bActive)
{
	if (HiddenActors.IsEmpty())
	{
		for (TActorIterator<AActor> It(GetWorld()); It; ++It)
		{
			if (It && It->IsA(Class))
			{
				HiddenActors.Add(*It);
			}
		}
	}
	
	for (AActor* Actor : HiddenActors)
	{
		if (Actor)
		{
			Actor->SetActorHiddenInGame(!bActive);
		}
	}
}

void AFayeCameraManager::BeginPlay()
{
	Super::BeginPlay();
	
	ACharacter* PlayerCharacter = UGameplayStatics::GetPlayerCharacter(this, 0);
	ensure(PlayerCharacter);
	
	SpringArm = PlayerCharacter->GetComponentByClass<USpringArmComponent>();
	Camera = PlayerCharacter->GetComponentByClass<UCameraComponent>();
}
