Major Changes including Options menu, logic blocks, modding system, and more.

This commit is contained in:
2026-08-06 01:28:52 -04:00
parent c9ac4641a0
commit b58acff195
90 changed files with 4065 additions and 485 deletions

474
src/App/App.cs Normal file
View File

@@ -0,0 +1,474 @@
namespace FoodFactory;
using Godot;
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using Chickensoft.GodotNodeInterfaces;
using Chickensoft.LogicBlocks.Auto;
using Chickensoft.LogicBlocks;
using System;
using System.Threading.Tasks;
using Chickensoft.UMLGenerator;
using System.Collections.Generic;
using System.Linq;
using FoodFactory.Modding;
using System.IO.Abstractions;
using Chickensoft.Sync.Primitives;
using Chickensoft.SaveFileBuilder;
using System.IO;
using System.Text.Json;
using Chickensoft.Serialization;
using Chickensoft.Collections;
using Chickensoft.Serialization.Godot;
using SJK.Functional;
// using Shouldly;
public interface IApp : ICanvasLayer, IProvide<IAppRepo>, IProvide<IOptionConfig>, IProvide<ISaveService>;
[Meta(typeof(IAutoNode))]
[ClassDiagram(UseVSCodePaths = true)]
public partial class App : CanvasLayer, IApp
{
public const string GAME_PATH = "res://src/Game/Game.tscn";
public override void _Notification(int what) => this.Notify(what);
[Node] public ISubViewport GameViewPort { get; private set; } = default!;
[Node] public Menu.IMainMenu MainMenu {get;set;} = default!;
[Node] public ICreateGameMenu CreateGameMenu {get;set;} = default!;
[Node] public ILoadingGameMenu LoadingGameMenu {get;set;} = default!;
[Node] public IOptionsMenu OptionsMenu {get;set;} = default!;
[Node] public IModMenu ModsMenu {get;set;} = default!;
public IGame Game { get; set; } = default!;
public IAppRepo AppRepo { get; set; } = default!;
public IOptionConfig OptionConfig { get; set; } = default!;
public IAppLogic AppLogic { get; set; } = default!;
public LogicBlock.Binding AppBinding { get; set; } = default!;
IAppRepo IProvide<IAppRepo>.Value() => AppRepo;
IOptionConfig IProvide<IOptionConfig>.Value() => OptionConfig;
private AutoChannel.Binding _binding;
private static JsonSerializerOptions _serializerOptions = new JsonSerializerOptions()
{
Converters = {
new SerializableTypeConverter(new Blackboard())
},
TypeInfoResolver = new SerializableTypeResolver(),
WriteIndented = true
};
public ISaveService SaveService { get; set; } = new SaveService(){
FilePath =Path.Join(OS.GetUserDataDir(), "saves", "game.json.gz"),
CurrentSave =
Chickensoft.SaveFileBuilder.SaveFile.CreateGZipJsonFile(
Path.Join(OS.GetUserDataDir(), "saves", "game.json.gz"),
// Create a standard JsonSerializerOptions with our introspective type
// resolver and the logic blocks converter.
_serializerOptions
)
};
private Dictionary<IOptionKey,Action<Variant>> _settingsBind = [];
public void BindSetting<[MustBeVariant] T>(IOptionKey<T> option, Action<T> action) => _settingsBind.Add(option, variant => action(variant.As<T>()));
public void Initialize()
{
GodotSerialization.Setup();
var fileSystem =new FileSystem();
AppRepo = new AppRepo()
{
ModManger = new ModManger()
{
AllMods = new AllMods("/home/ronnie/Documents/Godot/Projects/ChickenGameTest/mods", fileSystem),
Profiles = new ModProfiles()
}
};
AppRepo.ModManger.Profiles.Add(("base", [.. AppRepo.ModManger.AllMods.GetMods()]));
AppRepo.ModManger.Profiles.Add(("test", []));
// GD.Print(string.Join(',', AppRepo.ModManger.AllMods.GetMods()));
AppLogic = new AppLogic();
AppLogic.Set(AppRepo);
OptionConfig = new TestConfig();
((TestConfig)OptionConfig).OnSettingChanged += AppRepo.OnSettingChanged;
BindSetting(OptionConfig.SettingKeys.Video.RenderQuality, value => GameViewPort.Scaling3DScale = value);
BindSetting(OptionConfig.SettingKeys.Video.FullScreen, value => DisplayServer.WindowSetMode(value ? DisplayServer.WindowMode.Fullscreen : DisplayServer.WindowMode.Windowed));
_binding = AppRepo.AutoChannel.Bind();
_binding.On<IAppRepo.GameSettingChanged>((in setting) =>
{
GD.Print(setting);
if (_settingsBind.GetValue(setting.Setting).HasValue(out var action)){
action(setting.Value);
}
return;
if (setting.Setting is OptionKey<bool> key && key.Key == "FullScreen")
{
DisplayServer.WindowSetMode(setting.Value.As<bool>() ? DisplayServer.WindowMode.Fullscreen : DisplayServer.WindowMode.Windowed );
}
if (setting.Setting is OptionKey<float> key2 && key2.Key == "RenderQuality")
{
GameViewPort.Scaling3DScale = setting.Value.As<float>() / 100f;
}
});
_binding.On((in IAppRepo.GameExiting exiting) =>
{
AppLogic.Input(new AppLogicState.Input.EndGame(ExitGameReason.QuitToMenu));
});
MainMenu.NewGame += OnNewGame;
MainMenu.LastGame += () =>
{
var path = fileSystem.File.ReadAllText(Path.Combine(OS.GetUserDataDir(), "lastGame.txt"));
AppLogic.Input(new AppLogicState.Input.LoadGame());
OnLoadSaveGame(path);
};
MainMenu.LoadGame += OnLoadGame;
MainMenu.Options += OnOptions;
MainMenu.Exit += () => GetTree().Quit();
MainMenu.Mods += OnMods;
// =>
// {
// var vbox = new VBoxContainer();
// vbox.SetAnchorsPreset(Control.LayoutPreset.Center);
// foreach (var item in AppRepo.ModManger.AllMods.GetMods())
// {
// var b = new Button(){Text = item.ModName};
// b.Pressed += () =>
// {
// var p = AppRepo.ModManger.Profiles;
// if (p.Current.Contains(item))
// {
// p.Current.Remove(item);
// }
// else
// {
// p.Current.Add(item);
// }
// b.Text += "a";
// };
// vbox.AddChild(b);
// }
// MainMenu.AddChild(vbox);
// };
OptionsMenu.OnMenuExit += OnMenuExit;
CreateGameMenu.Exit += OnMenuExit;
CreateGameMenu.NewGame += OnNewGame;
CreateGameMenu.LevelSelected += (index) => GD.Print("selected ",index);
LoadingGameMenu.Exit += OnMenuExit;
LoadingGameMenu.LoadGame += index => OnLoadSaveGame(GetSaves()[index]);
MainMenu.SetLastGameVisible(fileSystem.File.Exists(Path.Combine(OS.GetUserDataDir(), "lastGame.txt")));
this.Provide();
}
private void OnLastGame()
{
AppLogic.Input(new AppLogicState.Input.LoadGame());
AppLogic.Input(new AppLogicState.Input.LoadSave());
}
private void OnMenuExit() => AppLogic.Input(new AppLogicState.Input.ExitMenu());
private void OnNewGame() => AppLogic.Input(new AppLogicState.Input.NewGame());
private void OnLoadGame() => AppLogic.Input(new AppLogicState.Input.LoadGame());
private void OnLoadSaveGame(string path)
{
SaveService.FilePath = path;
SaveService.CurrentSave = Chickensoft.SaveFileBuilder.SaveFile.CreateGZipJsonFile(
path,
_serializerOptions);
// Game.LoadExistingGame(GetSaves()[arg]);
GD.Print("save ", path, " loaded.");
AppLogic.Input(new AppLogicState.Input.LoadSave());
}
private void OnOptions() => AppLogic.Input(new AppLogicState.Input.Options());
private void OnMods() => AppLogic.Input(new AppLogicState.Input.Mods());
public void OnReady()
{
AppBinding = AppLogic.Bind();
AppBinding
.OnOutput((in AppLogicState.Output.ShowMainMenu _) =>
{
HideMenus();
MainMenu.Show();
//Fade In from black
})
.OnOutput((in AppLogicState.Output.StartLoadingSaveFile save) =>
{
Game.SaveFileLoaded += OnSaveFileLoaded;
Game.LoadGame();
})
.OnOutput((in AppLogicState.Output.RemoveExistingGame _) =>
{
GameViewPort.RemoveChildEx(Game);
Game.QueueFree();
Game = default!;
})
.OnOutput((in AppLogicState.Output.SetUpGameScene _) =>
{
Game = GD.Load<PackedScene>(GAME_PATH).Instantiate<Game>();
Game.Visible = false;
GameViewPort.AddChildEx(Game);
})
.OnOutput((in AppLogicState.Output.ShowGameCreationWindow _) =>
{
HideMenus();
CreateGameMenu.Initialize([.. GetLevels()]);
CreateGameMenu.Show();
})
.OnOutput((in AppLogicState.Output.ShowGameLoadingWindow _) =>
{
HideMenus();
LoadingGameMenu.Initialize(GetSaves());
LoadingGameMenu.Show();
})
.OnOutput((in AppLogicState.Output.ShowGame _) =>
{
HideMenus();
Game.Show();
})
.OnOutput((in AppLogicState.Output.QuitGame _) =>
{
GetTree().CallDeferred(SceneTree.MethodName.Quit);
})
.OnOutput((in AppLogicState.Output.ShowOptionMenu _) =>
{
HideMenus();
OptionsMenu.Show();
})
.OnOutput((in AppLogicState.Output.ShowModsMenu _) =>
{
HideMenus();
ModsMenu.Show();
})
;
AppLogic.Start<AppLogicState.MainMenu>();
}
private IReadOnlyList<string> GetSaves()
{
var fileSystem = new FileSystem();
var saves = fileSystem.Directory.EnumerateFiles(Path.Join(OS.GetUserDataDir(), "saves"));
return [.. saves];
}
private void OnSaveFileLoaded()
{
Game.SaveFileLoaded -= OnSaveFileLoaded;
AppLogic.Input(new AppLogicState.Input.SaveFileLoaded());
}
public void Setup()
{
}
public void OnExitTree()
{
AppLogic.Stop();
AppLogic.Dispose();
AppRepo.Dispose();
MainMenu.NewGame -= OnNewGame;
MainMenu.LoadGame -= OnLoadGame;
MainMenu.Options -= OnOptions;
MainMenu.Mods -= OnMods;
OptionsMenu.OnMenuExit -= OnMenuExit;
}
public void OnResolved()
{
}
public void HideMenus()
{
// Splash.Hide();
MainMenu.Hide();
CreateGameMenu.Hide();
LoadingGameMenu.Hide();
OptionsMenu.Hide();
ModsMenu.Hide();
}
public IEnumerable<LevelEntry> GetLevels()
{
yield return new LevelEntry("Level1", "res://assets/kenney_conveyor-kit/Sample.png");
yield return new LevelEntry("Level2", "res://assets/KayKit_Restaurant_Bits_1.0_FREE/sample.png");
yield return new LevelEntry("Level3", "res://assets/KayKit_Restaurant_Bits_1.0_FREE/contents.png");
}
public ISaveService Value() => SaveService;
// public override void _Ready()//=> new Test().TestECS();
// {
// // TestButton = GetNode<Button>("%TestButton");
// GD.Print(GameViewPort);
// }
// // public void OnTestButtonPressed() => ButtonPresses++;
// IGameLogic GameLogic = default!;
// LogicBlock.Binding GameLogicBinding = default!;
// Task task = default!;
// public void OnResolved()
// {
// // return;
// GD.Print("GLHF");
// GameLogic = new GameRootLogic();
// GameLogicBinding = GameLogic.Bind();
// GameLogicBinding
// .OnOutput((in GameRootLogicState.Output.QuitConfirmation _) => {
// var popup = new ConfirmationDialog();
// popup.Confirmed += () => GetTree().Quit();
// popup.Canceled += popup.QueueFree;
// popup.DialogText = "You sure you want to Quit";
// popup.OkButtonText = "Quit";
// popup.CancelButtonText = "Return to Menu";
// AddChild(popup);
// popup.PopupCentered();
// })
// .OnInput((in GameRootLogicState.Input.RequestQuit _) =>
// {
// }
// );
// // TestButton.ButtonUp += () => GameLogic.Input(new GameRootLogicState.Input.SaveRequested());
// GameLogic.Start<GameRootLogicState.MainMenu>();
// // GameLogic.Input(new GameLogicState.Input.Start());
// MainMenu.NewGame += () => GD.Print("New");
// MainMenu.LoadGame += () => GD.Print("Load");
// MainMenu.Options += () => GD.Print("Option");
// MainMenu.Mods += () => GD.Print("Mods");
// MainMenu.Exit += () => GameLogic.Input(new GameRootLogicState.Input.RequestQuit());
// }
}
// public interface IGameLogic : ILogicBlock
// {
// }
// [Meta]
// public partial class GameRootLogic : AutoBlock, IGameLogic
// {
// public GameRootLogic()
// {
// Preallocate<GameRootLogicState>();
// }
// }
// [Meta, StateDiagram]
// public abstract partial record GameRootLogicState : LogicBlockState
// {
// public static class Input
// {
// public readonly record struct Start;
// public readonly record struct Playing;
// public readonly record struct RequestQuit;
// // public readonly record struct SaveRequested;
// // public readonly record struct SaveCompleted;
// }
// public static class Output
// {
// // public readonly record struct StartSaving;
// public readonly record struct ShowMainMenu;
// public readonly record struct HideMainMenu;
// public readonly record struct QuitConfirmation;
// public readonly record struct Quit;
// }
// // [Meta]
// // public partial record Paused : GameRootLogicState, IGet<Input.SaveRequested>
// // {
// // public Paused()
// // {
// // this.OnEnter(() =>
// // {
// // GD.Print("enter paluse");
// // Output(new Output.ShowPauseMenu());
// // });
// // this.OnExit(()=>Output(new Output.HidePauseMenu()));
// // }
// // public Type On(in Input.SaveRequested input) => To<Saving>();
// // }
// // [Meta]
// // public partial record Saving : Paused, IGet<Input.SaveCompleted>
// // {
// // public Type On(in Input.SaveCompleted input) => To<MainMenu>();
// // public Saving()
// // {
// // this.OnEnter(
// // ()=>
// // {
// // GD.Print("enter save");
// // Output(new Output.StartSaving());
// // });
// // // this.OnExit(()=> Output(new Output.HidePauseMenu()));
// // }
// // }
// [Meta]
// public partial record MainMenu : GameRootLogicState, IGet<Input.RequestQuit>
// {
// public Type On(in Input.RequestQuit input) => To<ProcessQuit>();
// public MainMenu()
// {
// this.OnEnter(
// ()=>
// {
// GD.Print("enter menu");
// // Output(new Output.StartSaving());
// });
// // this.OnExit(()=> Output(new Output.HidePauseMenu()));
// }
// }
// [Meta]
// public partial record ProcessQuit : GameRootLogicState
// {
// public ProcessQuit()
// {
// this.OnEnter(
// ()=>
// {
// GD.Print("enter menu");
// Output(new Output.QuitConfirmation());
// });
// // this.OnExit(()=> Output(new Output.HidePauseMenu()));
// }
// }
// }

