Move save logic from NakatomiCharacter to PlayerCharacter
This commit is contained in:
parent
0e9a36f1c9
commit
804a752aa5
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "NakatomiCMC.h"
|
||||
#include "NakatomiGameInstance.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
|
||||
// Sets default values
|
||||
ANakatomiCharacter::ANakatomiCharacter(const FObjectInitializer& ObjectInitializer) : Super(
|
||||
|
@ -32,15 +31,6 @@ void ANakatomiCharacter::BeginPlay()
|
|||
SetInventoryToDefault();
|
||||
|
||||
NakatomiCMC = Cast<UNakatomiCMC>(GetCharacterMovement());
|
||||
|
||||
if (UNakatomiGameInstance* gameInstance = Cast<UNakatomiGameInstance>(UGameplayStatics::GetGameInstance(GetWorld())))
|
||||
{
|
||||
if (UNakatomiSaveGame* Save = gameInstance->GetSaveGameObject())
|
||||
{
|
||||
//TODO: More loading here
|
||||
GetHealthComponent()->SetCurrentHealth(Save->PlayerHealth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Called every frame
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "InputTriggers.h"
|
||||
#include "InteractableComponent.h"
|
||||
#include "NakatomiCMC.h"
|
||||
#include "NakatomiGameInstance.h"
|
||||
#include "WeaponThrowable.h"
|
||||
#include "NiagaraFunctionLibrary.h"
|
||||
#include "GameFramework/CharacterMovementComponent.h"
|
||||
|
@ -80,6 +81,15 @@ void APlayerCharacter::BeginPlay()
|
|||
|
||||
AimSensitivity = DefaultAimSensitivity;
|
||||
|
||||
if (UNakatomiGameInstance* gameInstance = Cast<UNakatomiGameInstance>(UGameplayStatics::GetGameInstance(GetWorld())))
|
||||
{
|
||||
if (UNakatomiSaveGame* Save = gameInstance->GetSaveGameObject())
|
||||
{
|
||||
//TODO: More loading here
|
||||
GetHealthComponent()->SetCurrentHealth(Save->PlayerHealth);
|
||||
}
|
||||
}
|
||||
|
||||
if (!this->ActorHasTag(FName("Player")))
|
||||
{
|
||||
this->Tags.Add(FName("Player"));
|
||||
|
|
Loading…
Reference in New Issue