You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.7 KiB
66 lines
1.7 KiB
12 months ago
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||
|
|
||
|
|
||
|
#include "StateMachineSubsystem.h"
|
||
|
|
||
|
void UStateMachineSubsystem::Initialize(FSubsystemCollectionBase& Collection)
|
||
|
{
|
||
|
Super::Initialize(Collection);
|
||
|
CurrentState = EGameState::MainMenu;
|
||
|
UE_LOG(LogTemp, Display, TEXT("Starting game state machine in MAINMENU state"))
|
||
|
}
|
||
|
|
||
|
bool UStateMachineSubsystem::ChangeState(EGameState NewState)
|
||
|
{
|
||
|
// Exit from old state
|
||
|
switch (CurrentState)
|
||
|
{
|
||
|
case EGameState::MainMenu:
|
||
|
switch(NewState)
|
||
|
{
|
||
|
case EGameState::Battle:
|
||
|
UE_LOG(LogTemp, Display, TEXT("Entering BATTLE state from MAINMENU"))
|
||
|
break;
|
||
|
default:
|
||
|
UE_LOG(LogTemp, Error, TEXT("NewState is invalid from MAINMENU state: %hhd"), NewState)
|
||
|
return false;
|
||
|
}
|
||
|
break;
|
||
|
case EGameState::Battle:
|
||
|
switch(NewState)
|
||
|
{
|
||
|
case EGameState::BattleMenu:
|
||
|
UE_LOG(LogTemp, Display, TEXT("Entering BATTLEMENU state from BATTLE"))
|
||
|
break;
|
||
|
case EGameState::GameOver:
|
||
|
UE_LOG(LogTemp, Display, TEXT("Entering GAMEOVER state from BATTLE"))
|
||
|
break;
|
||
|
case EGameState::Victory:
|
||
|
UE_LOG(LogTemp, Display, TEXT("Entering VICTORY state from BATTLE"))
|
||
|
break;
|
||
|
default:
|
||
|
UE_LOG(LogTemp, Error, TEXT("NewState is invalid from BATTLE state: %hhd"), NewState)
|
||
|
return false;
|
||
|
}
|
||
|
break;
|
||
|
case EGameState::BattleMenu:
|
||
|
switch(NewState)
|
||
|
{
|
||
|
case EGameState::Battle:
|
||
|
UE_LOG(LogTemp, Error, TEXT("Entering BATTLE state from BATTLEMENU"))
|
||
|
break;
|
||
|
default:
|
||
|
UE_LOG(LogTemp, Error, TEXT("NewState is invalid from BATTLEMENU state: %hhd"), NewState)
|
||
|
return false;
|
||
|
}
|
||
|
break;
|
||
|
default:
|
||
|
UE_LOG(LogTemp, Error, TEXT("Leaving unknown state, this is a problem"))
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
CurrentState = NewState;
|
||
|
StateChangedDelegate.Broadcast(NewState);
|
||
|
return true;
|
||
|
}
|