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 GI = Cast<UCustomGameInstanceBase>(GetWorld()->GetGameInstance()))
|
||||
if(auto GI = UCustomGameInstanceBase::GetGameInstance())
|
||||
{
|
||||
inputSubsystem->ClearAllMappings();
|
||||
for(auto& inputContext : GI->inputContexts)
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Oleg Petruny proprietary.
|
||||
|
||||
|
||||
#include "CustomGameInstanceBase.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'") };
|
||||
_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'") };
|
||||
_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();
|
||||
|
||||
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.
|
||||
|
||||
|
||||
#include "Checkpoint.h"
|
||||
|
||||
#include "CustomGameInstanceBase.h"
|
||||
|
||||
void ACheckpoint::SaveGame()
|
||||
{
|
||||
if(auto GI = Cast<UCustomGameInstanceBase>(GetWorld()->GetGameInstance()))
|
||||
if(auto GI = UCustomGameInstanceBase::GetGameInstance())
|
||||
GI->SaveGame(GetFName());
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "Checkpoint.generated.h"
|
||||
|
||||
/** Simple actor for game save */
|
||||
UCLASS(Blueprintable, BlueprintType, MinimalAPI)
|
||||
class ACheckpoint : public AActor
|
||||
{
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Oleg Petruny proprietary.
|
||||
|
||||
|
||||
#include "Level1.h"
|
||||
|
||||
#include "Atmosphere/AtmosphericFog.h"
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Oleg Petruny proprietary.
|
||||
|
||||
|
||||
#include "Level2.h"
|
||||
|
||||
void ALevel2::BeginPlay()
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Oleg Petruny proprietary.
|
||||
|
||||
|
||||
#include "Level3.h"
|
||||
|
||||
#include "Atmosphere/AtmosphericFog.h"
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Oleg Petruny proprietary.
|
||||
|
||||
|
||||
#include "Level4.h"
|
||||
|
||||
#include "Atmosphere/AtmosphericFog.h"
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Oleg Petruny proprietary.
|
||||
|
||||
|
||||
#include "Level5.h"
|
||||
|
||||
#include "Atmosphere/AtmosphericFog.h"
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Oleg Petruny proprietary.
|
||||
|
||||
|
||||
#include "LevelBase.h"
|
||||
|
||||
#include "Engine/StaticMesh.h"
|
||||
@ -23,14 +22,11 @@ void ALevelBase::BeginPlay()
|
||||
{
|
||||
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()
|
||||
{
|
||||
if(auto GI = Cast<UCustomGameInstanceBase>(GetWorld()->GetGameInstance()))
|
||||
if(auto GI = UCustomGameInstanceBase::GetGameInstance())
|
||||
GI->OnLevelBeginned.Broadcast(GetFName());
|
||||
}
|
||||
|
||||
|
@ -6,15 +6,24 @@
|
||||
|
||||
#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)
|
||||
class ALevelBase : public ALevelScriptActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
/** Iterates throught level states */
|
||||
UFUNCTION(BlueprintCallable)
|
||||
inline void CallNextState() { ++state; NextState(); }
|
||||
|
||||
/** Calls specific event id in level */
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
void CallEvent(int32 id);
|
||||
|
||||
@ -23,9 +32,11 @@ public:
|
||||
protected:
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
/** Notifies level to process current state */
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
void NextState();
|
||||
|
||||
/** Shortcut for iterating from current to expected state */
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void IterateToState(int32 to);
|
||||
|
||||
@ -33,12 +44,13 @@ protected:
|
||||
void StartLevelAnimations();
|
||||
void ApplySaveData();
|
||||
|
||||
/** List of level animations for instantiation on level BeginPlay */
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
TArray<TSoftObjectPtr<class ULevelSequence>> onBeginPlaySequences;
|
||||
/** Cache of actors that hold instantiated animations on BeginPlay */
|
||||
TArray<class ALevelSequenceActor*> onBeginPlaySequencesActors;
|
||||
|
||||
/** Current state of level */
|
||||
UPROPERTY(BlueprintReadOnly)
|
||||
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 GI = Cast<UCustomGameInstanceBase>(GetWorld()->GetGameInstance()))
|
||||
if(auto GI = UCustomGameInstanceBase::GetGameInstance())
|
||||
{
|
||||
inputSubsystem->ClearAllMappings();
|
||||
for(auto& inputContext : GI->inputContexts)
|
||||
@ -257,22 +257,23 @@ void APlayerBase::UpdatePitch(float min, float max)
|
||||
|
||||
void APlayerBase::LoadInteractablesActivators()
|
||||
{
|
||||
if(auto GI = Cast<UCustomGameInstanceBase>(GetWorld()->GetGameInstance()))
|
||||
{
|
||||
TSet<UClass*> instancedActivators;
|
||||
for(auto& act : GI->interactionsActivators)
|
||||
{
|
||||
if(instancedActivators.Contains(act))
|
||||
continue;
|
||||
instancedActivators.Add(act);
|
||||
auto GI = UCustomGameInstanceBase::GetGameInstance();
|
||||
if(!GI)
|
||||
return;
|
||||
|
||||
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);
|
||||
}
|
||||
TSet<UClass*> instancedActivators;
|
||||
for(auto& act : GI->interactionsActivators)
|
||||
{
|
||||
if(instancedActivators.Contains(act))
|
||||
continue;
|
||||
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(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