#pragma once #include "CoreMinimal.h" #include "DTFluxCoreSubsystemModule.h" #include "Assets/DTFluxModelAsset.h" #include "Containers/Deque.h" #include "Types/Struct/FDTFluxPursuitInfo.h" #include "Subsystems/EngineSubsystem.h" #include "Types/Struct/DTFluxRaceDataStructs.h" #include "Types/Struct/DTFluxTeamListStruct.h" #include "Types/Struct/DTFluxRankingStructs.h" #include "Types/Struct/DTFluxSplitSensor.h" #include "DTFluxCoreSubsystem.generated.h" class UDTFluxNetworkSubsystem; /** Forward Decl */ class UDTFluxModelAsset; class UDTFluxPursuitManager; struct FDTFluxServerResponse; /** * */ UCLASS(BlueprintType, meta=(DisplayName="DTFlux Core Subsystem")) class DTFLUXCORESUBSYSTEM_API UDTFluxCoreSubsystem : public UEngineSubsystem { GENERATED_BODY() public: DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnSplitRankings, FDTFluxSplitKey, SplitKey, FDTFluxSplitRankings, SplitRankings); UPROPERTY(BlueprintAssignable, Category="DTFlux|Core Subsystem") FOnSplitRankings OnSplitRankings; DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnStageRankings, FDTFluxStageKey, StageKey, FDTFluxStageRankings, StageRankings); UPROPERTY(BlueprintAssignable, Category="DTFlux|Core Subsystem") FOnStageRankings OnStageRankings; DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnContestRankingDisplayReady, const FGuid, RequestId, const bool, bSuccesRequest); UPROPERTY(BlueprintAssignable, Category="DTFlux|Core Subsystem") FOnContestRankingDisplayReady OnContestRankingDisplayReady; DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnStageRankingDisplayReady, const FGuid, RequestId, const bool, bSuccesRequest); UPROPERTY(BlueprintAssignable, Category="DTFlux|Core Subsystem") FOnStageRankingDisplayReady OnStageRankingDisplayReady; DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnSplitRankingDisplayReady, const FGuid, RequestId, const bool, bSuccesRequest); UPROPERTY(BlueprintAssignable, Category="DTFlux|Core Subsystem") FOnSplitRankingDisplayReady OnSplitRankingDisplayReady; DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnContestRankings, const int, ContestId, FDTFluxContestRankings, ContestRankings); UPROPERTY(BlueprintAssignable, Category="DTFlux|Core Subsystem") FOnContestRankings OnContestRankings; DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnTeamList); UPROPERTY(BlueprintAssignable, Category="DTFlux|Core Subsystem") FOnTeamList OnTeamList; DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnTeamStatusUpdate, FDTFluxParticipant, TeamUpdated); UPROPERTY(BlueprintAssignable, Category="DTFlux|Core Subsystem") FOnTeamStatusUpdate OnTeamStatusUpdate; UPROPERTY(BlueprintReadOnly, Category="DTFlux|Core Subsystem") UDTFluxPursuitManager* PursuitManager = nullptr; DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnSplitSensor, FDTFluxSplitSensorInfo, SplitSensorInfo); UPROPERTY(BlueprintAssignable, Category="DTFlux|Core Subsystem") FOnSplitSensor OnSplitSensor; DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnFinisher, FDTFluxSplitSensorInfo, SplitSensorInfo); UPROPERTY(BlueprintAssignable, Category="DTFlux|Core Subsystem") FOnFinisher OnFinisher; DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnPreFinish, FDTFluxSplitSensorInfo, SplitSensorInfo); UPROPERTY(BlueprintAssignable, Category="DTFlux|Core Subsystem") FOnPreFinish OnPreFinish; DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnWinner, FDTFluxSplitSensorInfo, SplitSensorInfo); UPROPERTY(BlueprintAssignable, Category="DTFlux|Core Subsystem") FOnWinner OnWinner; DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnParticipantTrackingReady, FDTFluxSplitHistory, SplitHistory); UPROPERTY(BlueprintAssignable, Category="DTFlux|Core Subsystem") FOnParticipantTrackingReady OnParticipantTrackingReady; //TODO : this must be a ProjectSetting UPROPERTY(BlueprintReadOnly, Category="DTFlux|Core Subsystem") bool bShouldKeepRankings = true; UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem") void InitParticipantTracking(const int Bib, const int ContestId, const int StageId); UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem") FGuid InitContestRankingsDisplay(const int ContestIds); UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem") FGuid InitStageRankingsDisplay(const int ContestId, const int StageId); UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem") FGuid InitSplitRankingsDisplay(const int ContestId, const int StageId, const int SplitId); UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem") bool GetStageRankingForBib(const int ContestId, const int StageId, const int Bib, FDTFluxStageRanking& OutStageRankings); UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem") bool GetSplitRankingForBib(const int ContestId, const int StageId, const int SplitId, const int Bib, FDTFluxSplitRanking& OutSplitRankings); UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem") bool GetContestRanking(const int ContestId, FDTFluxContestRanking& OutContestRanking); UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem") bool GetContestRankings(const int ContestId, FDTFluxContestRankings& OutContestRankings); UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem") bool GetStageRankings(const int ContestId, const int StageId, FDTFluxStageRankings& OutStageRankings); UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem") bool GetSplitRankings(const int ContestId, const int StageId, const int SplitId, FDTFluxSplitRankings& OutSplitRankings); UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem") bool GetStageRankingsWithKey(const FDTFluxStageKey StageKey, FDTFluxStageRankings& OutStageRankings, const bool bShouldUseCached = true); UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem") bool GetSplitRankingsWithKey(const FDTFluxSplitKey SplitKey, FDTFluxSplitRankings& OutSplitRankings, const bool bShouldUseCached = true); UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem") TArray TrackedRequestContestRankings(const TArray ForContests, bool bEnableCache = true); UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem") TArray TrackedRequestStageRankings(const TArray ForStages, bool bEnableCache = true); UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem") TArray TrackedRequestSplitRankings(const TArray ForSplits, bool bEnableCache = true); UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem") bool GetParticipant(int InBib, FDTFluxParticipant& OutParticipant); UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem") TArray GetCurrentContestsId(); UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem") bool GetCurrentContests(TArray& OutContests); UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem") TArray GetContestsIdForTime(const FDateTime Time); UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem") bool GetContestForId(const int Id, FDTFluxContest& OutContest); UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem") bool GetContestsForTime(const FDateTime Time, TArray& OutContests); UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem") bool GetContests(TArray& OutContests); UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem") void GetContest(const int ContestId, FDTFluxContest& OutContest); UFUNCTION() bool GetStageDefinition(const FDTFluxStageKey StageKey, FDTFluxStage& OutStageDefinition); UFUNCTION() bool GetSplitDefinition(const FDTFluxSplitKey SplitKey, FDTFluxSplit& OutSplitDefinition); UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem") void GetStage(const int ContestId, const int StageId, FDTFluxStage& OutStageDefinition); UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem") void GetSplit(const int ContestId, const int StageId, const int SplitId, FDTFluxSplit& OutSplitDefinition); protected: // ~Subsystem Interface virtual void Initialize(FSubsystemCollectionBase& Collection) override; virtual void Deinitialize() override; // ~Subsystem Interface UFUNCTION() void SaveDataStorage(); UFUNCTION() void ProcessTrackedResponse(FDTFluxServerResponse& InResponse); private: UDTFluxNetworkSubsystem* NetworkSubsystem = nullptr; UPROPERTY() UDTFluxModelAsset* DataStorage = nullptr; UFUNCTION() void ProcessRaceData(const FDTFluxRaceData& RaceDataDefinition); UFUNCTION() void ProcessTeamList(const FDTFluxTeamListDefinition& TeamListDefinition); UFUNCTION() void ProcessContestRanking(const FDTFluxContestRankings& ContestRankings); UFUNCTION() void ProcessStageRanking(const FDTFluxStageRankings& StageRankings); UFUNCTION() void ProcessSplitRanking(const FDTFluxSplitRankings& SplitRankings); UFUNCTION() void ProcessTeamStatusUpdate(const FDTFluxTeamStatusUpdate& NewParticipantStatus); UFUNCTION() void ProcessSplitSensor(const FDTFluxSplitSensorInfo& SplitSensorInfo); UFUNCTION() void ProcessTeamUpdate(const FDTFluxTeamListDefinition& TeamListDefinition); UFUNCTION() void SendRequest(const FString& Message); UFUNCTION() void RegisterDelegates(); UFUNCTION() bool IsStageRankingSealed(FDTFluxStageKey StageKey); UFUNCTION() bool IsContestRankingSealed(int ContestId); EDTFluxFinisherType GetSplitSensorType(const FDTFluxSplitSensorInfo& SplitSensorInfo); };