Match Settings
For more flexibility, match parameters are stored in Instanced Objects.
Preset
You can find match presets to quickly test the game.
For example, if you take a look at DA_AFT_Versus_SettingsPreset
, this is the same preset used in Training Mode.
Each "type" of setting is encapsulated in a UObject
.
For example, TimeLimit holds the parameters for the match timer,
and Character Selection Settings handles which players/characters are selected.
The preset is simply a set of pre-filled values for better readability and easier modification during testing.
Runtime
Here’s an example of how match parameters can be modified at runtime, as seen in W_AFT_MIN_MatchSettings_Versus
:
You can see that the singleton function GetOrCreateMatchSettingsInstance
retrieves (or creates)
a Versus-type match settings instance and assigns the new values to it.
Sync with Deterministic Battle
The loading of match parameters — in order to synchronize them with the deterministic battle state — is handled, for example, here:
void UAFTBattleModeSettings::Load(UAFTGGPOGameStateComponent* GameStateComponent)
{
FAFTBattleStateObject& bs = GameStateComponent->GetBattleState()->GetBS();
bs.Timer.Infinity = GameStateComponent->BattleModeSettingsInfo.bInfiniteTimer;
bs.Timer.FrameTimeMax = GameStateComponent->BattleModeSettingsInfo.TimeLimitSeconds * 60;
bs.RoundMax = GameStateComponent->BattleModeSettingsInfo.RoundMax;
}
void UAFTBattleModeSettings::ComputeFromLocalStorage()
{
FAFTBattleModeSettingInfo BattleModeSettingInfo;
auto* BattleSettingStorage = UAFTGameplayStatics::GetSubModuleByClass<UAFTLocalStorageModule>(this)->BattleSetting;
auto* MatchSettingsInstance = BattleSettingStorage->GetCurrentMatchSettingsInstance();
auto* TimeLimitSetting = MatchSettingsInstance->GetSettingByClass<UAFTTimeLimitSetting>();
auto* SideSelectSettings = MatchSettingsInstance->GetSettingByClass<UAFTSideSelectSettings>();
auto* VictoryConditionSetting = MatchSettingsInstance->GetSettingByClass<UAFTVictoryConditionSetting>();
BattleModeSettingInfo.RoundMax = VictoryConditionSetting->MaxRounds;
BattleModeSettingInfo.bInfiniteTimer = TimeLimitSetting->bIsInfiniteTime;
BattleModeSettingInfo.TimeLimitSeconds = TimeLimitSetting->TimeLimitSeconds;
ComputedBattleModeSettingInfo = BattleModeSettingInfo;
// Character selections
CharacterSelectInfos.Reset();
CharacterSelectInfos.Add(SideSelectSettings->P1_CharacterSide);
CharacterSelectInfos.Add(SideSelectSettings->P2_CharacterSide);
}