Start refactoring UI concerns away from game and into UI logic class
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
public partial class InGameUILogic
|
||||
{
|
||||
[Meta]
|
||||
public abstract partial record State : StateLogic<State>
|
||||
{
|
||||
protected State()
|
||||
{
|
||||
OnAttach(() =>
|
||||
{
|
||||
var gameRepo = Get<IGameRepo>();
|
||||
gameRepo.AnnounceMessage += OnAnnounceMessage;
|
||||
});
|
||||
OnDetach(() =>
|
||||
{
|
||||
var gameRepo = Get<IGameRepo>();
|
||||
gameRepo.AnnounceMessage -= OnAnnounceMessage;
|
||||
});
|
||||
}
|
||||
|
||||
private void OnAnnounceMessage(string message)
|
||||
{
|
||||
Output(new Output.AnnounceMessage(message));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
public interface IInGameUILogic : ILogicBlock<InGameUILogic.State>;
|
||||
|
||||
[Meta]
|
||||
[LogicBlock(typeof(State), Diagram = true)]
|
||||
public partial class InGameUILogic : LogicBlock<InGameUILogic.State>, IInGameUILogic
|
||||
{
|
||||
public override Transition GetInitialState() => To<State.Active>();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
public partial class InGameUILogic
|
||||
{
|
||||
public static class Output
|
||||
{
|
||||
public readonly record struct AnnounceMessage(string Message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using Chickensoft.Introspection;
|
||||
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
public partial class InGameUILogic
|
||||
{
|
||||
public partial record State
|
||||
{
|
||||
[Meta]
|
||||
public partial record Active : State
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user