-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
239 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
Source/DungeonGenerator/Private/DungeonLevelStreamingActor.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
\author Shun Moriya | ||
\copyright 2023- Shun Moriya | ||
All Rights Reserved. | ||
*/ | ||
|
||
#include "DungeonLevelStreamingActor.h" | ||
#include <Components/BoxComponent.h> | ||
#include <GameFramework/Character.h> | ||
#include <Kismet/GameplayStatics.h> | ||
|
||
ADungeonLevelStreamingActor::ADungeonLevelStreamingActor(const FObjectInitializer& initializer) | ||
: Super(initializer) | ||
{ | ||
PrimaryActorTick.bCanEverTick = true; | ||
|
||
OverlapVolume = CreateDefaultSubobject<UBoxComponent>(TEXT("OverlapVolume")); | ||
OverlapVolume->OnComponentBeginOverlap.AddUniqueDynamic(this, &ADungeonLevelStreamingActor::OverlapBegins); | ||
OverlapVolume->OnComponentEndOverlap.AddUniqueDynamic(this, &ADungeonLevelStreamingActor::OverlapEnds); | ||
RootComponent = OverlapVolume; | ||
} | ||
|
||
void ADungeonLevelStreamingActor::OverlapBegins(UPrimitiveComponent* overlappedComponent, AActor* otherActor, UPrimitiveComponent* otherComp, int32 otherBodyIndex, bool fromSweep, const FHitResult& sweepResult) | ||
{ | ||
if (Path.IsValid()) | ||
{ | ||
ACharacter* MyCharacter = UGameplayStatics::GetPlayerCharacter(this, 0); | ||
if (otherActor == Cast<AActor>(MyCharacter)) | ||
{ | ||
FLatentActionInfo LatentInfo; | ||
UGameplayStatics::LoadStreamLevel(this, Path.GetLongPackageFName(), true, true, LatentInfo); | ||
#if 0 | ||
ULevelStreaming* level = UGameplayStatics::GetStreamingLevel(GetWorld(), LevelToLoad); | ||
level->LevelTransform = GetTransform(); | ||
level->SetShouldBeVisible(true); | ||
#endif | ||
} | ||
} | ||
} | ||
|
||
void ADungeonLevelStreamingActor::OverlapEnds(UPrimitiveComponent* overlappedComponent, AActor* otherActor, UPrimitiveComponent* otherComp, int32 otherBodyIndex) | ||
{ | ||
if (Path.IsValid()) | ||
{ | ||
ACharacter* MyCharacter = UGameplayStatics::GetPlayerCharacter(this, 0); | ||
if (otherActor == Cast<AActor>(MyCharacter)) | ||
{ | ||
FLatentActionInfo LatentInfo; | ||
UGameplayStatics::UnloadStreamLevel(this, Path.GetLongPackageFName(), LatentInfo, false); | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
Source/DungeonGenerator/Private/DungeonLevelStreamingDynamic.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.