General Blueprint utilities Functions + First Implementation of Pursuit Logic
This commit is contained in:
@ -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"),
|
||||
};
|
||||
@ -1,63 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Types/Struct/DTFluxPursuitStructs.h"
|
||||
#include "Types/Struct/DTFluxRankingStructs.h"
|
||||
#include "UObject/Object.h"
|
||||
#include "DTFluxPursuitManager.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS(BlueprintType)
|
||||
class DTFLUXCORE_API UDTFluxPursuitManager : public UObject
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="DTFlux|Pursuit", meta=(Keywords="Poursuit pursuit poursuit"), Transient)
|
||||
TArray<FDTFluxPursuit> PursuitParticipants;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, EditAnywhere, Category="DTFlux|Pursuit", meta=(Keywords="Poursuit pursuit poursuit"))
|
||||
FDateTime MassStart;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, EditAnywhere, Category="DTFlux|Pursuit", meta=(Keywords="Poursuit pursuit poursuit"))
|
||||
int ContestId;
|
||||
|
||||
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(BlueprintCallable, Category="DTFlux|Pursuit", meta=(Keywords="Poursuit pursuit poursuit"))
|
||||
TArray<FDTFluxPursuit> GetNextPursuits(int MaxPursuit);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Pursuit", meta=(Keywords="Poursuit pursuit poursuit"))
|
||||
TArray<FDTFluxPursuit> GetPursuits(int FromIndex = 0, int MaxPursuit=10);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Pursuit", meta=(Keywords="Poursuit pursuit poursuit"))
|
||||
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("...")));
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Pursuit", meta=(Keywords="Poursuit pursuit poursuit"))
|
||||
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);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
private:
|
||||
|
||||
UPROPERTY(VisibleAnywhere, Category="DTFlux|Pursuit", meta=(Keywords="Poursuit pursuit poursuit"))
|
||||
int CurrentIndex;
|
||||
};
|
||||
|
||||
|
||||
@ -1,38 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "DTFluxTeamListStruct.h"
|
||||
#include "DTFluxPursuitStructs.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
USTRUCT(BlueprintType, Blueprintable)
|
||||
struct DTFLUXCORE_API FDTFluxPursuit
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
FDTFluxPursuit();
|
||||
FDTFluxPursuit(const TArray<FDTFluxParticipant>& InParticipants) : Participants(InParticipants){};
|
||||
|
||||
~FDTFluxPursuit();
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category="DTFlux|Pursuit")
|
||||
TArray<FDTFluxParticipant> Participants;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category="DTFlux|Pursuit")
|
||||
FDateTime StartTime;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category="DTFlux|Pursuit")
|
||||
int IndexMultiple = 0;
|
||||
|
||||
FText GetFormattedName(const int MaxChar = 15, const FString OverflowChar = FString(TEXT("...")));
|
||||
FText DisplayPursuit(const int MaxWidth = 20, const FString NameOverflowChar = FString(TEXT("...")));
|
||||
bool IsUnique() const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user