Levels
This commit is contained in:
parent
0226afe5ae
commit
39ab5e17a8
@ -39,7 +39,7 @@ void ACameraModeBase::BeginPlay()
|
|||||||
{
|
{
|
||||||
if(auto inputSubsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PC->GetLocalPlayer()))
|
if(auto inputSubsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PC->GetLocalPlayer()))
|
||||||
{
|
{
|
||||||
if(auto GI = Cast<UCustomGameInstanceBase>(GetWorld()->GetGameInstance()))
|
if(auto GI = UCustomGameInstanceBase::GetGameInstance())
|
||||||
{
|
{
|
||||||
inputSubsystem->ClearAllMappings();
|
inputSubsystem->ClearAllMappings();
|
||||||
for(auto& inputContext : GI->inputContexts)
|
for(auto& inputContext : GI->inputContexts)
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
// Oleg Petruny proprietary.
|
// Oleg Petruny proprietary.
|
||||||
|
|
||||||
|
|
||||||
#include "CustomGameInstanceBase.h"
|
#include "CustomGameInstanceBase.h"
|
||||||
|
|
||||||
#include "EnhancedInputLibrary.h"
|
#include "EnhancedInputLibrary.h"
|
||||||
|
@ -20,12 +20,9 @@ UCutsceneManager::UCutsceneManager()
|
|||||||
{
|
{
|
||||||
static ConstructorHelpers::FObjectFinder<UInputMappingContext> asset{ TEXT("/Script/EnhancedInput.InputMappingContext'/Game/Input/IMC_Cutscene.IMC_Cutscene'") };
|
static ConstructorHelpers::FObjectFinder<UInputMappingContext> asset{ TEXT("/Script/EnhancedInput.InputMappingContext'/Game/Input/IMC_Cutscene.IMC_Cutscene'") };
|
||||||
_inputContext = asset.Object;
|
_inputContext = asset.Object;
|
||||||
if(auto world = GetWorld())
|
if(auto GI = UCustomGameInstanceBase::GetGameInstance())
|
||||||
{
|
{
|
||||||
if(auto GI = Cast<UCustomGameInstanceBase>(world->GetGameInstance()))
|
GI->inputContexts.Add(_inputContext);
|
||||||
{
|
|
||||||
GI->inputContexts.Add(_inputContext);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,12 +22,9 @@ UDialogueManager::UDialogueManager()
|
|||||||
{
|
{
|
||||||
static ConstructorHelpers::FObjectFinder<UInputMappingContext> asset{ TEXT("/Script/EnhancedInput.InputMappingContext'/Game/Input/IMC_Dialogue.IMC_Dialogue'") };
|
static ConstructorHelpers::FObjectFinder<UInputMappingContext> asset{ TEXT("/Script/EnhancedInput.InputMappingContext'/Game/Input/IMC_Dialogue.IMC_Dialogue'") };
|
||||||
_inputContext = asset.Object;
|
_inputContext = asset.Object;
|
||||||
if(auto world = GetWorld())
|
if(auto GI = UCustomGameInstanceBase::GetGameInstance())
|
||||||
{
|
{
|
||||||
if(auto GI = Cast<UCustomGameInstanceBase>(world->GetGameInstance()))
|
GI->inputContexts.Add(_inputContext);
|
||||||
{
|
|
||||||
GI->inputContexts.Add(_inputContext);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,12 +11,9 @@ void UInteractableModificator::OnRegister()
|
|||||||
{
|
{
|
||||||
UActorComponent::OnRegister();
|
UActorComponent::OnRegister();
|
||||||
|
|
||||||
if(auto world = GetWorld())
|
if(auto GI = UCustomGameInstanceBase::GetGameInstance())
|
||||||
{
|
{
|
||||||
if(auto GI = Cast<UCustomGameInstanceBase>(world->GetGameInstance()))
|
GI->AppendInteractableModificatorClass(this->GetClass());
|
||||||
{
|
|
||||||
GI->AppendInteractableModificatorClass(this->GetClass());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
// Oleg Petruny proprietary.
|
// Oleg Petruny proprietary.
|
||||||
|
|
||||||
|
|
||||||
#include "Checkpoint.h"
|
#include "Checkpoint.h"
|
||||||
|
|
||||||
#include "CustomGameInstanceBase.h"
|
#include "CustomGameInstanceBase.h"
|
||||||
|
|
||||||
void ACheckpoint::SaveGame()
|
void ACheckpoint::SaveGame()
|
||||||
{
|
{
|
||||||
if(auto GI = Cast<UCustomGameInstanceBase>(GetWorld()->GetGameInstance()))
|
if(auto GI = UCustomGameInstanceBase::GetGameInstance())
|
||||||
GI->SaveGame(GetFName());
|
GI->SaveGame(GetFName());
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "Checkpoint.generated.h"
|
#include "Checkpoint.generated.h"
|
||||||
|
|
||||||
|
/** Simple actor for game save */
|
||||||
UCLASS(Blueprintable, BlueprintType, MinimalAPI)
|
UCLASS(Blueprintable, BlueprintType, MinimalAPI)
|
||||||
class ACheckpoint : public AActor
|
class ACheckpoint : public AActor
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
// Oleg Petruny proprietary.
|
// Oleg Petruny proprietary.
|
||||||
|
|
||||||
|
|
||||||
#include "Level1.h"
|
#include "Level1.h"
|
||||||
|
|
||||||
#include "Atmosphere/AtmosphericFog.h"
|
#include "Atmosphere/AtmosphericFog.h"
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
// Oleg Petruny proprietary.
|
// Oleg Petruny proprietary.
|
||||||
|
|
||||||
|
|
||||||
#include "Level2.h"
|
#include "Level2.h"
|
||||||
|
|
||||||
void ALevel2::BeginPlay()
|
void ALevel2::BeginPlay()
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
// Oleg Petruny proprietary.
|
// Oleg Petruny proprietary.
|
||||||
|
|
||||||
|
|
||||||
#include "Level3.h"
|
#include "Level3.h"
|
||||||
|
|
||||||
#include "Atmosphere/AtmosphericFog.h"
|
#include "Atmosphere/AtmosphericFog.h"
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
// Oleg Petruny proprietary.
|
// Oleg Petruny proprietary.
|
||||||
|
|
||||||
|
|
||||||
#include "Level4.h"
|
#include "Level4.h"
|
||||||
|
|
||||||
#include "Atmosphere/AtmosphericFog.h"
|
#include "Atmosphere/AtmosphericFog.h"
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
// Oleg Petruny proprietary.
|
// Oleg Petruny proprietary.
|
||||||
|
|
||||||
|
|
||||||
#include "Level5.h"
|
#include "Level5.h"
|
||||||
|
|
||||||
#include "Atmosphere/AtmosphericFog.h"
|
#include "Atmosphere/AtmosphericFog.h"
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
// Oleg Petruny proprietary.
|
// Oleg Petruny proprietary.
|
||||||
|
|
||||||
|
|
||||||
#include "LevelBase.h"
|
#include "LevelBase.h"
|
||||||
|
|
||||||
#include "Engine/StaticMesh.h"
|
#include "Engine/StaticMesh.h"
|
||||||
@ -23,14 +22,11 @@ void ALevelBase::BeginPlay()
|
|||||||
{
|
{
|
||||||
AMainGameModeBase::leadLevel = TStrongObjectPtr<ALevelBase>{ this };
|
AMainGameModeBase::leadLevel = TStrongObjectPtr<ALevelBase>{ this };
|
||||||
|
|
||||||
if(auto world = GetWorld())
|
if(auto GI = UCustomGameInstanceBase::GetGameInstance())
|
||||||
{
|
{
|
||||||
if(auto GI = Cast<UCustomGameInstanceBase>(world->GetGameInstance()))
|
for(TActorIterator<AMinigame> it(GetWorld()); it; ++it)
|
||||||
{
|
{
|
||||||
for(TActorIterator<AMinigame> it(GetWorld()); it; ++it)
|
GI->inputContexts.Add(it->GetInputMappings());
|
||||||
{
|
|
||||||
GI->inputContexts.Add(it->GetInputMappings());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +58,7 @@ void ALevelBase::IterateToState(int32 to)
|
|||||||
|
|
||||||
void ALevelBase::BroadcastNewLevelBeginPlay()
|
void ALevelBase::BroadcastNewLevelBeginPlay()
|
||||||
{
|
{
|
||||||
if(auto GI = Cast<UCustomGameInstanceBase>(GetWorld()->GetGameInstance()))
|
if(auto GI = UCustomGameInstanceBase::GetGameInstance())
|
||||||
GI->OnLevelBeginned.Broadcast(GetFName());
|
GI->OnLevelBeginned.Broadcast(GetFName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,15 +6,24 @@
|
|||||||
|
|
||||||
#include "LevelBase.generated.h"
|
#include "LevelBase.generated.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expands basic UE level script actor.
|
||||||
|
* Has int type level states and events.
|
||||||
|
* Brodcasts level instantiation by CustomGameInstance::OnLevelBeginned(FName).
|
||||||
|
* On BeginPlay applies last save data if valid,
|
||||||
|
* and instantiate all sequencers from array onBeginPlaySequences.
|
||||||
|
*/
|
||||||
UCLASS(BlueprintType)
|
UCLASS(BlueprintType)
|
||||||
class ALevelBase : public ALevelScriptActor
|
class ALevelBase : public ALevelScriptActor
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/** Iterates throught level states */
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
inline void CallNextState() { ++state; NextState(); }
|
inline void CallNextState() { ++state; NextState(); }
|
||||||
|
|
||||||
|
/** Calls specific event id in level */
|
||||||
UFUNCTION(BlueprintImplementableEvent)
|
UFUNCTION(BlueprintImplementableEvent)
|
||||||
void CallEvent(int32 id);
|
void CallEvent(int32 id);
|
||||||
|
|
||||||
@ -23,9 +32,11 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
|
/** Notifies level to process current state */
|
||||||
UFUNCTION(BlueprintImplementableEvent)
|
UFUNCTION(BlueprintImplementableEvent)
|
||||||
void NextState();
|
void NextState();
|
||||||
|
|
||||||
|
/** Shortcut for iterating from current to expected state */
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void IterateToState(int32 to);
|
void IterateToState(int32 to);
|
||||||
|
|
||||||
@ -33,12 +44,13 @@ protected:
|
|||||||
void StartLevelAnimations();
|
void StartLevelAnimations();
|
||||||
void ApplySaveData();
|
void ApplySaveData();
|
||||||
|
|
||||||
|
/** List of level animations for instantiation on level BeginPlay */
|
||||||
UPROPERTY(EditDefaultsOnly)
|
UPROPERTY(EditDefaultsOnly)
|
||||||
TArray<TSoftObjectPtr<class ULevelSequence>> onBeginPlaySequences;
|
TArray<TSoftObjectPtr<class ULevelSequence>> onBeginPlaySequences;
|
||||||
|
/** Cache of actors that hold instantiated animations on BeginPlay */
|
||||||
TArray<class ALevelSequenceActor*> onBeginPlaySequencesActors;
|
TArray<class ALevelSequenceActor*> onBeginPlaySequencesActors;
|
||||||
|
|
||||||
|
/** Current state of level */
|
||||||
UPROPERTY(BlueprintReadOnly)
|
UPROPERTY(BlueprintReadOnly)
|
||||||
int32 state = -1;
|
int32 state = -1;
|
||||||
UPROPERTY(EditDefaultsOnly)
|
|
||||||
TArray<TSoftObjectPtr<class ULevelSequence>> stateSequences;
|
|
||||||
};
|
};
|
||||||
|
@ -89,7 +89,7 @@ void APlayerBase::BeginPlay()
|
|||||||
{
|
{
|
||||||
if(auto inputSubsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(playerController->GetLocalPlayer()))
|
if(auto inputSubsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(playerController->GetLocalPlayer()))
|
||||||
{
|
{
|
||||||
if(auto GI = Cast<UCustomGameInstanceBase>(GetWorld()->GetGameInstance()))
|
if(auto GI = UCustomGameInstanceBase::GetGameInstance())
|
||||||
{
|
{
|
||||||
inputSubsystem->ClearAllMappings();
|
inputSubsystem->ClearAllMappings();
|
||||||
for(auto& inputContext : GI->inputContexts)
|
for(auto& inputContext : GI->inputContexts)
|
||||||
@ -257,22 +257,23 @@ void APlayerBase::UpdatePitch(float min, float max)
|
|||||||
|
|
||||||
void APlayerBase::LoadInteractablesActivators()
|
void APlayerBase::LoadInteractablesActivators()
|
||||||
{
|
{
|
||||||
if(auto GI = Cast<UCustomGameInstanceBase>(GetWorld()->GetGameInstance()))
|
auto GI = UCustomGameInstanceBase::GetGameInstance();
|
||||||
{
|
if(!GI)
|
||||||
TSet<UClass*> instancedActivators;
|
return;
|
||||||
for(auto& act : GI->interactionsActivators)
|
|
||||||
{
|
|
||||||
if(instancedActivators.Contains(act))
|
|
||||||
continue;
|
|
||||||
instancedActivators.Add(act);
|
|
||||||
|
|
||||||
auto component = NewObject<UInteractableActivator>(this, act);
|
TSet<UClass*> instancedActivators;
|
||||||
component->interactableActivatedDelegate.BindUObject(this, &APlayerBase::InteractableActivated);
|
for(auto& act : GI->interactionsActivators)
|
||||||
component->interactableDeactivatedDelegate.BindUObject(this, &APlayerBase::InteractableDeactivated);
|
{
|
||||||
component->SetupAttachment(camera);
|
if(instancedActivators.Contains(act))
|
||||||
component->RegisterComponent();
|
continue;
|
||||||
interactableActivators.Add(component);
|
instancedActivators.Add(act);
|
||||||
}
|
|
||||||
|
auto component = NewObject<UInteractableActivator>(this, act);
|
||||||
|
component->interactableActivatedDelegate.BindUObject(this, &APlayerBase::InteractableActivated);
|
||||||
|
component->interactableDeactivatedDelegate.BindUObject(this, &APlayerBase::InteractableDeactivated);
|
||||||
|
component->SetupAttachment(camera);
|
||||||
|
component->RegisterComponent();
|
||||||
|
interactableActivators.Add(component);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,13 +14,11 @@ bool UMainMenuWidget::Initialize()
|
|||||||
{
|
{
|
||||||
if(ButtonLoadLastSave)
|
if(ButtonLoadLastSave)
|
||||||
{
|
{
|
||||||
if(auto GI = UCustomGameInstanceBase::GetGameInstance())
|
auto GI = UCustomGameInstanceBase::GetGameInstance();
|
||||||
|
if(GI && GI->saveData)
|
||||||
{
|
{
|
||||||
if(GI->saveData)
|
ButtonLoadLastSave->SetIsEnabled(true);
|
||||||
{
|
ButtonLoadLastSave->SetRenderOpacity(1.0f);
|
||||||
ButtonLoadLastSave->SetIsEnabled(true);
|
|
||||||
ButtonLoadLastSave->SetRenderOpacity(1.0f);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user