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


#include "DemoEventEmittingActor.h"
#include "EventManagerDemo/Public/EventManager.h"
#include "EventManagerDemo/Public/DemoEvent.h"

// Sets default values
ADemoEventEmittingActor::ADemoEventEmittingActor()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

}

// Called when the game starts or when spawned
void ADemoEventEmittingActor::BeginPlay()
{
	m_value = 0;

	Super::BeginPlay();
}

// Called every frame
void ADemoEventEmittingActor::Tick(float DeltaTime)
{
	int old_vale = m_value;
	m_value = FMath::RandRange(0, 100);

	EventPtr evtPtr(new DemoEvent(old_vale, m_value));
	EventManager::getInstance().triggerEvent(evtPtr);

	Super::Tick(DeltaTime);
}
