diff --git a/EndlessVendetta/.idea/.idea.EndlessVendetta/.idea/workspace.xml b/EndlessVendetta/.idea/.idea.EndlessVendetta/.idea/workspace.xml
index 5d2c3eff..aa29ae48 100644
--- a/EndlessVendetta/.idea/.idea.EndlessVendetta/.idea/workspace.xml
+++ b/EndlessVendetta/.idea/.idea.EndlessVendetta/.idea/workspace.xml
@@ -9,10 +9,12 @@
-
-
+
+
+
+
@@ -129,7 +131,7 @@
1706900339638
-
+
diff --git a/EndlessVendetta/Content/StarterContent/Architecture/Floor_400x400.uasset b/EndlessVendetta/Content/StarterContent/Architecture/Floor_400x400.uasset
index 5f51ceb6..c2a34afc 100644
--- a/EndlessVendetta/Content/StarterContent/Architecture/Floor_400x400.uasset
+++ b/EndlessVendetta/Content/StarterContent/Architecture/Floor_400x400.uasset
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:54d78cbc2e7ef625432ee7b2da07e34a29fc46f230ab4ba5105f1efd2c9c7ca3
-size 14831
+oid sha256:4c0ecf0ac0702cc2bd355ec050232a61c49e10f102448efbeb735a51824adef6
+size 14948
diff --git a/EndlessVendetta/Content/StarterContent/Audio/Collapse01.uasset b/EndlessVendetta/Content/StarterContent/Audio/Collapse01.uasset
index 5e3ff30e..24412998 100644
--- a/EndlessVendetta/Content/StarterContent/Audio/Collapse01.uasset
+++ b/EndlessVendetta/Content/StarterContent/Audio/Collapse01.uasset
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:85c827023ee4b466228ec65e92b4b4a0415a106de041ac1c2cab481a2a5dfa8d
-size 348532
+oid sha256:3d2b0daf585d5c6052afc625471c8e235e09c7b6f76185220074287885b3fc06
+size 353648
diff --git a/EndlessVendetta/Source/EndlessVendetta/Characters/BountyHunterCharacter.cpp b/EndlessVendetta/Source/EndlessVendetta/Characters/BountyHunterCharacter.cpp
index 7e60169a..dd05262f 100644
--- a/EndlessVendetta/Source/EndlessVendetta/Characters/BountyHunterCharacter.cpp
+++ b/EndlessVendetta/Source/EndlessVendetta/Characters/BountyHunterCharacter.cpp
@@ -5,14 +5,10 @@
#include "Kismet/GameplayStatics.h"
#include "EnhancedInputComponent.h"
-void ABountyHunterCharacter::SpawnMainBounty()
+void ABountyHunterCharacter::SpawnMainBounty(UEVGameInstance* GI)
{
- UEVGameInstance* GI = Cast(GetGameInstance());
- if (!IsValid(GI->MainSaveGameInstanceRef)) return;
CurrentMainBountyIndex = GI->MainSaveGameInstanceRef->LastMainBountyIndexInOpenWorld;
- UE_LOG(LogTemp, Warning, TEXT("Loaded current bounty as %d"), CurrentMainBountyIndex);
-
if (GI->MainSaveGameInstanceRef->CurrentMainBountyIndexSave > CurrentMainBountyIndex) CompleteCurrentMainBounty(GI);
if (MainBountyClasses.IsEmpty() || MainBountyClasses.Num() <= CurrentMainBountyIndex|| !IsValid(MainBountyClasses[CurrentMainBountyIndex]))
@@ -49,7 +45,17 @@ void ABountyHunterCharacter::AllBountiesCompleted()
void ABountyHunterCharacter::BeginPlay()
{
- if (UGameplayStatics::DoesSaveGameExist("MainSave", 0)) SpawnMainBounty();
+ UEVGameInstance* GI = Cast(GetGameInstance());
+ if (IsValid(GI->MainSaveGameInstanceRef))
+ {
+ SpawnMainBounty(GI);
+ FTransform SpawnLoc = GI->MainSaveGameInstanceRef->PlayerOpenWorldSpawnTransformSave;
+ if (SpawnLoc.GetLocation() != FVector(0, 0, 0) && UGameplayStatics::GetCurrentLevelName(GetWorld()) == OpenWorldLevelName)
+ {
+ SetActorTransform(GI->MainSaveGameInstanceRef->PlayerOpenWorldSpawnTransformSave);
+ Cast(GetController())->SetControlRotation(GI->MainSaveGameInstanceRef->PlayerOpenWorldSpawnTransformSave.GetRotation().Rotator());
+ }
+ }
Super::BeginPlay();
}
@@ -94,3 +100,31 @@ void ABountyHunterCharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
+
+void ABountyHunterCharacter::EndPlay(const EEndPlayReason::Type EndPlayReason)
+{
+ Super::EndPlay(EndPlayReason);
+ if (UGameplayStatics::GetCurrentLevelName(GetWorld()) != OpenWorldLevelName) return;
+ UEVGameInstance* GI = Cast(GetGameInstance());
+ if (!IsValid(GI->MainSaveGameInstanceRef)) return;
+ TArray LandingZones;
+ ALandingZone* ClosestLandingZone = nullptr;
+ double DistToClosestLandingZone;
+ UGameplayStatics::GetAllActorsOfClass(GetWorld(), ALandingZone::StaticClass(), LandingZones);
+ for (AActor* LZ_Actor : LandingZones)
+ {
+ ALandingZone* LZ = Cast(LZ_Actor);
+ double DistToLZ = FVector::Dist(LZ->GetExitTransform().GetLocation(), GetActorLocation());
+ if (!IsValid(ClosestLandingZone))
+ {
+ ClosestLandingZone = LZ;
+ DistToClosestLandingZone = DistToLZ;
+ continue;
+ }
+ ClosestLandingZone = DistToClosestLandingZone >= DistToLZ ? LZ : ClosestLandingZone;
+ DistToClosestLandingZone = DistToClosestLandingZone >= DistToLZ ? DistToLZ : DistToClosestLandingZone;
+ }
+ if (!IsValid(ClosestLandingZone)) return;
+ GI->MainSaveGameInstanceRef->PlayerOpenWorldSpawnTransformSave = ClosestLandingZone->GetExitTransform();
+ UGameplayStatics::SaveGameToSlot(GI->MainSaveGameInstanceRef, "MainSave", 0);
+}
diff --git a/EndlessVendetta/Source/EndlessVendetta/Characters/BountyHunterCharacter.h b/EndlessVendetta/Source/EndlessVendetta/Characters/BountyHunterCharacter.h
index 7b6df1db..e628b489 100644
--- a/EndlessVendetta/Source/EndlessVendetta/Characters/BountyHunterCharacter.h
+++ b/EndlessVendetta/Source/EndlessVendetta/Characters/BountyHunterCharacter.h
@@ -58,7 +58,7 @@ public:
// ------------------- METHODS ---------------------------------
private:
// Spawns Current Main Bounty along with its Side Bounties, and spawns its appropriate CP's based on level
- void SpawnMainBounty();
+ void SpawnMainBounty(UEVGameInstance* GI);
// Collects Reward for Current Main Bounty and Increments the Main Bounty Index
void CompleteCurrentMainBounty(UEVGameInstance* GI);
@@ -78,6 +78,9 @@ protected:
// Called every frame
virtual void Tick(float DeltaTime) override;
+
+ // Called When Actor destroyed or Removed from Level
+ virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
public:
// Used by Final Checkpoint to always load the Level set as the Open Level in here
FString GetOpenWorldLevelName()
diff --git a/EndlessVendetta/Source/EndlessVendetta/MainSaveGameClass.h b/EndlessVendetta/Source/EndlessVendetta/MainSaveGameClass.h
index 3d7937da..ccd11131 100644
--- a/EndlessVendetta/Source/EndlessVendetta/MainSaveGameClass.h
+++ b/EndlessVendetta/Source/EndlessVendetta/MainSaveGameClass.h
@@ -27,5 +27,7 @@ public:
UPROPERTY()
TSubclassOf SecondaryWeaponClassSave;
-
+
+ UPROPERTY()
+ FTransform PlayerOpenWorldSpawnTransformSave;
};
diff --git a/EndlessVendetta/Source/EndlessVendetta/SpaceShip/LandingZone.h b/EndlessVendetta/Source/EndlessVendetta/SpaceShip/LandingZone.h
index 8ff2cbbf..75234e19 100644
--- a/EndlessVendetta/Source/EndlessVendetta/SpaceShip/LandingZone.h
+++ b/EndlessVendetta/Source/EndlessVendetta/SpaceShip/LandingZone.h
@@ -68,4 +68,10 @@ public:
// Updates all LZ's, then runs enter ship func on player passing the correct takeoff transform
void Takeoff();
+
+ // Returns Exit Transform for LZ, Used for Save System for when Player Leaves Open World
+ FTransform GetExitTransform()
+ {
+ return LZ_ExitTransform;
+ }
};