RestaurantRunController 오류 수정

This commit is contained in:
NTG 2025-08-18 14:09:56 +09:00
parent cb2970b897
commit 96aa756769
7 changed files with 26 additions and 35 deletions

Binary file not shown.

Binary file not shown.

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 6a8ae0a4b68a9b94889b9889b63ebacd
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -13,8 +13,8 @@ public enum GameFlowState : uint
RunRestaurant = 1u << 1, RunRestaurant = 1u << 1,
SettlementRestaurant = 1u << 2, SettlementRestaurant = 1u << 2,
All = 0xFFFFFFFFu All = 0xFFFFFFFFu
} }
public class GameFlowManager : Singleton<GameFlowManager>, IManager public class GameFlowManager : Singleton<GameFlowManager>, IManager
{ {
public GameFlowDataSo GameFlowDataSo; public GameFlowDataSo GameFlowDataSo;
@ -28,32 +28,32 @@ public void PreInit()
public Task Init() public Task Init()
{ {
return Task.CompletedTask;; return Task.CompletedTask; ;
} }
public void PostInit() public async void PostInit()
{ {
if (IsGameStarted() == false) if (IsGameStarted() == false)
{ {
ChangeFlow(GameFlowState.ReadyForRestaurant); await ChangeFlow(GameFlowState.ReadyForRestaurant);
} }
} }
private bool IsGameStarted() => GameFlowDataSo.CurrentGameState != GameFlowState.None; private bool IsGameStarted() => GameFlowDataSo.CurrentGameState != GameFlowState.None;
public void ChangeFlow(GameFlowState newFlowState) public async Task ChangeFlow(GameFlowState newFlowState)
{ {
if (!CanChangeFlow(newFlowState)) if (CanChangeFlow(newFlowState) == false)
{ {
Debug.LogError("Can't change flow"); Debug.LogError("Can't change flow");
return; return;
} }
_ = EndCurrentFlow();
_ = ReadyNewFlow(newFlowState); await EndCurrentFlow();
await ReadyNewFlow(newFlowState);
} }
private bool CanChangeFlow(GameFlowState newFlowState) private bool CanChangeFlow(GameFlowState newFlowState)
{ {
return true; return true;
@ -62,27 +62,27 @@ private bool CanChangeFlow(GameFlowState newFlowState)
private async Task EndCurrentFlow() private async Task EndCurrentFlow()
{ {
var endCurrentFlowState = GameFlowDataSo.CurrentGameState; var endCurrentFlowState = GameFlowDataSo.CurrentGameState;
foreach (var handler in FlowHandlers) foreach (var handler in FlowHandlers)
{ {
await handler.OnExitCurrentFlow(endCurrentFlowState); await handler.OnExitCurrentFlow(endCurrentFlowState);
} }
} }
private async Task ReadyNewFlow(GameFlowState newFlowState) private async Task ReadyNewFlow(GameFlowState newFlowState)
{ {
GameFlowDataSo.CurrentGameState = newFlowState; GameFlowDataSo.CurrentGameState = newFlowState;
await OpenFlowScene(newFlowState);
foreach (var handler in FlowHandlers) foreach (var handler in FlowHandlers)
{ {
await handler.OnReadyNewFlow(newFlowState); await handler.OnReadyNewFlow(newFlowState);
} }
await OpenFlowScene(newFlowState);
StartFlow(); StartFlow();
} }
private async Task OpenFlowScene(GameFlowState newFlowState) private async Task OpenFlowScene(GameFlowState newFlowState)
{ {
if (GetFlowScene(newFlowState)) if (GetFlowScene(newFlowState))
@ -102,7 +102,7 @@ private bool GetFlowScene(GameFlowState flowState)
private void StartFlow() private void StartFlow()
{ {
} }
} }
} }

View File

@ -8,8 +8,8 @@ public class RestaurantRunController : FlowController
RestaurantCustomerStateSo _restaurantCustomerStateSo; RestaurantCustomerStateSo _restaurantCustomerStateSo;
public override Task InitializeController() public override Task InitializeController()
{ {
return Task.CompletedTask; _restaurantCustomerStateSo = RestaurantState.instance.CustomerState;
return Task.CompletedTask;
} }
public override Task InitializeState() public override Task InitializeState()

View File

@ -9,6 +9,7 @@ public class RestaurantState : ScriptableSingleton<RestaurantState>
public RestaurantRunStateSo RunState { get; private set; } public RestaurantRunStateSo RunState { get; private set; }
public RestaurantEnvironmentStateSo EnvironmentState { get; private set; } public RestaurantEnvironmentStateSo EnvironmentState { get; private set; }
public RestaurantPlayerStateSo PlayerState { get; private set; } public RestaurantPlayerStateSo PlayerState { get; private set; }
public RestaurantCustomerStateSo CustomerState { get; private set; }
// TODO : Load from disk(SaveData) // TODO : Load from disk(SaveData)
private void OnEnable() private void OnEnable()
@ -17,6 +18,7 @@ private void OnEnable()
RunState = CreateInstance<RestaurantRunStateSo>(); RunState = CreateInstance<RestaurantRunStateSo>();
EnvironmentState = CreateInstance<RestaurantEnvironmentStateSo>(); EnvironmentState = CreateInstance<RestaurantEnvironmentStateSo>();
PlayerState = CreateInstance<RestaurantPlayerStateSo>(); PlayerState = CreateInstance<RestaurantPlayerStateSo>();
CustomerState = CreateInstance<RestaurantCustomerStateSo>();
} }
} }
} }