Newer
Older
SkyFrontier-Project-IADE-UE4-3D / Source / SkyFrontier / Private / PointsComponent.cpp
@Nelson Luis Moreira da Costa Nelson Luis Moreira da Costa on 16 Jan 2023 716 bytes Fixed issue that would soft crash the running application
#include "PointsComponent.h"
#include "Net/UnrealNetwork.h"

UPointsComponent::UPointsComponent()
{
	PrimaryComponentTick.bCanEverTick = false;
	PrimaryComponentTick.bStartWithTickEnabled = false;
	SetIsReplicatedByDefault(true);
}

void UPointsComponent::BeginPlay()
{
	Super::BeginPlay();
	Points = 0;
}

void UPointsComponent::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
	Super::GetLifetimeReplicatedProps(OutLifetimeProps);

	DOREPLIFETIME(UPointsComponent, Points);
}

int UPointsComponent::GetPoints() const
{
	return Points;
}

void UPointsComponent::AddPoints_Implementation(const int PointsToAdd)
{
	Points += PointsToAdd;

	OnPointsReceiveEvent.Broadcast(PointsToAdd);
}