Newer
Older
SkyFrontier-Project-IADE-UE4-3D / Source / SkyFrontier / Private / PointsComponent.cpp
@Genexuz Genexuz on 8 Jan 2023 683 bytes GameMode
  1. #include "PointsComponent.h"
  2. #include "Net/UnrealNetwork.h"
  3. UPointsComponent::UPointsComponent()
  4. {
  5. PrimaryComponentTick.bCanEverTick = false;
  6. PrimaryComponentTick.bStartWithTickEnabled = false;
  7. }
  8. void UPointsComponent::BeginPlay()
  9. {
  10. Super::BeginPlay();
  11. Points = 0;
  12. }
  13. void UPointsComponent::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
  14. {
  15. Super::GetLifetimeReplicatedProps(OutLifetimeProps);
  16. DOREPLIFETIME(UPointsComponent, Points);
  17. }
  18. int UPointsComponent::GetPoints() const
  19. {
  20. return Points;
  21. }
  22. void UPointsComponent::AddPoints_Implementation(const int PointsToAdd)
  23. {
  24. Points += PointsToAdd;
  25. OnPointsReceiveEvent.Broadcast(PointsToAdd);
  26. }