Move App logic to other projects

This commit is contained in:
2025-03-07 01:08:35 -08:00
parent 3b5ee84ce2
commit 1cb79f5b30
49 changed files with 185 additions and 205 deletions

View File

@@ -0,0 +1,22 @@
namespace Zennysoft.Game.Abstractions;
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();
}

View File

@@ -1,4 +1,4 @@
namespace Zennysoft.Game.Ma.src.enemy;
namespace Zennysoft.Game.Abstractions;
public interface ICanPatrol
{

View File

@@ -1,27 +1,6 @@
using System;
using Zennysoft.Game.Abstractions;
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();
}
namespace Zennysoft.Game.Ma.Implementation;
public class AppRepo : IAppRepo
{

View File

@@ -1,4 +1,5 @@
namespace Zennysoft.Game.Ma;
namespace Zennysoft.Game.Ma.Implementation;
public partial class AppLogic
{
public record Data

View File

@@ -1,4 +1,4 @@
namespace Zennysoft.Game.Ma;
namespace Zennysoft.Game.Ma.Implementation;
public partial class AppLogic
{

View File

@@ -1,4 +1,4 @@
namespace Zennysoft.Game.Ma;
namespace Zennysoft.Game.Ma.Implementation;
public partial class AppLogic
{

View File

@@ -1,7 +1,7 @@
using Chickensoft.Introspection;
using Chickensoft.LogicBlocks;
namespace Zennysoft.Game.Ma;
namespace Zennysoft.Game.Ma.Implementation;
public partial class AppLogic
{

View File

@@ -1,7 +1,7 @@
using Chickensoft.Introspection;
using Chickensoft.LogicBlocks;
namespace Zennysoft.Game.Ma;
namespace Zennysoft.Game.Ma.Implementation;
public interface IAppLogic : ILogicBlock<AppLogic.State>;

View File

@@ -1,7 +1,8 @@
using Chickensoft.Introspection;
using Chickensoft.LogicBlocks;
using Zennysoft.Game.Abstractions;
namespace Zennysoft.Game.Ma;
namespace Zennysoft.Game.Ma.Implementation;
public partial class AppLogic
{

View File

@@ -1,4 +1,4 @@
namespace Zennysoft.Game.Ma;
namespace Zennysoft.Game.Ma.Implementation;
using Chickensoft.Introspection;
using Chickensoft.LogicBlocks;

View File

@@ -1,4 +1,4 @@
namespace Zennysoft.Game.Ma;
namespace Zennysoft.Game.Ma.Implementation;
using Chickensoft.Introspection;
using Chickensoft.LogicBlocks;

View File

@@ -1,7 +1,8 @@
using Chickensoft.Introspection;
using Chickensoft.LogicBlocks;
using Zennysoft.Game.Abstractions;
namespace Zennysoft.Game.Ma;
namespace Zennysoft.Game.Ma.Implementation;
public partial class AppLogic
{

View File

@@ -1,7 +1,8 @@
namespace Zennysoft.Game.Ma;
namespace Zennysoft.Game.Ma.Implementation;
using Chickensoft.Introspection;
using Chickensoft.LogicBlocks;
using Zennysoft.Game.Abstractions;
public partial class AppLogic
{

View File

@@ -0,0 +1,8 @@
namespace Zennysoft.Game.Ma.Implementation;
public enum AccessoryTag
{
None,
HalfVTConsumption,
StatusEffectImmunity
}

View File

@@ -0,0 +1,6 @@
namespace Zennysoft.Game.Ma.Implementation;
public enum BoxItemTag
{
RandomNewItem,
}

View File

@@ -0,0 +1,11 @@
namespace Zennysoft.Game.Ma.Implementation;
public enum ElementType
{
None,
Aeolic,
Telluric,
Hydric,
Igneous,
Ferrum
}

View File

@@ -0,0 +1,7 @@
namespace Zennysoft.Game.Ma.Implementation;
public enum ItemTag
{
None,
BreaksOnChange
}

View File

@@ -0,0 +1,10 @@
namespace Zennysoft.Game.Ma.Implementation;
public enum ThrowableItemTag
{
None,
LowerTargetTo1HP,
CanChangeAffinity,
TeleportToRandomLocation,
WarpToExitIfFound
}

View File

@@ -0,0 +1,20 @@
namespace Zennysoft.Game.Ma.Implementation;
public enum UsableItemTag
{
None,
DoubleEXP,
IdentifyAllItemsCostHP,
BriefImmunity,
SwapHPAndVT,
TeleportAllEnemiesToRoom,
TurnAllEnemiesIntoHealingItem,
KillHalfEnemiesInRoom,
AbsorbHPFromAllEnemiesInRoom,
HealsAllInRoomToMaxHP,
DealElementalDamageToAllEnemiesInRoom,
RaiseCurrentWeaponAttack,
RaiseCurrentDefenseArmor,
RaiseLevel,
RandomEffect,
}

View File

@@ -0,0 +1,9 @@
namespace Zennysoft.Game.Ma.Implementation;
public enum WeaponTag
{
None,
SelfDamage,
IgnoreAffinity,
Knockback,
}

View File

@@ -2,87 +2,23 @@
namespace Zennysoft.Game.Ma.Implementation;
public enum WeaponTag
{
None,
SelfDamage,
IgnoreAffinity,
Knockback,
}
[JsonSerializable(typeof(WeaponTag))]
public partial class WeaponTagEnumContext : JsonSerializerContext;
public enum ItemTag
{
None,
BreaksOnChange
}
[JsonSerializable(typeof(ItemTag))]
public partial class ItemTagEnumContext : JsonSerializerContext;
public enum AccessoryTag
{
None,
HalfVTConsumption,
StatusEffectImmunity
}
[JsonSerializable(typeof(AccessoryTag))]
public partial class AccessoryTagEnumContext : JsonSerializerContext;
public enum ThrowableItemTag
{
None,
LowerTargetTo1HP,
CanChangeAffinity,
TeleportToRandomLocation,
WarpToExitIfFound
}
[JsonSerializable(typeof(ThrowableItemTag))]
public partial class ThrowableItemTagEnumContext : JsonSerializerContext;
public enum UsableItemTag
{
None,
DoubleEXP,
IdentifyAllItemsCostHP,
BriefImmunity,
SwapHPAndVT,
TeleportAllEnemiesToRoom,
TurnAllEnemiesIntoHealingItem,
KillHalfEnemiesInRoom,
AbsorbHPFromAllEnemiesInRoom,
HealsAllInRoomToMaxHP,
DealElementalDamageToAllEnemiesInRoom,
RaiseCurrentWeaponAttack,
RaiseCurrentDefenseArmor,
RaiseLevel,
RandomEffect,
}
[JsonSerializable(typeof(UsableItemTag))]
public partial class UsableItemTagEnumContext : JsonSerializerContext;
public enum BoxItemTag
{
RandomNewItem,
}
[JsonSerializable(typeof(BoxItemTag))]
public partial class BoxItemTagEnumContext : JsonSerializerContext;
public enum ElementType
{
None,
Aeolic,
Telluric,
Hydric,
Igneous,
Ferrum
}
[JsonSerializable(typeof(ElementType))]
public partial class ElementTypeEnumContext : JsonSerializerContext;

View File

@@ -10,17 +10,14 @@
<PackageReference Include="Chickensoft.GodotNodeInterfaces" Version="2.4.0" />
<PackageReference Include="Chickensoft.Introspection" Version="2.2.0" />
<PackageReference Include="Chickensoft.Introspection.Generator" Version="2.2.0" />
<PackageReference Include="Chickensoft.LogicBlocks" Version="5.16.0" />
<PackageReference Include="Chickensoft.Serialization.Godot" Version="0.7.6" />
<PackageReference Include="GodotSharp.SourceGenerators" Version="2.5.0" />
<PackageReference Include="System.IO.Abstractions" Version="21.2.1" />
<PackageReference Include="GodotSharp.SourceGenerators" Version="2.6.0-250131-2115.Release" />
<PackageReference Include="System.IO.Abstractions" Version="22.0.11" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Zennysoft.Game.Abstractions\Zennysoft.Game.Abstractions.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Enums\" />
</ItemGroup>
</Project>

View File

@@ -1,51 +1,51 @@
<Project Sdk="Godot.NET.Sdk/4.4.0">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
<!-- Use NativeAOT. -->
<PublishAot>true</PublishAot>
</PropertyGroup>
<ItemGroup>
<Compile Remove="src\items\weapons\models\**" />
<EmbeddedResource Remove="src\items\weapons\models\**" />
</ItemGroup>
<ItemGroup>
<!-- Root the assemblies to avoid trimming. -->
<TrimmerRootAssembly Include="GodotSharp" />
<TrimmerRootAssembly Include="$(TargetName)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Chickensoft.AutoInject" Version="2.5.0" />
<PackageReference Include="Chickensoft.GodotNodeInterfaces" Version="2.4.0" />
<PackageReference Include="Chickensoft.Introspection" Version="2.2.0" />
<PackageReference Include="Chickensoft.Introspection.Generator" Version="2.2.0" />
<PackageReference Include="Chickensoft.LogicBlocks" Version="5.15.0" />
<PackageReference Include="Chickensoft.LogicBlocks.DiagramGenerator" Version="5.15.0" />
<PackageReference Include="Chickensoft.SaveFileBuilder" Version="1.1.0" />
<PackageReference Include="Chickensoft.Serialization.Godot" Version="0.7.6" />
<PackageReference Include="GodotSharp.SourceGenerators" Version="2.5.0" />
<PackageReference Include="SimpleInjector" Version="5.5.0" />
<PackageReference Include="SSH.NET" Version="2024.2.0" />
<PackageReference Include="System.IO.Abstractions" Version="21.2.1" />
<PackageReference Include="Zeroconf" Version="3.7.16" />
</ItemGroup>
<ItemGroup>
<Folder Include="src\ui\dialogue\" />
</ItemGroup>
<ItemGroup>
<None Include=".editorconfig" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Zennysoft.Game.Abstractions\Zennysoft.Game.Abstractions.csproj" />
<ProjectReference Include="..\Zennysoft.Game.Ma.Implementation\Zennysoft.Game.Ma.Implementation.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="Godot.SourceGenerators" Version="4.4.0-dev.2" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="GodotSharp" Version="4.4.0-dev.2" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="GodotSharpEditor" Version="4.4.0-dev.2" />
</ItemGroup>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
<!-- Use NativeAOT. -->
<PublishAot>true</PublishAot>
</PropertyGroup>
<ItemGroup>
<Compile Remove="src\items\weapons\models\**" />
<EmbeddedResource Remove="src\items\weapons\models\**" />
</ItemGroup>
<ItemGroup>
<!-- Root the assemblies to avoid trimming. -->
<TrimmerRootAssembly Include="GodotSharp" />
<TrimmerRootAssembly Include="$(TargetName)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Chickensoft.AutoInject" Version="2.5.0" />
<PackageReference Include="Chickensoft.GodotNodeInterfaces" Version="2.4.0" />
<PackageReference Include="Chickensoft.Introspection" Version="2.2.0" />
<PackageReference Include="Chickensoft.Introspection.Generator" Version="2.2.0" />
<PackageReference Include="Chickensoft.LogicBlocks" Version="5.16.0" />
<PackageReference Include="Chickensoft.LogicBlocks.DiagramGenerator" Version="5.16.0" />
<PackageReference Include="Chickensoft.SaveFileBuilder" Version="1.1.0" />
<PackageReference Include="Chickensoft.Serialization.Godot" Version="0.7.6" />
<PackageReference Include="GodotSharp.SourceGenerators" Version="2.6.0-250131-2115.Release" />
<PackageReference Include="SimpleInjector" Version="5.5.0" />
<PackageReference Include="SSH.NET" Version="2024.2.0" />
<PackageReference Include="System.IO.Abstractions" Version="22.0.11" />
<PackageReference Include="Zeroconf" Version="3.7.16" />
</ItemGroup>
<ItemGroup>
<Folder Include="src\ui\dialogue\" />
</ItemGroup>
<ItemGroup>
<None Include=".editorconfig" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Zennysoft.Game.Abstractions\Zennysoft.Game.Abstractions.csproj" />
<ProjectReference Include="..\Zennysoft.Game.Ma.Implementation\Zennysoft.Game.Ma.Implementation.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="Godot.SourceGenerators" Version="4.4.0-dev.2" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="GodotSharp" Version="4.4.0-dev.2" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="GodotSharpEditor" Version="4.4.0-dev.2" />
</ItemGroup>
</Project>

View File

@@ -2,7 +2,11 @@
using Chickensoft.GodotNodeInterfaces;
using Chickensoft.Introspection;
using Godot;
using static Zennysoft.Game.Ma.AppLogic.Input;
using SimpleInjector;
using SimpleInjector.Lifestyles;
using Zennysoft.Game.Abstractions;
using Zennysoft.Game.Ma.Implementation;
using static Zennysoft.Game.Ma.Implementation.AppLogic.Input;
namespace Zennysoft.Game.Ma;
@@ -35,9 +39,17 @@ public partial class App : CanvasLayer, IApp
public void Initialize()
{
var container = new SimpleInjector.Container();
container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle();
container.Register<IAppRepo, AppRepo>(Lifestyle.Singleton);
container.Register<IAppLogic, AppLogic>(Lifestyle.Singleton);
container.Verify();
Instantiator = new Instantiator(GetTree());
AppRepo = new AppRepo();
AppLogic = new AppLogic();
AppRepo = container.GetInstance<IAppRepo>();
AppLogic = container.GetInstance<IAppLogic>();
AppLogic.Set(AppRepo);
AppLogic.Set(new AppLogic.Data());

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,30 +0,0 @@
@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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -2,6 +2,7 @@ using Chickensoft.AutoInject;
using Chickensoft.GodotNodeInterfaces;
using Chickensoft.Introspection;
using Godot;
using Zennysoft.Game.Abstractions;
namespace Zennysoft.Game.Ma;

View File

@@ -1,9 +1,9 @@
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using Zennysoft.Game.Ma.src.enemy;
using Godot;
using System;
using System.Threading.Tasks;
using Zennysoft.Game.Abstractions;
namespace Zennysoft.Game.Ma;

View File

@@ -1,7 +1,7 @@
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using Zennysoft.Game.Ma.src.enemy;
using Godot;
using Zennysoft.Game.Abstractions;
using Zennysoft.Game.Ma.Implementation;
namespace Zennysoft.Game.Ma;

View File

@@ -1,7 +1,7 @@
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using Zennysoft.Game.Ma.src.enemy;
using Godot;
using Zennysoft.Game.Abstractions;
using Zennysoft.Game.Ma.Implementation;
namespace Zennysoft.Game.Ma;

View File

@@ -1,7 +1,7 @@
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using Zennysoft.Game.Ma.src.enemy;
using Godot;
using Zennysoft.Game.Abstractions;
using Zennysoft.Game.Ma.Implementation;
namespace Zennysoft.Game.Ma;

View File

@@ -1,6 +1,7 @@
namespace Zennysoft.Game.Ma;
using Chickensoft.Introspection;
using Zennysoft.Game.Abstractions;
public partial class GameLogic
{

View File

@@ -2,6 +2,7 @@
using Chickensoft.GodotNodeInterfaces;
using Chickensoft.Introspection;
using Godot;
using Zennysoft.Game.Abstractions;
namespace Zennysoft.Game.Ma;

View File

@@ -1,4 +1,5 @@
using Chickensoft.Introspection;
using Zennysoft.Game.Abstractions;
namespace Zennysoft.Game.Ma;