Move App logic to other projects
This commit is contained in:
46
Zennysoft.Game.Ma.Implementation/App/AppRepo.cs
Normal file
46
Zennysoft.Game.Ma.Implementation/App/AppRepo.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using Zennysoft.Game.Abstractions;
|
||||
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
public partial class AppLogic
|
||||
{
|
||||
public record Data
|
||||
{
|
||||
public bool ShouldLoadExistingGame { get; set; }
|
||||
}
|
||||
}
|
||||
24
Zennysoft.Game.Ma.Implementation/App/State/AppLogic.Input.cs
Normal file
24
Zennysoft.Game.Ma.Implementation/App/State/AppLogic.Input.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
10
Zennysoft.Game.Ma.Implementation/App/State/AppLogic.State.cs
Normal file
10
Zennysoft.Game.Ma.Implementation/App/State/AppLogic.State.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
public partial class AppLogic
|
||||
{
|
||||
[Meta]
|
||||
public abstract partial record State : StateLogic<State>;
|
||||
}
|
||||
13
Zennysoft.Game.Ma.Implementation/App/State/AppLogic.cs
Normal file
13
Zennysoft.Game.Ma.Implementation/App/State/AppLogic.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
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>();
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
using Zennysoft.Game.Abstractions;
|
||||
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
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,24 @@
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
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,21 @@
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
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,43 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
using Zennysoft.Game.Abstractions;
|
||||
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
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,33 @@
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
using Zennysoft.Game.Abstractions;
|
||||
|
||||
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,8 @@
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
public enum AccessoryTag
|
||||
{
|
||||
None,
|
||||
HalfVTConsumption,
|
||||
StatusEffectImmunity
|
||||
}
|
||||
6
Zennysoft.Game.Ma.Implementation/Item/Tags/BoxItemTag.cs
Normal file
6
Zennysoft.Game.Ma.Implementation/Item/Tags/BoxItemTag.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
public enum BoxItemTag
|
||||
{
|
||||
RandomNewItem,
|
||||
}
|
||||
11
Zennysoft.Game.Ma.Implementation/Item/Tags/ElementType.cs
Normal file
11
Zennysoft.Game.Ma.Implementation/Item/Tags/ElementType.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
public enum ElementType
|
||||
{
|
||||
None,
|
||||
Aeolic,
|
||||
Telluric,
|
||||
Hydric,
|
||||
Igneous,
|
||||
Ferrum
|
||||
}
|
||||
7
Zennysoft.Game.Ma.Implementation/Item/Tags/ItemTag.cs
Normal file
7
Zennysoft.Game.Ma.Implementation/Item/Tags/ItemTag.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
public enum ItemTag
|
||||
{
|
||||
None,
|
||||
BreaksOnChange
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
public enum ThrowableItemTag
|
||||
{
|
||||
None,
|
||||
LowerTargetTo1HP,
|
||||
CanChangeAffinity,
|
||||
TeleportToRandomLocation,
|
||||
WarpToExitIfFound
|
||||
}
|
||||
20
Zennysoft.Game.Ma.Implementation/Item/Tags/UsableItemTag.cs
Normal file
20
Zennysoft.Game.Ma.Implementation/Item/Tags/UsableItemTag.cs
Normal 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,
|
||||
}
|
||||
9
Zennysoft.Game.Ma.Implementation/Item/Tags/WeaponTag.cs
Normal file
9
Zennysoft.Game.Ma.Implementation/Item/Tags/WeaponTag.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
public enum WeaponTag
|
||||
{
|
||||
None,
|
||||
SelfDamage,
|
||||
IgnoreAffinity,
|
||||
Knockback,
|
||||
}
|
||||
@@ -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;
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user