Пример #1
0
void AGameState::PostInitializeComponents()
{
	Super::PostInitializeComponents();

	GetWorldTimerManager().SetTimer(this, &AGameState::DefaultTimer, GetWorldSettings()->GetEffectiveTimeDilation(), true);

	UWorld* World = GetWorld();
	World->GameState = this;

	for (FActorIterator It(World); It; ++It)
	{
		AActor* TestActor = *It;
		if (TestActor && !TestActor->IsPendingKill() && TestActor->IsA<APlayerState>())
		{
			APlayerState* PlayerState = Cast<APlayerState>(TestActor);
			AddPlayerState(PlayerState);
		}
	}
}
Пример #2
0
void AGameState::PostInitializeComponents()
{
	Super::PostInitializeComponents();

	FTimerManager& TimerManager = GetWorldTimerManager();
	TimerManager.SetTimer(TimerHandle_DefaultTimer, this, &AGameState::DefaultTimer, 1.0f / GetWorldSettings()->GetEffectiveTimeDilation(), true);

	UWorld* World = GetWorld();
	World->GameState = this;

	if (World->IsGameWorld() && Role == ROLE_Authority)
	{
		UpdateServerTimeSeconds();
		if (ServerWorldTimeSecondsUpdateFrequency > 0.f)
		{
			TimerManager.SetTimer(TimerHandle_UpdateServerTimeSeconds, this, &AGameState::UpdateServerTimeSeconds, ServerWorldTimeSecondsUpdateFrequency, true);
		}
	}

	for (TActorIterator<APlayerState> It(World); It; ++It)
	{
		AddPlayerState(*It);
	}
}