Move save logic from NakatomiCharacter to PlayerCharacter
This commit is contained in:
		
							parent
							
								
									0e9a36f1c9
								
							
						
					
					
						commit
						804a752aa5
					
				| @ -5,7 +5,6 @@ | |||||||
| 
 | 
 | ||||||
| #include "NakatomiCMC.h" | #include "NakatomiCMC.h" | ||||||
| #include "NakatomiGameInstance.h" | #include "NakatomiGameInstance.h" | ||||||
| #include "Kismet/GameplayStatics.h" |  | ||||||
| 
 | 
 | ||||||
| // Sets default values
 | // Sets default values
 | ||||||
| ANakatomiCharacter::ANakatomiCharacter(const FObjectInitializer& ObjectInitializer) : Super( | ANakatomiCharacter::ANakatomiCharacter(const FObjectInitializer& ObjectInitializer) : Super( | ||||||
| @ -32,15 +31,6 @@ void ANakatomiCharacter::BeginPlay() | |||||||
| 	SetInventoryToDefault(); | 	SetInventoryToDefault(); | ||||||
| 
 | 
 | ||||||
| 	NakatomiCMC = Cast<UNakatomiCMC>(GetCharacterMovement()); | 	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
 | // Called every frame
 | ||||||
|  | |||||||
| @ -13,6 +13,7 @@ | |||||||
| #include "InputTriggers.h" | #include "InputTriggers.h" | ||||||
| #include "InteractableComponent.h" | #include "InteractableComponent.h" | ||||||
| #include "NakatomiCMC.h" | #include "NakatomiCMC.h" | ||||||
|  | #include "NakatomiGameInstance.h" | ||||||
| #include "WeaponThrowable.h" | #include "WeaponThrowable.h" | ||||||
| #include "NiagaraFunctionLibrary.h" | #include "NiagaraFunctionLibrary.h" | ||||||
| #include "GameFramework/CharacterMovementComponent.h"	 | #include "GameFramework/CharacterMovementComponent.h"	 | ||||||
| @ -80,6 +81,15 @@ void APlayerCharacter::BeginPlay() | |||||||
| 
 | 
 | ||||||
| 	AimSensitivity = DefaultAimSensitivity; | 	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"))) | 	if (!this->ActorHasTag(FName("Player"))) | ||||||
| 	{ | 	{ | ||||||
| 		this->Tags.Add(FName("Player")); | 		this->Tags.Add(FName("Player")); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user