Move GameLogic to new project
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
namespace Zennysoft.Game.Ma;
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
public partial class GameLogic
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Zennysoft.Game.Ma;
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
public partial class GameLogic
|
||||
{
|
||||
@@ -28,6 +28,8 @@ public partial class GameLogic
|
||||
|
||||
public readonly record struct LoadNextFloor;
|
||||
|
||||
public readonly record struct LoadMap;
|
||||
|
||||
public readonly record struct ShowFloorClearMenu;
|
||||
|
||||
public readonly record struct ExitFloorClearMenu;
|
||||
@@ -1,7 +1,7 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
public partial class GameLogic
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
public interface IGameLogic : ILogicBlock<GameLogic.State>;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
public interface IGameRepo : IDisposable
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Chickensoft.Introspection;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
public partial class GameLogic
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Chickensoft.Introspection;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
public partial class GameLogic
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
public partial class GameLogic
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Zennysoft.Game.Ma;
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
using Chickensoft.Introspection;
|
||||
using Zennysoft.Game.Abstractions;
|
||||
@@ -20,7 +20,7 @@ public partial class GameLogic
|
||||
|
||||
public Transition On(in Input.StartGame input)
|
||||
{
|
||||
Get<IMap>().LoadMap();
|
||||
Output(new Output.LoadMap());
|
||||
return To<Playing>();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
public partial class GameLogic
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
public partial class GameLogic
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
public partial class GameLogic
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
public partial class GameLogic
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Zennysoft.Game.Ma;
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
@@ -2,22 +2,18 @@
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Collections;
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.SaveFileBuilder;
|
||||
using Chickensoft.Serialization;
|
||||
using Chickensoft.Serialization.Godot;
|
||||
using Zennysoft.Game.Ma.src.items;
|
||||
using Godot;
|
||||
using System;
|
||||
using System.IO.Abstractions;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization.Metadata;
|
||||
using static Zennysoft.Game.Ma.GameLogic.State;
|
||||
using Zennysoft.Game.Abstractions;
|
||||
using Zennysoft.Game.Ma.Implementation;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
using SimpleInjector;
|
||||
using static Zennysoft.Game.Ma.Implementation.GameLogic.State;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class Game : Node3D, IGame
|
||||
@@ -89,10 +85,12 @@ public partial class Game : Node3D, IGame
|
||||
_container = new SimpleInjector.Container();
|
||||
_container.Register<IFileSystem, FileSystem>();
|
||||
_container.Register<ISaveFileManager<GameData>, SaveFileManager<GameData>>();
|
||||
_container.Register<IGameRepo, GameRepo>(Lifestyle.Singleton);
|
||||
_container.Register<IGameLogic, GameLogic>(Lifestyle.Singleton);
|
||||
_container.Verify();
|
||||
|
||||
GameRepo = new GameRepo();
|
||||
GameLogic = new GameLogic();
|
||||
GameRepo = _container.GetInstance<IGameRepo>();
|
||||
GameLogic = _container.GetInstance<IGameLogic>();
|
||||
GameEventDepot = new GameEventDepot();
|
||||
GameLogic.Set(GameRepo);
|
||||
GameLogic.Set(AppRepo);
|
||||
@@ -188,6 +186,7 @@ public partial class Game : Node3D, IGame
|
||||
PauseMenu.SetProcessUnhandledInput(true);
|
||||
})
|
||||
.Handle((in GameLogic.Output.LoadNextFloor _) => { Map.SpawnNextFloor(); })
|
||||
.Handle((in GameLogic.Output.LoadMap _) => { Map.LoadMap(); })
|
||||
.Handle((in GameLogic.Output.HidePauseMenu _) => { PauseMenu.Hide(); })
|
||||
.Handle((in GameLogic.Output.ExitPauseMenu _) => { PauseMenu.FadeOut(); Input.MouseMode = Input.MouseModeEnum.Visible; PauseMenu.SetProcessUnhandledInput(false); })
|
||||
.Handle((in GameLogic.Output.ShowFloorClearMenu _) => { FloorClearMenu.Show(); FloorClearMenu.FadeIn(); })
|
||||
|
||||
@@ -6,6 +6,7 @@ using Chickensoft.GodotNodeInterfaces;
|
||||
using Chickensoft.SaveFileBuilder;
|
||||
using Godot;
|
||||
using System;
|
||||
using Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
public interface IGame : IProvide<IGameRepo>, IProvide<IGameEventDepot>, IProvide<IGame>, IProvide<IPlayer>, IProvide<ISaveChunk<GameData>>, INode3D
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using Chickensoft.Introspection;
|
||||
using Chickensoft.SaveFileBuilder;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
using SimpleInjector;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Zennysoft.Game.Ma.Implementation;
|
||||
@@ -44,7 +45,7 @@ public partial class Player : CharacterBody3D, IPlayer
|
||||
|
||||
private PlayerLogic.Settings Settings { get; set; } = default!;
|
||||
|
||||
private PlayerLogic PlayerLogic { get; set; } = default!;
|
||||
private IPlayerLogic PlayerLogic { get; set; } = default!;
|
||||
|
||||
|
||||
#region Dependencies
|
||||
@@ -116,6 +117,10 @@ public partial class Player : CharacterBody3D, IPlayer
|
||||
|
||||
public void Setup()
|
||||
{
|
||||
var container = new SimpleInjector.Container();
|
||||
container.Register<IPlayerLogic, PlayerLogic>(Lifestyle.Singleton);
|
||||
container.Verify();
|
||||
|
||||
Settings = new PlayerLogic.Settings() { RotationSpeed = PlayerStatResource.RotationSpeed, MoveSpeed = PlayerStatResource.MoveSpeed, Acceleration = PlayerStatResource.Acceleration };
|
||||
Stats = new PlayerStatController();
|
||||
Stats.Init(
|
||||
@@ -139,7 +144,7 @@ public partial class Player : CharacterBody3D, IPlayer
|
||||
|
||||
Inventory = new Inventory();
|
||||
|
||||
PlayerLogic = new PlayerLogic();
|
||||
PlayerLogic = container.GetInstance<IPlayerLogic>();
|
||||
PlayerLogic.Set(this as IPlayer);
|
||||
PlayerLogic.Set(Settings);
|
||||
PlayerLogic.Set(Stats);
|
||||
|
||||
Reference in New Issue
Block a user