1
src/App/App.cs.uid Normal file
View File

@@ -0,0 +1 @@
uid://bcadf3uhcfy2

208
src/App/App.g.puml Normal file
View File

@@ -0,0 +1,208 @@
@startuml
package App-Type [[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs]] {
class App {
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs ScriptFile]]
[Properties]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs:47 AppBinding]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs:46 AppLogic]] - [[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/AppLogic.cs Script]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs:44 AppRepo]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs:37 CreateGameMenu]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs:42 Game]] - [[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs Script]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs:35 GameViewPort]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs:38 LoadingGameMenu]] - [[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/TitleMenu/LoadingGameMenu.cs Script]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs:36 MainMenu]] - [[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/TitleMenu/MainMenu.cs Script]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs:40 ModsMenu]] - [[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ModMenu/ModMenu.cs Script]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs:45 OptionConfig]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs:39 OptionsMenu]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs:59 SaveService]]
--
[Methods]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs:33 _Notification()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs:70 BindSetting()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs:299 GetLevels()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs:252 GetSaves()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs:288 HideMenus()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs:72 Initialize()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs:270 OnExitTree()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs:165 OnLastGame()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs:174 OnLoadGame()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs:175 OnLoadSaveGame()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs:172 OnMenuExit()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs:187 OnMods()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs:173 OnNewGame()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs:186 OnOptions()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs:189 OnReady()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs:283 OnResolved()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs:260 OnSaveFileLoaded()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs:266 Setup()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/App.cs:306 Value()]]
}
class AppLogic {
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/AppLogic.cs ScriptFile]]
[Constructors]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/App/AppLogic.cs:12 AppLogic]]()
}
package Game-Type [[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs]] {
class Game {
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs ScriptFile]]
[Properties]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs:40 Environment]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs:43 EquipmentTable]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs:39 FileSystem]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs:54 GameBinding]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs:53 GameLogic]] - [[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/GameLogicState.cs Script]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs:48 OptionsMenu]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs:47 PauseContainer]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs:46 PauseMenu]] - [[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/PauseMenu/PauseMenu.cs Script]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs:49 PlayerCamera]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs:38 SaveFile]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs:41 SaveFilePath]]
--
[Interface Methods]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs:162 LoadGame()]]
[Methods]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs:33 _Notification()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs:218 _UnhandledInput()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs:169 HideMenus()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs:71 Initialize()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs:232 Load()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs:233 LoadExistingGame()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs:198 OnExitTree()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs:103 OnReady()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs:201 OnResolved()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs:82 OnSaveButton()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs:97 OpenOptions()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs:85 PauseButtonPressed()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs:84 QuitToDesktop()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs:83 QuitToMainMenu()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs:228 Save()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs:143 SaveGame()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs:155 SaveGame2()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/Game.cs:175 Setup()]]
}
class GameLogicState {
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/GameLogicState.cs ScriptFile]]
[Constructors]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/Game/GameLogicState.cs:14 GameLogic]]()
}
class PauseMenu {
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/PauseMenu/PauseMenu.cs ScriptFile]]
[Properties]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/PauseMenu/PauseMenu.cs:29 BackToGameButton]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/PauseMenu/PauseMenu.cs:30 OptionsButton]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/PauseMenu/PauseMenu.cs:33 QuitToDesktopButton]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/PauseMenu/PauseMenu.cs:32 QuitToMainMenuButton]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/PauseMenu/PauseMenu.cs:31 SaveButton]]
--
[Methods]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/PauseMenu/PauseMenu.cs:27 _Notification()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/PauseMenu/PauseMenu.cs:44 Initialize()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/PauseMenu/PauseMenu.cs:79 OnExitTree()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/PauseMenu/PauseMenu.cs:55 OnReady()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/PauseMenu/PauseMenu.cs:84 OnResolved()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/PauseMenu/PauseMenu.cs:74 Setup()]]
}
Game::GameLogicState ---> GameLogicState
Game::PauseMenu ---> PauseMenu
}
class LoadingGameMenu {
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/TitleMenu/LoadingGameMenu.cs ScriptFile]]
[Properties]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/TitleMenu/LoadingGameMenu.cs:26 ExitButton]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/TitleMenu/LoadingGameMenu.cs:25 ItemList]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/TitleMenu/LoadingGameMenu.cs:24 LoadGameButton]]
--
[Interface Methods]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/TitleMenu/LoadingGameMenu.cs:32 Initialize()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/TitleMenu/LoadingGameMenu.cs:36 Initialize()]]
[Methods]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/TitleMenu/LoadingGameMenu.cs:22 _Notification()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/TitleMenu/LoadingGameMenu.cs:65 OnExitTree()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/TitleMenu/LoadingGameMenu.cs:56 OnGameLoad()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/TitleMenu/LoadingGameMenu.cs:63 OnItemSelected()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/TitleMenu/LoadingGameMenu.cs:49 OnReady()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/TitleMenu/LoadingGameMenu.cs:70 OnResolved()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/TitleMenu/LoadingGameMenu.cs:45 Setup()]]
}
class MainMenu {
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/TitleMenu/MainMenu.cs ScriptFile]]
[Properties]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/TitleMenu/MainMenu.cs:29 ExitButton]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/TitleMenu/MainMenu.cs:24 LastGameButton]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/TitleMenu/MainMenu.cs:26 LoadGameButton]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/TitleMenu/MainMenu.cs:28 ModsButton]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/TitleMenu/MainMenu.cs:25 NewGameButton]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/TitleMenu/MainMenu.cs:27 OptionsButton]]
--
[Interface Methods]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/TitleMenu/MainMenu.cs:70 SetLastGameVisible()]]
[Methods]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/TitleMenu/MainMenu.cs:23 _Notification()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/TitleMenu/MainMenu.cs:39 Initialize()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/TitleMenu/MainMenu.cs:56 OnExitTree()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/TitleMenu/MainMenu.cs:47 OnReady()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/TitleMenu/MainMenu.cs:65 OnResolved()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/TitleMenu/MainMenu.cs:43 Setup()]]
}
package ModMenu-Type [[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ModMenu/ModMenu.cs]] {
class ModMenu {
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ModMenu/ModMenu.cs ScriptFile]]
[Properties]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ModMenu/ModMenu.cs:15 ModEntryScene]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ModMenu/ModMenu.cs:17 ModManger]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ModMenu/ModMenu.cs:18 ModsContainer]] - [[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ReorderableContainer/ReOrderableContainer.cs Script]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ModMenu/ModMenu.cs:19 ProfilesButton]]
--
[Methods]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ModMenu/ModMenu.cs:74 _ExitTree()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ModMenu/ModMenu.cs:14 _Notification()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ModMenu/ModMenu.cs:26 OnModProfileSelected()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ModMenu/ModMenu.cs:20 OnResolved()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ModMenu/ModMenu.cs:32 OnVisibilityChanged()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ModMenu/ModMenu.cs:40 RefreshMods()]]
}
class ReOrderableContainer {
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ReorderableContainer/ReOrderableContainer.cs ScriptFile]]
[Properties]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ReorderableContainer/ReOrderableContainer.cs:62 AutoScrollRange]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ReorderableContainer/ReOrderableContainer.cs:61 AutoScrollSpeed]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ReorderableContainer/ReOrderableContainer.cs:23 HoldDuration]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ReorderableContainer/ReOrderableContainer.cs:64 IsDebugging]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ReorderableContainer/ReOrderableContainer.cs:38 IsVertical]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ReorderableContainer/ReOrderableContainer.cs:60 ScrollContainer]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ReorderableContainer/ReOrderableContainer.cs:63 ScrollThreshold]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ReorderableContainer/ReOrderableContainer.cs:25 Separation]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ReorderableContainer/ReOrderableContainer.cs:24 Speed]]
--
[Methods]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ReorderableContainer/ReOrderableContainer.cs:148 _Draw()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ReorderableContainer/ReOrderableContainer.cs:95 _GuiInput()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ReorderableContainer/ReOrderableContainer.cs:20 _Notification()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ReorderableContainer/ReOrderableContainer.cs:115 _Process()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ReorderableContainer/ReOrderableContainer.cs:319 AdjustChildRect()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ReorderableContainer/ReOrderableContainer.cs:364 AdjustDropZoneRect()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ReorderableContainer/ReOrderableContainer.cs:294 AdjustExpectedChildRect()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ReorderableContainer/ReOrderableContainer.cs:404 AsIReOrderableContainer()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ReorderableContainer/ReOrderableContainer.cs:405 GetVisibleChildren()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ReorderableContainer/ReOrderableContainer.cs:238 HandleAutoScroll()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ReorderableContainer/ReOrderableContainer.cs:207 HandleDraggingChildPos()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ReorderableContainer/ReOrderableContainer.cs:159 HandleInput()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ReorderableContainer/ReOrderableContainer.cs:267 OnExitTree()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ReorderableContainer/ReOrderableContainer.cs:276 OnNodeAdded()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ReorderableContainer/ReOrderableContainer.cs:80 OnReady()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ReorderableContainer/ReOrderableContainer.cs:284 OnSortChildren()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ReorderableContainer/ReOrderableContainer.cs:283 OnSortChildrenWrapper()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ReorderableContainer/ReOrderableContainer.cs:175 OnStartDragging()]]
[[vscode://file//home/ronnie/Documents/Godot/Projects/ChickenGameTest/src/ReorderableContainer/ReOrderableContainer.cs:186 OnStopDragging()]]
}
ModMenu::ReOrderableContainer ---> ReOrderableContainer
}
App::AppLogic ---> AppLogic
App::Game ---> Game
App::LoadingGameMenu ---> LoadingGameMenu
App::MainMenu ---> MainMenu
App::ModMenu ---> ModMenu
}
@enduml

84
src/App/App.tscn Normal file
View File

@@ -0,0 +1,84 @@
[gd_scene format=3 uid="uid://cywpu6lxdjhuu"]
[ext_resource type="Script" uid="uid://bcadf3uhcfy2" path="res://src/App/App.cs" id="1_tn3dc"]
[ext_resource type="PackedScene" uid="uid://nwt8o860iibl" path="res://src/TitleMenu/MainMenu.tscn" id="3_sb8ss"]
[ext_resource type="PackedScene" uid="uid://dkgrn8n1on4ec" path="res://src/TitleMenu/CreateGameMenu.tscn" id="4_qlumy"]
[ext_resource type="PackedScene" uid="uid://b7x2w61dwafxe" path="res://src/TitleMenu/LoadingGameMenu.tscn" id="5_sb8ss"]
[ext_resource type="PackedScene" uid="uid://bf3a5w3h1evaf" path="res://src/OptionsMenu/OptionMenu.tscn" id="6_6skpx"]
[ext_resource type="Script" uid="uid://c0qxjltjv53u7" path="res://addons/controller_icons/objects/ControllerIconTexture.cs" id="6_fj5p6"]
[ext_resource type="PackedScene" uid="uid://cgp6gntheq4g6" path="res://src/ModMenu/ModMenu.tscn" id="7_6skpx"]
[sub_resource type="Texture2D" id="Texture2D_6skpx"]
resource_local_to_scene = false
resource_name = ""
script = ExtResource("6_fj5p6")
path = "move_forward"
metadata/_custom_type_script = "uid://c0qxjltjv53u7"
[node name="App" type="CanvasLayer" unique_id=2068981625]
process_mode = 3
script = ExtResource("1_tn3dc")
[node name="GameSession" type="Control" parent="." unique_id=1185123368]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="SubViewportContainer" type="SubViewportContainer" parent="GameSession" unique_id=2046367171]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
stretch = true
[node name="GameViewPort" type="SubViewport" parent="GameSession/SubViewportContainer" unique_id=1388492347]
unique_name_in_owner = true
own_world_3d = true
handle_input_locally = false
size = Vector2i(720, 720)
render_target_update_mode = 4
[node name="CenterContainer" type="CenterContainer" parent="." unique_id=1905436581]
visible = false
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer" unique_id=1941107825]
layout_mode = 2
[node name="TestButton" type="Button" parent="CenterContainer/VBoxContainer" unique_id=1060152075]
unique_name_in_owner = true
layout_mode = 2
text = "Test Button"
[node name="OptionsMenu" parent="." unique_id=2143215493 instance=ExtResource("6_6skpx")]
unique_name_in_owner = true
visible = false
[node name="MainMenu" parent="." unique_id=869490384 instance=ExtResource("3_sb8ss")]
unique_name_in_owner = true
[node name="CreateGameMenu" parent="." unique_id=1233498611 instance=ExtResource("4_qlumy")]
unique_name_in_owner = true
visible = false
[node name="LoadingGameMenu" parent="." unique_id=1791717647 instance=ExtResource("5_sb8ss")]
unique_name_in_owner = true
visible = false
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=1847137886]
texture = SubResource("Texture2D_6skpx")
[node name="ModsMenu" parent="." unique_id=1651472975 instance=ExtResource("7_6skpx")]
unique_name_in_owner = true
visible = false
[connection signal="pressed" from="CenterContainer/VBoxContainer/TestButton" to="." method="OnTestButtonPressed"]

17
src/App/AppLogic.cs Normal file
View File

@@ -0,0 +1,17 @@
namespace FoodFactory;
using Chickensoft.Introspection;
using Chickensoft.LogicBlocks;
using Chickensoft.LogicBlocks.Auto;
public interface IAppLogic : ILogicBlock;
[Meta]
public partial class AppLogic : AutoBlock, IAppLogic
{
public AppLogic()
{
Preallocate<AppLogicState>();
}
}

1
src/App/AppLogic.cs.uid Normal file
View File

@@ -0,0 +1 @@
uid://dugahjx2qt4fq

View File

@@ -0,0 +1,22 @@
namespace FoodFactory;
public abstract partial record AppLogicState
{
public static class Input
{
public readonly record struct ExitMenu;
public readonly record struct NewGame;
public readonly record struct LoadGame;
public readonly record struct LoadSave;
public readonly record struct Options;
public readonly record struct Mods;
public readonly record struct EndGame(ExitGameReason Reason = ExitGameReason.QuitToMenu);
public readonly record struct SaveFileLoaded;
}
}
public enum ExitGameReason
{
QuitToDesktop,
QuitToMenu,
}

View File

@@ -0,0 +1 @@
uid://cvvofc4v4vmr5

View File

@@ -0,0 +1,25 @@
namespace FoodFactory;
public abstract partial record AppLogicState
{
public static class Output
{
public readonly record struct StartLoadingSaveFile();
// public readonly record struct StartLoadingSaveFile(LoadGameArgs Save);
public readonly record struct SetUpGameScene;
public readonly record struct ShowGameCreationWindow;
// public readonly record struct HideGameCreationWindow;
public readonly record struct ShowMainMenu;
public readonly record struct ShowOptionMenu;
public readonly record struct ShowModsMenu;
// public readonly record struct ShowHideMenu;
public readonly record struct PlayGame;
public readonly record struct ShowGame;
// public readonly record struct HideGame;
public readonly record struct RemoveExistingGame;
public readonly record struct ShowGameLoadingWindow;
public readonly record struct QuitGame;
// public readonly record struct HideGameLoadingWindow;
}
}

View File

@@ -0,0 +1 @@
uid://chh4b4blwffef

7
src/App/AppLogicState.cs Normal file
View File

@@ -0,0 +1,7 @@
namespace FoodFactory;
using Chickensoft.Introspection;
using Chickensoft.LogicBlocks;
[Meta, StateDiagram]
public abstract partial record AppLogicState : LogicBlockState;

View File

@@ -0,0 +1 @@
uid://c1315dvv52mf0

View File

@@ -0,0 +1,35 @@
@startuml AppLogicState
state "AppLogicState" as FoodFactory_AppLogicState {
state "CreatingGame" as FoodFactory_AppLogicState_CreatingGame
state "InGame" as FoodFactory_AppLogicState_InGame
state "LeavingGame" as FoodFactory_AppLogicState_LeavingGame
state "LoadingGame" as FoodFactory_AppLogicState_LoadingGame
state "MainMenu" as FoodFactory_AppLogicState_MainMenu
state "ModsMenu" as FoodFactory_AppLogicState_ModsMenu
state "OptionMenu" as FoodFactory_AppLogicState_OptionMenu
}
FoodFactory_AppLogicState_CreatingGame --> FoodFactory_AppLogicState_InGame : NewGame
FoodFactory_AppLogicState_CreatingGame --> FoodFactory_AppLogicState_MainMenu : ExitMenu
FoodFactory_AppLogicState_InGame --> FoodFactory_AppLogicState_MainMenu : EndGame
FoodFactory_AppLogicState_LeavingGame --> FoodFactory_AppLogicState_MainMenu : EndGame
FoodFactory_AppLogicState_LoadingGame --> FoodFactory_AppLogicState_InGame : LoadSave
FoodFactory_AppLogicState_LoadingGame --> FoodFactory_AppLogicState_MainMenu : ExitMenu
FoodFactory_AppLogicState_MainMenu --> FoodFactory_AppLogicState_CreatingGame : NewGame
FoodFactory_AppLogicState_MainMenu --> FoodFactory_AppLogicState_LoadingGame : LoadGame
FoodFactory_AppLogicState_MainMenu --> FoodFactory_AppLogicState_ModsMenu : Mods
FoodFactory_AppLogicState_MainMenu --> FoodFactory_AppLogicState_OptionMenu : Options
FoodFactory_AppLogicState_ModsMenu --> FoodFactory_AppLogicState_MainMenu : ExitMenu
FoodFactory_AppLogicState_OptionMenu --> FoodFactory_AppLogicState_MainMenu : ExitMenu
FoodFactory_AppLogicState_CreatingGame : OnEnter → ShowGameCreationWindow
FoodFactory_AppLogicState_CreatingGame : OnNewGame → SetUpGameScene
FoodFactory_AppLogicState_InGame : OnEndGame → RemoveExistingGame
FoodFactory_AppLogicState_InGame : OnEnter → ShowGame
FoodFactory_AppLogicState_LeavingGame : OnEndGame → QuitGame, RemoveExistingGame
FoodFactory_AppLogicState_LoadingGame : OnEnter → ShowGameLoadingWindow
FoodFactory_AppLogicState_LoadingGame : OnLoadSave → SetUpGameScene, StartLoadingSaveFile
FoodFactory_AppLogicState_MainMenu : OnEnter → ShowMainMenu
FoodFactory_AppLogicState_ModsMenu : OnEnter → ShowModsMenu
FoodFactory_AppLogicState_OptionMenu : OnEnter → ShowOptionMenu
@enduml

59
src/App/AppRepo.cs Normal file
View File

@@ -0,0 +1,59 @@
namespace FoodFactory;
using System;
using Chickensoft.Sync.Primitives;
using FoodFactory.Modding;
using Godot;
using TrimKit.VirtualFileSystem;
public interface IAppRepo : IDisposable
{
readonly record struct GameEntering;
readonly record struct GameExiting;
readonly record struct GameSettingChanged(IOptionKey Setting, Variant Value);
void OnEnteringGame();
void OnExitGame();
void OnSettingChanged(IOptionKey setting, Variant value);
IAutoChannel AutoChannel { get; }
IModManger ModManger { get; }
}
public class AppRepo : IAppRepo
{
private readonly AutoChannel _autoChannel = new();
private bool _disposedValue;
public IAutoChannel AutoChannel => _autoChannel;
// private readonly IModManger _vFSManager;
public required IModManger ModManger {get;init;}
public void OnEnteringGame() => _autoChannel.Send(new IAppRepo.GameEntering());
public void OnExitGame() => _autoChannel.Send(new IAppRepo.GameExiting());
public void OnSettingChanged(IOptionKey setting, Variant value) => _autoChannel.Send(new IAppRepo.GameSettingChanged(setting, value));
protected virtual void Dispose(bool disposing)
{
if (!_disposedValue)
{
if (disposing)
{
// TODO: dispose managed state (managed objects)
_autoChannel.Dispose();
ModManger.Dispose();
}
// TODO: free unmanaged resources (unmanaged objects) and override finalizer
// TODO: set large fields to null
_disposedValue = true;
}
}
void IDisposable.Dispose()
{
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
}

1
src/App/AppRepo.cs.uid Normal file
View File

@@ -0,0 +1 @@
uid://cgp65d616yhl0

View File

@@ -0,0 +1,53 @@
namespace FoodFactory;
using System;
using Chickensoft.Introspection;
using Chickensoft.LogicBlocks;
public partial record AppLogicState
{
[Meta]
public partial record CreatingGame : AppLogicState, IGet<Input.ExitMenu>, IGet<Input.NewGame>
{
public CreatingGame()
{
this.OnEnter(() =>
{
Output(new Output.ShowGameCreationWindow());
});
}
public Type On(in Input.ExitMenu input) => To<MainMenu>();
public Type On(in Input.NewGame input)
{
Output(new Output.SetUpGameScene());
return To<InGame>();
}
}
[Meta]
public partial record OptionMenu : AppLogicState, IGet<Input.ExitMenu>
{
public OptionMenu()
{
this.OnEnter(() =>
{
Output(new Output.ShowOptionMenu());
});
}
public Type On(in Input.ExitMenu input) => To<MainMenu>();
}
[Meta]
public partial record ModsMenu : AppLogicState, IGet<Input.ExitMenu>
{
public ModsMenu()
{
this.OnEnter(() =>
{
Output(new Output.ShowModsMenu());
});
}
public Type On(in Input.ExitMenu input) => To<MainMenu>();
}
}

View File

@@ -0,0 +1 @@
uid://coo66h6424rhu

28
src/App/States/InGame.cs Normal file
View File

@@ -0,0 +1,28 @@
namespace FoodFactory;
using System;
using Chickensoft.Introspection;
using Chickensoft.LogicBlocks;
public partial record AppLogicState
{
[Meta]
public partial record InGame : AppLogicState, IGet<Input.EndGame>
{
public InGame()
{
this.OnEnter(() =>
{
Get<IAppRepo>().OnEnteringGame();
Output(new Output.ShowGame());
});
}
public Type On(in Input.EndGame input)
{
// return To<LeavingGame>();
Output(new Output.RemoveExistingGame());
return To<MainMenu>();
}
}
}

View File

@@ -0,0 +1 @@
uid://cqaqghb5xytb8

View File

@@ -0,0 +1,31 @@
namespace FoodFactory;
using System;
using Chickensoft.Introspection;
using Chickensoft.LogicBlocks;
public partial record AppLogicState
{
[Meta]
public partial record LeavingGame : AppLogicState, IGet<Input.EndGame>
{
public LeavingGame()
{
this.OnEnter(() =>
{
// Output(new Output.ShowGame());
});
}
public Type On(in Input.EndGame input){
Output(new Output.RemoveExistingGame());
if (input.Reason == ExitGameReason.QuitToDesktop)
{
Output(new Output.QuitGame());
}
return To<MainMenu>();
}
}
}

View File

@@ -0,0 +1 @@
uid://xumdrcvr86av

View File

@@ -0,0 +1,29 @@
namespace FoodFactory;
using System;
using Chickensoft.Introspection;
using Chickensoft.LogicBlocks;
public partial record AppLogicState
{
[Meta]
public partial record LoadingGame : AppLogicState, IGet<Input.ExitMenu>, IGet<Input.LoadSave>
{
public LoadingGame()
{
this.OnEnter(() =>
{
Output(new Output.ShowGameLoadingWindow());
});
}
public Type On(in Input.ExitMenu input) => To<MainMenu>();
public Type On(in Input.LoadSave input)
{
Output(new Output.SetUpGameScene());
Output(new Output.StartLoadingSaveFile());
return To<InGame>();
}
}
}

View File

@@ -0,0 +1 @@
uid://bovjntefvngmh

View File

@@ -0,0 +1,26 @@
namespace FoodFactory;
using System;
using Chickensoft.Introspection;
using Chickensoft.LogicBlocks;
public partial record AppLogicState
{
[Meta]
public partial record MainMenu : AppLogicState,
IGet<Input.NewGame>, IGet<Input.LoadGame>, IGet<Input.Options>, IGet<Input.Mods>
{
public MainMenu()
{
this.OnEnter(() =>
{
Output(new Output.ShowMainMenu());
});
}
public Type On(in Input.LoadGame input) => To<LoadingGame>();
public Type On(in Input.NewGame input) => To<CreatingGame>();
public Type On(in Input.Options input) => To<OptionMenu>();
public Type On(in Input.Mods input) => To<ModsMenu>();
}
}

View File

@@ -0,0 +1 @@
uid://c6qr7sej5f6vh