Compare commits
2 Commits
0e9a36f1c9
...
2b5d67346a
Author | SHA1 | Date |
---|---|---|
baz | 2b5d67346a | |
baz | 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
|
||||||
|
|
|
@ -50,8 +50,8 @@ bool UNakatomiGameInstance::SaveGame(bool ResetDefaults)
|
||||||
{
|
{
|
||||||
APlayerCharacter* Player = Cast<APlayerCharacter>(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0));
|
APlayerCharacter* Player = Cast<APlayerCharacter>(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0));
|
||||||
SaveGameObject->PlayerHealth = Player->GetCurrentHealthCount();
|
SaveGameObject->PlayerHealth = Player->GetCurrentHealthCount();
|
||||||
SaveGameObject->WeaponInventory = Player->WeaponInventory;
|
// SaveGameObject->CurrentInventorySlot = Player->GetCurrentInventorySlot();
|
||||||
SaveGameObject->CurrentInventorySlot = Player->GetCurrentInventorySlot();
|
SaveGameObject->ThrowableInventory = Player->ThrowableInventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveGameObject->LevelName = GetWorld()->GetMapName();
|
SaveGameObject->LevelName = GetWorld()->GetMapName();
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
|
#include "Weapon.h"
|
||||||
|
#include "Throwable.h"
|
||||||
#include "NakatomiSaveFileInfo.generated.h"
|
#include "NakatomiSaveFileInfo.generated.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,4 +26,13 @@ struct FNakatomiSaveFileInfo
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Info")
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Info")
|
||||||
FString DateTimeSaved;
|
FString DateTimeSaved;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Info")
|
||||||
|
TArray<AWeapon*> WeaponInventory;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Info")
|
||||||
|
TArray<TSubclassOf<AThrowable>> ThrowableInventory;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Info")
|
||||||
|
int CurrentInventorySlot = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,6 +28,9 @@ public:
|
||||||
UPROPERTY(VisibleAnywhere, Category = Player)
|
UPROPERTY(VisibleAnywhere, Category = Player)
|
||||||
TArray<AWeapon*> WeaponInventory;
|
TArray<AWeapon*> WeaponInventory;
|
||||||
|
|
||||||
|
UPROPERTY(VisibleAnywhere, Category = Player)
|
||||||
|
TArray<TSubclassOf<AThrowable>> ThrowableInventory;
|
||||||
|
|
||||||
UPROPERTY(VisibleAnywhere, Category = Player)
|
UPROPERTY(VisibleAnywhere, Category = Player)
|
||||||
int CurrentInventorySlot = 0;
|
int CurrentInventorySlot = 0;
|
||||||
|
|
||||||
|
|
|
@ -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,21 @@ 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 (Save->ThrowableInventory.Num() > 0)
|
||||||
|
{
|
||||||
|
ThrowableInventory.Empty();
|
||||||
|
ThrowableInventory = Save->ThrowableInventory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!this->ActorHasTag(FName("Player")))
|
if (!this->ActorHasTag(FName("Player")))
|
||||||
{
|
{
|
||||||
this->Tags.Add(FName("Player"));
|
this->Tags.Add(FName("Player"));
|
||||||
|
|
Loading…
Reference in New Issue