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


#include "MyVICharacter.h"
#include "GAS/VIAbilitySystemComponent.h"
#include "Pawn/VIPawnVaultComponent.h"
#include "MotionWarpingComponent.h"


AMyVICharacter::AMyVICharacter(const FObjectInitializer& OI)
	: Super(OI)
{
	VaultComponent = CreateDefaultSubobject<UVIPawnVaultComponent>(TEXT("PawnVaulting"));
	MotionWarpingComponent = CreateDefaultSubobject<UMotionWarpingComponent>(TEXT("MotionWarping"));
}

void AMyVICharacter::BeginPlay()
{
	Super::BeginPlay();

	// Init simulated proxy
	if (AbilitySystem && GetLocalRole() == ROLE_SimulatedProxy)
	{
		// Will never have a valid controller
		AbilitySystem->InitAbilityActorInfo(this, this);
	}
}

void AMyVICharacter::PossessedBy(AController* NewController)
{
	Super::PossessedBy(NewController);

	// Init authority/standalone
	if (AbilitySystem)
	{
		AbilitySystem->InitAbilityActorInfo(this, this);
	}
}

void AMyVICharacter::OnRep_Controller()
{
	Super::OnRep_Controller();

	// Init local client
	if (AbilitySystem)
	{
		AbilitySystem->InitAbilityActorInfo(this, this);
	}
}