2025-07-09 03:27:23 +02:00
|
|
|
|
#pragma once
|
2025-06-29 19:04:36 +02:00
|
|
|
|
|
|
|
|
|
|
#include "CoreMinimal.h"
|
2025-07-13 04:13:02 +02:00
|
|
|
|
#include "DTFluxCoreSubsystemModule.h"
|
|
|
|
|
|
#include "Assets/DTFluxModelAsset.h"
|
2025-07-08 16:50:31 +02:00
|
|
|
|
#include "Containers/Deque.h"
|
2025-07-11 19:04:37 +02:00
|
|
|
|
#include "Types/Struct/FDTFluxPursuitInfo.h"
|
2025-06-29 19:04:36 +02:00
|
|
|
|
#include "Subsystems/EngineSubsystem.h"
|
|
|
|
|
|
#include "Types/Struct/DTFluxRaceDataStructs.h"
|
|
|
|
|
|
#include "Types/Struct/DTFluxTeamListStruct.h"
|
|
|
|
|
|
#include "Types/Struct/DTFluxRankingStructs.h"
|
2025-07-04 01:13:07 +02:00
|
|
|
|
#include "Types/Struct/DTFluxSplitSensor.h"
|
2025-06-29 19:04:36 +02:00
|
|
|
|
#include "DTFluxCoreSubsystem.generated.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-07-03 17:28:51 +02:00
|
|
|
|
class UDTFluxNetworkSubsystem;
|
2025-06-29 19:04:36 +02:00
|
|
|
|
/** Forward Decl */
|
|
|
|
|
|
class UDTFluxModelAsset;
|
2025-07-09 03:27:23 +02:00
|
|
|
|
class UDTFluxPursuitManager;
|
2025-07-11 23:45:23 +02:00
|
|
|
|
struct FDTFluxServerResponse;
|
2025-06-29 19:04:36 +02:00
|
|
|
|
|
2025-07-11 19:04:37 +02:00
|
|
|
|
|
2025-06-29 19:04:36 +02:00
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2025-07-11 13:09:18 +02:00
|
|
|
|
UCLASS(BlueprintType, meta=(DisplayName="DTFlux Core Subsystem"))
|
2025-06-29 19:04:36 +02:00
|
|
|
|
class DTFLUXCORESUBSYSTEM_API UDTFluxCoreSubsystem : public UEngineSubsystem
|
|
|
|
|
|
{
|
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
2025-07-12 09:41:15 +02:00
|
|
|
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnSplitRankings, FDTFluxSplitKey, SplitKey, FDTFluxSplitRankings,
|
|
|
|
|
|
SplitRankings);
|
2025-07-08 16:50:31 +02:00
|
|
|
|
|
2025-06-29 19:04:36 +02:00
|
|
|
|
UPROPERTY(BlueprintAssignable, Category="DTFlux|Core Subsystem")
|
|
|
|
|
|
FOnSplitRankings OnSplitRankings;
|
2025-07-12 09:41:15 +02:00
|
|
|
|
|
|
|
|
|
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnStageRankings, FDTFluxStageKey, StageKey, FDTFluxStageRankings,
|
|
|
|
|
|
StageRankings);
|
2025-07-08 16:50:31 +02:00
|
|
|
|
|
2025-06-29 19:04:36 +02:00
|
|
|
|
UPROPERTY(BlueprintAssignable, Category="DTFlux|Core Subsystem")
|
|
|
|
|
|
FOnStageRankings OnStageRankings;
|
2025-07-12 09:41:15 +02:00
|
|
|
|
|
|
|
|
|
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnContestRankings, const int, ContestId, FDTFluxContestRankings,
|
|
|
|
|
|
ContestRankings);
|
2025-07-08 16:50:31 +02:00
|
|
|
|
|
2025-06-29 19:04:36 +02:00
|
|
|
|
UPROPERTY(BlueprintAssignable, Category="DTFlux|Core Subsystem")
|
|
|
|
|
|
FOnContestRankings OnContestRankings;
|
2025-07-12 09:41:15 +02:00
|
|
|
|
|
2025-07-04 15:17:22 +02:00
|
|
|
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnTeamList);
|
2025-07-08 16:50:31 +02:00
|
|
|
|
|
2025-06-29 19:04:36 +02:00
|
|
|
|
UPROPERTY(BlueprintAssignable, Category="DTFlux|Core Subsystem")
|
|
|
|
|
|
FOnTeamList OnTeamList;
|
2025-07-04 15:17:22 +02:00
|
|
|
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnTeamStatusUpdate, FDTFluxParticipant, TeamUpdated);
|
2025-07-08 16:50:31 +02:00
|
|
|
|
|
2025-06-29 19:04:36 +02:00
|
|
|
|
UPROPERTY(BlueprintAssignable, Category="DTFlux|Core Subsystem")
|
|
|
|
|
|
FOnTeamStatusUpdate OnTeamStatusUpdate;
|
2025-07-11 19:04:37 +02:00
|
|
|
|
|
2025-07-12 16:07:37 +02:00
|
|
|
|
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Core Subsystem")
|
|
|
|
|
|
UDTFluxPursuitManager* PursuitManager = nullptr;
|
2025-07-11 19:04:37 +02:00
|
|
|
|
|
|
|
|
|
|
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")
|
2025-07-12 16:07:37 +02:00
|
|
|
|
TArray<FGuid> TrackedRequestContestRankings(const TArray<int> ForContests, bool bEnableCache = true);
|
2025-07-11 19:04:37 +02:00
|
|
|
|
|
|
|
|
|
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
2025-07-12 16:07:37 +02:00
|
|
|
|
TArray<FGuid> TrackedRequestStageRankings(const TArray<FDTFluxStageKey> ForStages, bool bEnableCache = true);
|
2025-07-11 19:04:37 +02:00
|
|
|
|
|
|
|
|
|
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
2025-07-12 16:07:37 +02:00
|
|
|
|
TArray<FGuid> TrackedRequestSplitRankings(const TArray<FDTFluxSplitKey> ForSplits, bool bEnableCache = true);
|
2025-07-11 19:04:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
2025-07-08 20:16:36 +02:00
|
|
|
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
|
|
|
|
|
const FDTFluxParticipant GetParticipant(int InBib);
|
|
|
|
|
|
|
2025-07-11 23:45:23 +02:00
|
|
|
|
//TODO : this must be a ProjectSetting
|
|
|
|
|
|
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Core Subsystem")
|
|
|
|
|
|
bool bShouldKeepRankings = true;
|
2025-06-29 19:04:36 +02:00
|
|
|
|
|
2025-07-04 15:17:22 +02:00
|
|
|
|
UFUNCTION()
|
|
|
|
|
|
TArray<int> GetCurrentContestsId();
|
|
|
|
|
|
UFUNCTION()
|
|
|
|
|
|
TArray<FDTFluxContest> GetCurrentContests();
|
|
|
|
|
|
UFUNCTION()
|
2025-07-11 23:45:23 +02:00
|
|
|
|
TArray<int> GetContestsIdForTime(const FDateTime Time) const;
|
2025-07-13 04:13:02 +02:00
|
|
|
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
2025-07-08 20:16:36 +02:00
|
|
|
|
bool GetContestForId(const int Id, FDTFluxContest& OutContest);
|
2025-07-13 04:13:02 +02:00
|
|
|
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
2025-07-04 15:17:22 +02:00
|
|
|
|
TArray<FDTFluxContest> GetContestsForTime(const FDateTime Time);
|
|
|
|
|
|
|
2025-07-08 16:50:31 +02:00
|
|
|
|
UFUNCTION()
|
|
|
|
|
|
void RequestRankingsForStages(const TArray<FDTFluxStage> RequestedStages) const;
|
|
|
|
|
|
UFUNCTION()
|
|
|
|
|
|
TArray<FDTFluxContest> GetContests();
|
2025-07-04 15:17:22 +02:00
|
|
|
|
|
2025-07-13 04:13:02 +02:00
|
|
|
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
|
|
|
|
|
void GetContest(const int ContestId, FDTFluxContest& OutContest)
|
|
|
|
|
|
{
|
|
|
|
|
|
OutContest = FDTFluxContest();
|
|
|
|
|
|
if (GetContestForId(ContestId, OutContest))
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("ContestId %d not found in ContestDefinition"), ContestId)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
|
|
|
|
|
bool GetStageDefinition(const FDTFluxStageKey StageKey, FDTFluxStage& OutStageDefinition)
|
|
|
|
|
|
{
|
|
|
|
|
|
int ContestId = StageKey.ContestId;
|
|
|
|
|
|
int StageId = StageKey.StageId;
|
|
|
|
|
|
FDTFluxContest ContestDefinition;
|
|
|
|
|
|
if (GetContestForId(ContestId, ContestDefinition))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (ContestDefinition.Stages.IsValidIndex(StageId))
|
|
|
|
|
|
{
|
|
|
|
|
|
OutStageDefinition = ContestDefinition.Stages[StageId];
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
OutStageDefinition = FDTFluxStage();
|
|
|
|
|
|
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("ContestId %d, StageId %d not found in ContestDefinition"),
|
|
|
|
|
|
ContestId, StageId)
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
|
|
|
|
|
bool GetSplitDefinition(const FDTFluxSplitKey SplitKey, FDTFluxSplit& OutSplitDefinition)
|
|
|
|
|
|
{
|
|
|
|
|
|
int ContestId = SplitKey.ContestId;
|
|
|
|
|
|
int SplitId = SplitKey.SplitId;
|
|
|
|
|
|
FDTFluxContest ContestDefinition;
|
|
|
|
|
|
if (GetContestForId(ContestId, ContestDefinition))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (ContestDefinition.Splits.IsValidIndex(SplitId))
|
|
|
|
|
|
{
|
|
|
|
|
|
OutSplitDefinition = ContestDefinition.Splits[SplitId];
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
OutSplitDefinition = FDTFluxSplit();
|
|
|
|
|
|
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("ContestId %d, SplitId %d not found in ContestDefinition"),
|
|
|
|
|
|
ContestId, SplitId);
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
|
|
|
|
|
void GetStage(const int ContestId, const int StageId, FDTFluxStage& OutStageDefinition)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (GetStageDefinition(FDTFluxStageKey(ContestId, StageId),
|
|
|
|
|
|
OutStageDefinition))
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
OutStageDefinition = FDTFluxStage();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
|
|
|
|
|
void GetSplit(const int ContestId, const int StageId, const int SplitId, FDTFluxSplit& OutSplitDefinition)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (GetSplitDefinition(FDTFluxSplitKey(ContestId, StageId, SplitId),
|
|
|
|
|
|
OutSplitDefinition))
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
OutSplitDefinition = FDTFluxSplit();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-29 19:04:36 +02:00
|
|
|
|
protected:
|
|
|
|
|
|
// ~Subsystem Interface
|
|
|
|
|
|
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
|
|
|
|
|
|
virtual void Deinitialize() override;
|
|
|
|
|
|
// ~Subsystem Interface
|
2025-07-04 01:13:07 +02:00
|
|
|
|
UFUNCTION()
|
2025-07-03 17:28:51 +02:00
|
|
|
|
void SaveDataStorage();
|
2025-07-11 23:45:23 +02:00
|
|
|
|
UFUNCTION()
|
|
|
|
|
|
void ProcessTrackedResponse(FDTFluxServerResponse& InResponse);
|
2025-07-08 16:50:31 +02:00
|
|
|
|
|
2025-06-29 19:04:36 +02:00
|
|
|
|
private:
|
2025-07-03 17:28:51 +02:00
|
|
|
|
UDTFluxNetworkSubsystem* NetworkSubsystem = nullptr;
|
2025-07-11 13:09:18 +02:00
|
|
|
|
UPROPERTY()
|
|
|
|
|
|
UDTFluxModelAsset* DataStorage = nullptr;
|
2025-06-29 19:04:36 +02:00
|
|
|
|
|
|
|
|
|
|
UFUNCTION()
|
2025-07-03 17:28:51 +02:00
|
|
|
|
void ProcessRaceData(const FDTFluxRaceData& RaceDataDefinition);
|
|
|
|
|
|
UFUNCTION()
|
|
|
|
|
|
void ProcessTeamList(const FDTFluxTeamListDefinition& TeamListDefinition);
|
|
|
|
|
|
UFUNCTION()
|
|
|
|
|
|
void ProcessContestRanking(const FDTFluxContestRankings& ContestRankings);
|
2025-06-29 19:04:36 +02:00
|
|
|
|
UFUNCTION()
|
2025-07-03 17:28:51 +02:00
|
|
|
|
void ProcessStageRanking(const FDTFluxStageRankings& StageRankings);
|
2025-06-29 19:04:36 +02:00
|
|
|
|
UFUNCTION()
|
2025-07-03 17:28:51 +02:00
|
|
|
|
void ProcessSplitRanking(const FDTFluxSplitRankings& SplitRankings);
|
2025-06-30 19:02:19 +02:00
|
|
|
|
UFUNCTION()
|
2025-07-08 16:50:31 +02:00
|
|
|
|
void ProcessTeamStatusUpdate(const FDTFluxTeamStatusUpdate& NewParticipantStatus);
|
2025-07-04 01:13:07 +02:00
|
|
|
|
UFUNCTION()
|
|
|
|
|
|
void ProcessSplitSensor(const FDTFluxSplitSensorInfo& SplitSensorInfo);
|
2025-06-30 19:02:19 +02:00
|
|
|
|
UFUNCTION()
|
2025-07-08 16:50:31 +02:00
|
|
|
|
void ProcessTeamUpdate(const FDTFluxTeamListDefinition& TeamListDefinition);
|
2025-06-29 19:04:36 +02:00
|
|
|
|
UFUNCTION()
|
|
|
|
|
|
void SendRequest(const FString& Message);
|
|
|
|
|
|
UFUNCTION()
|
|
|
|
|
|
void RegisterDelegates();
|
|
|
|
|
|
};
|