General Blueprint utilities Functions + First Implementation of Pursuit Logic
This commit is contained in:
@ -1,43 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Types/Objects/DTFluxPursuitManager.h"
|
||||
|
||||
void UDTFluxPursuitManager::InitForStage(const FDTFluxStageRankings& StageRankings)
|
||||
{
|
||||
}
|
||||
|
||||
TArray<FDTFluxPursuit> UDTFluxPursuitManager::GetNextPursuits(int MaxPursuit)
|
||||
{
|
||||
//TODO : Implement me !!!
|
||||
return PursuitParticipants;
|
||||
}
|
||||
|
||||
TArray<FDTFluxPursuit> UDTFluxPursuitManager::GetPursuits(int FromIndex, int MaxPursuit)
|
||||
{
|
||||
//TODO : Implement me !!!
|
||||
return PursuitParticipants;
|
||||
}
|
||||
|
||||
FDateTime UDTFluxPursuitManager::GetMassStart()
|
||||
{
|
||||
//TODO : Implement me !!!
|
||||
return MassStart;
|
||||
}
|
||||
|
||||
FText UDTFluxPursuitManager::GetFormattedName(FDTFluxPursuit& InPursuit, const int MaxChar,
|
||||
const FString OverflowChar)
|
||||
{
|
||||
return InPursuit.GetFormattedName(MaxChar, OverflowChar);
|
||||
}
|
||||
|
||||
FText UDTFluxPursuitManager::DisplayPursuit(FDTFluxPursuit& InPursuit, const int MaxWidth,
|
||||
const FString NameOverflowChar)
|
||||
{
|
||||
return InPursuit.DisplayPursuit(MaxWidth, NameOverflowChar);
|
||||
}
|
||||
|
||||
bool UDTFluxPursuitManager::IsUnique(const FDTFluxPursuit& InPursuit)
|
||||
{
|
||||
return InPursuit.IsUnique();
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Types/Struct/FDTFluxPoursuiteStruct.h"
|
||||
|
||||
FText FDTFluxPoursuite::GetParticipantFormatedName() const
|
||||
{
|
||||
return FText();
|
||||
}
|
||||
@ -56,7 +56,7 @@ ENUM_CLASS_FLAGS(EDTFluxSplitType);
|
||||
|
||||
|
||||
UENUM(BlueprintType, meta=(Bitflags, UseEnumValuesAsMaskValuesInEditor=true))
|
||||
enum EDTFluxSortingFilter : uint8
|
||||
enum class EDTFluxSortingFilter : uint8
|
||||
{
|
||||
None = 0b00000000 UMETA(DisplayName="No Sorting"),
|
||||
IgnoreStatusOut = 0b00000001 UMETA(DisplayName="IgnoreStatusOut"),
|
||||
@ -70,3 +70,20 @@ enum EDTFluxSortingFilter : uint8
|
||||
DescendingByRank= Descending | ByRank UMETA(DisplayName="DescendingByRank")
|
||||
};
|
||||
ENUM_CLASS_FLAGS(EDTFluxSortingFilter);
|
||||
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EDTFluxSortingRankingType: uint8
|
||||
{
|
||||
Rank = 0b00000000 UMETA(DisplayName="Rank (Default)"),
|
||||
Name = 0b00000001 UMETA(DisplayName="Name"),
|
||||
Bib = 0b00000010 UMETA(DisplayName="Bib"),
|
||||
TimeSwim = 0b00000100 UMETA(DisplayName="Swimming Time"),
|
||||
TimeTransition = 0b00001000 UMETA(DisplayName="Transition Time"),
|
||||
TimeRun = TimeSwim|TimeTransition UMETA(DisplayName="Running Time"),
|
||||
StartTime = 0b00001110 UMETA(DisplayName="StartTime"),
|
||||
Gap = 0b00010000 UMETA(DisplayName="StartTime"),
|
||||
SwimSpeed = 0b00100000 UMETA(DisplayName="StartTime"),
|
||||
RunningSpeed = 0b01000000 UMETA(DisplayName="StartTime"),
|
||||
TotalSpeed = 0b10000000 UMETA(DisplayName="StartTime"),
|
||||
};
|
||||
@ -73,8 +73,53 @@ public:
|
||||
TArray<FDTFluxSplit> Splits;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
|
||||
FDateTime Date;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
|
||||
FDateTime EndTime;
|
||||
UPROPERTY()
|
||||
int LastStageId = -1;
|
||||
|
||||
|
||||
bool IsFinished();
|
||||
inline void UpdateEndTime();
|
||||
int GetLastStageId();
|
||||
void UpdateLastStageId();
|
||||
};
|
||||
|
||||
inline bool FDTFluxContest::IsFinished()
|
||||
{
|
||||
return EndTime <= FDateTime::Now();
|
||||
}
|
||||
|
||||
inline void FDTFluxContest::UpdateEndTime()
|
||||
{
|
||||
TArray<FDTFluxStage> TempStages;
|
||||
TempStages.Sort([](const FDTFluxStage& A, const FDTFluxStage& B)
|
||||
{
|
||||
return A.EndTime < B.EndTime;
|
||||
});
|
||||
EndTime = TempStages.Last().EndTime;
|
||||
}
|
||||
|
||||
inline int FDTFluxContest::GetLastStageId()
|
||||
{
|
||||
if(LastStageId <= 0)
|
||||
{
|
||||
UpdateLastStageId();
|
||||
}
|
||||
return LastStageId;
|
||||
}
|
||||
|
||||
inline void FDTFluxContest::UpdateLastStageId()
|
||||
{
|
||||
TArray<FDTFluxStage> TempStages = Stages;
|
||||
TempStages.Sort([](const FDTFluxStage&A , const FDTFluxStage& B)
|
||||
{
|
||||
return A.StageId < B.StageId;
|
||||
});
|
||||
LastStageId = TempStages.Last().StageId;
|
||||
}
|
||||
|
||||
|
||||
USTRUCT()
|
||||
struct DTFLUXCORE_API FDTFluxRaceData
|
||||
{
|
||||
@ -84,6 +129,8 @@ public:
|
||||
UPROPERTY()
|
||||
// ReSharper disable once IdentifierTypo
|
||||
TArray<FDTFluxContest> Datas;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -97,9 +97,9 @@ struct FDTFluxDetailedRankings
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
UPROPERTY(BlueprintReadWrite,Category="DTFlux|Model|Ranking", VisibleAnywhere)
|
||||
int ContestId;
|
||||
int ContestId = -1;
|
||||
UPROPERTY(BlueprintReadWrite,Category="DTFlux|Model|Ranking", VisibleAnywhere)
|
||||
int StageId;
|
||||
int StageId = -1;
|
||||
TArray<FDTFluxDetailedRankingItem> Rankings;
|
||||
};
|
||||
|
||||
@ -143,6 +143,33 @@ struct FDTFluxStageRankings : public FDTFluxDetailedRankings
|
||||
{
|
||||
return FDTFluxStageKey(ContestId, StageId);
|
||||
}
|
||||
|
||||
inline bool IsInitialized() const
|
||||
{
|
||||
|
||||
return ContestId > 0 && StageId > 0;
|
||||
}
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
for(auto& Ranking : Rankings)
|
||||
{
|
||||
FDateTime RankingStartTime;
|
||||
if(Ranking.TimeStart != "")
|
||||
{
|
||||
TArray<FString> Exploded;
|
||||
Ranking.TimeStart.ParseIntoArray(Exploded, TEXT(":"), true);
|
||||
if(Exploded.Num() == 3)
|
||||
{
|
||||
RankingStartTime = FDateTime(0,0,0,
|
||||
FCString::Atoi(*Exploded[0]), FCString::Atoi(*Exploded[1]),
|
||||
FCString::Atoi(*Exploded[2]));
|
||||
}
|
||||
}
|
||||
Ranking.StartTime = RankingStartTime;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -162,6 +189,11 @@ public:
|
||||
{
|
||||
return FDTFluxSplitKey(ContestId, StageId, SplitId);
|
||||
}
|
||||
inline bool IsInitialized() const
|
||||
{
|
||||
|
||||
return ContestId > 0 && StageId > 0 && SplitId >0 ;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -1,27 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "DTFluxTeamListStruct.h"
|
||||
#include "UObject/Object.h"
|
||||
#include "FDTFluxPoursuiteStruct.generated.h"
|
||||
|
||||
|
||||
/**
|
||||
* @struct FDTFluxPoursuite
|
||||
* Representing a
|
||||
*/
|
||||
USTRUCT(BlueprintType, Category="DTFlux|Poursuite")
|
||||
struct FDTFluxPoursuite
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Poursuite")
|
||||
FDTFluxParticipant Participant;
|
||||
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Poursuite")
|
||||
FDateTime TimeStart;
|
||||
FText GetParticipantFormatedName() const;
|
||||
|
||||
};
|
||||
|
||||
@ -9,7 +9,7 @@ public class DTFluxCoreSubsystem : ModuleRules
|
||||
PublicDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"Core",
|
||||
"Core", "DTFluxCore",
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@ -207,6 +207,16 @@ void UDTFluxCoreSubsystem::RequestAllSplitRankingOfContest(int InContestId, int
|
||||
// TODO Implement this
|
||||
}
|
||||
|
||||
FDTFluxStageRankings UDTFluxCoreSubsystem::GetStageRankings(FDTFluxStageKey StageKey)
|
||||
{
|
||||
if(DataStorage->StageRankings.Contains(StageKey))
|
||||
{
|
||||
return DataStorage->StageRankings[StageKey];
|
||||
}
|
||||
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("Cannot find StageRankings for key [%s]"), *StageKey.GetDisplayName());
|
||||
return FDTFluxStageRankings();
|
||||
}
|
||||
|
||||
void UDTFluxCoreSubsystem::RequestAllSplitRankingOfStage(int InContestId, int InStageId, int InSplitId)
|
||||
{
|
||||
// TODO Implement this
|
||||
@ -216,3 +226,42 @@ void UDTFluxCoreSubsystem::RefreshStorage()
|
||||
{
|
||||
// TODO Implement this
|
||||
}
|
||||
|
||||
TArray<int> UDTFluxCoreSubsystem::GetCurrentContestsId()
|
||||
{
|
||||
return GetContestsIdForTime(FDateTime::Now());
|
||||
}
|
||||
|
||||
TArray<FDTFluxContest> UDTFluxCoreSubsystem::GetCurrentContests()
|
||||
{
|
||||
return GetContestsForTime(FDateTime::Now());
|
||||
}
|
||||
|
||||
TArray<int> UDTFluxCoreSubsystem::GetContestsIdForTime(const FDateTime Time)
|
||||
{
|
||||
TArray<int> Contests;
|
||||
for(const auto& Pair : DataStorage->Contests)
|
||||
{
|
||||
FDTFluxContest Contest = Pair.Value;
|
||||
int ContestId = Contest.ContestId;
|
||||
if(Contest.Date < Time && Contest.EndTime > Time)
|
||||
{
|
||||
Contests.Add(ContestId);
|
||||
}
|
||||
}
|
||||
return Contests;
|
||||
}
|
||||
TArray<FDTFluxContest> UDTFluxCoreSubsystem::GetContestsForTime(const FDateTime Time)
|
||||
{
|
||||
TArray<FDTFluxContest> Contests;
|
||||
for(const auto& Pair : DataStorage->Contests)
|
||||
{
|
||||
FDTFluxContest Contest = Pair.Value;
|
||||
int ContestId = Contest.ContestId;
|
||||
if(Contest.Date < Time && Contest.EndTime > Time)
|
||||
{
|
||||
Contests.Add(Contest);
|
||||
}
|
||||
}
|
||||
return Contests;
|
||||
}
|
||||
|
||||
103
Source/DTFluxCoreSubsystem/Private/DTFluxCoreSubsystemTools.cpp
Normal file
103
Source/DTFluxCoreSubsystem/Private/DTFluxCoreSubsystemTools.cpp
Normal file
@ -0,0 +1,103 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "DTFluxCoreSubsystemTools.h"
|
||||
|
||||
void UDTFluxCoreSubsystemTools::FilterContestRankings(FDTFluxContestRankings& ContestRankings,
|
||||
const EDTFluxSortingRankingType RankingType, TArray<FDTFluxContestRanking>& OutContestRankings, bool bAscendant)
|
||||
{
|
||||
// On fait une copie locale des Rankings
|
||||
TArray<FDTFluxContestRanking> ContestArray = ContestRankings.Rankings;
|
||||
|
||||
// Tri par type + direction
|
||||
ContestArray.Sort([RankingType, bAscendant](const FDTFluxContestRanking& A, const FDTFluxContestRanking& B)
|
||||
{
|
||||
switch (RankingType)
|
||||
{
|
||||
case EDTFluxSortingRankingType::Rank:
|
||||
return bAscendant ? A.Rank < B.Rank : A.Rank > B.Rank;
|
||||
|
||||
case EDTFluxSortingRankingType::Bib:
|
||||
return bAscendant ? A.Bib < B.Bib : A.Bib > B.Bib;
|
||||
|
||||
case EDTFluxSortingRankingType::Gap:
|
||||
return CompareTimeString(A.Gap, B.Gap, bAscendant);
|
||||
|
||||
case EDTFluxSortingRankingType::SwimSpeed:
|
||||
return CompareSpeed(A.SpeedSwimAverage, B.SpeedSwimAverage, bAscendant);
|
||||
|
||||
case EDTFluxSortingRankingType::RunningSpeed:
|
||||
return CompareSpeed(A.SpeedRunningAverage, B.SpeedRunningAverage, bAscendant);
|
||||
|
||||
case EDTFluxSortingRankingType::TotalSpeed:
|
||||
return CompareSpeed(A.SpeedTotalAverage, B.SpeedTotalAverage, bAscendant);
|
||||
|
||||
default:
|
||||
return CompareTimeString(A.Time, B.Time, bAscendant);
|
||||
}
|
||||
});
|
||||
|
||||
// Réaffecte les données triées
|
||||
ContestRankings.Rankings = ContestArray;
|
||||
OutContestRankings = ContestArray;
|
||||
}
|
||||
|
||||
void UDTFluxCoreSubsystemTools::FilterStageRankings(FDTFluxStageRankings& InStageRankings,
|
||||
const EDTFluxSortingRankingType RankingType, FDTFluxStageRankings& OutStageRankings, bool bAscendant)
|
||||
{
|
||||
// TArray<FDTFluxDetailedRankings> StageArray = static_cast<TDF>()InStageRankings.Rankings;
|
||||
}
|
||||
|
||||
void UDTFluxCoreSubsystemTools::FilterSplitRankings(FDTFluxSplitRankings& SplitRankings,
|
||||
const EDTFluxSortingRankingType RankinType, FDTFluxSplitRankings& OutSplitRankings, bool bAscendant)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
float UDTFluxCoreSubsystemTools::ConvertTimeStringToSeconds(const FString& TimeString)
|
||||
{
|
||||
|
||||
// Format attendu : "HH:MM:SS"
|
||||
TArray<FString> Parts;
|
||||
TimeString.ParseIntoArray(Parts, TEXT(":"), true);
|
||||
|
||||
if (Parts.Num() == 3)
|
||||
{
|
||||
const int32 Hours = FCString::Atoi(*Parts[0]);
|
||||
const int32 Minutes = FCString::Atoi(*Parts[1]);
|
||||
const int32 Seconds = FCString::Atoi(*Parts[2]);
|
||||
return Hours * 3600 + Minutes * 60 + Seconds;
|
||||
}
|
||||
if (Parts.Num() == 2)
|
||||
{
|
||||
const int32 Minutes = FCString::Atoi(*Parts[0]);
|
||||
const int32 Seconds = FCString::Atoi(*Parts[1]);
|
||||
return 3600 + Minutes * 60 + Seconds;
|
||||
}
|
||||
if (Parts.Num() == 1)
|
||||
{
|
||||
return FCString::Atoi(*Parts[0]);
|
||||
}
|
||||
return -1.0f;
|
||||
}
|
||||
|
||||
bool UDTFluxCoreSubsystemTools::CompareTimeString(const FString& A_TimeStr, const FString& B_TimeStr, bool bAscendant)
|
||||
{
|
||||
const float A_Time = ConvertTimeStringToSeconds(A_TimeStr);
|
||||
const float B_Time = ConvertTimeStringToSeconds(B_TimeStr);
|
||||
|
||||
return bAscendant ? A_Time < B_Time : A_Time > B_Time;
|
||||
}
|
||||
|
||||
bool UDTFluxCoreSubsystemTools::CompareSpeed(const FString& A_SpeedStr, const FString& B_SpeedStr, bool bAscendant)
|
||||
{
|
||||
float A_Speed = FCString::Atof(*A_SpeedStr);
|
||||
float B_Speed = FCString::Atof(*B_SpeedStr);
|
||||
|
||||
if (bAscendant)
|
||||
{
|
||||
return A_Speed < B_Speed;
|
||||
}
|
||||
return A_Speed > B_Speed;
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "DTFluxPursuitSystem/Public/Types/Objects/DTFluxPursuitManager.h"
|
||||
#include "Subsystems/EngineSubsystem.h"
|
||||
#include "Types/Enum/DTfluxCoreEnum.h"
|
||||
#include "Types/Struct/DTFluxRaceDataStructs.h"
|
||||
@ -29,32 +30,30 @@ class DTFLUXCORESUBSYSTEM_API UDTFluxCoreSubsystem : public UEngineSubsystem
|
||||
|
||||
public:
|
||||
|
||||
|
||||
// TSharedPtr<FDTFluxParser> Parser;
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnSplitRankings, FDateTime, ReceivedAt, TArray<FDTFluxStageRanking>, SplitRankings);
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnSplitRankings, FDTFluxSplitRankings&, SplitRankings);
|
||||
UPROPERTY(BlueprintAssignable, Category="DTFlux|Core Subsystem")
|
||||
FOnSplitRankings OnSplitRankings;
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnStageRankings, FDateTime, ReceivedAt, TArray<FDTFluxStageRanking>, StageRankings);
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnStageRankings, FDTFluxStageRankings&, StageRankings);
|
||||
UPROPERTY(BlueprintAssignable, Category="DTFlux|Core Subsystem")
|
||||
FOnStageRankings OnStageRankings;
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnContestRankings, FDateTime, ReceivedAt, TArray<FDTFluxContestRanking>, ContestRankings);
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnContestRankings, FDTFluxContestRankings&, ContestRankings);
|
||||
UPROPERTY(BlueprintAssignable, Category="DTFlux|Core Subsystem")
|
||||
FOnContestRankings OnContestRankings;
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnTeamList, FDateTime, ReceivedAt, TArray<FDTFluxParticipant>, TeamList);
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnTeamList);
|
||||
UPROPERTY(BlueprintAssignable, Category="DTFlux|Core Subsystem")
|
||||
FOnTeamList OnTeamList;
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnTeamUpdate, FDateTime, ReceivedAt, FDTFluxParticipant, TeamUpdatedList);
|
||||
UPROPERTY(BlueprintAssignable, Category="DTFlux|Core Subsystem")
|
||||
FOnTeamUpdate OnTeamUpdate;
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnTeamStatusUpdate, FDateTime, ReceivedAt, FDTFluxParticipant, TeamUpdated);
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnTeamStatusUpdate, FDTFluxParticipant, TeamUpdated);
|
||||
UPROPERTY(BlueprintAssignable, Category="DTFlux|Core Subsystem")
|
||||
FOnTeamStatusUpdate OnTeamStatusUpdate;
|
||||
//
|
||||
// DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnTeamUpdate, FDateTime, ReceivedAt, FDTFluxParticipant, TeamUpdatedList);
|
||||
// UPROPERTY(BlueprintAssignable, Category="DTFlux|Core Subsystem")
|
||||
// FOnTeamUpdate OnTeamUpdate;
|
||||
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||
void SendTeamListRequest();
|
||||
@ -77,12 +76,25 @@ public:
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||
void RequestAllSplitRankingOfContest(int InContestId, int InStageId);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||
FDTFluxStageRankings GetStageRankings(FDTFluxStageKey StageKey);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||
void RequestAllSplitRankingOfStage(int InContestId, int InStageId, int InSplitId);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||
void RefreshStorage();
|
||||
|
||||
UFUNCTION()
|
||||
TArray<int> GetCurrentContestsId();
|
||||
UFUNCTION()
|
||||
TArray<FDTFluxContest> GetCurrentContests();
|
||||
UFUNCTION()
|
||||
TArray<int> GetContestsIdForTime(const FDateTime Time);
|
||||
UFUNCTION()
|
||||
TArray<FDTFluxContest> GetContestsForTime(const FDateTime Time);
|
||||
|
||||
|
||||
protected:
|
||||
// ~Subsystem Interface
|
||||
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
|
||||
|
||||
37
Source/DTFluxCoreSubsystem/Public/DTFluxCoreSubsystemTools.h
Normal file
37
Source/DTFluxCoreSubsystem/Public/DTFluxCoreSubsystemTools.h
Normal file
@ -0,0 +1,37 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "Types/Enum/DTFluxModelEnums.h"
|
||||
#include "Types/Struct/DTFluxRankingStructs.h"
|
||||
#include "DTFluxCoreSubsystemTools.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class DTFLUXCORESUBSYSTEM_API UDTFluxCoreSubsystemTools : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UFUNCTION(Blueprintable, Category="DTFlux|Core Subsystem|Tools")
|
||||
static void FilterContestRankings(FDTFluxContestRankings& ContestRankings,
|
||||
const EDTFluxSortingRankingType RankingType, TArray<FDTFluxContestRanking>& OutContestRankings, bool bAscendant);
|
||||
|
||||
UFUNCTION(Blueprintable, Category="DTFlux|Core Subsystem|Tools")
|
||||
static void FilterStageRankings(FDTFluxStageRankings& InStageRankings, const EDTFluxSortingRankingType RankingType, FDTFluxStageRankings& OutStageRankings, bool bAscendant = true);
|
||||
|
||||
UFUNCTION(Blueprintable, Category="DTFlux|Core Subsystem|Tools")
|
||||
static void FilterSplitRankings(FDTFluxSplitRankings& SplitRankings, const EDTFluxSortingRankingType RankinType, FDTFluxSplitRankings& OutSplitRankings, bool bAscendant = true);
|
||||
|
||||
UFUNCTION(Blueprintable, Category="DTFlux|Core Subsystem|Tools")
|
||||
static float ConvertTimeStringToSeconds(const FString& TimeString);
|
||||
UFUNCTION(Blueprintable, Category="DTFlux|Core Subsystem|Tools")
|
||||
static bool CompareTimeString(const FString& A_TimeStr, const FString& B_TimeStr, bool bAscendant = true);
|
||||
|
||||
UFUNCTION(Blueprintable, Category="DTFlux|Core Subsystem|Tools")
|
||||
static bool CompareSpeed(const FString& A_SpeedStr, const FString& B_SpeedStr, bool bAscendant=true);
|
||||
};
|
||||
@ -287,6 +287,8 @@ void UDTFluxNetworkSubsystem::ParseRaceData(const FDTFluxServerResponse& Respons
|
||||
UE_LOG(logDTFluxNetwork, Warning, TEXT("Stage %i [%s]: \nSTartTime Received [%s] -> Datetime[%s], CutOff [%s], EndTime [%s] \n"), Stage.Id, *Stage.Name,
|
||||
*Stage.StartTime, *NewStage.StartTime.ToString(), *NewStage.CutOff.ToString(), *NewStage.EndTime.ToString());
|
||||
}
|
||||
NewContest.UpdateEndTime();
|
||||
NewContest.UpdateLastStageId();
|
||||
UE_LOG(logDTFluxNetwork, Warning, TEXT("Contest %i [%s]\nSplits: \n"), Contest.Id, *Contest.Name);
|
||||
for(auto Split: Contest.Splits)
|
||||
{
|
||||
@ -334,6 +336,7 @@ void UDTFluxNetworkSubsystem::ParseStageRankingResponse(const FDTFluxServerRespo
|
||||
NewRankings.ContestId = Response.ContestID;
|
||||
NewRankings.StageId = Response.StageID;
|
||||
NewRankings.Rankings = static_cast<TArray<FDTFluxDetailedRankingItem>>(RankingResponse.Datas);
|
||||
NewRankings.Initialize();
|
||||
UE_LOG(logDTFluxNetwork, Warning, TEXT("StageRanking Data Sent for Contest %i, Stage %i\n[Result] : %s"),
|
||||
NewRankings.ContestId, NewRankings.StageId,
|
||||
OnStageRankingReceived.ExecuteIfBound(NewRankings) ? TEXT("SUCCESS_SEND") : TEXT("NOT_BOUNDED")
|
||||
|
||||
28
Source/DTFluxPursuitSystem/DTFluxPursuitSystem.Build.cs
Normal file
28
Source/DTFluxPursuitSystem/DTFluxPursuitSystem.Build.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using UnrealBuildTool;
|
||||
|
||||
public class DTFluxPursuitSystem : ModuleRules
|
||||
{
|
||||
public DTFluxPursuitSystem(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"Core",
|
||||
}
|
||||
);
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"CoreUObject",
|
||||
"Engine",
|
||||
"Slate",
|
||||
"SlateCore",
|
||||
"DTFluxCore",
|
||||
"DTFluxCoreSubsystem"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
#include "DTFluxPursuitSystemModule.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "FDTFluxPursuitSystemModule"
|
||||
|
||||
DEFINE_LOG_CATEGORY(logDTFluxPursuitSystem);
|
||||
|
||||
void FDTFluxPursuitSystem::StartupModule()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void FDTFluxPursuitSystem::ShutdownModule()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
IMPLEMENT_MODULE(FDTFluxPursuitSystem, DTFluxPursuitSystem)
|
||||
@ -0,0 +1,81 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Types/Objects/DTFluxPursuitManager.h"
|
||||
|
||||
#include "DTFluxCoreSubsystem.h"
|
||||
#include "DTFluxPursuitSystemModule.h"
|
||||
#include "K2Node_GetSubsystem.h"
|
||||
|
||||
|
||||
UDTFluxPursuitManager::UDTFluxPursuitManager(const FObjectInitializer& ObjectInitializer):Super(ObjectInitializer)
|
||||
{
|
||||
if(!FModuleManager::Get().IsModuleLoaded("DTFluxCoreSubsystem"))
|
||||
{
|
||||
FModuleManager::LoadModuleChecked<UDTFluxCoreSubsystem>("DTFluxCoreSubsystem");
|
||||
}
|
||||
CoreSubsystem = GEngine->GetEngineSubsystem<UDTFluxCoreSubsystem>();
|
||||
if(!CoreSubsystem)
|
||||
{
|
||||
UE_LOG(logDTFluxPursuitSystem, Error, TEXT("Cannot Get DTFluxCoreSubsystem"));
|
||||
}
|
||||
}
|
||||
|
||||
void UDTFluxPursuitManager::InitForTime(const FDateTime InFromTime)
|
||||
{
|
||||
FromTime = InFromTime;
|
||||
//Get the stage rankings
|
||||
TArray<FDTFluxContest> TargetContests = CoreSubsystem->GetContestsForTime(FromTime);
|
||||
TArray<FDTFluxPursuit> PursuitParticipantContainer;
|
||||
for(auto& Contest : TargetContests)
|
||||
{
|
||||
int LastStage = Contest.GetLastStageId();
|
||||
FDTFluxStageRankings CurrentRanking = CoreSubsystem->GetStageRankings(FDTFluxStageKey(Contest.ContestId, LastStage));
|
||||
if(CurrentRanking.IsInitialized())
|
||||
{
|
||||
TArray<FDTFluxDetailedRankingItem> Rankings = CurrentRanking.Rankings;
|
||||
for(auto& Ranking : Rankings)
|
||||
{
|
||||
Ranking.TimeStart
|
||||
}
|
||||
}
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
bool UDTFluxPursuitManager::GetNextPursuits(TArray<FDTFluxPursuitInfo>& OutFocusNext,
|
||||
TArray<FDTFluxPursuitInfo>& OutNext, int MaxPoursuit)
|
||||
{
|
||||
// TODO: Implement UDTFluxPursuitManager::GetNextPursuits(TArray<FDTFluxPursuitInfo>& ,TArray<FDTFluxPursuitInfo>& , int)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UDTFluxPursuitManager::GetPursuits(const FDateTime& InFromTime, TArray<FDTFluxPursuitInfo>& OutFocusNext,
|
||||
TArray<FDTFluxPursuitInfo>& OutNext, int MaxPoursuit)
|
||||
{
|
||||
// TODO: Implement UDTFluxPursuitManager::GetPursuits(const FDateTime&, TArray<FDTFluxPursuitInfo>& ,TArray<FDTFluxPursuitInfo>& , int)
|
||||
return true;
|
||||
}
|
||||
|
||||
FDateTime UDTFluxPursuitManager::GetMassStart()
|
||||
{
|
||||
//TODO : Implement me !!!
|
||||
return MassStart;
|
||||
}
|
||||
|
||||
FText UDTFluxPursuitManager::GetFormattedName(FDTFluxPursuit& InPursuit, const int MaxChar,
|
||||
const FString OverflowChar)
|
||||
{
|
||||
return InPursuit.GetFormattedName(MaxChar, OverflowChar);
|
||||
}
|
||||
|
||||
FText UDTFluxPursuitManager::DisplayPursuit(FDTFluxPursuit& InPursuit, const int MaxWidth,
|
||||
const FString NameOverflowChar)
|
||||
{
|
||||
return InPursuit.DisplayPursuit(MaxWidth, NameOverflowChar);
|
||||
}
|
||||
|
||||
bool UDTFluxPursuitManager::IsUnique(const FDTFluxPursuit& InPursuit)
|
||||
{
|
||||
return InPursuit.IsUnique();
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
DECLARE_LOG_CATEGORY_EXTERN(logDTFluxPursuitSystem, All, All)
|
||||
|
||||
class DTFLUXPURSUITSYSTEM_API FDTFluxPursuitSystem : public IModuleInterface
|
||||
{
|
||||
public:
|
||||
virtual void StartupModule() override;
|
||||
virtual void ShutdownModule() override;
|
||||
};
|
||||
@ -3,19 +3,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Types/Struct/DTFluxPursuitStructs.h"
|
||||
#include "Types/Struct/DTFluxRankingStructs.h"
|
||||
#include "Types/Structs/DTFluxPursuitStructs.h"
|
||||
#include "UObject/Object.h"
|
||||
#include "DTFluxPursuitManager.generated.h"
|
||||
|
||||
class UDTFluxCoreSubsystem;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS(BlueprintType)
|
||||
class DTFLUXCORE_API UDTFluxPursuitManager : public UObject
|
||||
class DTFLUXPURSUITSYSTEM_API UDTFluxPursuitManager : public UObject
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
DTFLUXPURSUITSYSTEM_API UDTFluxPursuitManager(const FObjectInitializer& ObjectInitializer );
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="DTFlux|Pursuit", meta=(Keywords="Poursuit pursuit poursuit"), Transient)
|
||||
@ -25,31 +28,29 @@ public:
|
||||
FDateTime MassStart;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, EditAnywhere, Category="DTFlux|Pursuit", meta=(Keywords="Poursuit pursuit poursuit"))
|
||||
int ContestId;
|
||||
FDateTime FromTime;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, EditAnywhere, Category="DTFlux|Pursuit", meta=(Keywords="Poursuit pursuit poursuit"))
|
||||
int StageId;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Pursuit", meta=(Keywords="Poursuit pursuit poursuit"))
|
||||
void InitForStage(const FDTFluxStageRankings& StageRankings);
|
||||
UFUNCTION()
|
||||
DTFLUXPURSUITSYSTEM_API void InitForTime(const FDateTime InFromTime);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Pursuit", meta=(Keywords="Poursuit pursuit poursuit"))
|
||||
TArray<FDTFluxPursuit> GetNextPursuits(int MaxPursuit);
|
||||
DTFLUXPURSUITSYSTEM_API bool GetNextPursuits(TArray<FDTFluxPursuitInfo>& OutFocusNext, TArray<FDTFluxPursuitInfo>& OutNext, int MaxPoursuit = 8);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Pursuit", meta=(Keywords="Poursuit pursuit poursuit"))
|
||||
TArray<FDTFluxPursuit> GetPursuits(int FromIndex = 0, int MaxPursuit=10);
|
||||
DTFLUXPURSUITSYSTEM_API bool GetPursuits(const FDateTime& InFromTime, TArray<FDTFluxPursuitInfo>& OutFocusNext, TArray<FDTFluxPursuitInfo>& OutNext, int MaxPoursuit = 8 );
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Pursuit", meta=(Keywords="Poursuit pursuit poursuit"))
|
||||
FDateTime GetMassStart();
|
||||
DTFLUXPURSUITSYSTEM_API FDateTime GetMassStart();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Pursuit", meta=(Keywords="Poursuit pursuit poursuit"))
|
||||
static FText GetFormattedName(FDTFluxPursuit& InPursuit, const int MaxChar = 10, const FString OverflowChar = FString(TEXT("...")));
|
||||
DTFLUXPURSUITSYSTEM_API static FText GetFormattedName(FDTFluxPursuit& InPursuit, const int MaxChar = 10, const FString OverflowChar = FString(TEXT("...")));
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Pursuit", meta=(Keywords="Poursuit pursuit poursuit"))
|
||||
static FText DisplayPursuit(FDTFluxPursuit& InPursuit, const int MaxWidth = 14, const FString NameOverflowChar = FString(TEXT("...")));
|
||||
DTFLUXPURSUITSYSTEM_API static FText DisplayPursuit(FDTFluxPursuit& InPursuit, const int MaxWidth = 14, const FString NameOverflowChar = FString(TEXT("...")));
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Pursuit", meta=(Keywords="Poursuit pursuit poursuit"))
|
||||
static bool IsUnique(const FDTFluxPursuit& InPursuit);
|
||||
DTFLUXPURSUITSYSTEM_API static bool IsUnique(const FDTFluxPursuit& InPursuit);
|
||||
|
||||
protected:
|
||||
|
||||
@ -58,6 +59,12 @@ private:
|
||||
|
||||
UPROPERTY(VisibleAnywhere, Category="DTFlux|Pursuit", meta=(Keywords="Poursuit pursuit poursuit"))
|
||||
int CurrentIndex;
|
||||
|
||||
UPROPERTY()
|
||||
TArray<int> TargetStages;
|
||||
|
||||
UPROPERTY()
|
||||
UDTFluxCoreSubsystem* CoreSubsystem = nullptr;
|
||||
};
|
||||
|
||||
|
||||
@ -36,3 +36,23 @@ public:
|
||||
};
|
||||
|
||||
|
||||
USTRUCT(BlueprintType, Blueprintable)
|
||||
struct DTFLUXCORE_API FDTFluxPursuitInfo
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category="DTFlux|Pursuit")
|
||||
int Bib = -1;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category="DTFlux|Pursuit")
|
||||
FString Name;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category="DTFlux|Pursuit")
|
||||
bool bIsMassStart;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category="DTFlux|Pursuit")
|
||||
FDateTime StartTime;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user