diff --git a/Ma.sln b/Ma.sln index 5a80ede2..7d7e667b 100644 --- a/Ma.sln +++ b/Ma.sln @@ -5,7 +5,7 @@ VisualStudioVersion = 17.11.35222.181 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ma", "Zennysoft.Game.Ma\Ma.csproj", "{B685AA99-B971-46A7-A708-00546BA0EF55}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Zennysoft.Ma.Godot.Adapter", "Zennysoft.Game.Ma.Implementation\Zennysoft.Ma.Godot.Adapter.csproj", "{3C934960-1375-4971-BF3F-C21F5241573A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Zennysoft.Ma.Adapter", "Zennysoft.Game.Ma.Implementation\Zennysoft.Ma.Adapter.csproj", "{3C934960-1375-4971-BF3F-C21F5241573A}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E4C0167B-02AB-49E0-B36D-30D0A2479C25}" ProjectSection(SolutionItems) = preProject @@ -14,6 +14,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Zennysoft.Game.Abstractions", "Zennysoft.Game.Abstractions\Zennysoft.Game.Abstractions.csproj", "{EB9A8B79-82E1-4254-B4FB-7F4BCB57BDBF}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Zennysoft.Game.Implementation", "Zennysoft.Game.Godot.Implementation\Zennysoft.Game.Implementation.csproj", "{F93CA4C0-DFA0-4AE2-AFB4-8238390F11F0}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -46,6 +48,14 @@ Global {EB9A8B79-82E1-4254-B4FB-7F4BCB57BDBF}.ExportRelease|Any CPU.Build.0 = Release|Any CPU {EB9A8B79-82E1-4254-B4FB-7F4BCB57BDBF}.Release|Any CPU.ActiveCfg = Release|Any CPU {EB9A8B79-82E1-4254-B4FB-7F4BCB57BDBF}.Release|Any CPU.Build.0 = Release|Any CPU + {F93CA4C0-DFA0-4AE2-AFB4-8238390F11F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F93CA4C0-DFA0-4AE2-AFB4-8238390F11F0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F93CA4C0-DFA0-4AE2-AFB4-8238390F11F0}.ExportDebug|Any CPU.ActiveCfg = Debug|Any CPU + {F93CA4C0-DFA0-4AE2-AFB4-8238390F11F0}.ExportDebug|Any CPU.Build.0 = Debug|Any CPU + {F93CA4C0-DFA0-4AE2-AFB4-8238390F11F0}.ExportRelease|Any CPU.ActiveCfg = Release|Any CPU + {F93CA4C0-DFA0-4AE2-AFB4-8238390F11F0}.ExportRelease|Any CPU.Build.0 = Release|Any CPU + {F93CA4C0-DFA0-4AE2-AFB4-8238390F11F0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F93CA4C0-DFA0-4AE2-AFB4-8238390F11F0}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Zennysoft.Game.Abstractions/Inventory/IInventoryItem.cs b/Zennysoft.Game.Abstractions/Inventory/IInventoryItem.cs deleted file mode 100644 index 1717b63a..00000000 --- a/Zennysoft.Game.Abstractions/Inventory/IInventoryItem.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Zennysoft.Game.Abstractions; - -public interface IInventoryItem -{ - string ItemName { get; } - - string Description { get; } -} diff --git a/Zennysoft.Game.Abstractions/Save/ISaveFileManager.cs b/Zennysoft.Game.Abstractions/Save/ISaveFileManager.cs index 0db34c41..b3bbe34f 100644 --- a/Zennysoft.Game.Abstractions/Save/ISaveFileManager.cs +++ b/Zennysoft.Game.Abstractions/Save/ISaveFileManager.cs @@ -1,16 +1,15 @@ using System.Text.Json; +using System.Text.Json.Serialization.Metadata; namespace Zennysoft.Game.Abstractions; public interface ISaveFileManager { - public Task WriteToFile(T gameData); + public Task WriteToFile(T gameData, params IJsonTypeInfoResolver?[] resolvers); - public Task WriteToFile(T gameData, string filePath); + public Task WriteToFile(T gameData, string filePath, params IJsonTypeInfoResolver?[] resolvers); - public Task WriteToFile(T gameData, string filePath, JsonSerializerOptions jsonOptions); + public Task ReadFromFile(params IJsonTypeInfoResolver?[] resolvers); - public Task ReadFromFile(); - - public Task ReadFromFile(string filePath); + public Task ReadFromFile(string filePath, params IJsonTypeInfoResolver?[] resolvers); } diff --git a/Zennysoft.Game.Ma.Implementation/Save/SaveFileManager.cs b/Zennysoft.Game.Godot.Implementation/Save/SaveFileManager.cs similarity index 61% rename from Zennysoft.Game.Ma.Implementation/Save/SaveFileManager.cs rename to Zennysoft.Game.Godot.Implementation/Save/SaveFileManager.cs index 48a56646..5e4d35bc 100644 --- a/Zennysoft.Game.Ma.Implementation/Save/SaveFileManager.cs +++ b/Zennysoft.Game.Godot.Implementation/Save/SaveFileManager.cs @@ -7,12 +7,12 @@ using System.Text.Json; using System.Text.Json.Serialization.Metadata; using Zennysoft.Game.Abstractions; -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Game.Implementation; public class SaveFileManager : ISaveFileManager { private readonly IFileSystem _fileSystem; - private JsonSerializerOptions _jsonOptions; + private readonly JsonSerializerOptions _jsonOptions; private string _defaultSaveLocation; public const string DEFAULT_SAVE_FILE_NAME = "game.json"; @@ -21,7 +21,6 @@ public class SaveFileManager : ISaveFileManager _fileSystem = fileSystem; _defaultSaveLocation = _fileSystem.Path.Join(OS.GetUserDataDir(), DEFAULT_SAVE_FILE_NAME); - var resolver = new SerializableTypeResolver(); GodotSerialization.Setup(); Serializer.AddConverter(new Texture2DConverter()); @@ -32,42 +31,40 @@ public class SaveFileManager : ISaveFileManager Converters = { new SerializableTypeConverter(upgradeDependencies) }, - TypeInfoResolver = JsonTypeInfoResolver.Combine(resolver, WeaponTagEnumContext.Default, ItemTagEnumContext.Default, ElementTypeEnumContext.Default, AccessoryTagEnumContext.Default, ThrowableItemTagEnumContext.Default, UsableItemTagEnumContext.Default, BoxItemTagEnumContext.Default), WriteIndented = true }; } - public Task ReadFromFile() + public Task ReadFromFile(params IJsonTypeInfoResolver?[] resolvers) { if (!_fileSystem.File.Exists(_defaultSaveLocation)) throw new FileNotFoundException(); - return ReadFromFile(_defaultSaveLocation); + return ReadFromFile(_defaultSaveLocation, resolvers); } - public async Task ReadFromFile(string filePath) + public async Task ReadFromFile(string filePath, params IJsonTypeInfoResolver?[] resolvers) { if (!_fileSystem.File.Exists(filePath)) throw new FileNotFoundException(); var json = await _fileSystem.File.ReadAllTextAsync(filePath); + var resolver = new SerializableTypeResolver(); + _jsonOptions.TypeInfoResolver = JsonTypeInfoResolver.Combine([resolver, .. resolvers]); return JsonSerializer.Deserialize(json, _jsonOptions); } - public Task WriteToFile(T gameData) + public Task WriteToFile(T gameData, params IJsonTypeInfoResolver?[] resolvers) { - return WriteToFile(gameData, _defaultSaveLocation, _jsonOptions); + return WriteToFile(gameData, _defaultSaveLocation, resolvers); } - public Task WriteToFile(T gameData, string filePath) + public async Task WriteToFile(T gameData, string filePath, params IJsonTypeInfoResolver?[] resolvers) { - return WriteToFile(gameData, filePath, _jsonOptions); - } - - public async Task WriteToFile(T gameData, string filePath, JsonSerializerOptions jsonOptions) - { - var json = JsonSerializer.Serialize(gameData, jsonOptions); + var resolver = new SerializableTypeResolver(); + _jsonOptions.TypeInfoResolver = JsonTypeInfoResolver.Combine([resolver, .. resolvers]); + var json = JsonSerializer.Serialize(gameData, _jsonOptions); await _fileSystem.File.WriteAllTextAsync(filePath, json); } } diff --git a/Zennysoft.Game.Ma.Implementation/JsonConverters/Texture2DConverter.cs b/Zennysoft.Game.Godot.Implementation/Save/Texture2DConverter.cs similarity index 100% rename from Zennysoft.Game.Ma.Implementation/JsonConverters/Texture2DConverter.cs rename to Zennysoft.Game.Godot.Implementation/Save/Texture2DConverter.cs diff --git a/Zennysoft.Game.Godot.Implementation/Zennysoft.Game.Implementation.csproj b/Zennysoft.Game.Godot.Implementation/Zennysoft.Game.Implementation.csproj new file mode 100644 index 00000000..6061f1c6 --- /dev/null +++ b/Zennysoft.Game.Godot.Implementation/Zennysoft.Game.Implementation.csproj @@ -0,0 +1,20 @@ + + + + net8.0 + enable + enable + + + + + + + + + + + + + + diff --git a/Zennysoft.Game.Godot.Implementation/cspell.json b/Zennysoft.Game.Godot.Implementation/cspell.json new file mode 100644 index 00000000..2283c7bb --- /dev/null +++ b/Zennysoft.Game.Godot.Implementation/cspell.json @@ -0,0 +1,70 @@ +{ + "files": [ + "**/*.*" + ], + "ignorePaths": [ + "**/*.tscn", + "**/*.import", + "**/badges/**/*.*", + "**/coverage/**/*.*", + "**/.godot/**/*.*", + "**/obj/**/*.*", + "**/bin/**/*.*", + "**/nupkg/**/*.*" + ], + "words": [ + "assemblyfilters", + "automerge", + "branchcoverage", + "brandedoutcast", + "buildtransitive", + "camelcase", + "chickenpackage", + "Chickensoft", + "classfilters", + "contentfiles", + "CYGWIN", + "devbuild", + "endregion", + "Finalizer", + "Finalizers", + "globaltool", + "godotengine", + "godotpackage", + "issuecomment", + "justalemon", + "lcov", + "lihop", + "linecoverage", + "methodcoverage", + "missingall", + "msbuild", + "MSYS", + "nameof", + "Nerdbank", + "netstandard", + "NOLOGO", + "nupkg", + "Omnisharp", + "opencover", + "OPTOUT", + "paramref", + "pascalcase", + "Postinitialize", + "Predelete", + "renovatebot", + "reportgenerator", + "reporttypes", + "Shouldly", + "subfolders", + "targetargs", + "targetdir", + "tscn", + "typeof", + "typeparam", + "typeparamref", + "ulong", + "Unparented", + "Xunit" + ] +} \ No newline at end of file diff --git a/Zennysoft.Game.Ma.Implementation/App/AppRepo.cs b/Zennysoft.Game.Ma.Implementation/App/AppRepo.cs index dec6e899..06cd7690 100644 --- a/Zennysoft.Game.Ma.Implementation/App/AppRepo.cs +++ b/Zennysoft.Game.Ma.Implementation/App/AppRepo.cs @@ -1,6 +1,6 @@ using Zennysoft.Game.Abstractions; -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public class AppRepo : IAppRepo { diff --git a/Zennysoft.Game.Ma.Implementation/App/State/AppLogic.Data.cs b/Zennysoft.Game.Ma.Implementation/App/State/AppLogic.Data.cs index 6516f9ae..7c8e98ad 100644 --- a/Zennysoft.Game.Ma.Implementation/App/State/AppLogic.Data.cs +++ b/Zennysoft.Game.Ma.Implementation/App/State/AppLogic.Data.cs @@ -1,4 +1,4 @@ -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public partial class AppLogic { diff --git a/Zennysoft.Game.Ma.Implementation/App/State/AppLogic.Input.cs b/Zennysoft.Game.Ma.Implementation/App/State/AppLogic.Input.cs index b42e8376..21e9ee1a 100644 --- a/Zennysoft.Game.Ma.Implementation/App/State/AppLogic.Input.cs +++ b/Zennysoft.Game.Ma.Implementation/App/State/AppLogic.Input.cs @@ -1,4 +1,4 @@ -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public partial class AppLogic { diff --git a/Zennysoft.Game.Ma.Implementation/App/State/AppLogic.Output.cs b/Zennysoft.Game.Ma.Implementation/App/State/AppLogic.Output.cs index 14ae6955..475800b6 100644 --- a/Zennysoft.Game.Ma.Implementation/App/State/AppLogic.Output.cs +++ b/Zennysoft.Game.Ma.Implementation/App/State/AppLogic.Output.cs @@ -1,4 +1,4 @@ -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public partial class AppLogic { diff --git a/Zennysoft.Game.Ma.Implementation/App/State/AppLogic.State.cs b/Zennysoft.Game.Ma.Implementation/App/State/AppLogic.State.cs index 8fb39dd9..6ad4eabf 100644 --- a/Zennysoft.Game.Ma.Implementation/App/State/AppLogic.State.cs +++ b/Zennysoft.Game.Ma.Implementation/App/State/AppLogic.State.cs @@ -1,7 +1,7 @@ using Chickensoft.Introspection; using Chickensoft.LogicBlocks; -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public partial class AppLogic { diff --git a/Zennysoft.Game.Ma.Implementation/App/State/AppLogic.cs b/Zennysoft.Game.Ma.Implementation/App/State/AppLogic.cs index 2ad60c30..38806d65 100644 --- a/Zennysoft.Game.Ma.Implementation/App/State/AppLogic.cs +++ b/Zennysoft.Game.Ma.Implementation/App/State/AppLogic.cs @@ -1,7 +1,7 @@ using Chickensoft.Introspection; using Chickensoft.LogicBlocks; -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public interface IAppLogic : ILogicBlock; diff --git a/Zennysoft.Game.Ma.Implementation/App/State/States/AppLogic.State.InGame.cs b/Zennysoft.Game.Ma.Implementation/App/State/States/AppLogic.State.InGame.cs index fd84e28c..63ecae91 100644 --- a/Zennysoft.Game.Ma.Implementation/App/State/States/AppLogic.State.InGame.cs +++ b/Zennysoft.Game.Ma.Implementation/App/State/States/AppLogic.State.InGame.cs @@ -2,7 +2,7 @@ using Chickensoft.LogicBlocks; using Zennysoft.Game.Abstractions; -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public partial class AppLogic { diff --git a/Zennysoft.Game.Ma.Implementation/App/State/States/AppLogic.State.LeavingMenu.cs b/Zennysoft.Game.Ma.Implementation/App/State/States/AppLogic.State.LeavingMenu.cs index 2ea1dfe2..67c877e8 100644 --- a/Zennysoft.Game.Ma.Implementation/App/State/States/AppLogic.State.LeavingMenu.cs +++ b/Zennysoft.Game.Ma.Implementation/App/State/States/AppLogic.State.LeavingMenu.cs @@ -1,4 +1,4 @@ -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; using Chickensoft.Introspection; using Chickensoft.LogicBlocks; diff --git a/Zennysoft.Game.Ma.Implementation/App/State/States/AppLogic.State.LoadingSaveFile.cs b/Zennysoft.Game.Ma.Implementation/App/State/States/AppLogic.State.LoadingSaveFile.cs index 2ac55671..f5713960 100644 --- a/Zennysoft.Game.Ma.Implementation/App/State/States/AppLogic.State.LoadingSaveFile.cs +++ b/Zennysoft.Game.Ma.Implementation/App/State/States/AppLogic.State.LoadingSaveFile.cs @@ -1,4 +1,4 @@ -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; using Chickensoft.Introspection; using Chickensoft.LogicBlocks; diff --git a/Zennysoft.Game.Ma.Implementation/App/State/States/AppLogic.State.MainMenu.cs b/Zennysoft.Game.Ma.Implementation/App/State/States/AppLogic.State.MainMenu.cs index 38d60955..f7e41ed2 100644 --- a/Zennysoft.Game.Ma.Implementation/App/State/States/AppLogic.State.MainMenu.cs +++ b/Zennysoft.Game.Ma.Implementation/App/State/States/AppLogic.State.MainMenu.cs @@ -2,7 +2,7 @@ using Chickensoft.LogicBlocks; using Zennysoft.Game.Abstractions; -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public partial class AppLogic { diff --git a/Zennysoft.Game.Ma.Implementation/App/State/States/AppLogic.State.SplashScreen.cs b/Zennysoft.Game.Ma.Implementation/App/State/States/AppLogic.State.SplashScreen.cs index a5d50bf3..22f2a884 100644 --- a/Zennysoft.Game.Ma.Implementation/App/State/States/AppLogic.State.SplashScreen.cs +++ b/Zennysoft.Game.Ma.Implementation/App/State/States/AppLogic.State.SplashScreen.cs @@ -1,4 +1,4 @@ -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; using Chickensoft.Introspection; using Chickensoft.LogicBlocks; diff --git a/Zennysoft.Game.Ma/src/game/GameData.cs b/Zennysoft.Game.Ma.Implementation/Game/GameData.cs similarity index 86% rename from Zennysoft.Game.Ma/src/game/GameData.cs rename to Zennysoft.Game.Ma.Implementation/Game/GameData.cs index ff6574c9..6f4f4f5a 100644 --- a/Zennysoft.Game.Ma/src/game/GameData.cs +++ b/Zennysoft.Game.Ma.Implementation/Game/GameData.cs @@ -1,7 +1,8 @@ using Chickensoft.Introspection; using Chickensoft.Serialization; +using Zennysoft.Game.Ma; -namespace Zennysoft.Game.Ma; +namespace Zennysoft.Ma.Adapter; [Meta, Id("game_data")] public partial record GameData diff --git a/Zennysoft.Game.Ma.Implementation/Game/GameLogic.Input.cs b/Zennysoft.Game.Ma.Implementation/Game/GameLogic.Input.cs index 0adac9b1..2f2d3753 100644 --- a/Zennysoft.Game.Ma.Implementation/Game/GameLogic.Input.cs +++ b/Zennysoft.Game.Ma.Implementation/Game/GameLogic.Input.cs @@ -1,4 +1,4 @@ -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public partial class GameLogic { diff --git a/Zennysoft.Game.Ma.Implementation/Game/GameLogic.Output.cs b/Zennysoft.Game.Ma.Implementation/Game/GameLogic.Output.cs index 49042948..be4386b6 100644 --- a/Zennysoft.Game.Ma.Implementation/Game/GameLogic.Output.cs +++ b/Zennysoft.Game.Ma.Implementation/Game/GameLogic.Output.cs @@ -1,4 +1,4 @@ -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public partial class GameLogic { diff --git a/Zennysoft.Game.Ma.Implementation/Game/GameLogic.State.cs b/Zennysoft.Game.Ma.Implementation/Game/GameLogic.State.cs index 22c64380..5892449c 100644 --- a/Zennysoft.Game.Ma.Implementation/Game/GameLogic.State.cs +++ b/Zennysoft.Game.Ma.Implementation/Game/GameLogic.State.cs @@ -1,7 +1,7 @@ using Chickensoft.Introspection; using Chickensoft.LogicBlocks; -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public partial class GameLogic { diff --git a/Zennysoft.Game.Ma.Implementation/Game/GameLogic.cs b/Zennysoft.Game.Ma.Implementation/Game/GameLogic.cs index 07e89f9f..5b51ad1a 100644 --- a/Zennysoft.Game.Ma.Implementation/Game/GameLogic.cs +++ b/Zennysoft.Game.Ma.Implementation/Game/GameLogic.cs @@ -1,7 +1,7 @@ using Chickensoft.Introspection; using Chickensoft.LogicBlocks; -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public interface IGameLogic : ILogicBlock; diff --git a/Zennysoft.Game.Ma.Implementation/Game/GameRepo.cs b/Zennysoft.Game.Ma.Implementation/Game/GameRepo.cs index 8b72547b..a1cc83fb 100644 --- a/Zennysoft.Game.Ma.Implementation/Game/GameRepo.cs +++ b/Zennysoft.Game.Ma.Implementation/Game/GameRepo.cs @@ -1,8 +1,7 @@ using Chickensoft.Collections; using Godot; -using Zennysoft.Game.Abstractions; -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public interface IGameRepo : IDisposable { @@ -18,7 +17,7 @@ public interface IGameRepo : IDisposable event Action? DoubleExpTimeEnd; - event Action? RemoveItemFromInventoryEvent; + event Action? RemoveItemFromInventoryEvent; void Pause(); @@ -34,7 +33,7 @@ public interface IGameRepo : IDisposable public void AnnounceMessageInInventory(string message); - public void RemoveItemFromInventory(IInventoryItem item); + public void RemoveItemFromInventory(InventoryItem item); public void CloseInventory(); @@ -51,7 +50,7 @@ public class GameRepo : IGameRepo public event Action? AnnounceMessageInInventoryEvent; public event Action? DoubleExpTimeStart; public event Action? DoubleExpTimeEnd; - public event Action? RemoveItemFromInventoryEvent; + public event Action? RemoveItemFromInventoryEvent; public IAutoProp IsPaused => _isPaused; private readonly AutoProp _isPaused; @@ -101,7 +100,7 @@ public class GameRepo : IGameRepo AnnounceMessageInInventoryEvent?.Invoke(message); } - public void RemoveItemFromInventory(IInventoryItem item) + public void RemoveItemFromInventory(InventoryItem item) { RemoveItemFromInventoryEvent?.Invoke(item); } diff --git a/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.AskForTeleport.cs b/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.AskForTeleport.cs index 2323f212..8842d1f2 100644 --- a/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.AskForTeleport.cs +++ b/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.AskForTeleport.cs @@ -1,6 +1,6 @@ using Chickensoft.Introspection; -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public partial class GameLogic { diff --git a/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.FloorCleared.cs b/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.FloorCleared.cs index b7d50b3b..8495f285 100644 --- a/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.FloorCleared.cs +++ b/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.FloorCleared.cs @@ -1,6 +1,6 @@ using Chickensoft.Introspection; -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public partial class GameLogic { diff --git a/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.MenuBackdrop.cs b/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.MenuBackdrop.cs index 921509c9..8f6fa714 100644 --- a/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.MenuBackdrop.cs +++ b/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.MenuBackdrop.cs @@ -1,4 +1,4 @@ -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; using Chickensoft.Introspection; using Zennysoft.Game.Abstractions; diff --git a/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.Paused.cs b/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.Paused.cs index 7946fa22..5f1ece25 100644 --- a/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.Paused.cs +++ b/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.Paused.cs @@ -1,7 +1,7 @@ using Chickensoft.Introspection; using Chickensoft.LogicBlocks; -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public partial class GameLogic { diff --git a/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.Playing.cs b/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.Playing.cs index c7ba553e..9c2b47ab 100644 --- a/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.Playing.cs +++ b/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.Playing.cs @@ -1,6 +1,6 @@ using Chickensoft.Introspection; -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public partial class GameLogic { diff --git a/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.Quit.cs b/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.Quit.cs index 19379df3..0e605b06 100644 --- a/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.Quit.cs +++ b/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.Quit.cs @@ -1,7 +1,7 @@ using Chickensoft.Introspection; using Chickensoft.LogicBlocks; -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public partial class GameLogic { diff --git a/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.Resuming.cs b/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.Resuming.cs index 9cea12db..46596b55 100644 --- a/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.Resuming.cs +++ b/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.Resuming.cs @@ -1,4 +1,4 @@ -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; using Chickensoft.Introspection; using Chickensoft.LogicBlocks; diff --git a/Zennysoft.Game.Ma.Implementation/Item/IInventory.cs b/Zennysoft.Game.Ma.Implementation/Item/IInventory.cs new file mode 100644 index 00000000..e14ae245 --- /dev/null +++ b/Zennysoft.Game.Ma.Implementation/Item/IInventory.cs @@ -0,0 +1,12 @@ +namespace Zennysoft.Ma.Adapter; + +public interface IInventory +{ + public List Items { get; } + + public bool TryAdd(InventoryItem inventoryItem); + + public void Remove(InventoryItem inventoryItem); + + public void Sort(); +} diff --git a/Zennysoft.Game.Ma/src/items/InventoryItem.cs b/Zennysoft.Game.Ma.Implementation/Item/InventoryItem.cs similarity index 63% rename from Zennysoft.Game.Ma/src/items/InventoryItem.cs rename to Zennysoft.Game.Ma.Implementation/Item/InventoryItem.cs index 66171b33..5a738532 100644 --- a/Zennysoft.Game.Ma/src/items/InventoryItem.cs +++ b/Zennysoft.Game.Ma.Implementation/Item/InventoryItem.cs @@ -1,17 +1,17 @@ using Chickensoft.Introspection; using Chickensoft.Serialization; using Godot; -using System; -using Zennysoft.Game.Abstractions; -namespace Zennysoft.Game.Ma; +namespace Zennysoft.Ma.Adapter; -[Meta] -public abstract partial class InventoryItem : Node3D, IInventoryItem +[Meta, Id("inventory_item")] +public abstract partial class InventoryItem : Node3D { [Save("inventory_item_id")] public Guid ID => Guid.NewGuid(); + [Save("inventory_item_name")] public abstract string ItemName { get; } + [Save("inventory_item_description")] public abstract string Description { get; } [Save("inventory_item_spawn_rate")] public abstract float SpawnRate { get; } @@ -20,8 +20,5 @@ public abstract partial class InventoryItem : Node3D, IInventoryItem [Save("inventory_item_throw_speed")] public abstract float ThrowSpeed { get; } - [Save("inventory_item_stats")] - public abstract InventoryItemStats ItemStats { get; set; } - - public Sprite3D Sprite { get; set; } + public abstract Texture2D GetTexture(); } diff --git a/Zennysoft.Game.Ma/src/item_rescue/RescuedItemDatabase.cs b/Zennysoft.Game.Ma.Implementation/Item/RescuedItemDatabase.cs similarity index 61% rename from Zennysoft.Game.Ma/src/item_rescue/RescuedItemDatabase.cs rename to Zennysoft.Game.Ma.Implementation/Item/RescuedItemDatabase.cs index c649fb7d..78760722 100644 --- a/Zennysoft.Game.Ma/src/item_rescue/RescuedItemDatabase.cs +++ b/Zennysoft.Game.Ma.Implementation/Item/RescuedItemDatabase.cs @@ -1,18 +1,17 @@ using Chickensoft.Introspection; using Chickensoft.Serialization; -using System.Collections.Generic; using Zennysoft.Game.Abstractions; -namespace Zennysoft.Game.Ma; +namespace Zennysoft.Ma.Adapter; [Meta, Id("rescued_items")] public partial class RescuedItemDatabase { [Save("rescued_item_list")] - public List Items { get; init; } + public List Items { get; init; } public RescuedItemDatabase() { - Items = new List(); + Items = new List(); } } diff --git a/Zennysoft.Game.Ma.Implementation/Item/Tags/AccessoryTag.cs b/Zennysoft.Game.Ma.Implementation/Item/Tags/AccessoryTag.cs index 08aa33ca..3ea730b3 100644 --- a/Zennysoft.Game.Ma.Implementation/Item/Tags/AccessoryTag.cs +++ b/Zennysoft.Game.Ma.Implementation/Item/Tags/AccessoryTag.cs @@ -1,4 +1,4 @@ -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public enum AccessoryTag { diff --git a/Zennysoft.Game.Ma.Implementation/Item/Tags/BoxItemTag.cs b/Zennysoft.Game.Ma.Implementation/Item/Tags/BoxItemTag.cs index d748b0b1..c220a682 100644 --- a/Zennysoft.Game.Ma.Implementation/Item/Tags/BoxItemTag.cs +++ b/Zennysoft.Game.Ma.Implementation/Item/Tags/BoxItemTag.cs @@ -1,4 +1,4 @@ -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public enum BoxItemTag { diff --git a/Zennysoft.Game.Ma.Implementation/Item/Tags/ElementType.cs b/Zennysoft.Game.Ma.Implementation/Item/Tags/ElementType.cs index a278eccb..d640b628 100644 --- a/Zennysoft.Game.Ma.Implementation/Item/Tags/ElementType.cs +++ b/Zennysoft.Game.Ma.Implementation/Item/Tags/ElementType.cs @@ -1,4 +1,4 @@ -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public enum ElementType { diff --git a/Zennysoft.Game.Ma.Implementation/Item/Tags/ItemTag.cs b/Zennysoft.Game.Ma.Implementation/Item/Tags/ItemTag.cs index 52a1635d..685c83b4 100644 --- a/Zennysoft.Game.Ma.Implementation/Item/Tags/ItemTag.cs +++ b/Zennysoft.Game.Ma.Implementation/Item/Tags/ItemTag.cs @@ -1,4 +1,4 @@ -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public enum ItemTag { diff --git a/Zennysoft.Game.Ma.Implementation/Item/Tags/ThrowableItemTag.cs b/Zennysoft.Game.Ma.Implementation/Item/Tags/ThrowableItemTag.cs index c7746e36..9ddd79db 100644 --- a/Zennysoft.Game.Ma.Implementation/Item/Tags/ThrowableItemTag.cs +++ b/Zennysoft.Game.Ma.Implementation/Item/Tags/ThrowableItemTag.cs @@ -1,4 +1,4 @@ -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public enum ThrowableItemTag { diff --git a/Zennysoft.Game.Ma.Implementation/Item/Tags/UsableItemTag.cs b/Zennysoft.Game.Ma.Implementation/Item/Tags/UsableItemTag.cs index 8d7e68b5..90da5467 100644 --- a/Zennysoft.Game.Ma.Implementation/Item/Tags/UsableItemTag.cs +++ b/Zennysoft.Game.Ma.Implementation/Item/Tags/UsableItemTag.cs @@ -1,4 +1,4 @@ -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public enum UsableItemTag { diff --git a/Zennysoft.Game.Ma.Implementation/Item/Tags/WeaponTag.cs b/Zennysoft.Game.Ma.Implementation/Item/Tags/WeaponTag.cs index d26bd2db..6d50134e 100644 --- a/Zennysoft.Game.Ma.Implementation/Item/Tags/WeaponTag.cs +++ b/Zennysoft.Game.Ma.Implementation/Item/Tags/WeaponTag.cs @@ -1,4 +1,4 @@ -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public enum WeaponTag { diff --git a/Zennysoft.Game.Ma.Implementation/JsonConverters/EnumConverters.cs b/Zennysoft.Game.Ma.Implementation/JsonConverters/EnumConverters.cs index 65aff5ae..4ddb3765 100644 --- a/Zennysoft.Game.Ma.Implementation/JsonConverters/EnumConverters.cs +++ b/Zennysoft.Game.Ma.Implementation/JsonConverters/EnumConverters.cs @@ -1,6 +1,6 @@ using System.Text.Json.Serialization; -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; [JsonSerializable(typeof(WeaponTag))] public partial class WeaponTagEnumContext : JsonSerializerContext; diff --git a/Zennysoft.Game.Ma.Implementation/Module/Module.cs b/Zennysoft.Game.Ma.Implementation/Module/Module.cs new file mode 100644 index 00000000..266a148c --- /dev/null +++ b/Zennysoft.Game.Ma.Implementation/Module/Module.cs @@ -0,0 +1,18 @@ +using SimpleInjector; +using System.IO.Abstractions; +using Zennysoft.Game.Abstractions; +using Zennysoft.Game.Implementation; + +namespace Zennysoft.Ma.Adapter; + +public class Module +{ + public static void Bootstrap(Container container) + { + container.RegisterSingleton(); + container.RegisterSingleton, SaveFileManager>(); + container.RegisterSingleton, MaSaveFileManager>(); + container.Register(Lifestyle.Singleton); + container.Register(Lifestyle.Singleton); + } +} diff --git a/Zennysoft.Game.Ma/src/player/PlayerData.cs b/Zennysoft.Game.Ma.Implementation/Player/PlayerData.cs similarity index 82% rename from Zennysoft.Game.Ma/src/player/PlayerData.cs rename to Zennysoft.Game.Ma.Implementation/Player/PlayerData.cs index 74c5638b..b75aaf84 100644 --- a/Zennysoft.Game.Ma/src/player/PlayerData.cs +++ b/Zennysoft.Game.Ma.Implementation/Player/PlayerData.cs @@ -1,6 +1,6 @@ using Chickensoft.Introspection; using Chickensoft.Serialization; -using System.Collections.Generic; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; @@ -11,7 +11,7 @@ public partial record PlayerData public required PlayerStats PlayerStats { get; init; } [Save("player_inventory")] - public required Inventory Inventory { get; init; } + public required IInventory Inventory { get; init; } } [Meta, Id("map_data")] diff --git a/Zennysoft.Game.Ma/src/player/PlayerStats.cs b/Zennysoft.Game.Ma.Implementation/Player/PlayerStats.cs similarity index 100% rename from Zennysoft.Game.Ma/src/player/PlayerStats.cs rename to Zennysoft.Game.Ma.Implementation/Player/PlayerStats.cs diff --git a/Zennysoft.Game.Ma.Implementation/Player/State/PlayerLogic.Input.cs b/Zennysoft.Game.Ma.Implementation/Player/State/PlayerLogic.Input.cs index 543d6065..d35e22d6 100644 --- a/Zennysoft.Game.Ma.Implementation/Player/State/PlayerLogic.Input.cs +++ b/Zennysoft.Game.Ma.Implementation/Player/State/PlayerLogic.Input.cs @@ -1,6 +1,6 @@ using Godot; -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public partial class PlayerLogic { diff --git a/Zennysoft.Game.Ma.Implementation/Player/State/PlayerLogic.Output.cs b/Zennysoft.Game.Ma.Implementation/Player/State/PlayerLogic.Output.cs index 06f365b9..9ed7ed32 100644 --- a/Zennysoft.Game.Ma.Implementation/Player/State/PlayerLogic.Output.cs +++ b/Zennysoft.Game.Ma.Implementation/Player/State/PlayerLogic.Output.cs @@ -1,4 +1,4 @@ -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public partial class PlayerLogic { diff --git a/Zennysoft.Game.Ma.Implementation/Player/State/PlayerLogic.Settings.cs b/Zennysoft.Game.Ma.Implementation/Player/State/PlayerLogic.Settings.cs index ba753812..0c81f627 100644 --- a/Zennysoft.Game.Ma.Implementation/Player/State/PlayerLogic.Settings.cs +++ b/Zennysoft.Game.Ma.Implementation/Player/State/PlayerLogic.Settings.cs @@ -1,4 +1,4 @@ -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public partial class PlayerLogic { diff --git a/Zennysoft.Game.Ma.Implementation/Player/State/PlayerLogic.State.cs b/Zennysoft.Game.Ma.Implementation/Player/State/PlayerLogic.State.cs index fffeaa68..b48abac2 100644 --- a/Zennysoft.Game.Ma.Implementation/Player/State/PlayerLogic.State.cs +++ b/Zennysoft.Game.Ma.Implementation/Player/State/PlayerLogic.State.cs @@ -1,7 +1,7 @@ using Chickensoft.Introspection; using Chickensoft.LogicBlocks; -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public partial class PlayerLogic { diff --git a/Zennysoft.Game.Ma.Implementation/Player/State/PlayerLogic.cs b/Zennysoft.Game.Ma.Implementation/Player/State/PlayerLogic.cs index d0b2d9f9..59fac969 100644 --- a/Zennysoft.Game.Ma.Implementation/Player/State/PlayerLogic.cs +++ b/Zennysoft.Game.Ma.Implementation/Player/State/PlayerLogic.cs @@ -1,7 +1,7 @@ using Chickensoft.Introspection; using Chickensoft.LogicBlocks; -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public interface IPlayerLogic : ILogicBlock; diff --git a/Zennysoft.Game.Ma.Implementation/Player/State/States/PlayerLogic.State.Alive.Attacking.cs b/Zennysoft.Game.Ma.Implementation/Player/State/States/PlayerLogic.State.Alive.Attacking.cs index a62ffd0a..38f0111a 100644 --- a/Zennysoft.Game.Ma.Implementation/Player/State/States/PlayerLogic.State.Alive.Attacking.cs +++ b/Zennysoft.Game.Ma.Implementation/Player/State/States/PlayerLogic.State.Alive.Attacking.cs @@ -1,6 +1,6 @@ using Chickensoft.Introspection; -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public partial class PlayerLogic { diff --git a/Zennysoft.Game.Ma.Implementation/Player/State/States/PlayerLogic.State.Alive.Idle.cs b/Zennysoft.Game.Ma.Implementation/Player/State/States/PlayerLogic.State.Alive.Idle.cs index 52586d0f..08712e88 100644 --- a/Zennysoft.Game.Ma.Implementation/Player/State/States/PlayerLogic.State.Alive.Idle.cs +++ b/Zennysoft.Game.Ma.Implementation/Player/State/States/PlayerLogic.State.Alive.Idle.cs @@ -1,7 +1,7 @@ using Chickensoft.Introspection; using Godot; -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public partial class PlayerLogic { diff --git a/Zennysoft.Game.Ma.Implementation/Player/State/States/PlayerLogic.State.Alive.cs b/Zennysoft.Game.Ma.Implementation/Player/State/States/PlayerLogic.State.Alive.cs index 236edc2a..e4355f99 100644 --- a/Zennysoft.Game.Ma.Implementation/Player/State/States/PlayerLogic.State.Alive.cs +++ b/Zennysoft.Game.Ma.Implementation/Player/State/States/PlayerLogic.State.Alive.cs @@ -1,7 +1,7 @@ using Chickensoft.Introspection; using Godot; -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public partial class PlayerLogic { diff --git a/Zennysoft.Game.Ma.Implementation/Player/State/States/PlayerLogic.State.Dead.cs b/Zennysoft.Game.Ma.Implementation/Player/State/States/PlayerLogic.State.Dead.cs index d130009a..621e5bee 100644 --- a/Zennysoft.Game.Ma.Implementation/Player/State/States/PlayerLogic.State.Dead.cs +++ b/Zennysoft.Game.Ma.Implementation/Player/State/States/PlayerLogic.State.Dead.cs @@ -1,6 +1,6 @@ using Chickensoft.Introspection; -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public partial class PlayerLogic { diff --git a/Zennysoft.Game.Ma.Implementation/Player/State/States/PlayerLogic.State.Disabled.cs b/Zennysoft.Game.Ma.Implementation/Player/State/States/PlayerLogic.State.Disabled.cs index d437b810..f22c66b6 100644 --- a/Zennysoft.Game.Ma.Implementation/Player/State/States/PlayerLogic.State.Disabled.cs +++ b/Zennysoft.Game.Ma.Implementation/Player/State/States/PlayerLogic.State.Disabled.cs @@ -1,7 +1,7 @@ using Chickensoft.Introspection; using Zennysoft.Game.Abstractions; -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public partial class PlayerLogic { diff --git a/Zennysoft.Game.Ma.Implementation/Save/MaSaveFileManager.cs b/Zennysoft.Game.Ma.Implementation/Save/MaSaveFileManager.cs new file mode 100644 index 00000000..f52522bf --- /dev/null +++ b/Zennysoft.Game.Ma.Implementation/Save/MaSaveFileManager.cs @@ -0,0 +1,31 @@ +using System.Collections.Immutable; +using System.Text.Json.Serialization.Metadata; +using Zennysoft.Game.Abstractions; + +namespace Zennysoft.Ma.Adapter; + +public interface IMaSaveFileManager +{ + Task Save(T gameData); + + Task Load(); +} + +public sealed class MaSaveFileManager : IMaSaveFileManager +{ + private readonly ISaveFileManager _saveFileManager; + private ImmutableList _converters; + + public MaSaveFileManager(ISaveFileManager saveFileManager) + { + _saveFileManager = saveFileManager; + _converters = [WeaponTagEnumContext.Default, ItemTagEnumContext.Default, ElementTypeEnumContext.Default, AccessoryTagEnumContext.Default, ThrowableItemTagEnumContext.Default, UsableItemTagEnumContext.Default, BoxItemTagEnumContext.Default]; + } + + public async Task Save(T gameData) + { + await _saveFileManager.WriteToFile(gameData, [.. _converters]); + } + + public async Task Load() => await _saveFileManager.ReadFromFile([.. _converters]); +} diff --git a/Zennysoft.Game.Ma.Implementation/UI/InGameUI/InGameUILogic.State.cs b/Zennysoft.Game.Ma.Implementation/UI/InGameUI/InGameUILogic.State.cs index 572f322c..326b49ff 100644 --- a/Zennysoft.Game.Ma.Implementation/UI/InGameUI/InGameUILogic.State.cs +++ b/Zennysoft.Game.Ma.Implementation/UI/InGameUI/InGameUILogic.State.cs @@ -1,9 +1,8 @@ using Chickensoft.Introspection; using Chickensoft.LogicBlocks; -using Zennysoft.Game.Abstractions; -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public partial class InGameUILogic { @@ -38,7 +37,7 @@ public partial class InGameUILogic Output(new Output.AnnounceMessageInInventory(message)); } - private void OnRemoveItemFromInventory(IInventoryItem item) => Output(new Output.RemoveItemFromInventory(item)); + private void OnRemoveItemFromInventory(InventoryItem item) => Output(new Output.RemoveItemFromInventory(item)); } } diff --git a/Zennysoft.Game.Ma.Implementation/UI/InGameUI/InGameUILogic.cs b/Zennysoft.Game.Ma.Implementation/UI/InGameUI/InGameUILogic.cs index 2ea362dc..087f4fec 100644 --- a/Zennysoft.Game.Ma.Implementation/UI/InGameUI/InGameUILogic.cs +++ b/Zennysoft.Game.Ma.Implementation/UI/InGameUI/InGameUILogic.cs @@ -1,7 +1,7 @@ using Chickensoft.Introspection; using Chickensoft.LogicBlocks; -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public interface IInGameUILogic : ILogicBlock; diff --git a/Zennysoft.Game.Ma.Implementation/UI/InGameUI/state/InGameUILogic.Input.cs b/Zennysoft.Game.Ma.Implementation/UI/InGameUI/state/InGameUILogic.Input.cs index 514ea1db..1b263ba3 100644 --- a/Zennysoft.Game.Ma.Implementation/UI/InGameUI/state/InGameUILogic.Input.cs +++ b/Zennysoft.Game.Ma.Implementation/UI/InGameUI/state/InGameUILogic.Input.cs @@ -1,4 +1,4 @@ -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public partial class InGameUILogic { public static class Input diff --git a/Zennysoft.Game.Ma.Implementation/UI/InGameUI/state/InGameUILogic.Output.cs b/Zennysoft.Game.Ma.Implementation/UI/InGameUI/state/InGameUILogic.Output.cs index 8c9303fb..a017a4fe 100644 --- a/Zennysoft.Game.Ma.Implementation/UI/InGameUI/state/InGameUILogic.Output.cs +++ b/Zennysoft.Game.Ma.Implementation/UI/InGameUI/state/InGameUILogic.Output.cs @@ -1,13 +1,13 @@ -using Zennysoft.Game.Abstractions; +using Zennysoft.Game.Ma; -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public partial class InGameUILogic { public static class Output { public readonly record struct AnnounceMessageOnMainScreen(string Message); public readonly record struct AnnounceMessageInInventory(string Message); - public readonly record struct RemoveItemFromInventory(IInventoryItem Item); + public readonly record struct RemoveItemFromInventory(InventoryItem Item); public readonly record struct DisplayMinimap; public readonly record struct HideMinimap; public readonly record struct ShowInventory; diff --git a/Zennysoft.Game.Ma.Implementation/UI/InGameUI/state/States/InGameUI.State.Active.cs b/Zennysoft.Game.Ma.Implementation/UI/InGameUI/state/States/InGameUI.State.Active.cs index e50308c1..463d8c90 100644 --- a/Zennysoft.Game.Ma.Implementation/UI/InGameUI/state/States/InGameUI.State.Active.cs +++ b/Zennysoft.Game.Ma.Implementation/UI/InGameUI/state/States/InGameUI.State.Active.cs @@ -1,6 +1,6 @@ using Chickensoft.Introspection; -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public partial class InGameUILogic { diff --git a/Zennysoft.Game.Ma.Implementation/UI/InGameUI/state/States/InGameUI.State.InventoryOpen.cs b/Zennysoft.Game.Ma.Implementation/UI/InGameUI/state/States/InGameUI.State.InventoryOpen.cs index a53a3443..ccff79d1 100644 --- a/Zennysoft.Game.Ma.Implementation/UI/InGameUI/state/States/InGameUI.State.InventoryOpen.cs +++ b/Zennysoft.Game.Ma.Implementation/UI/InGameUI/state/States/InGameUI.State.InventoryOpen.cs @@ -1,6 +1,6 @@ using Chickensoft.Introspection; -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public partial class InGameUILogic { diff --git a/Zennysoft.Game.Ma.Implementation/UI/InGameUI/state/States/InGameUI.State.MinimapOpen.cs b/Zennysoft.Game.Ma.Implementation/UI/InGameUI/state/States/InGameUI.State.MinimapOpen.cs index 693abb09..46375b7e 100644 --- a/Zennysoft.Game.Ma.Implementation/UI/InGameUI/state/States/InGameUI.State.MinimapOpen.cs +++ b/Zennysoft.Game.Ma.Implementation/UI/InGameUI/state/States/InGameUI.State.MinimapOpen.cs @@ -1,6 +1,6 @@ using Chickensoft.Introspection; -namespace Zennysoft.Ma.Godot.Adapter; +namespace Zennysoft.Ma.Adapter; public partial class InGameUILogic { diff --git a/Zennysoft.Game.Ma.Implementation/Zennysoft.Ma.Godot.Adapter.csproj b/Zennysoft.Game.Ma.Implementation/Zennysoft.Ma.Adapter.csproj similarity index 75% rename from Zennysoft.Game.Ma.Implementation/Zennysoft.Ma.Godot.Adapter.csproj rename to Zennysoft.Game.Ma.Implementation/Zennysoft.Ma.Adapter.csproj index e3c32ac0..01146717 100644 --- a/Zennysoft.Game.Ma.Implementation/Zennysoft.Ma.Godot.Adapter.csproj +++ b/Zennysoft.Game.Ma.Implementation/Zennysoft.Ma.Adapter.csproj @@ -13,11 +13,13 @@ + - + + diff --git a/Zennysoft.Game.Ma.Implementation/cspell.json b/Zennysoft.Game.Ma.Implementation/cspell.json new file mode 100644 index 00000000..2283c7bb --- /dev/null +++ b/Zennysoft.Game.Ma.Implementation/cspell.json @@ -0,0 +1,70 @@ +{ + "files": [ + "**/*.*" + ], + "ignorePaths": [ + "**/*.tscn", + "**/*.import", + "**/badges/**/*.*", + "**/coverage/**/*.*", + "**/.godot/**/*.*", + "**/obj/**/*.*", + "**/bin/**/*.*", + "**/nupkg/**/*.*" + ], + "words": [ + "assemblyfilters", + "automerge", + "branchcoverage", + "brandedoutcast", + "buildtransitive", + "camelcase", + "chickenpackage", + "Chickensoft", + "classfilters", + "contentfiles", + "CYGWIN", + "devbuild", + "endregion", + "Finalizer", + "Finalizers", + "globaltool", + "godotengine", + "godotpackage", + "issuecomment", + "justalemon", + "lcov", + "lihop", + "linecoverage", + "methodcoverage", + "missingall", + "msbuild", + "MSYS", + "nameof", + "Nerdbank", + "netstandard", + "NOLOGO", + "nupkg", + "Omnisharp", + "opencover", + "OPTOUT", + "paramref", + "pascalcase", + "Postinitialize", + "Predelete", + "renovatebot", + "reportgenerator", + "reporttypes", + "Shouldly", + "subfolders", + "targetargs", + "targetdir", + "tscn", + "typeof", + "typeparam", + "typeparamref", + "ulong", + "Unparented", + "Xunit" + ] +} \ No newline at end of file diff --git a/Zennysoft.Game.Ma/Ma.csproj b/Zennysoft.Game.Ma/Ma.csproj index f9aade3c..fd26b5af 100644 --- a/Zennysoft.Game.Ma/Ma.csproj +++ b/Zennysoft.Game.Ma/Ma.csproj @@ -36,8 +36,8 @@ - - + + diff --git a/Zennysoft.Game.Ma/src/app/App.cs b/Zennysoft.Game.Ma/src/app/App.cs index a339db0d..27f13589 100644 --- a/Zennysoft.Game.Ma/src/app/App.cs +++ b/Zennysoft.Game.Ma/src/app/App.cs @@ -5,8 +5,7 @@ using Godot; using SimpleInjector; using SimpleInjector.Lifestyles; using Zennysoft.Game.Abstractions; -using Zennysoft.Ma.Godot.Adapter; -using static Zennysoft.Ma.Godot.Adapter.AppLogic.Input; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; @@ -115,16 +114,16 @@ public partial class App : CanvasLayer, IApp AppLogic.Start(); } - public void OnNewGame() => AppLogic.Input(new NewGame()); + public void OnNewGame() => AppLogic.Input(new AppLogic.Input.NewGame()); - private void OnLoadGame() => AppLogic.Input(new LoadGame()); + private void OnLoadGame() => AppLogic.Input(new AppLogic.Input.LoadGame()); - public void OnQuit() => AppLogic.Input(new QuitGame()); + public void OnQuit() => AppLogic.Input(new AppLogic.Input.QuitGame()); public void OnSaveFileLoaded() { Game.SaveFileLoaded -= OnSaveFileLoaded; - AppLogic.Input(new SaveFileLoaded()); + AppLogic.Input(new AppLogic.Input.SaveFileLoaded()); } public void FadeInFromBlack() @@ -149,12 +148,12 @@ public partial class App : CanvasLayer, IApp { if (animation == "fade_in") { - AppLogic.Input(new FadeInFinished()); + AppLogic.Input(new AppLogic.Input.FadeInFinished()); BlankScreen.Hide(); return; } - AppLogic.Input(new FadeOutFinished()); + AppLogic.Input(new AppLogic.Input.FadeOutFinished()); } public void OnExitTree() diff --git a/Zennysoft.Game.Ma/src/boss/Boss.cs b/Zennysoft.Game.Ma/src/boss/Boss.cs index 2e4a7d6f..18bd3711 100644 --- a/Zennysoft.Game.Ma/src/boss/Boss.cs +++ b/Zennysoft.Game.Ma/src/boss/Boss.cs @@ -3,7 +3,7 @@ using Chickensoft.Collections; using Chickensoft.GodotNodeInterfaces; using Chickensoft.Introspection; using Godot; -using Zennysoft.Ma.Godot.Adapter; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; diff --git a/Zennysoft.Game.Ma/src/enemy/Enemy.cs b/Zennysoft.Game.Ma/src/enemy/Enemy.cs index 7e6a53f8..85dfd388 100644 --- a/Zennysoft.Game.Ma/src/enemy/Enemy.cs +++ b/Zennysoft.Game.Ma/src/enemy/Enemy.cs @@ -3,7 +3,7 @@ using Chickensoft.Collections; using Chickensoft.Introspection; using Godot; using System.Linq; -using Zennysoft.Ma.Godot.Adapter; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; diff --git a/Zennysoft.Game.Ma/src/enemy/IEnemy.cs b/Zennysoft.Game.Ma/src/enemy/IEnemy.cs index 4f1f6fab..ec456d25 100644 --- a/Zennysoft.Game.Ma/src/enemy/IEnemy.cs +++ b/Zennysoft.Game.Ma/src/enemy/IEnemy.cs @@ -1,5 +1,5 @@ using Godot; -using Zennysoft.Ma.Godot.Adapter; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; diff --git a/Zennysoft.Game.Ma/src/enemy/enemy_types/01. sproingy/Sproingy.cs b/Zennysoft.Game.Ma/src/enemy/enemy_types/01. sproingy/Sproingy.cs index 06dfb8b7..48921251 100644 --- a/Zennysoft.Game.Ma/src/enemy/enemy_types/01. sproingy/Sproingy.cs +++ b/Zennysoft.Game.Ma/src/enemy/enemy_types/01. sproingy/Sproingy.cs @@ -2,7 +2,7 @@ using Chickensoft.AutoInject; using Chickensoft.Introspection; using Godot; using Zennysoft.Game.Abstractions; -using Zennysoft.Ma.Godot.Adapter; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; diff --git a/Zennysoft.Game.Ma/src/enemy/enemy_types/01. sproingy/Sproingy.tscn b/Zennysoft.Game.Ma/src/enemy/enemy_types/01. sproingy/Sproingy.tscn index 2361ea6b..9f0346b1 100644 --- a/Zennysoft.Game.Ma/src/enemy/enemy_types/01. sproingy/Sproingy.tscn +++ b/Zennysoft.Game.Ma/src/enemy/enemy_types/01. sproingy/Sproingy.tscn @@ -8,12 +8,12 @@ [sub_resource type="Resource" id="Resource_oln85"] script = ExtResource("2_oln85") CurrentHP = 30.0 -MaximumHP = 0 +MaximumHP = 30 CurrentAttack = 15 CurrentDefense = 7 MaxAttack = 15 MaxDefense = 7 -ExpFromDefeat = 15 +ExpFromDefeat = 5 Luck = 0.05 TelluricResistance = 0.0 AeolicResistance = 0.0 diff --git a/Zennysoft.Game.Ma/src/enemy/enemy_types/02. michael/Michael.cs b/Zennysoft.Game.Ma/src/enemy/enemy_types/02. michael/Michael.cs index 0312805d..20fcb13f 100644 --- a/Zennysoft.Game.Ma/src/enemy/enemy_types/02. michael/Michael.cs +++ b/Zennysoft.Game.Ma/src/enemy/enemy_types/02. michael/Michael.cs @@ -2,7 +2,7 @@ using Chickensoft.AutoInject; using Chickensoft.Introspection; using Godot; using Zennysoft.Game.Abstractions; -using Zennysoft.Ma.Godot.Adapter; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; diff --git a/Zennysoft.Game.Ma/src/enemy/enemy_types/02. michael/Michael.tscn b/Zennysoft.Game.Ma/src/enemy/enemy_types/02. michael/Michael.tscn index 23ae2f1e..5f1314c5 100644 --- a/Zennysoft.Game.Ma/src/enemy/enemy_types/02. michael/Michael.tscn +++ b/Zennysoft.Game.Ma/src/enemy/enemy_types/02. michael/Michael.tscn @@ -8,12 +8,12 @@ [sub_resource type="Resource" id="Resource_xhsah"] script = ExtResource("2_wrps7") CurrentHP = 50.0 -MaximumHP = 0 +MaximumHP = 50 CurrentAttack = 15 CurrentDefense = 0 MaxAttack = 15 MaxDefense = 0 -ExpFromDefeat = 0 +ExpFromDefeat = 5 Luck = 0.05 TelluricResistance = 0.0 AeolicResistance = 0.0 diff --git a/Zennysoft.Game.Ma/src/enemy/enemy_types/03. filth_eater/FilthEater.cs b/Zennysoft.Game.Ma/src/enemy/enemy_types/03. filth_eater/FilthEater.cs index bd98b4a8..bbaf5746 100644 --- a/Zennysoft.Game.Ma/src/enemy/enemy_types/03. filth_eater/FilthEater.cs +++ b/Zennysoft.Game.Ma/src/enemy/enemy_types/03. filth_eater/FilthEater.cs @@ -3,7 +3,7 @@ using Chickensoft.Introspection; using Godot; using System; using System.Collections.Generic; -using Zennysoft.Ma.Godot.Adapter; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; diff --git a/Zennysoft.Game.Ma/src/enemy/enemy_types/05. ballos/Ballos.cs b/Zennysoft.Game.Ma/src/enemy/enemy_types/05. ballos/Ballos.cs index dff480ce..db4769b8 100644 --- a/Zennysoft.Game.Ma/src/enemy/enemy_types/05. ballos/Ballos.cs +++ b/Zennysoft.Game.Ma/src/enemy/enemy_types/05. ballos/Ballos.cs @@ -3,7 +3,7 @@ using Chickensoft.Introspection; using Godot; using System.Collections.Generic; using System; -using Zennysoft.Ma.Godot.Adapter; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; diff --git a/Zennysoft.Game.Ma/src/enemy/enemy_types/06. chariot/Chariot.cs b/Zennysoft.Game.Ma/src/enemy/enemy_types/06. chariot/Chariot.cs index e574a511..e983dea4 100644 --- a/Zennysoft.Game.Ma/src/enemy/enemy_types/06. chariot/Chariot.cs +++ b/Zennysoft.Game.Ma/src/enemy/enemy_types/06. chariot/Chariot.cs @@ -1,7 +1,7 @@ using Chickensoft.AutoInject; using Chickensoft.Introspection; using Godot; -using Zennysoft.Ma.Godot.Adapter; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; diff --git a/Zennysoft.Game.Ma/src/enemy/enemy_types/07. chinthe/Chinthe.cs b/Zennysoft.Game.Ma/src/enemy/enemy_types/07. chinthe/Chinthe.cs index c146dc94..99fc746c 100644 --- a/Zennysoft.Game.Ma/src/enemy/enemy_types/07. chinthe/Chinthe.cs +++ b/Zennysoft.Game.Ma/src/enemy/enemy_types/07. chinthe/Chinthe.cs @@ -2,7 +2,7 @@ using Chickensoft.AutoInject; using Chickensoft.Introspection; using Godot; using Zennysoft.Game.Abstractions; -using Zennysoft.Ma.Godot.Adapter; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; diff --git a/Zennysoft.Game.Ma/src/enemy/enemy_types/10. Eden Pillar/EdenPillar.cs b/Zennysoft.Game.Ma/src/enemy/enemy_types/10. Eden Pillar/EdenPillar.cs index aa622536..0acb4bc0 100644 --- a/Zennysoft.Game.Ma/src/enemy/enemy_types/10. Eden Pillar/EdenPillar.cs +++ b/Zennysoft.Game.Ma/src/enemy/enemy_types/10. Eden Pillar/EdenPillar.cs @@ -3,7 +3,7 @@ using Chickensoft.Introspection; using Godot; using System.Collections.Generic; using System; -using Zennysoft.Ma.Godot.Adapter; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; diff --git a/Zennysoft.Game.Ma/src/game/Game.cs b/Zennysoft.Game.Ma/src/game/Game.cs index 435cc435..ee098ecd 100644 --- a/Zennysoft.Game.Ma/src/game/Game.cs +++ b/Zennysoft.Game.Ma/src/game/Game.cs @@ -6,12 +6,10 @@ using Chickensoft.Introspection; using Chickensoft.SaveFileBuilder; using Godot; using System; -using System.IO.Abstractions; using System.Text.Json; using Zennysoft.Game.Abstractions; -using Zennysoft.Ma.Godot.Adapter; +using Zennysoft.Ma.Adapter; using System.IO; -using SimpleInjector; using System.Threading.Tasks; [Meta(typeof(IAutoNode))] @@ -82,10 +80,7 @@ public partial class Game : Node3D, IGame public void Setup() { _container = new SimpleInjector.Container(); - _container.Register(); - _container.Register, SaveFileManager>(); - _container.Register(Lifestyle.Singleton); - _container.Register(Lifestyle.Singleton); + Module.Bootstrap(_container); _container.Verify(); GameRepo = _container.GetInstance(); @@ -146,15 +141,15 @@ public partial class Game : Node3D, IGame public void OnResolved() { - var saveFileManager = _container.GetInstance>(); + var saveFileManager = _container.GetInstance>(); SaveFile = new SaveFile( root: GameChunk, - onSave: saveFileManager.WriteToFile, + onSave: saveFileManager.Save, onLoad: async () => { try { - var gameData = await saveFileManager.ReadFromFile(); + var gameData = await saveFileManager.Load(); return gameData; } catch (FileNotFoundException) @@ -246,7 +241,7 @@ public partial class Game : Node3D, IGame GameEventDepot.OnTeleportEntered(); } - public async Task UseItem(IInventoryItem item) + public async Task UseItem(InventoryItem item) { if (item is ConsumableItem consumableItem) { @@ -329,7 +324,7 @@ public partial class Game : Node3D, IGame GameRepo.RemoveItemFromInventory(item); } - public void DropItem(IInventoryItem item) + public void DropItem(InventoryItem item) { var droppedScene = GD.Load("res://src/items/dropped/DroppedItem.tscn"); var dropped = droppedScene.Instantiate(); @@ -338,11 +333,11 @@ public partial class Game : Node3D, IGame dropped.Drop(); } - public void ThrowItem(IInventoryItem item) + public void ThrowItem(InventoryItem item) { var thrownScene = GD.Load("res://src/items/thrown/ThrownItem.tscn"); var thrown = thrownScene.Instantiate(); - thrown.ItemThatIsThrown = item; + thrown.ItemThatIsThrown = (InventoryItem)item; AddChild(thrown); thrown.Position += new Vector3(0, 1.5f, 0); thrown.Throw(_effectService); diff --git a/Zennysoft.Game.Ma/src/game/IGame.cs b/Zennysoft.Game.Ma/src/game/IGame.cs index a58e32c1..edb9e342 100644 --- a/Zennysoft.Game.Ma/src/game/IGame.cs +++ b/Zennysoft.Game.Ma/src/game/IGame.cs @@ -7,7 +7,7 @@ using Chickensoft.SaveFileBuilder; using Godot; using System.Threading.Tasks; using Zennysoft.Game.Abstractions; -using Zennysoft.Ma.Godot.Adapter; +using Zennysoft.Ma.Adapter; public interface IGame : IProvide, IProvide, IProvide, IProvide, IProvide>, INode3D { @@ -21,11 +21,11 @@ public interface IGame : IProvide, IProvide, IProvid public IDungeonFloor CurrentFloor { get; } - public Task UseItem(IInventoryItem item); + public Task UseItem(InventoryItem item); - public void DropItem(IInventoryItem item); + public void DropItem(InventoryItem item); - public void ThrowItem(IInventoryItem item); + public void ThrowItem(InventoryItem item); public void FloorExitReached(); diff --git a/Zennysoft.Game.Ma/src/inventory_menu/InventoryMenu.cs b/Zennysoft.Game.Ma/src/inventory_menu/InventoryMenu.cs index aa945dcf..977712bf 100644 --- a/Zennysoft.Game.Ma/src/inventory_menu/InventoryMenu.cs +++ b/Zennysoft.Game.Ma/src/inventory_menu/InventoryMenu.cs @@ -4,8 +4,7 @@ using Chickensoft.Introspection; using Godot; using System.Linq; using System.Threading.Tasks; -using Zennysoft.Game.Abstractions; -using Zennysoft.Ma.Godot.Adapter; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; @@ -15,7 +14,7 @@ public interface IInventoryMenu : IControl public Task DisplayMessage(string message); - public void RemoveItem(IInventoryItem item); + public void RemoveItem(InventoryItem item); } [Meta(typeof(IAutoNode))] @@ -227,7 +226,7 @@ public partial class InventoryMenu : Control, IInventoryMenu } #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed - public async void RemoveItem(IInventoryItem item) + public async void RemoveItem(InventoryItem item) { Player.Inventory.Remove(item); if (_currentIndex >= ItemSlots.Length - 1) diff --git a/Zennysoft.Game.Ma/src/inventory_menu/ItemSlot.cs b/Zennysoft.Game.Ma/src/inventory_menu/ItemSlot.cs index f05fb45e..261eb582 100644 --- a/Zennysoft.Game.Ma/src/inventory_menu/ItemSlot.cs +++ b/Zennysoft.Game.Ma/src/inventory_menu/ItemSlot.cs @@ -2,13 +2,13 @@ using Chickensoft.AutoInject; using Chickensoft.GodotNodeInterfaces; using Chickensoft.Introspection; using Godot; -using Zennysoft.Game.Abstractions; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; public interface IItemSlot : IHBoxContainer { - public IInventoryItem Item { get; set; } + public InventoryItem Item { get; set; } public void SetItemStyle(); @@ -42,7 +42,7 @@ public partial class ItemSlot : HBoxContainer, IItemSlot { ItemName.Text = Item.ItemName; //EquipBonus.Text = "..."; - ItemTexture.Texture = ((InventoryItem)Item).ItemStats.Texture; + ItemTexture.Texture = Item.GetTexture(); Player.EquippedWeapon.Sync += EquippedWeapon_Sync; Player.EquippedArmor.Sync += EquippedArmor_Sync; Player.EquippedAccessory.Sync += EquippedAccessory_Sync; @@ -114,5 +114,5 @@ public partial class ItemSlot : HBoxContainer, IItemSlot //EquipBonus.LabelSettings = EquippedItemFont; } - public IInventoryItem Item { get; set; } = default!; + public InventoryItem Item { get; set; } = default!; } diff --git a/Zennysoft.Game.Ma/src/items/EffectService.cs b/Zennysoft.Game.Ma/src/items/EffectService.cs index 3d563ade..7dbbb8dc 100644 --- a/Zennysoft.Game.Ma/src/items/EffectService.cs +++ b/Zennysoft.Game.Ma/src/items/EffectService.cs @@ -1,7 +1,7 @@ using Godot; using System.Linq; using System; -using Zennysoft.Ma.Godot.Adapter; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; @@ -76,7 +76,7 @@ public class EffectService rng.Randomize(); var randomResource = resourceFiles[rng.RandiRange(0, resourceFiles.Length - 1)]; var randomFile = ResourceLoader.Load($"{consumableFolder}/resources/{randomResource}"); - consumable.ItemStats = randomFile; + consumable.Stats = randomFile; _game.AddChild(consumable); consumable.GlobalPosition = vector; } diff --git a/Zennysoft.Game.Ma/src/items/EquipableItem.cs b/Zennysoft.Game.Ma/src/items/EquipableItem.cs index 8e3dd14f..8a38b14b 100644 --- a/Zennysoft.Game.Ma/src/items/EquipableItem.cs +++ b/Zennysoft.Game.Ma/src/items/EquipableItem.cs @@ -1,10 +1,10 @@ using Chickensoft.Introspection; using Chickensoft.Serialization; -using Zennysoft.Ma.Godot.Adapter; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; -[Meta] +[Meta, Id("equipable_item")] public abstract partial class EquipableItem : InventoryItem { public abstract ItemTag ItemTag { get; } diff --git a/Zennysoft.Game.Ma/src/items/Inventory.cs b/Zennysoft.Game.Ma/src/items/Inventory.cs index c9935591..90ebd58b 100644 --- a/Zennysoft.Game.Ma/src/items/Inventory.cs +++ b/Zennysoft.Game.Ma/src/items/Inventory.cs @@ -1,25 +1,13 @@ using Chickensoft.AutoInject; -using Chickensoft.GodotNodeInterfaces; using Chickensoft.Introspection; using Chickensoft.Serialization; using Godot; using System.Collections.Generic; using System.Linq; -using Zennysoft.Game.Abstractions; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; -public interface IInventory : INode -{ - public List Items { get; } - - public bool TryAdd(IInventoryItem inventoryItem); - - public void Remove(IInventoryItem inventoryItem); - - public void Sort(); -} - [Meta(typeof(IAutoNode)), Id("inventory")] public partial class Inventory : Node, IInventory { @@ -34,9 +22,9 @@ public partial class Inventory : Node, IInventory } [Save("inventory_items")] - public List Items { get; private set; } + public List Items { get; private set; } - public bool TryAdd(IInventoryItem inventoryItem) + public bool TryAdd(InventoryItem inventoryItem) { if (Items.Count >= _maxInventorySize) return false; @@ -45,15 +33,15 @@ public partial class Inventory : Node, IInventory return true; } - public void Remove(IInventoryItem inventoryItem) => Items.Remove(inventoryItem); + public void Remove(InventoryItem inventoryItem) => Items.Remove(inventoryItem); public void Sort() { - var equippedWeapon = Items.OfType().Where(x => x.IsEquipped).Cast(); - var equippedArmor = Items.OfType().Where(x => x.IsEquipped).Cast(); - var equippedAccessory = Items.OfType().Where(x => x.IsEquipped).Cast(); - var equippedItems = new List(); + var equippedWeapon = Items.OfType().Where(x => x.IsEquipped); + var equippedArmor = Items.OfType().Where(x => x.IsEquipped); + var equippedAccessory = Items.OfType().Where(x => x.IsEquipped); + var equippedItems = new List(); equippedItems.AddRange(equippedWeapon); equippedItems.AddRange(equippedArmor); equippedItems.AddRange(equippedAccessory); diff --git a/Zennysoft.Game.Ma/src/items/InventoryItemStats.cs b/Zennysoft.Game.Ma/src/items/InventoryItemStats.cs index 9c80819e..a4ee0ae2 100644 --- a/Zennysoft.Game.Ma/src/items/InventoryItemStats.cs +++ b/Zennysoft.Game.Ma/src/items/InventoryItemStats.cs @@ -1,23 +1,18 @@ using Chickensoft.Introspection; using Chickensoft.Serialization; using Godot; -using Zennysoft.Ma.Godot.Adapter; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; [Meta, Id("inventory_item_stats")] -public partial class InventoryItemStats : Resource +public abstract partial class InventoryItemStats : Resource { [Export] - [Save("inventory_item_name")] - public string Name { get; set; } = string.Empty; + public abstract string Name { get; set; } [Export(PropertyHint.MultilineText)] - [Save("inventory_item_description")] - public string Description { get; set; } = string.Empty; - - [Save("inventory_item_texture")] - [Export] public Texture2D Texture { get; set; } = default!; + public abstract string Description { get; set; } [Export(PropertyHint.Range, "0, 1, 0.01")] public float SpawnRate { get; set; } = 0.5f; @@ -36,4 +31,8 @@ public partial class InventoryItemStats : Resource [Export] public ItemTag ItemTag { get; set; } = ItemTag.None; + + [Export] + [Save("inventory_item_texture")] + public Texture2D Texture { get; set; } } \ No newline at end of file diff --git a/Zennysoft.Game.Ma/src/items/ItemDatabase.cs b/Zennysoft.Game.Ma/src/items/ItemDatabase.cs index 4173e25e..9dee3631 100644 --- a/Zennysoft.Game.Ma/src/items/ItemDatabase.cs +++ b/Zennysoft.Game.Ma/src/items/ItemDatabase.cs @@ -1,5 +1,6 @@ using Godot; using System.Collections.Generic; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; @@ -20,6 +21,9 @@ public partial class ItemDatabase : Node [Export] public PackedScene ConsumableItemScene { get; set; } + [Export] + public PackedScene EffectItemScene { get; set; } + public InventoryItem[] Initialize() { var database = new List(); @@ -28,14 +32,13 @@ public partial class ItemDatabase : Node var accessoryResources = DirAccess.GetFilesAt("res://src/items/accessory/resources/"); var throwableResources = DirAccess.GetFilesAt("res://src/items/throwable/resources/"); var consumableResources = DirAccess.GetFilesAt("res://src/items/consumable/resources/"); + var effectResources = DirAccess.GetFilesAt("res://src/items/effect/resources/"); foreach (var armor in armorResources) { var armorInfo = GD.Load($"res://src/items/armor/resources/{armor}"); var armorScene = ArmorScene.Instantiate(); - armorScene.ItemStats = armorInfo; - armorScene.Sprite = armorScene.GetNode("%Sprite"); - armorScene.Sprite.Texture = armorInfo.Texture; + armorScene.Stats = armorInfo; database.Add(armorScene); } @@ -43,9 +46,7 @@ public partial class ItemDatabase : Node { var weaponInfo = GD.Load($"res://src/items/weapons/resources/{weapon}"); var weaponScene = WeaponScene.Instantiate(); - weaponScene.ItemStats = weaponInfo; - weaponScene.Sprite = weaponScene.GetNode("%Sprite"); - weaponScene.Sprite.Texture = weaponInfo.Texture; + weaponScene.Stats = weaponInfo; database.Add(weaponScene); } @@ -53,9 +54,7 @@ public partial class ItemDatabase : Node { var accessoryInfo = GD.Load($"res://src/items/accessory/resources/{accessory}"); var accessoryScene = AccessoryScene.Instantiate(); - accessoryScene.ItemStats = accessoryInfo; - accessoryScene.Sprite = accessoryScene.GetNode("%Sprite"); - accessoryScene.Sprite.Texture = accessoryInfo.Texture; + accessoryScene.Stats = accessoryInfo; database.Add(accessoryScene); } @@ -63,9 +62,7 @@ public partial class ItemDatabase : Node { var throwableItemInfo = GD.Load($"res://src/items/throwable/resources/{throwable}"); var throwableItemScene = ThrowableItemScene.Instantiate(); - throwableItemScene.ItemStats = throwableItemInfo; - throwableItemScene.Sprite = throwableItemScene.GetNode("%Sprite"); - throwableItemScene.Sprite.Texture = throwableItemInfo.Texture; + throwableItemScene.Stats = throwableItemInfo; database.Add(throwableItemScene); } @@ -73,12 +70,18 @@ public partial class ItemDatabase : Node { var consumableItemInfo = GD.Load($"res://src/items/consumable/resources/{consumable}"); var consumableItemScene = ConsumableItemScene.Instantiate(); - consumableItemScene.ItemStats = consumableItemInfo; - consumableItemScene.Sprite = consumableItemScene.GetNode("%Sprite"); - consumableItemScene.Sprite.Texture = consumableItemInfo.Texture; + consumableItemScene.Stats = consumableItemInfo; database.Add(consumableItemScene); } + foreach (var effectItem in effectResources) + { + var effectItemInfo = GD.Load($"res://src/items/effect/resources/{effectItem}"); + var effectItemScene = EffectItemScene.Instantiate(); + effectItemScene.Stats = effectItemInfo; + database.Add(effectItemScene); + } + return [.. database]; } } diff --git a/Zennysoft.Game.Ma/src/items/ItemDatabase.tscn b/Zennysoft.Game.Ma/src/items/ItemDatabase.tscn index 76d524e1..65d0f5f6 100644 --- a/Zennysoft.Game.Ma/src/items/ItemDatabase.tscn +++ b/Zennysoft.Game.Ma/src/items/ItemDatabase.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=7 format=3 uid="uid://twrj4wixcbu7"] +[gd_scene load_steps=8 format=3 uid="uid://twrj4wixcbu7"] [ext_resource type="Script" uid="uid://vdunjh1f4jry" path="res://src/items/ItemDatabase.cs" id="1_7b315"] [ext_resource type="PackedScene" uid="uid://db206brufi83s" path="res://src/items/weapons/Weapon.tscn" id="2_wq002"] @@ -6,6 +6,7 @@ [ext_resource type="PackedScene" uid="uid://b07srt3lckt4e" path="res://src/items/accessory/Accessory.tscn" id="4_pr7ub"] [ext_resource type="PackedScene" uid="uid://1fl6s352e2ej" path="res://src/items/throwable/ThrowableItem.tscn" id="5_r5y4t"] [ext_resource type="PackedScene" uid="uid://c6w7dpk0hurj0" path="res://src/items/consumable/ConsumableItem.tscn" id="6_yvger"] +[ext_resource type="PackedScene" uid="uid://d0pl1n1jf77jm" path="res://src/items/effect/EffectItem.tscn" id="7_37rlc"] [node name="ItemDatabase" type="Node"] script = ExtResource("1_7b315") @@ -14,3 +15,4 @@ ArmorScene = ExtResource("3_8wlg5") AccessoryScene = ExtResource("4_pr7ub") ThrowableItemScene = ExtResource("5_r5y4t") ConsumableItemScene = ExtResource("6_yvger") +EffectItemScene = ExtResource("7_37rlc") diff --git a/Zennysoft.Game.Ma/src/items/accessory/Accessory.cs b/Zennysoft.Game.Ma/src/items/accessory/Accessory.cs index e9b3cee2..e739c2d5 100644 --- a/Zennysoft.Game.Ma/src/items/accessory/Accessory.cs +++ b/Zennysoft.Game.Ma/src/items/accessory/Accessory.cs @@ -1,37 +1,49 @@ +using Chickensoft.AutoInject; using Chickensoft.Introspection; +using Chickensoft.Serialization; using Godot; -using Zennysoft.Ma.Godot.Adapter; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; -[Meta, Id("accessory")] +[Meta(typeof(IAutoNode)), Id("accessory")] public partial class Accessory : EquipableItem { - [Export] private AccessoryStats _accessoryStats { get; set; } = new AccessoryStats(); + public override void _Notification(int what) => this.Notify(what); - public override string ItemName => _accessoryStats.Name; + [Node] private Sprite3D _sprite { get; set; } = default!; - public override string Description => _accessoryStats.Description; + public override void _Ready() + { + _sprite.Texture = Stats.Texture; + } + public override string ItemName => Stats.Name; - public override float SpawnRate => _accessoryStats.SpawnRate; + public override string Description => Stats.Description; - public override double ThrowDamage => _accessoryStats.ThrowDamage; + public override float SpawnRate => Stats.SpawnRate; - public override float ThrowSpeed => _accessoryStats.ThrowSpeed; + public override double ThrowDamage => Stats.ThrowDamage; - public int MaxHPUp => _accessoryStats.MaxHPUp; + public override float ThrowSpeed => Stats.ThrowSpeed; - public int MaxVTUp => _accessoryStats.MaxVTUp; + public int MaxHPUp => Stats.MaxHPUp; - public double LuckUp => _accessoryStats.LuckUp; + public int MaxVTUp => Stats.MaxVTUp; - public int ATKUp => _accessoryStats.ATKUp; + public double LuckUp => Stats.LuckUp; - public int DEFUp => _accessoryStats.DEFUp; + public int ATKUp => Stats.ATKUp; - public AccessoryTag AccessoryTag => _accessoryStats.AccessoryTag; + public int DEFUp => Stats.DEFUp; - public override ItemTag ItemTag => _accessoryStats.ItemTag; + public AccessoryTag AccessoryTag => Stats.AccessoryTag; - public override InventoryItemStats ItemStats { get => _accessoryStats; set => _accessoryStats = (AccessoryStats)value; } + public override ItemTag ItemTag => Stats.ItemTag; + + [Export] + [Save("accessory_stats")] + public AccessoryStats Stats { get; set; } = new AccessoryStats(); + + public override Texture2D GetTexture() => Stats.Texture; } diff --git a/Zennysoft.Game.Ma/src/items/accessory/AccessoryStats.cs b/Zennysoft.Game.Ma/src/items/accessory/AccessoryStats.cs index b8718341..b5c31cab 100644 --- a/Zennysoft.Game.Ma/src/items/accessory/AccessoryStats.cs +++ b/Zennysoft.Game.Ma/src/items/accessory/AccessoryStats.cs @@ -1,7 +1,7 @@ using Chickensoft.Introspection; using Chickensoft.Serialization; using Godot; -using Zennysoft.Ma.Godot.Adapter; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; @@ -9,6 +9,14 @@ namespace Zennysoft.Game.Ma; [Meta, Id("accessory_stat_type")] public partial class AccessoryStats : InventoryItemStats { + [Export] + [Save("accessory_name")] + public override string Name { get; set; } = default!; + + [Export(PropertyHint.MultilineText)] + [Save("accessory_description")] + public override string Description { get; set; } = default!; + [Export] [Save("accessory_atk_up")] public int ATKUp { get; set; } = 0; diff --git a/Zennysoft.Game.Ma/src/items/armor/Armor.cs b/Zennysoft.Game.Ma/src/items/armor/Armor.cs index c195d903..22b0d4e4 100644 --- a/Zennysoft.Game.Ma/src/items/armor/Armor.cs +++ b/Zennysoft.Game.Ma/src/items/armor/Armor.cs @@ -1,30 +1,36 @@ +using Chickensoft.AutoInject; using Chickensoft.Introspection; +using Chickensoft.Serialization; using Godot; -using Zennysoft.Ma.Godot.Adapter; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; -[Meta, Id("armor")] +[Meta(typeof(IAutoNode)), Id("armor")] public partial class Armor : EquipableItem { + public override void _Notification(int what) => this.Notify(what); + + [Node] private Sprite3D Sprite { get; set; } = default!; + + public override string ItemName => Stats.Name; + + public override string Description => Stats.Description; + + public override float SpawnRate => Stats.SpawnRate; + + public override double ThrowDamage => Stats.ThrowDamage; + + public override float ThrowSpeed => Stats.ThrowSpeed; + + public int Defense => Stats.Defense; + + public void IncreaseArmorDefense(int bonus) => Stats.Defense += bonus; + + public override ItemTag ItemTag => Stats.ItemTag; + [Export] - private ArmorStats _armorStats { get; set; } = new ArmorStats(); - - public override string ItemName => _armorStats.Name; - - public override string Description => _armorStats.Description; - - public override float SpawnRate => _armorStats.SpawnRate; - - public override double ThrowDamage => _armorStats.ThrowDamage; - - public override float ThrowSpeed => _armorStats.ThrowSpeed; - - public int Defense => _armorStats.Defense; - - public void IncreaseArmorDefense(int bonus) => _armorStats.Defense += bonus; - - public override ItemTag ItemTag => _armorStats.ItemTag; - - public override InventoryItemStats ItemStats { get => _armorStats; set => _armorStats = (ArmorStats)value; } + [Save("armor_stats")] + public ArmorStats Stats { get; set; } = new ArmorStats(); + public override Texture2D GetTexture() => Stats.Texture; } diff --git a/Zennysoft.Game.Ma/src/items/armor/ArmorStats.cs b/Zennysoft.Game.Ma/src/items/armor/ArmorStats.cs index a70a3473..23007472 100644 --- a/Zennysoft.Game.Ma/src/items/armor/ArmorStats.cs +++ b/Zennysoft.Game.Ma/src/items/armor/ArmorStats.cs @@ -8,6 +8,14 @@ namespace Zennysoft.Game.Ma; [Meta, Id("armor_stats")] public partial class ArmorStats : InventoryItemStats { + [Export] + [Save("armor_name")] + public override string Name { get; set; } = default!; + + [Export(PropertyHint.MultilineText)] + [Save("armor_description")] + public override string Description { get; set; } = default!; + [Export] [Save("armor_defense")] public int Defense { get; set; } = 0; diff --git a/Zennysoft.Game.Ma/src/items/consumable/ConsumableItem.cs b/Zennysoft.Game.Ma/src/items/consumable/ConsumableItem.cs index 78c15c88..1b21f168 100644 --- a/Zennysoft.Game.Ma/src/items/consumable/ConsumableItem.cs +++ b/Zennysoft.Game.Ma/src/items/consumable/ConsumableItem.cs @@ -1,31 +1,43 @@ +using Chickensoft.AutoInject; using Chickensoft.Introspection; +using Chickensoft.Serialization; using Godot; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; -[Meta, Id("consumable_item")] +[Meta(typeof(IAutoNode)), Id("consumable_item")] public partial class ConsumableItem : InventoryItem { + public override void _Notification(int what) => this.Notify(what); + + [Node] private Sprite3D _sprite { get; set; } = default!; + + public override void _Ready() + { + _sprite.Texture = Stats.Texture; + } + + public override string ItemName => Stats.Name; + + public override string Description => Stats.Description; + + public override float SpawnRate => Stats.SpawnRate; + + public override double ThrowDamage => Stats.ThrowDamage; + + public override float ThrowSpeed => Stats.ThrowSpeed; + + public int HealHPAmount => Stats.HealHPAmount; + + public int HealVTAmount => Stats.HealVTAmount; + + public int RaiseHPAmount => Stats.RaiseHPAmount; + + public int RaiseVTAmount => Stats.RaiseVTAmount; + [Export] - private ConsumableItemStats _consumableItemStats { get; set; } = new ConsumableItemStats(); - - public override string ItemName => _consumableItemStats.Name; - - public override string Description => _consumableItemStats.Description; - - public override float SpawnRate => _consumableItemStats.SpawnRate; - - public override double ThrowDamage => _consumableItemStats.ThrowDamage; - - public override float ThrowSpeed => _consumableItemStats.ThrowSpeed; - - public int HealHPAmount => _consumableItemStats.HealHPAmount; - - public int HealVTAmount => _consumableItemStats.HealVTAmount; - - public int RaiseHPAmount => _consumableItemStats.RaiseHPAmount; - - public int RaiseVTAmount => _consumableItemStats.RaiseVTAmount; - - public override InventoryItemStats ItemStats { get => _consumableItemStats; set => _consumableItemStats = (ConsumableItemStats)value; } + [Save("consumable_item_stats")] + public ConsumableItemStats Stats { get; set; } = new ConsumableItemStats(); + public override Texture2D GetTexture() => Stats.Texture; } diff --git a/Zennysoft.Game.Ma/src/items/consumable/ConsumableItemStats.cs b/Zennysoft.Game.Ma/src/items/consumable/ConsumableItemStats.cs index 758261db..fe117b31 100644 --- a/Zennysoft.Game.Ma/src/items/consumable/ConsumableItemStats.cs +++ b/Zennysoft.Game.Ma/src/items/consumable/ConsumableItemStats.cs @@ -8,6 +8,14 @@ namespace Zennysoft.Game.Ma; [Meta, Id("consumable_item_stats")] public partial class ConsumableItemStats : InventoryItemStats { + [Export] + [Save("consumable_item_name")] + public override string Name { get; set; } = default!; + + [Export(PropertyHint.MultilineText)] + [Save("consumable_item_description")] + public override string Description { get; set; } = default!; + [Export] [Save("consumable_item_raise_hp")] public int RaiseHPAmount { get; set; } = 0; diff --git a/Zennysoft.Game.Ma/src/items/dropped/DroppedItem.cs b/Zennysoft.Game.Ma/src/items/dropped/DroppedItem.cs index 8cb8e1bc..bd71337a 100644 --- a/Zennysoft.Game.Ma/src/items/dropped/DroppedItem.cs +++ b/Zennysoft.Game.Ma/src/items/dropped/DroppedItem.cs @@ -2,7 +2,7 @@ using Chickensoft.GodotNodeInterfaces; using Chickensoft.Introspection; using Godot; -using Zennysoft.Game.Abstractions; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; @@ -24,12 +24,12 @@ public partial class DroppedItem : RigidBody3D, IDroppedItem [Node] private Area3D Pickup { get; set; } = default!; - public IInventoryItem Item { get; set; } + public InventoryItem Item { get; set; } public void OnResolved() { ContactMonitor = true; - Sprite.Texture = ((InventoryItem)Item).ItemStats.Texture; + Sprite.Texture = Item.GetTexture(); } public async void Drop() diff --git a/Zennysoft.Game.Ma/src/items/effect/EffectItem.cs b/Zennysoft.Game.Ma/src/items/effect/EffectItem.cs index b13eeaf1..04dabe24 100644 --- a/Zennysoft.Game.Ma/src/items/effect/EffectItem.cs +++ b/Zennysoft.Game.Ma/src/items/effect/EffectItem.cs @@ -1,28 +1,39 @@ -using Chickensoft.Introspection; +using Chickensoft.AutoInject; +using Chickensoft.Introspection; +using Chickensoft.Serialization; using Godot; -using Zennysoft.Ma.Godot.Adapter; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; -[Meta, Id("effect_item")] +[Meta(typeof(IAutoNode)), Id("effect_item")] public partial class EffectItem : InventoryItem { + public override void _Notification(int what) => this.Notify(what); + + [Node] private Sprite3D _sprite { get; set; } = default!; + + public override void _Ready() + { + _sprite.Texture = Stats.Texture; + } + + public override string ItemName => Stats.Name; + + public override string Description => Stats.Description; + + public override float SpawnRate => Stats.SpawnRate; + + public override double ThrowDamage => Stats.ThrowDamage; + + public override float ThrowSpeed => Stats.ThrowSpeed; + + public UsableItemTag UsableItemTag => Stats.UsableItemTag; + + public void SetEffectTag(UsableItemTag effect) => Stats.UsableItemTag = effect; + [Export] - private EffectItemStats _effectItemStats { get; set; } = new EffectItemStats(); - - public override string ItemName => _effectItemStats.Name; - - public override string Description => _effectItemStats.Description; - - public override float SpawnRate => _effectItemStats.SpawnRate; - - public override double ThrowDamage => _effectItemStats.ThrowDamage; - - public override float ThrowSpeed => _effectItemStats.ThrowSpeed; - - public UsableItemTag UsableItemTag => _effectItemStats.UsableItemTag; - - public void SetEffectTag(UsableItemTag effect) => _effectItemStats.UsableItemTag = effect; - - public override InventoryItemStats ItemStats { get => _effectItemStats; set => _effectItemStats = (EffectItemStats)value; } + [Save("effect_item_stats")] + public EffectItemStats Stats { get; set; } = new EffectItemStats(); + public override Texture2D GetTexture() => Stats.Texture; } diff --git a/Zennysoft.Game.Ma/src/items/effect/EffectItemStats.cs b/Zennysoft.Game.Ma/src/items/effect/EffectItemStats.cs index a886f661..13889bc6 100644 --- a/Zennysoft.Game.Ma/src/items/effect/EffectItemStats.cs +++ b/Zennysoft.Game.Ma/src/items/effect/EffectItemStats.cs @@ -1,7 +1,7 @@ using Chickensoft.Introspection; using Chickensoft.Serialization; using Godot; -using Zennysoft.Ma.Godot.Adapter; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; @@ -9,6 +9,14 @@ namespace Zennysoft.Game.Ma; [Meta, Id("effect_item_stats")] public partial class EffectItemStats : InventoryItemStats { + [Export] + [Save("effect_item_name")] + public override string Name { get; set; } = default!; + + [Export(PropertyHint.MultilineText)] + [Save("effect_item_description")] + public override string Description { get; set; } = default!; + [Export] [Save("effect_item_tag")] public UsableItemTag UsableItemTag { get; set; } = UsableItemTag.None; diff --git a/Zennysoft.Game.Ma/src/items/throwable/ThrowableItem.cs b/Zennysoft.Game.Ma/src/items/throwable/ThrowableItem.cs index 541caa38..82e7c8e6 100644 --- a/Zennysoft.Game.Ma/src/items/throwable/ThrowableItem.cs +++ b/Zennysoft.Game.Ma/src/items/throwable/ThrowableItem.cs @@ -1,38 +1,49 @@ +using Chickensoft.AutoInject; using Chickensoft.Introspection; +using Chickensoft.Serialization; using Godot; -using Zennysoft.Ma.Godot.Adapter; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; -[Meta, Id("throwable_item")] +[Meta(typeof(IAutoNode)), Id("throwable_item")] public partial class ThrowableItem : InventoryItem { - [Export] - private ThrowableItemStats _throwableItemStats { get; set; } + public override void _Notification(int what) => this.Notify(what); - public override string ItemName => _throwableItemStats.Name; + [Node] private Sprite3D _sprite { get; set; } = default!; - public override string Description => _throwableItemStats.Description; + public override void _Ready() + { + _sprite.Texture = Stats.Texture; + } - public override float SpawnRate => _throwableItemStats.SpawnRate; + public override string ItemName => Stats.Name; - public override double ThrowDamage => _throwableItemStats.ThrowDamage; + public override string Description => Stats.Description; - public override float ThrowSpeed => _throwableItemStats.ThrowSpeed; + public override float SpawnRate => Stats.SpawnRate; - public ElementType ElementType => _throwableItemStats.ElementType; + public override double ThrowDamage => Stats.ThrowDamage; - public ThrowableItemTag ThrowableItemTag => _throwableItemStats.ThrowableItemTag; + public override float ThrowSpeed => Stats.ThrowSpeed; - public int HealHPAmount => _throwableItemStats.HealHPAmount; + public ElementType ElementType => Stats.ElementType; - public int HealVTAmount => _throwableItemStats.HealVTAmount; + public ThrowableItemTag ThrowableItemTag => Stats.ThrowableItemTag; - public void SetElementType(ElementType elementType) => _throwableItemStats.ElementType = elementType; + public int HealHPAmount => Stats.HealHPAmount; - public void SetDescription(string description) => _throwableItemStats.Description = description; + public int HealVTAmount => Stats.HealVTAmount; + + public void SetElementType(ElementType elementType) => Stats.ElementType = elementType; + + public void SetDescription(string description) => Stats.Description = description; public int Count { get; } - public override InventoryItemStats ItemStats { get => _throwableItemStats; set => _throwableItemStats = (ThrowableItemStats)value; } + [Export] + [Save("throwable_item_stats")] + public ThrowableItemStats Stats { get; set; } + public override Texture2D GetTexture() => Stats.Texture; } diff --git a/Zennysoft.Game.Ma/src/items/throwable/ThrowableItemStats.cs b/Zennysoft.Game.Ma/src/items/throwable/ThrowableItemStats.cs index 47f5ee41..1d66ad55 100644 --- a/Zennysoft.Game.Ma/src/items/throwable/ThrowableItemStats.cs +++ b/Zennysoft.Game.Ma/src/items/throwable/ThrowableItemStats.cs @@ -1,7 +1,7 @@ using Chickensoft.Introspection; using Chickensoft.Serialization; using Godot; -using Zennysoft.Ma.Godot.Adapter; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; @@ -9,6 +9,14 @@ namespace Zennysoft.Game.Ma; [Meta, Id("throwable_item_stats")] public partial class ThrowableItemStats : InventoryItemStats { + [Export] + [Save("throwable_item_name")] + public override string Name { get; set; } = default!; + + [Export(PropertyHint.MultilineText)] + [Save("throwable_item_description")] + public override string Description { get; set; } = default!; + [Export] [Save("throwable_item_tag")] public ThrowableItemTag ThrowableItemTag { get; set; } = ThrowableItemTag.None; diff --git a/Zennysoft.Game.Ma/src/items/throwable/resources/Gospel of Dimension.tres b/Zennysoft.Game.Ma/src/items/throwable/resources/Gospel of Dimension.tres index 96dd58e9..e9dee5d9 100644 --- a/Zennysoft.Game.Ma/src/items/throwable/resources/Gospel of Dimension.tres +++ b/Zennysoft.Game.Ma/src/items/throwable/resources/Gospel of Dimension.tres @@ -10,10 +10,10 @@ ElementType = 0 UsableItemTag = 0 Name = "Gospel of Dimension" Description = "Teleports target to a random location." -Texture = ExtResource("1_xt2mp") SpawnRate = 0.1 ThrowSpeed = 20.0 HealHPAmount = 0 HealVTAmount = 0 ThrowDamage = 20 ItemTag = 0 +Texture = ExtResource("1_xt2mp") diff --git a/Zennysoft.Game.Ma/src/items/throwable/resources/GospelOfEscape.tres b/Zennysoft.Game.Ma/src/items/throwable/resources/GospelOfEscape.tres index 28a6ca2f..a33d0a5e 100644 --- a/Zennysoft.Game.Ma/src/items/throwable/resources/GospelOfEscape.tres +++ b/Zennysoft.Game.Ma/src/items/throwable/resources/GospelOfEscape.tres @@ -10,11 +10,11 @@ ElementType = 0 UsableItemTag = 0 Name = "Gospel of Escape" Description = "Warps target to the exit. No effect on player if exit has not been found." -Texture = ExtResource("1_26kno") SpawnRate = 0.5 ThrowSpeed = 12.0 HealHPAmount = 0 HealVTAmount = 0 ThrowDamage = 5 ItemTag = 0 +Texture = ExtResource("1_26kno") metadata/_custom_type_script = "uid://d3wlunkcuv2w2" diff --git a/Zennysoft.Game.Ma/src/items/throwable/resources/SpellSignKnowledge.tres b/Zennysoft.Game.Ma/src/items/throwable/resources/SpellSignKnowledge.tres index f8fd65c6..db516041 100644 --- a/Zennysoft.Game.Ma/src/items/throwable/resources/SpellSignKnowledge.tres +++ b/Zennysoft.Game.Ma/src/items/throwable/resources/SpellSignKnowledge.tres @@ -5,15 +5,17 @@ [resource] script = ExtResource("1_s3pq7") +Name = "Spell Sign: Knowledge" +Description = "Doubles experience points earned. Effect is temporary." ThrowableItemTag = 1 ElementType = 0 UsableItemTag = 0 Name = "Spell Sign: Knowledge" Description = "Doubles experience points earned. Effect is temporary." -Texture = ExtResource("1_3605p") SpawnRate = 0.1 ThrowSpeed = 12.0 HealHPAmount = 0 HealVTAmount = 0 ThrowDamage = 5 ItemTag = 0 +Texture = ExtResource("1_3605p") diff --git a/Zennysoft.Game.Ma/src/items/thrown/ThrownItem.cs b/Zennysoft.Game.Ma/src/items/thrown/ThrownItem.cs index 7d33d033..2d4b2569 100644 --- a/Zennysoft.Game.Ma/src/items/thrown/ThrownItem.cs +++ b/Zennysoft.Game.Ma/src/items/thrown/ThrownItem.cs @@ -1,8 +1,7 @@ using Chickensoft.AutoInject; using Chickensoft.Introspection; using Godot; -using Zennysoft.Ma.Godot.Adapter; -using Zennysoft.Game.Abstractions; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; @@ -15,7 +14,7 @@ public partial class ThrownItem : RigidBody3D [Dependency] public IGame Game => this.DependOn(); - public IInventoryItem ItemThatIsThrown; + public InventoryItem ItemThatIsThrown; private EffectService _effectService; @@ -25,7 +24,7 @@ public partial class ThrownItem : RigidBody3D { BodyEntered += ThrownItem_BodyEntered; GlobalPosition = Player.CurrentPosition; - Sprite.Texture = ((InventoryItem)ItemThatIsThrown).ItemStats.Texture; + Sprite.Texture = ItemThatIsThrown.GetTexture(); AddCollisionExceptionWith((Node)Player); } @@ -39,7 +38,7 @@ public partial class ThrownItem : RigidBody3D public void Throw(EffectService effectService) { _effectService = effectService; - ApplyCentralImpulse(-Player.CurrentBasis.Z.Normalized() * ((InventoryItem)ItemThatIsThrown).ThrowSpeed); + ApplyCentralImpulse(-Player.CurrentBasis.Z.Normalized() * ItemThatIsThrown.ThrowSpeed); } public void RescueItem() diff --git a/Zennysoft.Game.Ma/src/items/weapons/Weapon.cs b/Zennysoft.Game.Ma/src/items/weapons/Weapon.cs index f7628df4..a8022516 100644 --- a/Zennysoft.Game.Ma/src/items/weapons/Weapon.cs +++ b/Zennysoft.Game.Ma/src/items/weapons/Weapon.cs @@ -1,40 +1,51 @@ +using Chickensoft.AutoInject; using Chickensoft.Introspection; +using Chickensoft.Serialization; using Godot; -using Zennysoft.Ma.Godot.Adapter; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; -[Meta, Id("weapon")] +[Meta(typeof(IAutoNode)), Id("weapon")] public partial class Weapon : EquipableItem { + public override void _Notification(int what) => this.Notify(what); + + [Node] private Sprite3D _sprite { get; set; } = default!; + + public override void _Ready() + { + _sprite.Texture = Stats.Texture; + } + + public override string ItemName => Stats.Name; + + public override string Description => Stats.Description; + + public override float SpawnRate => Stats.SpawnRate; + + public int Damage => Stats.Damage; + + public override double ThrowDamage => Stats.ThrowDamage; + + public override float ThrowSpeed => Stats.ThrowSpeed; + + public double Luck => Stats.Luck; + + public double AttackSpeed => Stats.AttackSpeed; + + public WeaponTag WeaponTag => Stats.WeaponTag; + + public override ItemTag ItemTag => Stats.ItemTag; + + public ElementType WeaponElement => Stats.WeaponElement; + + public double ElementalDamageBonus => Stats.ElementalDamageBonus; + + public void IncreaseWeaponAttack(int bonus) => Stats.Damage += bonus; + [Export] - private WeaponStats _weaponStats { get; set; } = new WeaponStats(); - - public override string ItemName => _weaponStats.Name; - - public override string Description => _weaponStats.Description; - - public override float SpawnRate => _weaponStats.SpawnRate; - - public int Damage => _weaponStats.Damage; - - public override double ThrowDamage => _weaponStats.ThrowDamage; - - public override float ThrowSpeed => _weaponStats.ThrowSpeed; - - public double Luck => _weaponStats.Luck; - - public double AttackSpeed => _weaponStats.AttackSpeed; - - public WeaponTag WeaponTag => _weaponStats.WeaponTag; - - public override ItemTag ItemTag => _weaponStats.ItemTag; - - public ElementType WeaponElement => _weaponStats.WeaponElement; - - public double ElementalDamageBonus => _weaponStats.ElementalDamageBonus; - - public void IncreaseWeaponAttack(int bonus) => _weaponStats.Damage += bonus; - - public override InventoryItemStats ItemStats { get => _weaponStats; set => _weaponStats = (WeaponStats)value; } + [Save("weapon_stats")] + public WeaponStats Stats { get; set; } = new WeaponStats(); + public override Texture2D GetTexture() => Stats.Texture; } diff --git a/Zennysoft.Game.Ma/src/items/weapons/WeaponStats.cs b/Zennysoft.Game.Ma/src/items/weapons/WeaponStats.cs index f0033b0c..52c7e575 100644 --- a/Zennysoft.Game.Ma/src/items/weapons/WeaponStats.cs +++ b/Zennysoft.Game.Ma/src/items/weapons/WeaponStats.cs @@ -1,7 +1,7 @@ using Chickensoft.Introspection; using Chickensoft.Serialization; using Godot; -using Zennysoft.Ma.Godot.Adapter; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; @@ -9,6 +9,14 @@ namespace Zennysoft.Game.Ma; [Meta, Id("weapon_stat_type")] public partial class WeaponStats : InventoryItemStats { + [Export] + [Save("weapon_name")] + public override string Name { get; set; } = default!; + + [Export(PropertyHint.MultilineText)] + [Save("weapon_description")] + public override string Description { get; set; } = default!; + [Export] [Save("weapon_damage")] public int Damage { get; set; } = 0; diff --git a/Zennysoft.Game.Ma/src/map/Map.cs b/Zennysoft.Game.Ma/src/map/Map.cs index 0ea7d456..1b1781d0 100644 --- a/Zennysoft.Game.Ma/src/map/Map.cs +++ b/Zennysoft.Game.Ma/src/map/Map.cs @@ -5,6 +5,7 @@ using Chickensoft.SaveFileBuilder; using Godot; using System.Collections.Generic; using System.Linq; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; diff --git a/Zennysoft.Game.Ma/src/map/dungeon/floors/Floor00.tscn b/Zennysoft.Game.Ma/src/map/dungeon/floors/Floor00.tscn index fbe2f1ec..d9d2e249 100644 --- a/Zennysoft.Game.Ma/src/map/dungeon/floors/Floor00.tscn +++ b/Zennysoft.Game.Ma/src/map/dungeon/floors/Floor00.tscn @@ -869,7 +869,7 @@ debug_color = Color(0.937255, 0, 0.623529, 1) [node name="PlayerSpawnPoint" type="Marker3D" parent="Spawn Points"] unique_name_in_owner = true -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.625, -3, -1.035) +transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 3.625, -3, -1.035) [node name="ExitSpawnPoint" type="Marker3D" parent="Spawn Points"] unique_name_in_owner = true @@ -901,4 +901,4 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -9.00384, 1.80761, 11.3571) [node name="ThrowableItem" parent="." instance=ExtResource("16_db2o3")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.78811, -3.32789, 0) -_throwableItemStats = ExtResource("17_ntxe5") +Stats = ExtResource("17_ntxe5") diff --git a/Zennysoft.Game.Ma/src/player/IPlayer.cs b/Zennysoft.Game.Ma/src/player/IPlayer.cs index 1399a691..47d0ffc0 100644 --- a/Zennysoft.Game.Ma/src/player/IPlayer.cs +++ b/Zennysoft.Game.Ma/src/player/IPlayer.cs @@ -2,7 +2,8 @@ using Chickensoft.Collections; using Chickensoft.SaveFileBuilder; using Godot; -using Zennysoft.Ma.Godot.Adapter; +using Zennysoft.Game.Abstractions; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; @@ -44,7 +45,7 @@ public interface IPlayer : IKillable, IProvide> public void ModifyBonusLuck(double amount); - public Inventory Inventory { get; } + public IInventory Inventory { get; } public PlayerStatController Stats { get; } diff --git a/Zennysoft.Game.Ma/src/player/Player.cs b/Zennysoft.Game.Ma/src/player/Player.cs index 1a683d5e..4236d0f3 100644 --- a/Zennysoft.Game.Ma/src/player/Player.cs +++ b/Zennysoft.Game.Ma/src/player/Player.cs @@ -8,7 +8,8 @@ using Godot.Collections; using SimpleInjector; using System; using System.Linq; -using Zennysoft.Ma.Godot.Adapter; +using Zennysoft.Game.Abstractions; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; @@ -34,7 +35,7 @@ public partial class Player : CharacterBody3D, IPlayer public Basis CurrentBasis => Transform.Basis; public PlayerStatController Stats { get; set; } = default!; - public Inventory Inventory { get; private set; } = default!; + public IInventory Inventory { get; private set; } = default!; public IAutoProp EquippedWeapon => _equippedWeapon; private AutoProp _equippedWeapon { get; set; } = new AutoProp(new Weapon()); @@ -153,9 +154,9 @@ public partial class Player : CharacterBody3D, IPlayer PlayerLogic.Set(_gameRepo); var defaultWeapon = new Weapon(); - defaultWeapon.ItemStats = _defaultWeapon; + defaultWeapon.Stats = _defaultWeapon; var defaultArmor = new Armor(); - defaultArmor.ItemStats = _defaultArmor; + defaultArmor.Stats = _defaultArmor; Inventory.TryAdd(defaultWeapon); Inventory.TryAdd(defaultArmor); diff --git a/Zennysoft.Game.Ma/src/system/IHasPrimaryAttack.cs b/Zennysoft.Game.Ma/src/system/IHasPrimaryAttack.cs index 71b1640d..a732801f 100644 --- a/Zennysoft.Game.Ma/src/system/IHasPrimaryAttack.cs +++ b/Zennysoft.Game.Ma/src/system/IHasPrimaryAttack.cs @@ -1,4 +1,4 @@ -using Zennysoft.Ma.Godot.Adapter; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; diff --git a/Zennysoft.Game.Ma/src/ui/in_game_ui/InGameUI.cs b/Zennysoft.Game.Ma/src/ui/in_game_ui/InGameUI.cs index abfe4ded..1e3be0e7 100644 --- a/Zennysoft.Game.Ma/src/ui/in_game_ui/InGameUI.cs +++ b/Zennysoft.Game.Ma/src/ui/in_game_ui/InGameUI.cs @@ -2,7 +2,7 @@ using Chickensoft.AutoInject; using Chickensoft.GodotNodeInterfaces; using Chickensoft.Introspection; using Godot; -using Zennysoft.Ma.Godot.Adapter; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma;