Removed LZs from Save System and Replaced with Last Location
This commit is contained in:
parent
a2018e02ac
commit
d45f659af9
BIN
EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset
(Stored with Git LFS)
Binary file not shown.
@ -149,25 +149,26 @@ void ABountyHunterCharacter::EndPlay(const EEndPlayReason::Type EndPlayReason)
|
||||
if (UGameplayStatics::GetCurrentLevelName(GetWorld()) != OpenWorldLevelName) return;
|
||||
UEVGameInstance* GI = Cast<UEVGameInstance>(GetGameInstance());
|
||||
if (!IsValid(GI->MainSaveGameInstanceRef)) return;
|
||||
TArray<AActor*> LandingZones;
|
||||
ALandingZone* ClosestLandingZone = nullptr;
|
||||
double DistToClosestLandingZone;
|
||||
UGameplayStatics::GetAllActorsOfClass(GetWorld(), ALandingZone::StaticClass(), LandingZones);
|
||||
for (AActor* LZ_Actor : LandingZones)
|
||||
{
|
||||
ALandingZone* LZ = Cast<ALandingZone>(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();
|
||||
GI->MainSaveGameInstanceRef->PlayerOpenWorldSpawnTransformSave = GetActorTransform();
|
||||
// TArray<AActor*> LandingZones;
|
||||
// ALandingZone* ClosestLandingZone = nullptr;
|
||||
// double DistToClosestLandingZone;
|
||||
// UGameplayStatics::GetAllActorsOfClass(GetWorld(), ALandingZone::StaticClass(), LandingZones);
|
||||
// for (AActor* LZ_Actor : LandingZones)
|
||||
// {
|
||||
// ALandingZone* LZ = Cast<ALandingZone>(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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user