|
|
|
|
@@ -31,18 +31,12 @@ ALuprexGameModeBase::ALuprexGameModeBase()
|
|
|
|
|
//PrimaryActorTick.bCanEverTick = true; // Probably wrong
|
|
|
|
|
//PrimaryActorTick.bTickEvenWhenPaused = true; // Probably wrong
|
|
|
|
|
//PrimaryActorTick.TickGroup = TG_PrePhysics; // Probably wrong
|
|
|
|
|
SetActorTickEnabled(true);
|
|
|
|
|
SetActorTickInterval(0.0f);
|
|
|
|
|
ResetToInitialState();
|
|
|
|
|
OnWorldPreActorTickHandle = FWorldDelegates::OnWorldPreActorTick.AddUObject(this, &ALuprexGameModeBase::OnWorldPreActorTick);
|
|
|
|
|
OnWorldPostActorTickHandle = FWorldDelegates::OnWorldPostActorTick.AddUObject(this, &ALuprexGameModeBase::OnWorldPostActorTick);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ALuprexGameModeBase::~ALuprexGameModeBase()
|
|
|
|
|
{
|
|
|
|
|
ResetToInitialState();
|
|
|
|
|
FWorldDelegates::OnWorldPreActorTick.Remove(OnWorldPreActorTickHandle);
|
|
|
|
|
FWorldDelegates::OnWorldPostActorTick.Remove(OnWorldPostActorTickHandle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This method runs in the background thread,
|
|
|
|
|
@@ -74,6 +68,7 @@ uint32 ALuprexGameModeBase::Run() {
|
|
|
|
|
void ALuprexGameModeBase::ResetToInitialState()
|
|
|
|
|
{
|
|
|
|
|
Playing = false;
|
|
|
|
|
TickEnabled = true;
|
|
|
|
|
|
|
|
|
|
if (TangibleManager != nullptr) {
|
|
|
|
|
TangibleManager->ConditionalBeginDestroy();
|
|
|
|
|
@@ -85,6 +80,12 @@ void ALuprexGameModeBase::ResetToInitialState()
|
|
|
|
|
AssetLookup = nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Stop the tick functions.
|
|
|
|
|
FWorldDelegates::OnWorldPreActorTick.Remove(OnWorldPreActorTickHandle);
|
|
|
|
|
FWorldDelegates::OnWorldPostActorTick.Remove(OnWorldPostActorTickHandle);
|
|
|
|
|
OnWorldPreActorTickHandle.Reset();
|
|
|
|
|
OnWorldPostActorTickHandle.Reset();
|
|
|
|
|
|
|
|
|
|
// Shut down the thread
|
|
|
|
|
LuprexUpdateTask.Shutdown();
|
|
|
|
|
|
|
|
|
|
@@ -256,7 +257,7 @@ void ALuprexGameModeBase::ConsoleSendInput(const FString& fs)
|
|
|
|
|
|
|
|
|
|
void ALuprexGameModeBase::OnWorldPreActorTick(UWorld* InWorld, ELevelTick InLevelTick, float deltaseconds)
|
|
|
|
|
{
|
|
|
|
|
if(Playing && (GetWorld() == InWorld) && (InLevelTick == LEVELTICK_All))
|
|
|
|
|
if(Playing && TickEnabled && (GetWorld() == InWorld) && (InLevelTick == LEVELTICK_All))
|
|
|
|
|
{
|
|
|
|
|
LuprexUpdateTask.Wait();
|
|
|
|
|
EngineSeconds += deltaseconds;
|
|
|
|
|
@@ -269,18 +270,12 @@ void ALuprexGameModeBase::OnWorldPreActorTick(UWorld* InWorld, ELevelTick InLeve
|
|
|
|
|
|
|
|
|
|
void ALuprexGameModeBase::OnWorldPostActorTick(UWorld* InWorld, ELevelTick InLevelTick, float deltaseconds)
|
|
|
|
|
{
|
|
|
|
|
if(Playing && (GetWorld() == InWorld) && (InLevelTick == LEVELTICK_All))
|
|
|
|
|
if(Playing && TickEnabled && (GetWorld() == InWorld) && (InLevelTick == LEVELTICK_All))
|
|
|
|
|
{
|
|
|
|
|
LuprexUpdateTask.Trigger();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ALuprexGameModeBase::Tick(float deltaseconds)
|
|
|
|
|
{
|
|
|
|
|
Super::Tick(deltaseconds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ALuprexGameModeBase::BeginPlay()
|
|
|
|
|
{
|
|
|
|
|
ResetToInitialState();
|
|
|
|
|
@@ -341,6 +336,11 @@ void ALuprexGameModeBase::InitializeGlobalState()
|
|
|
|
|
LuprexUpdateTask.Startup(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Playing) {
|
|
|
|
|
OnWorldPreActorTickHandle = FWorldDelegates::OnWorldPreActorTick.AddUObject(this, &ALuprexGameModeBase::OnWorldPreActorTick);
|
|
|
|
|
OnWorldPostActorTickHandle = FWorldDelegates::OnWorldPostActorTick.AddUObject(this, &ALuprexGameModeBase::OnWorldPostActorTick);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Initialize the asset lookup table.
|
|
|
|
|
AssetLookup = NewObject<UlxAssetLookup>(this);
|
|
|
|
|
AssetLookup->RebuildIndex();
|
|
|
|
|
|