This repository has been archived on 2026-05-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
AgrarianGameArchive/Source/AgrarianGame/AgrarianGameGameMode.cpp
T
2026-05-18 15:23:01 -07:00

38 lines
1.4 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "AgrarianGameGameMode.h"
#include "AgrarianGameCharacter.h"
#include "AgrarianDebugHUD.h"
#include "AgrarianGameState.h"
#include "AgrarianPersistenceSubsystem.h"
AAgrarianGameGameMode::AAgrarianGameGameMode()
{
GameStateClass = AAgrarianGameState::StaticClass();
HUDClass = AAgrarianDebugHUD::StaticClass();
}
void AAgrarianGameGameMode::RestartPlayer(AController* NewPlayer)
{
Super::RestartPlayer(NewPlayer);
AAgrarianGameCharacter* AgrarianCharacter = NewPlayer ? Cast<AAgrarianGameCharacter>(NewPlayer->GetPawn()) : nullptr;
UAgrarianPersistenceSubsystem* Persistence = GetGameInstance() ? GetGameInstance()->GetSubsystem<UAgrarianPersistenceSubsystem>() : nullptr;
if (AgrarianCharacter && Persistence && Persistence->RestorePlayerSnapshot(AgrarianCharacter))
{
UE_LOG(LogTemp, Log, TEXT("Agrarian restored reconnect snapshot for %s."), *AgrarianCharacter->GetName());
}
}
void AAgrarianGameGameMode::Logout(AController* Exiting)
{
AAgrarianGameCharacter* AgrarianCharacter = Exiting ? Cast<AAgrarianGameCharacter>(Exiting->GetPawn()) : nullptr;
UAgrarianPersistenceSubsystem* Persistence = GetGameInstance() ? GetGameInstance()->GetSubsystem<UAgrarianPersistenceSubsystem>() : nullptr;
if (AgrarianCharacter && Persistence)
{
Persistence->SavePlayerSnapshot(AgrarianCharacter);
}
Super::Logout(Exiting);
}