Add plastique item
Add Door object Initial work for look up animation
This commit is contained in:
@@ -31,6 +31,8 @@ public partial class App : Node, IApp
|
||||
|
||||
[Node] private GalleryMenu GalleryMenu { get; set; }
|
||||
|
||||
[Node] private VideoStreamPlayer VideoStreamPlayer { get; set; }
|
||||
|
||||
IAppRepo IProvide<IAppRepo>.Value() => AppRepo;
|
||||
|
||||
public IAppRepo AppRepo { get; set; } = default!;
|
||||
@@ -53,141 +55,144 @@ public partial class App : Node, IApp
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
_container = new SimpleInjector.Container();
|
||||
_container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle();
|
||||
_container.RegisterSingleton<IAppRepo, AppRepo>();
|
||||
_container.RegisterSingleton<IAppLogic, AppLogic>();
|
||||
_container.RegisterSingleton<IFileSystem, FileSystem>();
|
||||
_container.RegisterSingleton<ISaveFileManager, SaveFileManager>();
|
||||
_container = new SimpleInjector.Container();
|
||||
_container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle();
|
||||
_container.RegisterSingleton<IAppRepo, AppRepo>();
|
||||
_container.RegisterSingleton<IAppLogic, AppLogic>();
|
||||
_container.RegisterSingleton<IFileSystem, FileSystem>();
|
||||
_container.RegisterSingleton<ISaveFileManager, SaveFileManager>();
|
||||
|
||||
_saveFileManager = _container.GetInstance<ISaveFileManager>();
|
||||
_optionsSavePath = $"{OS.GetUserDataDir()}/options.json";
|
||||
_controllerSavePath = $"{OS.GetUserDataDir()}/controls.json";
|
||||
_saveFileManager = _container.GetInstance<ISaveFileManager>();
|
||||
_optionsSavePath = $"{OS.GetUserDataDir()}/options.json";
|
||||
_controllerSavePath = $"{OS.GetUserDataDir()}/controls.json";
|
||||
|
||||
Task.Run(() => _saveFileManager.ReadFromFile<OptionsData>(_optionsSavePath).ContinueWith((data) =>
|
||||
{
|
||||
if (data.IsCompletedSuccessfully)
|
||||
OptionsMenu.CallDeferred("Load", data.Result);
|
||||
}));
|
||||
MainMenu.StartGame += OnStartGame;
|
||||
MainMenu.EnemyViewer += OnEnemyViewer;
|
||||
MainMenu.Gallery += OnGallery;
|
||||
MainMenu.Options += OnOptions;
|
||||
MainMenu.Quit += OnQuit;
|
||||
|
||||
Task.Run(() => _saveFileManager.ReadFromFile<string>(_controllerSavePath).ContinueWith((data) =>
|
||||
{
|
||||
if (data.IsCompletedSuccessfully)
|
||||
OptionsMenu.Controller.CallDeferred(nameof(OptionsMenu.Controller.LoadControllerInput), data.Result);
|
||||
}));
|
||||
GalleryMenu.GalleryExited += GalleryExited;
|
||||
|
||||
MainMenu.StartGame += OnStartGame;
|
||||
MainMenu.EnemyViewer += OnEnemyViewer;
|
||||
MainMenu.Gallery += OnGallery;
|
||||
MainMenu.Options += OnOptions;
|
||||
MainMenu.Quit += OnQuit;
|
||||
OptionsMenu.OptionsMenuExited += OptionsMenu_OptionsMenuExited;
|
||||
OptionsMenu.DeleteSaveData += DeleteSaveData;
|
||||
AppRepo = _container.GetInstance<IAppRepo>();
|
||||
AppLogic = _container.GetInstance<IAppLogic>();
|
||||
|
||||
GalleryMenu.GalleryExited += GalleryExited;
|
||||
Task.Run(() => _saveFileManager.ReadFromFile<string>(_controllerSavePath).ContinueWith((data) =>
|
||||
{
|
||||
if (data.IsCompletedSuccessfully)
|
||||
OptionsMenu.Controller.CallDeferred(nameof(OptionsMenu.Controller.LoadControllerInput), data.Result);
|
||||
}));
|
||||
|
||||
OptionsMenu.OptionsMenuExited += OptionsMenu_OptionsMenuExited;
|
||||
OptionsMenu.DeleteSaveData += DeleteSaveData;
|
||||
AppRepo = _container.GetInstance<IAppRepo>();
|
||||
AppLogic = _container.GetInstance<IAppLogic>();
|
||||
AppLogic.Set(AppRepo);
|
||||
AppLogic.Set(new AppLogic.Data());
|
||||
|
||||
AppLogic.Set(AppRepo);
|
||||
AppLogic.Set(new AppLogic.Data());
|
||||
AppRepo.DataViewerExited += DataViewerExited;
|
||||
|
||||
AppRepo.DataViewerExited += DataViewerExited;
|
||||
|
||||
Input.MouseMode = Input.MouseModeEnum.Visible;
|
||||
_progress = [];
|
||||
this.Provide();
|
||||
Input.MouseMode = Input.MouseModeEnum.Visible;
|
||||
_progress = [];
|
||||
this.Provide();
|
||||
}
|
||||
|
||||
private void GameExitRequested()
|
||||
{
|
||||
AppLogic.Input(new AppLogic.Input.QuitGame());
|
||||
AppLogic.Input(new AppLogic.Input.QuitGame());
|
||||
}
|
||||
|
||||
private void DeleteSaveData()
|
||||
{
|
||||
var saveFileManager = _container.GetInstance<ISaveFileManager>();
|
||||
saveFileManager.DeleteSaveData();
|
||||
var saveFileManager = _container.GetInstance<ISaveFileManager>();
|
||||
saveFileManager.DeleteSaveData();
|
||||
}
|
||||
|
||||
private void DataViewerExited()
|
||||
{
|
||||
AppLogic.Input(new AppLogic.Input.EnemyViewerExited());
|
||||
AppLogic.Input(new AppLogic.Input.EnemyViewerExited());
|
||||
}
|
||||
|
||||
private async void OptionsMenu_OptionsMenuExited()
|
||||
{
|
||||
var saveFileManager = _container.GetInstance<ISaveFileManager>();
|
||||
await saveFileManager.WriteToFile(OptionsMenu.OptionsData, _optionsSavePath);
|
||||
var controllerOutput = InputHelper.SerializeInputsForActions();
|
||||
await saveFileManager.WriteToFile(controllerOutput, _controllerSavePath);
|
||||
OptionsMenu.Hide();
|
||||
MainMenu.OptionsButton.GrabFocus();
|
||||
var saveFileManager = _container.GetInstance<ISaveFileManager>();
|
||||
await saveFileManager.WriteToFile(OptionsMenu.OptionsData, _optionsSavePath);
|
||||
var controllerOutput = InputHelper.SerializeInputsForActions();
|
||||
await saveFileManager.WriteToFile(controllerOutput, _controllerSavePath);
|
||||
OptionsMenu.Hide();
|
||||
MainMenu.OptionsButton.GrabFocus();
|
||||
}
|
||||
|
||||
private void GalleryExited()
|
||||
{
|
||||
GalleryMenu.Hide();
|
||||
MainMenu.GalleryButton.GrabFocus();
|
||||
GalleryMenu.Hide();
|
||||
MainMenu.GalleryButton.GrabFocus();
|
||||
}
|
||||
|
||||
public void OnReady()
|
||||
{
|
||||
AppBinding = AppLogic.Bind();
|
||||
AppBinding = AppLogic.Bind();
|
||||
|
||||
AppBinding
|
||||
.Handle((in AppLogic.Output.ShowSplashScreen _) =>
|
||||
{
|
||||
})
|
||||
.Handle((in AppLogic.Output.HideSplashScreen _) =>
|
||||
{
|
||||
})
|
||||
.Handle((in AppLogic.Output.SetupGameScene _) =>
|
||||
{
|
||||
LoadingScreen.Show();
|
||||
LoadGame(GAME_SCENE_PATH);
|
||||
})
|
||||
.Handle((in AppLogic.Output.ShowMainMenu _) =>
|
||||
{
|
||||
})
|
||||
.Handle((in AppLogic.Output.CloseGame _) =>
|
||||
{
|
||||
LoadingScreen.Hide();
|
||||
_game.GameExitRequested -= GameExitRequested;
|
||||
MainMenu.StartGameButton.GrabFocus();
|
||||
_game.CallDeferred(MethodName.QueueFree, []);
|
||||
GetTree().Paused = false;
|
||||
})
|
||||
.Handle((in AppLogic.Output.StartLoadingSaveFile _) =>
|
||||
{
|
||||
})
|
||||
.Handle((in AppLogic.Output.EnemyViewerOpened _) =>
|
||||
{
|
||||
LoadingScreen.Show();
|
||||
LoadEnemyViewer(ENEMY_VIEWER_PATH);
|
||||
})
|
||||
.Handle((in AppLogic.Output.EnemyViewerExited _) =>
|
||||
{
|
||||
LoadingScreen.Hide();
|
||||
if (_enemyViewer != null && _enemyViewer is DataViewer enemyViewer)
|
||||
enemyViewer.CallDeferred(MethodName.QueueFree);
|
||||
MainMenu.Show();
|
||||
MainMenu.EnemyViewerButton.GrabFocus();
|
||||
})
|
||||
.Handle((in AppLogic.Output.ExitGame _) =>
|
||||
{
|
||||
GetTree().Quit();
|
||||
});
|
||||
AppBinding
|
||||
.Handle((in AppLogic.Output.Initialize _) =>
|
||||
{
|
||||
Task.Run(() => _saveFileManager.ReadFromFile<string>(_optionsSavePath).ContinueWith((data) =>
|
||||
{
|
||||
AppLogic.Input(new AppLogic.Input.SaveFileLoaded());
|
||||
}));
|
||||
})
|
||||
.Handle((in AppLogic.Output.ShowSplashScreen _) =>
|
||||
{
|
||||
AppLogic.Input(new AppLogic.Input.FadeOutFinished());
|
||||
})
|
||||
.Handle((in AppLogic.Output.HideSplashScreen _) =>
|
||||
{
|
||||
})
|
||||
.Handle((in AppLogic.Output.SetupGameScene _) =>
|
||||
{
|
||||
LoadingScreen.Show();
|
||||
LoadGame(GAME_SCENE_PATH);
|
||||
})
|
||||
.Handle((in AppLogic.Output.ShowMainMenu _) =>
|
||||
{
|
||||
MainMenu.CallDeferred(MainMenu.MethodName.FadeIn);
|
||||
})
|
||||
.Handle((in AppLogic.Output.CloseGame _) =>
|
||||
{
|
||||
LoadingScreen.Hide();
|
||||
_game.GameExitRequested -= GameExitRequested;
|
||||
MainMenu.StartGameButton.GrabFocus();
|
||||
_game.CallDeferred(MethodName.QueueFree, []);
|
||||
GetTree().Paused = false;
|
||||
})
|
||||
.Handle((in AppLogic.Output.StartLoadingSaveFile _) =>
|
||||
{
|
||||
})
|
||||
.Handle((in AppLogic.Output.EnemyViewerOpened _) =>
|
||||
{
|
||||
LoadingScreen.Show();
|
||||
LoadEnemyViewer(ENEMY_VIEWER_PATH);
|
||||
})
|
||||
.Handle((in AppLogic.Output.EnemyViewerExited _) =>
|
||||
{
|
||||
LoadingScreen.Hide();
|
||||
if (_enemyViewer != null && _enemyViewer is DataViewer enemyViewer)
|
||||
enemyViewer.CallDeferred(MethodName.QueueFree);
|
||||
MainMenu.Show();
|
||||
MainMenu.EnemyViewerButton.GrabFocus();
|
||||
})
|
||||
.Handle((in AppLogic.Output.ExitGame _) =>
|
||||
{
|
||||
GetTree().Quit();
|
||||
});
|
||||
|
||||
AppLogic.Start();
|
||||
AppLogic.Start();
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (_reportedProgress < 1)
|
||||
LoadingScreen.ProgressBar.Value = Mathf.RoundToInt(Mathf.Lerp(LoadingScreen.ProgressBar.Value, _reportedProgress * 100, (float)delta * 2));
|
||||
else
|
||||
LoadingScreen.ProgressBar.Value = Mathf.RoundToInt(Mathf.Lerp(LoadingScreen.ProgressBar.Value, 200, (float)delta * 5));
|
||||
if (_reportedProgress < 1)
|
||||
LoadingScreen.ProgressBar.Value = Mathf.RoundToInt(Mathf.Lerp(LoadingScreen.ProgressBar.Value, _reportedProgress * 100, (float)delta * 2));
|
||||
else
|
||||
LoadingScreen.ProgressBar.Value = Mathf.RoundToInt(Mathf.Lerp(LoadingScreen.ProgressBar.Value, 200, (float)delta * 5));
|
||||
}
|
||||
|
||||
public void OnStartGame() => AppLogic.Input(new AppLogic.Input.NewGame());
|
||||
@@ -198,64 +203,64 @@ public partial class App : Node, IApp
|
||||
|
||||
private async void LoadGame(string sceneName)
|
||||
{
|
||||
var scene = await LoadSceneInternal(sceneName);
|
||||
_game = scene as IGame;
|
||||
_game.GameExitRequested += GameExitRequested;
|
||||
await ToSignal(GetTree().CreateTimer(0.8f), "timeout");
|
||||
CallDeferred(MethodName.AddChild, scene);
|
||||
var scene = await LoadSceneInternal(sceneName);
|
||||
_game = scene as IGame;
|
||||
_game.GameExitRequested += GameExitRequested;
|
||||
await ToSignal(GetTree().CreateTimer(0.8f), "timeout");
|
||||
CallDeferred(MethodName.AddChild, scene);
|
||||
}
|
||||
|
||||
private async void LoadEnemyViewer(string sceneName)
|
||||
{
|
||||
var scene = await LoadSceneInternal(sceneName);
|
||||
_enemyViewer = scene as IDataViewer;
|
||||
await ToSignal(GetTree().CreateTimer(0.8f), "timeout");
|
||||
CallDeferred(MethodName.AddChild, scene);
|
||||
var scene = await LoadSceneInternal(sceneName);
|
||||
_enemyViewer = scene as IDataViewer;
|
||||
await ToSignal(GetTree().CreateTimer(0.8f), "timeout");
|
||||
CallDeferred(MethodName.AddChild, scene);
|
||||
}
|
||||
|
||||
private async Task<Node> LoadSceneInternal(string sceneName)
|
||||
{
|
||||
LoadingScreen.Show();
|
||||
LoadingScreen.ProgressBar.Value = 0;
|
||||
var sceneLoader = new SceneLoader();
|
||||
CallDeferred(MethodName.AddChild, sceneLoader);
|
||||
sceneLoader.LoadSceneRequest(sceneName);
|
||||
sceneLoader.SceneReportedProgress += SceneLoader_SceneReportedProgress;
|
||||
await ToSignal(sceneLoader, SceneLoader.SignalName.SceneLoaded);
|
||||
var result = sceneLoader.LoadedScene;
|
||||
sceneLoader.QueueFree();
|
||||
return result;
|
||||
LoadingScreen.Show();
|
||||
LoadingScreen.ProgressBar.Value = 0;
|
||||
var sceneLoader = new SceneLoader();
|
||||
CallDeferred(MethodName.AddChild, sceneLoader);
|
||||
sceneLoader.LoadSceneRequest(sceneName);
|
||||
sceneLoader.SceneReportedProgress += SceneLoader_SceneReportedProgress;
|
||||
await ToSignal(sceneLoader, SceneLoader.SignalName.SceneLoaded);
|
||||
var result = sceneLoader.LoadedScene;
|
||||
sceneLoader.QueueFree();
|
||||
return result;
|
||||
}
|
||||
|
||||
private void SceneLoader_SceneReportedProgress(double progress) => _reportedProgress = progress;
|
||||
|
||||
private async void OnOptions()
|
||||
{
|
||||
OptionsMenu.Show();
|
||||
OptionsMenu.GameTab.GrabFocus();
|
||||
OptionsMenu.Show();
|
||||
OptionsMenu.GameTab.GrabFocus();
|
||||
}
|
||||
|
||||
private async void OnGallery()
|
||||
{
|
||||
GalleryMenu.Show();
|
||||
GalleryMenu.ItemButton1.GrabFocus();
|
||||
GalleryMenu.Show();
|
||||
GalleryMenu.ItemButton1.GrabFocus();
|
||||
}
|
||||
|
||||
public void OnQuit() => AppLogic.Input(new AppLogic.Input.QuitGame());
|
||||
|
||||
public void OnSaveFileLoaded()
|
||||
{
|
||||
AppLogic.Input(new AppLogic.Input.SaveFileLoaded());
|
||||
AppLogic.Input(new AppLogic.Input.SaveFileLoaded());
|
||||
}
|
||||
|
||||
public void OnExitTree()
|
||||
{
|
||||
AppLogic.Stop();
|
||||
AppBinding.Dispose();
|
||||
AppRepo.Dispose();
|
||||
AppLogic.Stop();
|
||||
AppBinding.Dispose();
|
||||
AppRepo.Dispose();
|
||||
|
||||
MainMenu.StartGame -= OnStartGame;
|
||||
MainMenu.EnemyViewer -= OnEnemyViewer;
|
||||
MainMenu.Quit -= OnQuit;
|
||||
MainMenu.StartGame -= OnStartGame;
|
||||
MainMenu.EnemyViewer -= OnEnemyViewer;
|
||||
MainMenu.Quit -= OnQuit;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user