Newer
Older
SkyFrontier-Project-IADE-UE4-3D / Source / SkyFrontier / Public / PointsComponent.h
  1. #pragma once
  2. #include "CoreMinimal.h"
  3. #include "Net/UnrealNetwork.h"
  4. #include "Components/ActorComponent.h"
  5. #include "PointsComponent.generated.h"
  6. DECLARE_EVENT_OneParam(UCPP_PointsComponent, PointsReceiveEvent, int)
  7. UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent))
  8. class SKYFRONTIER_API UPointsComponent : public UActorComponent
  9. {
  10. GENERATED_BODY()
  11. public:
  12. UPointsComponent();
  13. UFUNCTION(BlueprintCallable, Category = "Points")
  14. int GetPoints() const;
  15. UFUNCTION(Server, Reliable, BlueprintCallable, Category = "Points")
  16. void AddPoints(int PointsToAdd);
  17. protected: // Functions
  18. virtual void BeginPlay() override;
  19. virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
  20. public: // Events
  21. PointsReceiveEvent OnPointsReceiveEvent;
  22. public:
  23. UPROPERTY(Replicated, VisibleAnywhere, Category = "Points")
  24. int Points;
  25. };