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
  1. #include "PointsComponent.h"
  2. #include "Net/UnrealNetwork.h"
  3. UPointsComponent::UPointsComponent()
  4. {
  5. PrimaryComponentTick.bCanEverTick = false;
  6. PrimaryComponentTick.bStartWithTickEnabled = false;
  7. SetIsReplicatedByDefault(true);
  8. }
  9. void UPointsComponent::BeginPlay()
  10. {
  11. Super::BeginPlay();
  12. Points = 0;
  13. }
  14. void UPointsComponent::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
  15. {
  16. Super::GetLifetimeReplicatedProps(OutLifetimeProps);
  17. DOREPLIFETIME(UPointsComponent, Points);
  18. }
  19. int UPointsComponent::GetPoints() const
  20. {
  21. return Points;
  22. }
  23. void UPointsComponent::AddPoints_Implementation(const int PointsToAdd)
  24. {
  25. Points += PointsToAdd;
  26. OnPointsReceiveEvent.Broadcast(PointsToAdd);
  27. }