Apply imported selector options to active runs
This commit is contained in:
parent
20d5b113e9
commit
bec22af2a0
6 changed files with 112 additions and 0 deletions
|
|
@ -2760,6 +2760,47 @@ bool UHyperTwistTrainingCatalogLibrary::TryGetImportedRuntimeSelectorOptionCases
|
|||
return OutCases.Num() > 0;
|
||||
}
|
||||
|
||||
bool UHyperTwistTrainingCatalogLibrary::TryGetImportedRuntimeSelectorOptionCaseFromDeck(
|
||||
const FHyperTwistTrainingDeck& Deck,
|
||||
const FString& SelectorId,
|
||||
const FString& OptionId,
|
||||
FHyperTwistTrainingCase& OutCase
|
||||
)
|
||||
{
|
||||
OutCase = FHyperTwistTrainingCase();
|
||||
|
||||
FHyperTwistTrainingImportedRuntimeSelector Selector;
|
||||
if (!TryGetImportedRuntimeSelectorFromDeck(Deck, SelectorId, Selector) || OptionId.IsEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const FHyperTwistTrainingImportedRuntimeSelectorOption* MatchingOption = Selector.Options.FindByPredicate(
|
||||
[&OptionId](const FHyperTwistTrainingImportedRuntimeSelectorOption& Candidate)
|
||||
{
|
||||
return Candidate.OptionId == OptionId || Candidate.OptionValue == OptionId;
|
||||
}
|
||||
);
|
||||
if (MatchingOption == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const FHyperTwistTrainingCase* MatchingCase = Deck.Cases.FindByPredicate(
|
||||
[&MatchingOption](const FHyperTwistTrainingCase& Candidate)
|
||||
{
|
||||
return HyperTwistTrainingCatalogLibraryInternal::DoesSelectorOptionMatchCase(*MatchingOption, Candidate);
|
||||
}
|
||||
);
|
||||
if (MatchingCase == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
OutCase = *MatchingCase;
|
||||
return OutCase.IsStructurallyValid();
|
||||
}
|
||||
|
||||
FHyperTwistTrainingMethodDescriptor UHyperTwistTrainingCatalogLibrary::DescribeTrainingDeckMethod(
|
||||
const FHyperTwistTrainingDeck& Deck
|
||||
)
|
||||
|
|
|
|||
|
|
@ -102,6 +102,20 @@ bool UHyperTwistTrainingRuntimeLibrary::TryGetActiveImportedRuntimeSelectorOptio
|
|||
return false;
|
||||
}
|
||||
|
||||
FHyperTwistTrainingRunState UHyperTwistTrainingRuntimeLibrary::ApplyActiveImportedRuntimeSelectorOption(
|
||||
UObject* WorldContextObject,
|
||||
const FString& SelectorId,
|
||||
const FString& OptionId
|
||||
)
|
||||
{
|
||||
if (UHyperTwistTrainingSubsystem* TrainingSubsystem = GetTrainingSubsystem(WorldContextObject))
|
||||
{
|
||||
return TrainingSubsystem->ApplyActiveImportedRuntimeSelectorOption(SelectorId, OptionId);
|
||||
}
|
||||
|
||||
return FHyperTwistTrainingRunState();
|
||||
}
|
||||
|
||||
FHyperTwistTrainingMethodDrillRunState UHyperTwistTrainingRuntimeLibrary::GetActiveMethodDrillRunState(
|
||||
UObject* WorldContextObject
|
||||
)
|
||||
|
|
|
|||
|
|
@ -745,6 +745,42 @@ bool UHyperTwistTrainingSubsystem::TryGetActiveImportedRuntimeSelectorOptionCase
|
|||
);
|
||||
}
|
||||
|
||||
FHyperTwistTrainingRunState UHyperTwistTrainingSubsystem::ApplyActiveImportedRuntimeSelectorOption(
|
||||
const FString& SelectorId,
|
||||
const FString& OptionId
|
||||
)
|
||||
{
|
||||
if (!HasActiveRun())
|
||||
{
|
||||
return FHyperTwistTrainingRunState();
|
||||
}
|
||||
|
||||
FHyperTwistTrainingCase SelectedCase;
|
||||
if (!UHyperTwistTrainingCatalogLibrary::TryGetImportedRuntimeSelectorOptionCaseFromDeck(
|
||||
ActiveRunState.ActiveDeck,
|
||||
SelectorId,
|
||||
OptionId,
|
||||
SelectedCase))
|
||||
{
|
||||
return FHyperTwistTrainingRunState();
|
||||
}
|
||||
|
||||
FHyperTwistTrainingDeck SelectedDeck = ActiveRunState.ActiveDeck;
|
||||
SelectedDeck.SelectionPolicy = EHyperTwistTrainingSelectionPolicy::Scripted;
|
||||
SelectedDeck.Cases.Reset();
|
||||
SelectedDeck.Cases.Add(SelectedCase);
|
||||
SelectedDeck.Tags.AddUnique(TEXT("runtime-surface:selector-option-applied"));
|
||||
SelectedDeck.Tags.AddUnique(FString::Printf(TEXT("selector:%s"), *SelectorId.ToLower()));
|
||||
SelectedDeck.Tags.AddUnique(FString::Printf(TEXT("selector-option:%s"), *OptionId.ToLower()));
|
||||
|
||||
return StartTrainingRunFromDeck(
|
||||
SelectedDeck,
|
||||
ActiveRunState.Session.UserId,
|
||||
ActiveRunState.Session.TrainingSessionId,
|
||||
ActiveRunState.Session.Mode
|
||||
);
|
||||
}
|
||||
|
||||
FHyperTwistTrainingMethodDrillRunState UHyperTwistTrainingSubsystem::GetActiveMethodDrillRunState() const
|
||||
{
|
||||
return ActiveMethodDrillRunState;
|
||||
|
|
|
|||
|
|
@ -154,6 +154,14 @@ public:
|
|||
TArray<FHyperTwistTrainingCase>& OutCases
|
||||
);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Catalog")
|
||||
static bool TryGetImportedRuntimeSelectorOptionCaseFromDeck(
|
||||
const FHyperTwistTrainingDeck& Deck,
|
||||
const FString& SelectorId,
|
||||
const FString& OptionId,
|
||||
FHyperTwistTrainingCase& OutCase
|
||||
);
|
||||
|
||||
UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Catalog")
|
||||
static FHyperTwistTrainingMethodDescriptor DescribeTrainingDeckMethod(
|
||||
const FHyperTwistTrainingDeck& Deck
|
||||
|
|
|
|||
|
|
@ -48,6 +48,13 @@ public:
|
|||
TArray<FHyperTwistTrainingCase>& OutCases
|
||||
);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training", meta = (WorldContext = "WorldContextObject"))
|
||||
static FHyperTwistTrainingRunState ApplyActiveImportedRuntimeSelectorOption(
|
||||
UObject* WorldContextObject,
|
||||
const FString& SelectorId,
|
||||
const FString& OptionId
|
||||
);
|
||||
|
||||
UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Drill", meta = (WorldContext = "WorldContextObject"))
|
||||
static FHyperTwistTrainingMethodDrillRunState GetActiveMethodDrillRunState(UObject* WorldContextObject);
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,12 @@ public:
|
|||
TArray<FHyperTwistTrainingCase>& OutCases
|
||||
) const;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training")
|
||||
FHyperTwistTrainingRunState ApplyActiveImportedRuntimeSelectorOption(
|
||||
const FString& SelectorId,
|
||||
const FString& OptionId
|
||||
);
|
||||
|
||||
UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Drill")
|
||||
FHyperTwistTrainingMethodDrillRunState GetActiveMethodDrillRunState() const;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue