Move files and folders to new repo format to enable multi-project format
This commit is contained in:
154
Zennysoft.Game.Ma/src/app/App.cs
Normal file
154
Zennysoft.Game.Ma/src/app/App.cs
Normal file
@@ -0,0 +1,154 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.GodotNodeInterfaces;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
using static Zennysoft.Game.Ma.AppLogic.Input;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
public interface IApp : ICanvasLayer, IProvide<IAppRepo>;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class App : CanvasLayer, IApp
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
public const string GAME_SCENE_PATH = "res://src/game/Game.tscn";
|
||||
|
||||
public IGame Game { get; set; } = default!;
|
||||
|
||||
public IInstantiator Instantiator { get; set; } = default!;
|
||||
|
||||
IAppRepo IProvide<IAppRepo>.Value() => AppRepo;
|
||||
|
||||
public IAppRepo AppRepo { get; set; } = default!;
|
||||
public IAppLogic AppLogic { get; set; } = default!;
|
||||
public AppLogic.IBinding AppBinding { get; set; } = default!;
|
||||
|
||||
[Node] public Menu Menu { get; set; } = default!;
|
||||
|
||||
[Node] public ISubViewport GameWindow { get; set; } = default!;
|
||||
|
||||
[Node] public ISplash Splash { get; set; } = default!;
|
||||
[Node] public IColorRect BlankScreen { get; set; } = default!;
|
||||
[Node] public IAnimationPlayer AnimationPlayer { get; set; } = default!;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
Instantiator = new Instantiator(GetTree());
|
||||
AppRepo = new AppRepo();
|
||||
AppLogic = new AppLogic();
|
||||
AppLogic.Set(AppRepo);
|
||||
AppLogic.Set(new AppLogic.Data());
|
||||
|
||||
Menu.NewGame += OnNewGame;
|
||||
Menu.LoadGame += OnLoadGame;
|
||||
Menu.Quit += OnQuit;
|
||||
|
||||
AnimationPlayer.AnimationFinished += OnAnimationFinished;
|
||||
|
||||
Input.MouseMode = Input.MouseModeEnum.Visible;
|
||||
this.Provide();
|
||||
}
|
||||
|
||||
public void OnReady()
|
||||
{
|
||||
AppBinding = AppLogic.Bind();
|
||||
|
||||
AppBinding
|
||||
.Handle((in AppLogic.Output.ShowSplashScreen _) =>
|
||||
{
|
||||
HideMenus();
|
||||
BlankScreen.Hide();
|
||||
Splash.Show();
|
||||
})
|
||||
.Handle((in AppLogic.Output.HideSplashScreen _) =>
|
||||
{
|
||||
BlankScreen.Show();
|
||||
FadeToBlack();
|
||||
})
|
||||
.Handle((in AppLogic.Output.SetupGameScene _) =>
|
||||
{
|
||||
Game = Instantiator.LoadAndInstantiate<Game>(GAME_SCENE_PATH);
|
||||
GameWindow.AddChildEx(Game);
|
||||
Instantiator.SceneTree.Paused = false;
|
||||
})
|
||||
.Handle((in AppLogic.Output.ShowMainMenu _) =>
|
||||
{
|
||||
// Load everything while we're showing a black screen, then fade in.
|
||||
HideMenus();
|
||||
Menu.Show();
|
||||
|
||||
FadeInFromBlack();
|
||||
Menu.NewGameButton.GrabFocus();
|
||||
})
|
||||
.Handle((in AppLogic.Output.FadeToBlack _) => FadeToBlack())
|
||||
.Handle((in AppLogic.Output.HideGame _) => FadeToBlack())
|
||||
.Handle((in AppLogic.Output.ShowGame _) =>
|
||||
{
|
||||
HideMenus();
|
||||
FadeInFromBlack();
|
||||
})
|
||||
.Handle((in AppLogic.Output.StartLoadingSaveFile _) =>
|
||||
{
|
||||
Game.SaveFileLoaded += OnSaveFileLoaded;
|
||||
Game.LoadExistingGame();
|
||||
})
|
||||
.Handle((in AppLogic.Output.ExitGame _) =>
|
||||
{
|
||||
GetTree().Quit();
|
||||
});
|
||||
|
||||
|
||||
AppLogic.Start();
|
||||
}
|
||||
|
||||
public void OnNewGame() => AppLogic.Input(new NewGame());
|
||||
|
||||
private void OnLoadGame() => AppLogic.Input(new LoadGame());
|
||||
|
||||
public void OnQuit() => AppLogic.Input(new QuitGame());
|
||||
|
||||
public void OnSaveFileLoaded()
|
||||
{
|
||||
Game.SaveFileLoaded -= OnSaveFileLoaded;
|
||||
AppLogic.Input(new SaveFileLoaded());
|
||||
}
|
||||
|
||||
public void FadeInFromBlack()
|
||||
{
|
||||
BlankScreen.Show();
|
||||
AnimationPlayer.Play("fade_in");
|
||||
}
|
||||
|
||||
public void FadeToBlack()
|
||||
{
|
||||
BlankScreen.Show();
|
||||
AnimationPlayer.Play("fade_out");
|
||||
}
|
||||
|
||||
public void HideMenus()
|
||||
{
|
||||
Splash.Hide();
|
||||
Menu.Hide();
|
||||
}
|
||||
|
||||
public void OnAnimationFinished(StringName animation)
|
||||
{
|
||||
if (animation == "fade_in")
|
||||
{
|
||||
AppLogic.Input(new FadeInFinished());
|
||||
BlankScreen.Hide();
|
||||
return;
|
||||
}
|
||||
|
||||
AppLogic.Input(new FadeOutFinished());
|
||||
}
|
||||
|
||||
public void OnExitTree()
|
||||
{
|
||||
AppLogic.Stop();
|
||||
AppBinding.Dispose();
|
||||
AppRepo.Dispose();
|
||||
}
|
||||
}
|
||||
1
Zennysoft.Game.Ma/src/app/App.cs.uid
Normal file
1
Zennysoft.Game.Ma/src/app/App.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://d1f8blk5ucqvq
|
||||
140
Zennysoft.Game.Ma/src/app/App.gdshader
Normal file
140
Zennysoft.Game.Ma/src/app/App.gdshader
Normal file
@@ -0,0 +1,140 @@
|
||||
shader_type canvas_item;
|
||||
|
||||
// Handles the resolution changes, color depth, and dithering
|
||||
group_uniforms resolution_and_colors;
|
||||
uniform bool change_color_depth = false;
|
||||
uniform int target_color_depth : hint_range(1, 8) = 5;
|
||||
uniform bool dithering = false;
|
||||
uniform bool scale_resolution = false;
|
||||
uniform int target_resolution_scale = 3;
|
||||
|
||||
// Handles the LUTish recoloring
|
||||
group_uniforms gradient_recoloring;
|
||||
uniform bool enable_recolor = false;
|
||||
uniform sampler2D to_gradient: hint_default_black;
|
||||
|
||||
int dithering_pattern(ivec2 fragcoord) {
|
||||
const int pattern[] = {
|
||||
-4, +0, -3, +1,
|
||||
+2, -2, +3, -1,
|
||||
-3, +1, -4, +0,
|
||||
+3, -1, +2, -2
|
||||
};
|
||||
|
||||
int x = fragcoord.x % 4;
|
||||
int y = fragcoord.y % 4;
|
||||
|
||||
return pattern[y * 4 + x];
|
||||
}
|
||||
|
||||
vec3 rgb2hsv(vec3 rgb) { //Converts RGB values to HSV
|
||||
float r = rgb.r;
|
||||
float g = rgb.g;
|
||||
float b = rgb.b;
|
||||
|
||||
float cmax = max(r,max(g,b));
|
||||
float cmin = min(r,min(g,b));
|
||||
float delta = cmax - cmin;
|
||||
|
||||
float h = 0.f; //hue
|
||||
|
||||
if (delta > 0.f){
|
||||
if (cmax == r){
|
||||
h = (g-b)/delta;
|
||||
h = mod(h,6.f);
|
||||
} else if (cmax == g){
|
||||
h = ((b - r) / delta) + 2.f;
|
||||
} else {
|
||||
h = ((r-g)/delta) + 4.f;
|
||||
}
|
||||
h = h * 60.f;
|
||||
}
|
||||
|
||||
float s = 0.f; //saturation
|
||||
if (cmax > 0.f){
|
||||
s = delta / cmax;
|
||||
}
|
||||
|
||||
return vec3(h,s,cmax); // Keep original alpha value
|
||||
|
||||
}
|
||||
|
||||
vec3 hsv2rgb(vec3 hsv) { //Converts HSV values to RGB
|
||||
float h = hsv.r;
|
||||
float s = hsv.g;
|
||||
float v = hsv.b;
|
||||
float c = v * s;
|
||||
//X = C × (1 - |(H / 60°) mod 2 - 1|)
|
||||
float x = h / 60.f;
|
||||
x = mod(x,2.f);
|
||||
x = abs(x - 1.f);
|
||||
x = c * (1.f - x);
|
||||
|
||||
float m = v - c;
|
||||
|
||||
vec3 rgb = vec3(0.f,0.f,0.f);
|
||||
|
||||
if (h < 60.f) {
|
||||
rgb = vec3(c,x,0.f);
|
||||
} else if (h < 120.f){
|
||||
rgb = vec3(x,c,0.f);
|
||||
} else if (h < 180.f){
|
||||
rgb = vec3(0.f,c,x);
|
||||
} else if (h < 240.f){
|
||||
rgb = vec3(0.f,x,c);
|
||||
} else if (h < 300.f){
|
||||
rgb = vec3(x,0.f,c);
|
||||
} else if (h < 360.f){
|
||||
rgb = vec3(c,0.f,x);
|
||||
}
|
||||
rgb[0] = rgb[0] + m;
|
||||
rgb[1] = rgb[1] + m;
|
||||
rgb[2] = rgb[2] + m;
|
||||
|
||||
return rgb;
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
ivec2 uv;
|
||||
vec3 color;
|
||||
|
||||
if(scale_resolution){
|
||||
uv = ivec2(FRAGCOORD.xy / float(target_resolution_scale));
|
||||
color = texelFetch(TEXTURE, uv * target_resolution_scale, 0).rgb;
|
||||
} else {
|
||||
uv = ivec2(FRAGCOORD.xy);
|
||||
color = texelFetch(TEXTURE, uv, 0).rgb;
|
||||
}
|
||||
|
||||
if(enable_recolor){
|
||||
vec3 hsv = rgb2hsv(color);
|
||||
float color_pos = (hsv.x / 360.0);
|
||||
vec3 new_color = texture(to_gradient, vec2((color_pos), 0.5)).rgb;
|
||||
vec3 new_hsv = rgb2hsv(new_color);
|
||||
hsv.x = new_hsv.x;
|
||||
vec3 final_rgb = hsv2rgb(hsv);
|
||||
|
||||
color.rgb = final_rgb;
|
||||
}
|
||||
|
||||
|
||||
// Convert from [0.0, 1.0] range to [0, 255] range
|
||||
ivec3 c = ivec3(round(color * 255.0));
|
||||
|
||||
// Apply the dithering pattern
|
||||
if (dithering) {
|
||||
c += ivec3(dithering_pattern(uv));
|
||||
}
|
||||
|
||||
vec3 final_color;
|
||||
if(change_color_depth){
|
||||
// Truncate from 8 bits to color_depth bits
|
||||
c >>= (8 - target_color_depth);
|
||||
final_color = vec3(c) / float(1 << target_color_depth);
|
||||
} else {
|
||||
final_color = vec3(c) / float(1 << 8);
|
||||
}
|
||||
|
||||
// Convert back to [0.0, 1.0] range
|
||||
COLOR.rgb = final_color;
|
||||
}
|
||||
1
Zennysoft.Game.Ma/src/app/App.gdshader.uid
Normal file
1
Zennysoft.Game.Ma/src/app/App.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dmjxo4k2rx1an
|
||||
111
Zennysoft.Game.Ma/src/app/App.tscn
Normal file
111
Zennysoft.Game.Ma/src/app/App.tscn
Normal file
@@ -0,0 +1,111 @@
|
||||
[gd_scene load_steps=8 format=3 uid="uid://cagfc5ridmteu"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://d1f8blk5ucqvq" path="res://src/app/App.cs" id="1_rt73h"]
|
||||
[ext_resource type="PackedScene" uid="uid://rfvnddfqufho" path="res://src/menu/Menu.tscn" id="2_kvwo1"]
|
||||
[ext_resource type="PackedScene" uid="uid://bd0p761qakisw" path="res://src/menu/splash/Splash.tscn" id="3_3st5l"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_3st5l"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("BlankScreenControl/BlankScreen:color")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Color(0, 0, 0, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_1uiag"]
|
||||
resource_name = "fade_in"
|
||||
length = 0.1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("BlankScreenControl/BlankScreen:color")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(0, 0, 0, 1), Color(0, 0, 0, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_v0mgf"]
|
||||
resource_name = "fade_out"
|
||||
length = 0.1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("BlankScreenControl/BlankScreen:color")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(0, 0, 0, 0), Color(0, 0, 0, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_3st5l"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_3st5l"),
|
||||
&"fade_in": SubResource("Animation_1uiag"),
|
||||
&"fade_out": SubResource("Animation_v0mgf")
|
||||
}
|
||||
|
||||
[node name="App" type="CanvasLayer"]
|
||||
process_mode = 3
|
||||
script = ExtResource("1_rt73h")
|
||||
|
||||
[node name="SubViewportContainer" type="SubViewportContainer" parent="."]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
stretch = true
|
||||
|
||||
[node name="GameWindow" type="SubViewport" parent="SubViewportContainer"]
|
||||
unique_name_in_owner = true
|
||||
transparent_bg = true
|
||||
handle_input_locally = false
|
||||
audio_listener_enable_2d = true
|
||||
audio_listener_enable_3d = true
|
||||
size = Vector2i(1280, 960)
|
||||
render_target_update_mode = 4
|
||||
|
||||
[node name="Menu" parent="." instance=ExtResource("2_kvwo1")]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
|
||||
[node name="Splash" parent="." instance=ExtResource("3_3st5l")]
|
||||
unique_name_in_owner = true
|
||||
|
||||
[node name="BlankScreenControl" type="Control" parent="."]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="BlankScreen" type="ColorRect" parent="BlankScreenControl"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(0, 0, 0, 1)
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_3st5l")
|
||||
}
|
||||
67
Zennysoft.Game.Ma/src/app/domain/AppRepo.cs
Normal file
67
Zennysoft.Game.Ma/src/app/domain/AppRepo.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
public interface IAppRepo : IDisposable
|
||||
{
|
||||
event Action? GameEntered;
|
||||
|
||||
event Action? GameExited;
|
||||
|
||||
event Action? SplashScreenSkipped;
|
||||
|
||||
event Action? MainMenuEntered;
|
||||
|
||||
void SkipSplashScreen();
|
||||
|
||||
void OnMainMenuEntered();
|
||||
|
||||
void OnEnterGame();
|
||||
|
||||
void OnExitGame();
|
||||
|
||||
void OnGameOver();
|
||||
}
|
||||
|
||||
public class AppRepo : IAppRepo
|
||||
{
|
||||
public event Action? SplashScreenSkipped;
|
||||
public event Action? MainMenuEntered;
|
||||
public event Action? GameEntered;
|
||||
public event Action? GameExited;
|
||||
|
||||
private bool _disposedValue;
|
||||
|
||||
public void SkipSplashScreen() => SplashScreenSkipped?.Invoke();
|
||||
|
||||
public void OnMainMenuEntered() => MainMenuEntered?.Invoke();
|
||||
|
||||
public void OnEnterGame() => GameEntered?.Invoke();
|
||||
|
||||
public void OnExitGame() => GameExited?.Invoke();
|
||||
|
||||
public void OnGameOver() => GameExited?.Invoke();
|
||||
|
||||
protected void Dispose(bool disposing)
|
||||
{
|
||||
if (!_disposedValue)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// Dispose managed objects.
|
||||
SplashScreenSkipped = null;
|
||||
MainMenuEntered = null;
|
||||
GameEntered = null;
|
||||
GameExited = null;
|
||||
}
|
||||
|
||||
_disposedValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(disposing: true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
1
Zennysoft.Game.Ma/src/app/domain/AppRepo.cs.uid
Normal file
1
Zennysoft.Game.Ma/src/app/domain/AppRepo.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dyd1r1pl5beku
|
||||
8
Zennysoft.Game.Ma/src/app/state/AppLogic.Data.cs
Normal file
8
Zennysoft.Game.Ma/src/app/state/AppLogic.Data.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Zennysoft.Game.Ma;
|
||||
public partial class AppLogic
|
||||
{
|
||||
public record Data
|
||||
{
|
||||
public bool ShouldLoadExistingGame { get; set; }
|
||||
}
|
||||
}
|
||||
1
Zennysoft.Game.Ma/src/app/state/AppLogic.Data.cs.uid
Normal file
1
Zennysoft.Game.Ma/src/app/state/AppLogic.Data.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cbqvl36d7foae
|
||||
24
Zennysoft.Game.Ma/src/app/state/AppLogic.Input.cs
Normal file
24
Zennysoft.Game.Ma/src/app/state/AppLogic.Input.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
public partial class AppLogic
|
||||
{
|
||||
public static class Input
|
||||
{
|
||||
public readonly record struct NewGame;
|
||||
|
||||
public readonly record struct LoadGame;
|
||||
|
||||
public readonly record struct LoadGameFinished;
|
||||
|
||||
public readonly record struct FadeInFinished;
|
||||
public readonly record struct FadeOutFinished;
|
||||
|
||||
public readonly record struct QuitGame;
|
||||
|
||||
public readonly record struct GameOver;
|
||||
|
||||
public readonly record struct ShowLoadingScreen;
|
||||
|
||||
public readonly record struct SaveFileLoaded;
|
||||
}
|
||||
}
|
||||
1
Zennysoft.Game.Ma/src/app/state/AppLogic.Input.cs.uid
Normal file
1
Zennysoft.Game.Ma/src/app/state/AppLogic.Input.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b2hwfi78870pf
|
||||
33
Zennysoft.Game.Ma/src/app/state/AppLogic.Output.cs
Normal file
33
Zennysoft.Game.Ma/src/app/state/AppLogic.Output.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
public partial class AppLogic
|
||||
{
|
||||
public static class Output
|
||||
{
|
||||
public readonly record struct FadeToBlack;
|
||||
|
||||
public readonly record struct ShowSplashScreen;
|
||||
|
||||
public readonly record struct HideSplashScreen;
|
||||
|
||||
public readonly record struct RemoveExistingGame;
|
||||
|
||||
public readonly record struct PlayGame;
|
||||
|
||||
public readonly record struct ShowGame;
|
||||
|
||||
public readonly record struct HideGame;
|
||||
|
||||
public readonly record struct SetupGameScene;
|
||||
|
||||
public readonly record struct ShowLoadingScreen;
|
||||
|
||||
public readonly record struct ShowMainMenu;
|
||||
|
||||
public readonly record struct ExitGame;
|
||||
|
||||
public readonly record struct GameOver;
|
||||
|
||||
public readonly record struct StartLoadingSaveFile;
|
||||
}
|
||||
}
|
||||
1
Zennysoft.Game.Ma/src/app/state/AppLogic.Output.cs.uid
Normal file
1
Zennysoft.Game.Ma/src/app/state/AppLogic.Output.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dfygx4qdyomdw
|
||||
10
Zennysoft.Game.Ma/src/app/state/AppLogic.State.cs
Normal file
10
Zennysoft.Game.Ma/src/app/state/AppLogic.State.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
public partial class AppLogic
|
||||
{
|
||||
[Meta]
|
||||
public abstract partial record State : StateLogic<State>;
|
||||
}
|
||||
1
Zennysoft.Game.Ma/src/app/state/AppLogic.State.cs.uid
Normal file
1
Zennysoft.Game.Ma/src/app/state/AppLogic.State.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dqc8wddrx0txd
|
||||
13
Zennysoft.Game.Ma/src/app/state/AppLogic.cs
Normal file
13
Zennysoft.Game.Ma/src/app/state/AppLogic.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
public interface IAppLogic : ILogicBlock<AppLogic.State>;
|
||||
|
||||
[Meta]
|
||||
[LogicBlock(typeof(State), Diagram = true)]
|
||||
public partial class AppLogic : LogicBlock<AppLogic.State>, IAppLogic
|
||||
{
|
||||
public override Transition GetInitialState() => To<State.SplashScreen>();
|
||||
}
|
||||
1
Zennysoft.Game.Ma/src/app/state/AppLogic.cs.uid
Normal file
1
Zennysoft.Game.Ma/src/app/state/AppLogic.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://e51dlkiwpksy
|
||||
30
Zennysoft.Game.Ma/src/app/state/AppLogic.g.puml
Normal file
30
Zennysoft.Game.Ma/src/app/state/AppLogic.g.puml
Normal file
@@ -0,0 +1,30 @@
|
||||
@startuml AppLogic
|
||||
state "AppLogic State" as Zennysoft_Game_Ma_AppLogic_State {
|
||||
state "InGame" as Zennysoft_Game_Ma_AppLogic_State_InGame
|
||||
state "LeavingMenu" as Zennysoft_Game_Ma_AppLogic_State_LeavingMenu
|
||||
state "LoadingSaveFile" as Zennysoft_Game_Ma_AppLogic_State_LoadingSaveFile
|
||||
state "MainMenu" as Zennysoft_Game_Ma_AppLogic_State_MainMenu
|
||||
state "SplashScreen" as Zennysoft_Game_Ma_AppLogic_State_SplashScreen
|
||||
}
|
||||
|
||||
Zennysoft_Game_Ma_AppLogic_State_InGame --> Zennysoft_Game_Ma_AppLogic_State_MainMenu : GameOver
|
||||
Zennysoft_Game_Ma_AppLogic_State_LeavingMenu --> Zennysoft_Game_Ma_AppLogic_State_InGame : FadeOutFinished
|
||||
Zennysoft_Game_Ma_AppLogic_State_LeavingMenu --> Zennysoft_Game_Ma_AppLogic_State_LoadingSaveFile : FadeOutFinished
|
||||
Zennysoft_Game_Ma_AppLogic_State_LoadingSaveFile --> Zennysoft_Game_Ma_AppLogic_State_InGame : SaveFileLoaded
|
||||
Zennysoft_Game_Ma_AppLogic_State_MainMenu --> Zennysoft_Game_Ma_AppLogic_State_LeavingMenu : LoadGame
|
||||
Zennysoft_Game_Ma_AppLogic_State_MainMenu --> Zennysoft_Game_Ma_AppLogic_State_LeavingMenu : NewGame
|
||||
Zennysoft_Game_Ma_AppLogic_State_MainMenu --> Zennysoft_Game_Ma_AppLogic_State_MainMenu : QuitGame
|
||||
Zennysoft_Game_Ma_AppLogic_State_SplashScreen --> Zennysoft_Game_Ma_AppLogic_State_MainMenu : FadeOutFinished
|
||||
|
||||
Zennysoft_Game_Ma_AppLogic_State_InGame : OnEnter → ShowGame
|
||||
Zennysoft_Game_Ma_AppLogic_State_InGame : OnExit → HideGame
|
||||
Zennysoft_Game_Ma_AppLogic_State_InGame : OnGameOver → RemoveExistingGame
|
||||
Zennysoft_Game_Ma_AppLogic_State_LeavingMenu : OnEnter → FadeToBlack
|
||||
Zennysoft_Game_Ma_AppLogic_State_LoadingSaveFile : OnEnter → StartLoadingSaveFile
|
||||
Zennysoft_Game_Ma_AppLogic_State_MainMenu : OnEnter → SetupGameScene, ShowMainMenu
|
||||
Zennysoft_Game_Ma_AppLogic_State_MainMenu : OnQuitGame → ExitGame
|
||||
Zennysoft_Game_Ma_AppLogic_State_SplashScreen : OnEnter → ShowSplashScreen
|
||||
Zennysoft_Game_Ma_AppLogic_State_SplashScreen : OnSplashScreenSkipped() → HideSplashScreen
|
||||
|
||||
[*] --> Zennysoft_Game_Ma_AppLogic_State_SplashScreen
|
||||
@enduml
|
||||
@@ -0,0 +1,36 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
public partial class AppLogic
|
||||
{
|
||||
public partial record State
|
||||
{
|
||||
[Meta]
|
||||
public partial record InGame : State, IGet<Input.GameOver>
|
||||
{
|
||||
public InGame()
|
||||
{
|
||||
|
||||
this.OnEnter(() =>
|
||||
{
|
||||
Output(new Output.ShowGame());
|
||||
Get<IAppRepo>().OnEnterGame();
|
||||
});
|
||||
this.OnExit(() => Output(new Output.HideGame()));
|
||||
|
||||
OnAttach(() => Get<IAppRepo>().GameExited += OnGameExited);
|
||||
OnDetach(() => Get<IAppRepo>().GameExited -= OnGameExited);
|
||||
}
|
||||
|
||||
public Transition On(in Input.GameOver input)
|
||||
{
|
||||
Output(new Output.RemoveExistingGame());
|
||||
return To<MainMenu>();
|
||||
}
|
||||
|
||||
public void OnGameExited() => Input(new Input.QuitGame());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://ckb88dvtckagu
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
public partial class AppLogic
|
||||
{
|
||||
public partial record State
|
||||
{
|
||||
[Meta]
|
||||
public partial record LeavingMenu : State, IGet<Input.FadeOutFinished>
|
||||
{
|
||||
public LeavingMenu()
|
||||
{
|
||||
this.OnEnter(() => Output(new Output.FadeToBlack()));
|
||||
}
|
||||
|
||||
public Transition On(in Input.FadeOutFinished input) =>
|
||||
Get<Data>().ShouldLoadExistingGame
|
||||
? To<LoadingSaveFile>()
|
||||
: To<InGame>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://du7y6o0h004sm
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
public partial class AppLogic
|
||||
{
|
||||
public partial record State
|
||||
{
|
||||
[Meta]
|
||||
public partial record LoadingSaveFile : State, IGet<Input.SaveFileLoaded>
|
||||
{
|
||||
public LoadingSaveFile()
|
||||
{
|
||||
this.OnEnter(() => Output(new Output.StartLoadingSaveFile()));
|
||||
}
|
||||
|
||||
public Transition On(in Input.SaveFileLoaded input) => To<InGame>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://b5j2df20jd05i
|
||||
@@ -0,0 +1,42 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
public partial class AppLogic
|
||||
{
|
||||
public partial record State
|
||||
{
|
||||
[Meta]
|
||||
public partial record MainMenu : State, IGet<Input.NewGame>, IGet<Input.LoadGame>, IGet<Input.QuitGame>
|
||||
{
|
||||
public MainMenu()
|
||||
{
|
||||
this.OnEnter(() =>
|
||||
{
|
||||
Get<Data>().ShouldLoadExistingGame = false;
|
||||
Output(new Output.SetupGameScene());
|
||||
Get<IAppRepo>().OnMainMenuEntered();
|
||||
Output(new Output.ShowMainMenu());
|
||||
});
|
||||
}
|
||||
|
||||
public Transition On(in Input.NewGame input)
|
||||
{
|
||||
return To<LeavingMenu>();
|
||||
}
|
||||
|
||||
public Transition On(in Input.LoadGame input)
|
||||
{
|
||||
Get<Data>().ShouldLoadExistingGame = true;
|
||||
return To<LeavingMenu>();
|
||||
}
|
||||
|
||||
public Transition On(in Input.QuitGame input)
|
||||
{
|
||||
Output(new Output.ExitGame());
|
||||
return ToSelf();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://b5ehfb8l8u2fy
|
||||
@@ -0,0 +1 @@
|
||||
uid://ddceu88ak7e41
|
||||
@@ -0,0 +1,32 @@
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
public partial class AppLogic
|
||||
{
|
||||
public partial record State
|
||||
{
|
||||
[Meta]
|
||||
public partial record SplashScreen : State, IGet<Input.FadeOutFinished>
|
||||
{
|
||||
public SplashScreen()
|
||||
{
|
||||
this.OnEnter(() => Output(new Output.ShowSplashScreen()));
|
||||
|
||||
OnAttach(
|
||||
() => Get<IAppRepo>().SplashScreenSkipped += OnSplashScreenSkipped
|
||||
);
|
||||
|
||||
OnDetach(
|
||||
() => Get<IAppRepo>().SplashScreenSkipped -= OnSplashScreenSkipped
|
||||
);
|
||||
}
|
||||
|
||||
public Transition On(in Input.FadeOutFinished input) => To<MainMenu>();
|
||||
|
||||
public void OnSplashScreenSkipped() =>
|
||||
Output(new Output.HideSplashScreen());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://dxbrwt7jduxu8
|
||||
1
Zennysoft.Game.Ma/src/app/state/states/InGame.cs.uid
Normal file
1
Zennysoft.Game.Ma/src/app/state/states/InGame.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://xix7akau8f8g
|
||||
@@ -0,0 +1 @@
|
||||
uid://cm2spwox38qgx
|
||||
1
Zennysoft.Game.Ma/src/app/state/states/MainMenu.cs.uid
Normal file
1
Zennysoft.Game.Ma/src/app/state/states/MainMenu.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bjhw05eivyte3
|
||||
Reference in New Issue
Block a user