Fix texture stuff

This commit is contained in:
2025-03-09 12:24:30 -07:00
parent b93630756c
commit d8c5bc8f78
112 changed files with 671 additions and 355 deletions

12
Ma.sln
View File

@@ -5,7 +5,7 @@ VisualStudioVersion = 17.11.35222.181
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ma", "Zennysoft.Game.Ma\Ma.csproj", "{B685AA99-B971-46A7-A708-00546BA0EF55}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ma", "Zennysoft.Game.Ma\Ma.csproj", "{B685AA99-B971-46A7-A708-00546BA0EF55}"
EndProject 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 EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E4C0167B-02AB-49E0-B36D-30D0A2479C25}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E4C0167B-02AB-49E0-B36D-30D0A2479C25}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
@@ -14,6 +14,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Zennysoft.Game.Abstractions", "Zennysoft.Game.Abstractions\Zennysoft.Game.Abstractions.csproj", "{EB9A8B79-82E1-4254-B4FB-7F4BCB57BDBF}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Zennysoft.Game.Abstractions", "Zennysoft.Game.Abstractions\Zennysoft.Game.Abstractions.csproj", "{EB9A8B79-82E1-4254-B4FB-7F4BCB57BDBF}"
EndProject 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 Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU 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}.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.ActiveCfg = Release|Any CPU
{EB9A8B79-82E1-4254-B4FB-7F4BCB57BDBF}.Release|Any CPU.Build.0 = 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 EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@@ -1,8 +0,0 @@
namespace Zennysoft.Game.Abstractions;
public interface IInventoryItem
{
string ItemName { get; }
string Description { get; }
}

View File

@@ -1,16 +1,15 @@
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization.Metadata;
namespace Zennysoft.Game.Abstractions; namespace Zennysoft.Game.Abstractions;
public interface ISaveFileManager<T> public interface ISaveFileManager<T>
{ {
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<T?> ReadFromFile(params IJsonTypeInfoResolver?[] resolvers);
public Task<T?> ReadFromFile(); public Task<T?> ReadFromFile(string filePath, params IJsonTypeInfoResolver?[] resolvers);
public Task<T?> ReadFromFile(string filePath);
} }

View File

@@ -7,12 +7,12 @@ using System.Text.Json;
using System.Text.Json.Serialization.Metadata; using System.Text.Json.Serialization.Metadata;
using Zennysoft.Game.Abstractions; using Zennysoft.Game.Abstractions;
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Game.Implementation;
public class SaveFileManager<T> : ISaveFileManager<T> public class SaveFileManager<T> : ISaveFileManager<T>
{ {
private readonly IFileSystem _fileSystem; private readonly IFileSystem _fileSystem;
private JsonSerializerOptions _jsonOptions; private readonly JsonSerializerOptions _jsonOptions;
private string _defaultSaveLocation; private string _defaultSaveLocation;
public const string DEFAULT_SAVE_FILE_NAME = "game.json"; public const string DEFAULT_SAVE_FILE_NAME = "game.json";
@@ -21,7 +21,6 @@ public class SaveFileManager<T> : ISaveFileManager<T>
_fileSystem = fileSystem; _fileSystem = fileSystem;
_defaultSaveLocation = _fileSystem.Path.Join(OS.GetUserDataDir(), DEFAULT_SAVE_FILE_NAME); _defaultSaveLocation = _fileSystem.Path.Join(OS.GetUserDataDir(), DEFAULT_SAVE_FILE_NAME);
var resolver = new SerializableTypeResolver();
GodotSerialization.Setup(); GodotSerialization.Setup();
Serializer.AddConverter(new Texture2DConverter()); Serializer.AddConverter(new Texture2DConverter());
@@ -32,42 +31,40 @@ public class SaveFileManager<T> : ISaveFileManager<T>
Converters = { Converters = {
new SerializableTypeConverter(upgradeDependencies) new SerializableTypeConverter(upgradeDependencies)
}, },
TypeInfoResolver = JsonTypeInfoResolver.Combine(resolver, WeaponTagEnumContext.Default, ItemTagEnumContext.Default, ElementTypeEnumContext.Default, AccessoryTagEnumContext.Default, ThrowableItemTagEnumContext.Default, UsableItemTagEnumContext.Default, BoxItemTagEnumContext.Default),
WriteIndented = true WriteIndented = true
}; };
} }
public Task<T?> ReadFromFile() public Task<T?> ReadFromFile(params IJsonTypeInfoResolver?[] resolvers)
{ {
if (!_fileSystem.File.Exists(_defaultSaveLocation)) if (!_fileSystem.File.Exists(_defaultSaveLocation))
throw new FileNotFoundException(); throw new FileNotFoundException();
return ReadFromFile(_defaultSaveLocation); return ReadFromFile(_defaultSaveLocation, resolvers);
} }
public async Task<T?> ReadFromFile(string filePath) public async Task<T?> ReadFromFile(string filePath, params IJsonTypeInfoResolver?[] resolvers)
{ {
if (!_fileSystem.File.Exists(filePath)) if (!_fileSystem.File.Exists(filePath))
throw new FileNotFoundException(); throw new FileNotFoundException();
var json = await _fileSystem.File.ReadAllTextAsync(filePath); var json = await _fileSystem.File.ReadAllTextAsync(filePath);
var resolver = new SerializableTypeResolver();
_jsonOptions.TypeInfoResolver = JsonTypeInfoResolver.Combine([resolver, .. resolvers]);
return JsonSerializer.Deserialize<T?>(json, _jsonOptions); return JsonSerializer.Deserialize<T?>(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); var resolver = new SerializableTypeResolver();
} _jsonOptions.TypeInfoResolver = JsonTypeInfoResolver.Combine([resolver, .. resolvers]);
var json = JsonSerializer.Serialize(gameData, _jsonOptions);
public async Task WriteToFile(T gameData, string filePath, JsonSerializerOptions jsonOptions)
{
var json = JsonSerializer.Serialize(gameData, jsonOptions);
await _fileSystem.File.WriteAllTextAsync(filePath, json); await _fileSystem.File.WriteAllTextAsync(filePath, json);
} }
} }

View File

@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Chickensoft.Introspection" Version="2.2.0" />
<PackageReference Include="Chickensoft.Introspection.Generator" Version="2.2.0" />
<PackageReference Include="Chickensoft.Serialization.Godot" Version="0.7.6" />
<PackageReference Include="System.IO.Abstractions" Version="22.0.11" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Zennysoft.Game.Abstractions\Zennysoft.Game.Abstractions.csproj" />
</ItemGroup>
</Project>

View File

@@ -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"
]
}

View File

@@ -1,6 +1,6 @@
using Zennysoft.Game.Abstractions; using Zennysoft.Game.Abstractions;
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public class AppRepo : IAppRepo public class AppRepo : IAppRepo
{ {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -2,7 +2,7 @@
using Chickensoft.LogicBlocks; using Chickensoft.LogicBlocks;
using Zennysoft.Game.Abstractions; using Zennysoft.Game.Abstractions;
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public partial class AppLogic public partial class AppLogic
{ {

View File

@@ -1,4 +1,4 @@
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Chickensoft.LogicBlocks; using Chickensoft.LogicBlocks;

View File

@@ -1,4 +1,4 @@
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Chickensoft.LogicBlocks; using Chickensoft.LogicBlocks;

View File

@@ -2,7 +2,7 @@
using Chickensoft.LogicBlocks; using Chickensoft.LogicBlocks;
using Zennysoft.Game.Abstractions; using Zennysoft.Game.Abstractions;
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public partial class AppLogic public partial class AppLogic
{ {

View File

@@ -1,4 +1,4 @@
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Chickensoft.LogicBlocks; using Chickensoft.LogicBlocks;

View File

@@ -1,7 +1,8 @@
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Chickensoft.Serialization; using Chickensoft.Serialization;
using Zennysoft.Game.Ma;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Ma.Adapter;
[Meta, Id("game_data")] [Meta, Id("game_data")]
public partial record GameData public partial record GameData

View File

@@ -1,4 +1,4 @@
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public partial class GameLogic public partial class GameLogic
{ {

View File

@@ -1,4 +1,4 @@
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public partial class GameLogic public partial class GameLogic
{ {

View File

@@ -1,7 +1,7 @@
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Chickensoft.LogicBlocks; using Chickensoft.LogicBlocks;
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public partial class GameLogic public partial class GameLogic
{ {

View File

@@ -1,7 +1,7 @@
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Chickensoft.LogicBlocks; using Chickensoft.LogicBlocks;
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public interface IGameLogic : ILogicBlock<GameLogic.State>; public interface IGameLogic : ILogicBlock<GameLogic.State>;

View File

@@ -1,8 +1,7 @@
using Chickensoft.Collections; using Chickensoft.Collections;
using Godot; using Godot;
using Zennysoft.Game.Abstractions;
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public interface IGameRepo : IDisposable public interface IGameRepo : IDisposable
{ {
@@ -18,7 +17,7 @@ public interface IGameRepo : IDisposable
event Action? DoubleExpTimeEnd; event Action? DoubleExpTimeEnd;
event Action<IInventoryItem>? RemoveItemFromInventoryEvent; event Action<InventoryItem>? RemoveItemFromInventoryEvent;
void Pause(); void Pause();
@@ -34,7 +33,7 @@ public interface IGameRepo : IDisposable
public void AnnounceMessageInInventory(string message); public void AnnounceMessageInInventory(string message);
public void RemoveItemFromInventory(IInventoryItem item); public void RemoveItemFromInventory(InventoryItem item);
public void CloseInventory(); public void CloseInventory();
@@ -51,7 +50,7 @@ public class GameRepo : IGameRepo
public event Action<string>? AnnounceMessageInInventoryEvent; public event Action<string>? AnnounceMessageInInventoryEvent;
public event Action<int>? DoubleExpTimeStart; public event Action<int>? DoubleExpTimeStart;
public event Action? DoubleExpTimeEnd; public event Action? DoubleExpTimeEnd;
public event Action<IInventoryItem>? RemoveItemFromInventoryEvent; public event Action<InventoryItem>? RemoveItemFromInventoryEvent;
public IAutoProp<bool> IsPaused => _isPaused; public IAutoProp<bool> IsPaused => _isPaused;
private readonly AutoProp<bool> _isPaused; private readonly AutoProp<bool> _isPaused;
@@ -101,7 +100,7 @@ public class GameRepo : IGameRepo
AnnounceMessageInInventoryEvent?.Invoke(message); AnnounceMessageInInventoryEvent?.Invoke(message);
} }
public void RemoveItemFromInventory(IInventoryItem item) public void RemoveItemFromInventory(InventoryItem item)
{ {
RemoveItemFromInventoryEvent?.Invoke(item); RemoveItemFromInventoryEvent?.Invoke(item);
} }

View File

@@ -1,6 +1,6 @@
using Chickensoft.Introspection; using Chickensoft.Introspection;
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public partial class GameLogic public partial class GameLogic
{ {

View File

@@ -1,6 +1,6 @@
using Chickensoft.Introspection; using Chickensoft.Introspection;
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public partial class GameLogic public partial class GameLogic
{ {

View File

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

View File

@@ -1,7 +1,7 @@
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Chickensoft.LogicBlocks; using Chickensoft.LogicBlocks;
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public partial class GameLogic public partial class GameLogic
{ {

View File

@@ -1,6 +1,6 @@
using Chickensoft.Introspection; using Chickensoft.Introspection;
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public partial class GameLogic public partial class GameLogic
{ {

View File

@@ -1,7 +1,7 @@
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Chickensoft.LogicBlocks; using Chickensoft.LogicBlocks;
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public partial class GameLogic public partial class GameLogic
{ {

View File

@@ -1,4 +1,4 @@
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Chickensoft.LogicBlocks; using Chickensoft.LogicBlocks;

View File

@@ -0,0 +1,12 @@
namespace Zennysoft.Ma.Adapter;
public interface IInventory
{
public List<InventoryItem> Items { get; }
public bool TryAdd(InventoryItem inventoryItem);
public void Remove(InventoryItem inventoryItem);
public void Sort();
}

View File

@@ -1,17 +1,17 @@
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Chickensoft.Serialization; using Chickensoft.Serialization;
using Godot; using Godot;
using System;
using Zennysoft.Game.Abstractions;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Ma.Adapter;
[Meta] [Meta, Id("inventory_item")]
public abstract partial class InventoryItem : Node3D, IInventoryItem public abstract partial class InventoryItem : Node3D
{ {
[Save("inventory_item_id")] [Save("inventory_item_id")]
public Guid ID => Guid.NewGuid(); public Guid ID => Guid.NewGuid();
[Save("inventory_item_name")]
public abstract string ItemName { get; } public abstract string ItemName { get; }
[Save("inventory_item_description")]
public abstract string Description { get; } public abstract string Description { get; }
[Save("inventory_item_spawn_rate")] [Save("inventory_item_spawn_rate")]
public abstract float SpawnRate { get; } public abstract float SpawnRate { get; }
@@ -20,8 +20,5 @@ public abstract partial class InventoryItem : Node3D, IInventoryItem
[Save("inventory_item_throw_speed")] [Save("inventory_item_throw_speed")]
public abstract float ThrowSpeed { get; } public abstract float ThrowSpeed { get; }
[Save("inventory_item_stats")] public abstract Texture2D GetTexture();
public abstract InventoryItemStats ItemStats { get; set; }
public Sprite3D Sprite { get; set; }
} }

View File

@@ -1,18 +1,17 @@
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Chickensoft.Serialization; using Chickensoft.Serialization;
using System.Collections.Generic;
using Zennysoft.Game.Abstractions; using Zennysoft.Game.Abstractions;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Ma.Adapter;
[Meta, Id("rescued_items")] [Meta, Id("rescued_items")]
public partial class RescuedItemDatabase public partial class RescuedItemDatabase
{ {
[Save("rescued_item_list")] [Save("rescued_item_list")]
public List<IInventoryItem> Items { get; init; } public List<InventoryItem> Items { get; init; }
public RescuedItemDatabase() public RescuedItemDatabase()
{ {
Items = new List<IInventoryItem>(); Items = new List<InventoryItem>();
} }
} }

View File

@@ -1,4 +1,4 @@
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public enum AccessoryTag public enum AccessoryTag
{ {

View File

@@ -1,4 +1,4 @@
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public enum BoxItemTag public enum BoxItemTag
{ {

View File

@@ -1,4 +1,4 @@
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public enum ElementType public enum ElementType
{ {

View File

@@ -1,4 +1,4 @@
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public enum ItemTag public enum ItemTag
{ {

View File

@@ -1,4 +1,4 @@
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public enum ThrowableItemTag public enum ThrowableItemTag
{ {

View File

@@ -1,4 +1,4 @@
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public enum UsableItemTag public enum UsableItemTag
{ {

View File

@@ -1,4 +1,4 @@
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public enum WeaponTag public enum WeaponTag
{ {

View File

@@ -1,6 +1,6 @@
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
[JsonSerializable(typeof(WeaponTag))] [JsonSerializable(typeof(WeaponTag))]
public partial class WeaponTagEnumContext : JsonSerializerContext; public partial class WeaponTagEnumContext : JsonSerializerContext;

View File

@@ -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<IFileSystem, FileSystem>();
container.RegisterSingleton<ISaveFileManager<GameData>, SaveFileManager<GameData>>();
container.RegisterSingleton<IMaSaveFileManager<GameData>, MaSaveFileManager<GameData>>();
container.Register<IGameRepo, GameRepo>(Lifestyle.Singleton);
container.Register<IGameLogic, GameLogic>(Lifestyle.Singleton);
}
}

View File

@@ -1,6 +1,6 @@
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Chickensoft.Serialization; using Chickensoft.Serialization;
using System.Collections.Generic; using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Game.Ma;
@@ -11,7 +11,7 @@ public partial record PlayerData
public required PlayerStats PlayerStats { get; init; } public required PlayerStats PlayerStats { get; init; }
[Save("player_inventory")] [Save("player_inventory")]
public required Inventory Inventory { get; init; } public required IInventory Inventory { get; init; }
} }
[Meta, Id("map_data")] [Meta, Id("map_data")]

View File

@@ -1,6 +1,6 @@
using Godot; using Godot;
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public partial class PlayerLogic public partial class PlayerLogic
{ {

View File

@@ -1,4 +1,4 @@
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public partial class PlayerLogic public partial class PlayerLogic
{ {

View File

@@ -1,4 +1,4 @@
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public partial class PlayerLogic public partial class PlayerLogic
{ {

View File

@@ -1,7 +1,7 @@
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Chickensoft.LogicBlocks; using Chickensoft.LogicBlocks;
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public partial class PlayerLogic public partial class PlayerLogic
{ {

View File

@@ -1,7 +1,7 @@
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Chickensoft.LogicBlocks; using Chickensoft.LogicBlocks;
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public interface IPlayerLogic : ILogicBlock<PlayerLogic.State>; public interface IPlayerLogic : ILogicBlock<PlayerLogic.State>;

View File

@@ -1,6 +1,6 @@
using Chickensoft.Introspection; using Chickensoft.Introspection;
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public partial class PlayerLogic public partial class PlayerLogic
{ {

View File

@@ -1,7 +1,7 @@
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Godot; using Godot;
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public partial class PlayerLogic public partial class PlayerLogic
{ {

View File

@@ -1,7 +1,7 @@
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Godot; using Godot;
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public partial class PlayerLogic public partial class PlayerLogic
{ {

View File

@@ -1,6 +1,6 @@
using Chickensoft.Introspection; using Chickensoft.Introspection;
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public partial class PlayerLogic public partial class PlayerLogic
{ {

View File

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

View File

@@ -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<T>
{
Task Save(T gameData);
Task<T?> Load();
}
public sealed class MaSaveFileManager<T> : IMaSaveFileManager<T>
{
private readonly ISaveFileManager<T> _saveFileManager;
private ImmutableList<IJsonTypeInfoResolver> _converters;
public MaSaveFileManager(ISaveFileManager<T> 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<T?> Load() => await _saveFileManager.ReadFromFile([.. _converters]);
}

View File

@@ -1,9 +1,8 @@
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Chickensoft.LogicBlocks; using Chickensoft.LogicBlocks;
using Zennysoft.Game.Abstractions;
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public partial class InGameUILogic public partial class InGameUILogic
{ {
@@ -38,7 +37,7 @@ public partial class InGameUILogic
Output(new Output.AnnounceMessageInInventory(message)); 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));
} }
} }

View File

@@ -1,7 +1,7 @@
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Chickensoft.LogicBlocks; using Chickensoft.LogicBlocks;
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public interface IInGameUILogic : ILogicBlock<InGameUILogic.State>; public interface IInGameUILogic : ILogicBlock<InGameUILogic.State>;

View File

@@ -1,4 +1,4 @@
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public partial class InGameUILogic public partial class InGameUILogic
{ {
public static class Input public static class Input

View File

@@ -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 partial class InGameUILogic
{ {
public static class Output public static class Output
{ {
public readonly record struct AnnounceMessageOnMainScreen(string Message); public readonly record struct AnnounceMessageOnMainScreen(string Message);
public readonly record struct AnnounceMessageInInventory(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 DisplayMinimap;
public readonly record struct HideMinimap; public readonly record struct HideMinimap;
public readonly record struct ShowInventory; public readonly record struct ShowInventory;

View File

@@ -1,6 +1,6 @@
using Chickensoft.Introspection; using Chickensoft.Introspection;
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public partial class InGameUILogic public partial class InGameUILogic
{ {

View File

@@ -1,6 +1,6 @@
using Chickensoft.Introspection; using Chickensoft.Introspection;
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public partial class InGameUILogic public partial class InGameUILogic
{ {

View File

@@ -1,6 +1,6 @@
using Chickensoft.Introspection; using Chickensoft.Introspection;
namespace Zennysoft.Ma.Godot.Adapter; namespace Zennysoft.Ma.Adapter;
public partial class InGameUILogic public partial class InGameUILogic
{ {

View File

@@ -13,11 +13,13 @@
<PackageReference Include="Chickensoft.LogicBlocks" Version="5.16.0" /> <PackageReference Include="Chickensoft.LogicBlocks" Version="5.16.0" />
<PackageReference Include="Chickensoft.Serialization.Godot" Version="0.7.6" /> <PackageReference Include="Chickensoft.Serialization.Godot" Version="0.7.6" />
<PackageReference Include="GodotSharp.SourceGenerators" Version="2.6.0-250131-2115.Release" /> <PackageReference Include="GodotSharp.SourceGenerators" Version="2.6.0-250131-2115.Release" />
<PackageReference Include="SimpleInjector" Version="5.5.0" />
<PackageReference Include="System.IO.Abstractions" Version="22.0.11" /> <PackageReference Include="System.IO.Abstractions" Version="22.0.11" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Zennysoft.Game.Abstractions\Zennysoft.Game.Abstractions.csproj" /> <ProjectReference Include="..\Zennysoft.Game.Abstractions\Zennysoft.Game.Abstractions.csproj" />
<ProjectReference Include="..\Zennysoft.Game.Godot.Implementation\Zennysoft.Game.Implementation.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -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"
]
}

View File

@@ -36,8 +36,8 @@
<None Include=".editorconfig" /> <None Include=".editorconfig" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Zennysoft.Game.Abstractions\Zennysoft.Game.Abstractions.csproj" /> <ProjectReference Include="..\Zennysoft.Game.Godot.Implementation\Zennysoft.Game.Implementation.csproj" />
<ProjectReference Include="..\Zennysoft.Game.Ma.Implementation\Zennysoft.Ma.Godot.Adapter.csproj" /> <ProjectReference Include="..\Zennysoft.Game.Ma.Implementation\Zennysoft.Ma.Adapter.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Update="Godot.SourceGenerators" Version="4.4.0-dev.2" /> <PackageReference Update="Godot.SourceGenerators" Version="4.4.0-dev.2" />

View File

@@ -5,8 +5,7 @@ using Godot;
using SimpleInjector; using SimpleInjector;
using SimpleInjector.Lifestyles; using SimpleInjector.Lifestyles;
using Zennysoft.Game.Abstractions; using Zennysoft.Game.Abstractions;
using Zennysoft.Ma.Godot.Adapter; using Zennysoft.Ma.Adapter;
using static Zennysoft.Ma.Godot.Adapter.AppLogic.Input;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Game.Ma;
@@ -115,16 +114,16 @@ public partial class App : CanvasLayer, IApp
AppLogic.Start(); 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() public void OnSaveFileLoaded()
{ {
Game.SaveFileLoaded -= OnSaveFileLoaded; Game.SaveFileLoaded -= OnSaveFileLoaded;
AppLogic.Input(new SaveFileLoaded()); AppLogic.Input(new AppLogic.Input.SaveFileLoaded());
} }
public void FadeInFromBlack() public void FadeInFromBlack()
@@ -149,12 +148,12 @@ public partial class App : CanvasLayer, IApp
{ {
if (animation == "fade_in") if (animation == "fade_in")
{ {
AppLogic.Input(new FadeInFinished()); AppLogic.Input(new AppLogic.Input.FadeInFinished());
BlankScreen.Hide(); BlankScreen.Hide();
return; return;
} }
AppLogic.Input(new FadeOutFinished()); AppLogic.Input(new AppLogic.Input.FadeOutFinished());
} }
public void OnExitTree() public void OnExitTree()

View File

@@ -3,7 +3,7 @@ using Chickensoft.Collections;
using Chickensoft.GodotNodeInterfaces; using Chickensoft.GodotNodeInterfaces;
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Godot; using Godot;
using Zennysoft.Ma.Godot.Adapter; using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Game.Ma;

View File

@@ -3,7 +3,7 @@ using Chickensoft.Collections;
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Godot; using Godot;
using System.Linq; using System.Linq;
using Zennysoft.Ma.Godot.Adapter; using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Game.Ma;

View File

@@ -1,5 +1,5 @@
using Godot; using Godot;
using Zennysoft.Ma.Godot.Adapter; using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Game.Ma;

View File

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

View File

@@ -8,12 +8,12 @@
[sub_resource type="Resource" id="Resource_oln85"] [sub_resource type="Resource" id="Resource_oln85"]
script = ExtResource("2_oln85") script = ExtResource("2_oln85")
CurrentHP = 30.0 CurrentHP = 30.0
MaximumHP = 0 MaximumHP = 30
CurrentAttack = 15 CurrentAttack = 15
CurrentDefense = 7 CurrentDefense = 7
MaxAttack = 15 MaxAttack = 15
MaxDefense = 7 MaxDefense = 7
ExpFromDefeat = 15 ExpFromDefeat = 5
Luck = 0.05 Luck = 0.05
TelluricResistance = 0.0 TelluricResistance = 0.0
AeolicResistance = 0.0 AeolicResistance = 0.0

View File

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

View File

@@ -8,12 +8,12 @@
[sub_resource type="Resource" id="Resource_xhsah"] [sub_resource type="Resource" id="Resource_xhsah"]
script = ExtResource("2_wrps7") script = ExtResource("2_wrps7")
CurrentHP = 50.0 CurrentHP = 50.0
MaximumHP = 0 MaximumHP = 50
CurrentAttack = 15 CurrentAttack = 15
CurrentDefense = 0 CurrentDefense = 0
MaxAttack = 15 MaxAttack = 15
MaxDefense = 0 MaxDefense = 0
ExpFromDefeat = 0 ExpFromDefeat = 5
Luck = 0.05 Luck = 0.05
TelluricResistance = 0.0 TelluricResistance = 0.0
AeolicResistance = 0.0 AeolicResistance = 0.0

View File

@@ -3,7 +3,7 @@ using Chickensoft.Introspection;
using Godot; using Godot;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Zennysoft.Ma.Godot.Adapter; using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Game.Ma;

View File

@@ -3,7 +3,7 @@ using Chickensoft.Introspection;
using Godot; using Godot;
using System.Collections.Generic; using System.Collections.Generic;
using System; using System;
using Zennysoft.Ma.Godot.Adapter; using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Game.Ma;

View File

@@ -1,7 +1,7 @@
using Chickensoft.AutoInject; using Chickensoft.AutoInject;
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Godot; using Godot;
using Zennysoft.Ma.Godot.Adapter; using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Game.Ma;

View File

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

View File

@@ -3,7 +3,7 @@ using Chickensoft.Introspection;
using Godot; using Godot;
using System.Collections.Generic; using System.Collections.Generic;
using System; using System;
using Zennysoft.Ma.Godot.Adapter; using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Game.Ma;

View File

@@ -6,12 +6,10 @@ using Chickensoft.Introspection;
using Chickensoft.SaveFileBuilder; using Chickensoft.SaveFileBuilder;
using Godot; using Godot;
using System; using System;
using System.IO.Abstractions;
using System.Text.Json; using System.Text.Json;
using Zennysoft.Game.Abstractions; using Zennysoft.Game.Abstractions;
using Zennysoft.Ma.Godot.Adapter; using Zennysoft.Ma.Adapter;
using System.IO; using System.IO;
using SimpleInjector;
using System.Threading.Tasks; using System.Threading.Tasks;
[Meta(typeof(IAutoNode))] [Meta(typeof(IAutoNode))]
@@ -82,10 +80,7 @@ public partial class Game : Node3D, IGame
public void Setup() public void Setup()
{ {
_container = new SimpleInjector.Container(); _container = new SimpleInjector.Container();
_container.Register<IFileSystem, FileSystem>(); Module.Bootstrap(_container);
_container.Register<ISaveFileManager<GameData>, SaveFileManager<GameData>>();
_container.Register<IGameRepo, GameRepo>(Lifestyle.Singleton);
_container.Register<IGameLogic, GameLogic>(Lifestyle.Singleton);
_container.Verify(); _container.Verify();
GameRepo = _container.GetInstance<IGameRepo>(); GameRepo = _container.GetInstance<IGameRepo>();
@@ -146,15 +141,15 @@ public partial class Game : Node3D, IGame
public void OnResolved() public void OnResolved()
{ {
var saveFileManager = _container.GetInstance<ISaveFileManager<GameData>>(); var saveFileManager = _container.GetInstance<IMaSaveFileManager<GameData>>();
SaveFile = new SaveFile<GameData>( SaveFile = new SaveFile<GameData>(
root: GameChunk, root: GameChunk,
onSave: saveFileManager.WriteToFile, onSave: saveFileManager.Save,
onLoad: async () => onLoad: async () =>
{ {
try try
{ {
var gameData = await saveFileManager.ReadFromFile(); var gameData = await saveFileManager.Load();
return gameData; return gameData;
} }
catch (FileNotFoundException) catch (FileNotFoundException)
@@ -246,7 +241,7 @@ public partial class Game : Node3D, IGame
GameEventDepot.OnTeleportEntered(); GameEventDepot.OnTeleportEntered();
} }
public async Task UseItem(IInventoryItem item) public async Task UseItem(InventoryItem item)
{ {
if (item is ConsumableItem consumableItem) if (item is ConsumableItem consumableItem)
{ {
@@ -329,7 +324,7 @@ public partial class Game : Node3D, IGame
GameRepo.RemoveItemFromInventory(item); GameRepo.RemoveItemFromInventory(item);
} }
public void DropItem(IInventoryItem item) public void DropItem(InventoryItem item)
{ {
var droppedScene = GD.Load<PackedScene>("res://src/items/dropped/DroppedItem.tscn"); var droppedScene = GD.Load<PackedScene>("res://src/items/dropped/DroppedItem.tscn");
var dropped = droppedScene.Instantiate<DroppedItem>(); var dropped = droppedScene.Instantiate<DroppedItem>();
@@ -338,11 +333,11 @@ public partial class Game : Node3D, IGame
dropped.Drop(); dropped.Drop();
} }
public void ThrowItem(IInventoryItem item) public void ThrowItem(InventoryItem item)
{ {
var thrownScene = GD.Load<PackedScene>("res://src/items/thrown/ThrownItem.tscn"); var thrownScene = GD.Load<PackedScene>("res://src/items/thrown/ThrownItem.tscn");
var thrown = thrownScene.Instantiate<ThrownItem>(); var thrown = thrownScene.Instantiate<ThrownItem>();
thrown.ItemThatIsThrown = item; thrown.ItemThatIsThrown = (InventoryItem)item;
AddChild(thrown); AddChild(thrown);
thrown.Position += new Vector3(0, 1.5f, 0); thrown.Position += new Vector3(0, 1.5f, 0);
thrown.Throw(_effectService); thrown.Throw(_effectService);

View File

@@ -7,7 +7,7 @@ using Chickensoft.SaveFileBuilder;
using Godot; using Godot;
using System.Threading.Tasks; using System.Threading.Tasks;
using Zennysoft.Game.Abstractions; using Zennysoft.Game.Abstractions;
using Zennysoft.Ma.Godot.Adapter; using Zennysoft.Ma.Adapter;
public interface IGame : IProvide<IGameRepo>, IProvide<IGameEventDepot>, IProvide<IGame>, IProvide<IPlayer>, IProvide<ISaveChunk<GameData>>, INode3D public interface IGame : IProvide<IGameRepo>, IProvide<IGameEventDepot>, IProvide<IGame>, IProvide<IPlayer>, IProvide<ISaveChunk<GameData>>, INode3D
{ {
@@ -21,11 +21,11 @@ public interface IGame : IProvide<IGameRepo>, IProvide<IGameEventDepot>, IProvid
public IDungeonFloor CurrentFloor { get; } 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(); public void FloorExitReached();

View File

@@ -4,8 +4,7 @@ using Chickensoft.Introspection;
using Godot; using Godot;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Zennysoft.Game.Abstractions; using Zennysoft.Ma.Adapter;
using Zennysoft.Ma.Godot.Adapter;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Game.Ma;
@@ -15,7 +14,7 @@ public interface IInventoryMenu : IControl
public Task DisplayMessage(string message); public Task DisplayMessage(string message);
public void RemoveItem(IInventoryItem item); public void RemoveItem(InventoryItem item);
} }
[Meta(typeof(IAutoNode))] [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 #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); Player.Inventory.Remove(item);
if (_currentIndex >= ItemSlots.Length - 1) if (_currentIndex >= ItemSlots.Length - 1)

View File

@@ -2,13 +2,13 @@ using Chickensoft.AutoInject;
using Chickensoft.GodotNodeInterfaces; using Chickensoft.GodotNodeInterfaces;
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Godot; using Godot;
using Zennysoft.Game.Abstractions; using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Game.Ma;
public interface IItemSlot : IHBoxContainer public interface IItemSlot : IHBoxContainer
{ {
public IInventoryItem Item { get; set; } public InventoryItem Item { get; set; }
public void SetItemStyle(); public void SetItemStyle();
@@ -42,7 +42,7 @@ public partial class ItemSlot : HBoxContainer, IItemSlot
{ {
ItemName.Text = Item.ItemName; ItemName.Text = Item.ItemName;
//EquipBonus.Text = "..."; //EquipBonus.Text = "...";
ItemTexture.Texture = ((InventoryItem)Item).ItemStats.Texture; ItemTexture.Texture = Item.GetTexture();
Player.EquippedWeapon.Sync += EquippedWeapon_Sync; Player.EquippedWeapon.Sync += EquippedWeapon_Sync;
Player.EquippedArmor.Sync += EquippedArmor_Sync; Player.EquippedArmor.Sync += EquippedArmor_Sync;
Player.EquippedAccessory.Sync += EquippedAccessory_Sync; Player.EquippedAccessory.Sync += EquippedAccessory_Sync;
@@ -114,5 +114,5 @@ public partial class ItemSlot : HBoxContainer, IItemSlot
//EquipBonus.LabelSettings = EquippedItemFont; //EquipBonus.LabelSettings = EquippedItemFont;
} }
public IInventoryItem Item { get; set; } = default!; public InventoryItem Item { get; set; } = default!;
} }

View File

@@ -1,7 +1,7 @@
using Godot; using Godot;
using System.Linq; using System.Linq;
using System; using System;
using Zennysoft.Ma.Godot.Adapter; using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Game.Ma;
@@ -76,7 +76,7 @@ public class EffectService
rng.Randomize(); rng.Randomize();
var randomResource = resourceFiles[rng.RandiRange(0, resourceFiles.Length - 1)]; var randomResource = resourceFiles[rng.RandiRange(0, resourceFiles.Length - 1)];
var randomFile = ResourceLoader.Load<ConsumableItemStats>($"{consumableFolder}/resources/{randomResource}"); var randomFile = ResourceLoader.Load<ConsumableItemStats>($"{consumableFolder}/resources/{randomResource}");
consumable.ItemStats = randomFile; consumable.Stats = randomFile;
_game.AddChild(consumable); _game.AddChild(consumable);
consumable.GlobalPosition = vector; consumable.GlobalPosition = vector;
} }

View File

@@ -1,10 +1,10 @@
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Chickensoft.Serialization; using Chickensoft.Serialization;
using Zennysoft.Ma.Godot.Adapter; using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Game.Ma;
[Meta] [Meta, Id("equipable_item")]
public abstract partial class EquipableItem : InventoryItem public abstract partial class EquipableItem : InventoryItem
{ {
public abstract ItemTag ItemTag { get; } public abstract ItemTag ItemTag { get; }

View File

@@ -1,25 +1,13 @@
using Chickensoft.AutoInject; using Chickensoft.AutoInject;
using Chickensoft.GodotNodeInterfaces;
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Chickensoft.Serialization; using Chickensoft.Serialization;
using Godot; using Godot;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Zennysoft.Game.Abstractions; using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Game.Ma;
public interface IInventory : INode
{
public List<IInventoryItem> Items { get; }
public bool TryAdd(IInventoryItem inventoryItem);
public void Remove(IInventoryItem inventoryItem);
public void Sort();
}
[Meta(typeof(IAutoNode)), Id("inventory")] [Meta(typeof(IAutoNode)), Id("inventory")]
public partial class Inventory : Node, IInventory public partial class Inventory : Node, IInventory
{ {
@@ -34,9 +22,9 @@ public partial class Inventory : Node, IInventory
} }
[Save("inventory_items")] [Save("inventory_items")]
public List<IInventoryItem> Items { get; private set; } public List<InventoryItem> Items { get; private set; }
public bool TryAdd(IInventoryItem inventoryItem) public bool TryAdd(InventoryItem inventoryItem)
{ {
if (Items.Count >= _maxInventorySize) if (Items.Count >= _maxInventorySize)
return false; return false;
@@ -45,15 +33,15 @@ public partial class Inventory : Node, IInventory
return true; return true;
} }
public void Remove(IInventoryItem inventoryItem) => Items.Remove(inventoryItem); public void Remove(InventoryItem inventoryItem) => Items.Remove(inventoryItem);
public void Sort() public void Sort()
{ {
var equippedWeapon = Items.OfType<Weapon>().Where(x => x.IsEquipped).Cast<IInventoryItem>(); var equippedWeapon = Items.OfType<Weapon>().Where(x => x.IsEquipped);
var equippedArmor = Items.OfType<Armor>().Where(x => x.IsEquipped).Cast<IInventoryItem>(); var equippedArmor = Items.OfType<Armor>().Where(x => x.IsEquipped);
var equippedAccessory = Items.OfType<Accessory>().Where(x => x.IsEquipped).Cast<IInventoryItem>(); var equippedAccessory = Items.OfType<Accessory>().Where(x => x.IsEquipped);
var equippedItems = new List<IInventoryItem>(); var equippedItems = new List<InventoryItem>();
equippedItems.AddRange(equippedWeapon); equippedItems.AddRange(equippedWeapon);
equippedItems.AddRange(equippedArmor); equippedItems.AddRange(equippedArmor);
equippedItems.AddRange(equippedAccessory); equippedItems.AddRange(equippedAccessory);

View File

@@ -1,23 +1,18 @@
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Chickensoft.Serialization; using Chickensoft.Serialization;
using Godot; using Godot;
using Zennysoft.Ma.Godot.Adapter; using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Game.Ma;
[Meta, Id("inventory_item_stats")] [Meta, Id("inventory_item_stats")]
public partial class InventoryItemStats : Resource public abstract partial class InventoryItemStats : Resource
{ {
[Export] [Export]
[Save("inventory_item_name")] public abstract string Name { get; set; }
public string Name { get; set; } = string.Empty;
[Export(PropertyHint.MultilineText)] [Export(PropertyHint.MultilineText)]
[Save("inventory_item_description")] public abstract string Description { get; set; }
public string Description { get; set; } = string.Empty;
[Save("inventory_item_texture")]
[Export] public Texture2D Texture { get; set; } = default!;
[Export(PropertyHint.Range, "0, 1, 0.01")] [Export(PropertyHint.Range, "0, 1, 0.01")]
public float SpawnRate { get; set; } = 0.5f; public float SpawnRate { get; set; } = 0.5f;
@@ -36,4 +31,8 @@ public partial class InventoryItemStats : Resource
[Export] [Export]
public ItemTag ItemTag { get; set; } = ItemTag.None; public ItemTag ItemTag { get; set; } = ItemTag.None;
[Export]
[Save("inventory_item_texture")]
public Texture2D Texture { get; set; }
} }

View File

@@ -1,5 +1,6 @@
using Godot; using Godot;
using System.Collections.Generic; using System.Collections.Generic;
using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Game.Ma;
@@ -20,6 +21,9 @@ public partial class ItemDatabase : Node
[Export] [Export]
public PackedScene ConsumableItemScene { get; set; } public PackedScene ConsumableItemScene { get; set; }
[Export]
public PackedScene EffectItemScene { get; set; }
public InventoryItem[] Initialize() public InventoryItem[] Initialize()
{ {
var database = new List<InventoryItem>(); var database = new List<InventoryItem>();
@@ -28,14 +32,13 @@ public partial class ItemDatabase : Node
var accessoryResources = DirAccess.GetFilesAt("res://src/items/accessory/resources/"); var accessoryResources = DirAccess.GetFilesAt("res://src/items/accessory/resources/");
var throwableResources = DirAccess.GetFilesAt("res://src/items/throwable/resources/"); var throwableResources = DirAccess.GetFilesAt("res://src/items/throwable/resources/");
var consumableResources = DirAccess.GetFilesAt("res://src/items/consumable/resources/"); var consumableResources = DirAccess.GetFilesAt("res://src/items/consumable/resources/");
var effectResources = DirAccess.GetFilesAt("res://src/items/effect/resources/");
foreach (var armor in armorResources) foreach (var armor in armorResources)
{ {
var armorInfo = GD.Load<ArmorStats>($"res://src/items/armor/resources/{armor}"); var armorInfo = GD.Load<ArmorStats>($"res://src/items/armor/resources/{armor}");
var armorScene = ArmorScene.Instantiate<Armor>(); var armorScene = ArmorScene.Instantiate<Armor>();
armorScene.ItemStats = armorInfo; armorScene.Stats = armorInfo;
armorScene.Sprite = armorScene.GetNode<Sprite3D>("%Sprite");
armorScene.Sprite.Texture = armorInfo.Texture;
database.Add(armorScene); database.Add(armorScene);
} }
@@ -43,9 +46,7 @@ public partial class ItemDatabase : Node
{ {
var weaponInfo = GD.Load<WeaponStats>($"res://src/items/weapons/resources/{weapon}"); var weaponInfo = GD.Load<WeaponStats>($"res://src/items/weapons/resources/{weapon}");
var weaponScene = WeaponScene.Instantiate<Weapon>(); var weaponScene = WeaponScene.Instantiate<Weapon>();
weaponScene.ItemStats = weaponInfo; weaponScene.Stats = weaponInfo;
weaponScene.Sprite = weaponScene.GetNode<Sprite3D>("%Sprite");
weaponScene.Sprite.Texture = weaponInfo.Texture;
database.Add(weaponScene); database.Add(weaponScene);
} }
@@ -53,9 +54,7 @@ public partial class ItemDatabase : Node
{ {
var accessoryInfo = GD.Load<AccessoryStats>($"res://src/items/accessory/resources/{accessory}"); var accessoryInfo = GD.Load<AccessoryStats>($"res://src/items/accessory/resources/{accessory}");
var accessoryScene = AccessoryScene.Instantiate<Accessory>(); var accessoryScene = AccessoryScene.Instantiate<Accessory>();
accessoryScene.ItemStats = accessoryInfo; accessoryScene.Stats = accessoryInfo;
accessoryScene.Sprite = accessoryScene.GetNode<Sprite3D>("%Sprite");
accessoryScene.Sprite.Texture = accessoryInfo.Texture;
database.Add(accessoryScene); database.Add(accessoryScene);
} }
@@ -63,9 +62,7 @@ public partial class ItemDatabase : Node
{ {
var throwableItemInfo = GD.Load<ThrowableItemStats>($"res://src/items/throwable/resources/{throwable}"); var throwableItemInfo = GD.Load<ThrowableItemStats>($"res://src/items/throwable/resources/{throwable}");
var throwableItemScene = ThrowableItemScene.Instantiate<ThrowableItem>(); var throwableItemScene = ThrowableItemScene.Instantiate<ThrowableItem>();
throwableItemScene.ItemStats = throwableItemInfo; throwableItemScene.Stats = throwableItemInfo;
throwableItemScene.Sprite = throwableItemScene.GetNode<Sprite3D>("%Sprite");
throwableItemScene.Sprite.Texture = throwableItemInfo.Texture;
database.Add(throwableItemScene); database.Add(throwableItemScene);
} }
@@ -73,12 +70,18 @@ public partial class ItemDatabase : Node
{ {
var consumableItemInfo = GD.Load<ConsumableItemStats>($"res://src/items/consumable/resources/{consumable}"); var consumableItemInfo = GD.Load<ConsumableItemStats>($"res://src/items/consumable/resources/{consumable}");
var consumableItemScene = ConsumableItemScene.Instantiate<ConsumableItem>(); var consumableItemScene = ConsumableItemScene.Instantiate<ConsumableItem>();
consumableItemScene.ItemStats = consumableItemInfo; consumableItemScene.Stats = consumableItemInfo;
consumableItemScene.Sprite = consumableItemScene.GetNode<Sprite3D>("%Sprite");
consumableItemScene.Sprite.Texture = consumableItemInfo.Texture;
database.Add(consumableItemScene); database.Add(consumableItemScene);
} }
foreach (var effectItem in effectResources)
{
var effectItemInfo = GD.Load<EffectItemStats>($"res://src/items/effect/resources/{effectItem}");
var effectItemScene = EffectItemScene.Instantiate<EffectItem>();
effectItemScene.Stats = effectItemInfo;
database.Add(effectItemScene);
}
return [.. database]; return [.. database];
} }
} }

View File

@@ -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="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"] [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://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://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://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"] [node name="ItemDatabase" type="Node"]
script = ExtResource("1_7b315") script = ExtResource("1_7b315")
@@ -14,3 +15,4 @@ ArmorScene = ExtResource("3_8wlg5")
AccessoryScene = ExtResource("4_pr7ub") AccessoryScene = ExtResource("4_pr7ub")
ThrowableItemScene = ExtResource("5_r5y4t") ThrowableItemScene = ExtResource("5_r5y4t")
ConsumableItemScene = ExtResource("6_yvger") ConsumableItemScene = ExtResource("6_yvger")
EffectItemScene = ExtResource("7_37rlc")

View File

@@ -1,37 +1,49 @@
using Chickensoft.AutoInject;
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Chickensoft.Serialization;
using Godot; using Godot;
using Zennysoft.Ma.Godot.Adapter; using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Game.Ma;
[Meta, Id("accessory")] [Meta(typeof(IAutoNode)), Id("accessory")]
public partial class Accessory : EquipableItem 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;
} }

View File

@@ -1,7 +1,7 @@
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Chickensoft.Serialization; using Chickensoft.Serialization;
using Godot; using Godot;
using Zennysoft.Ma.Godot.Adapter; using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Game.Ma;
@@ -9,6 +9,14 @@ namespace Zennysoft.Game.Ma;
[Meta, Id("accessory_stat_type")] [Meta, Id("accessory_stat_type")]
public partial class AccessoryStats : InventoryItemStats 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] [Export]
[Save("accessory_atk_up")] [Save("accessory_atk_up")]
public int ATKUp { get; set; } = 0; public int ATKUp { get; set; } = 0;

View File

@@ -1,30 +1,36 @@
using Chickensoft.AutoInject;
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Chickensoft.Serialization;
using Godot; using Godot;
using Zennysoft.Ma.Godot.Adapter; using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Game.Ma;
[Meta, Id("armor")] [Meta(typeof(IAutoNode)), Id("armor")]
public partial class Armor : EquipableItem 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] [Export]
private ArmorStats _armorStats { get; set; } = new ArmorStats(); [Save("armor_stats")]
public ArmorStats Stats { get; set; } = new ArmorStats();
public override string ItemName => _armorStats.Name; public override Texture2D GetTexture() => Stats.Texture;
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; }
} }

View File

@@ -8,6 +8,14 @@ namespace Zennysoft.Game.Ma;
[Meta, Id("armor_stats")] [Meta, Id("armor_stats")]
public partial class ArmorStats : InventoryItemStats 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] [Export]
[Save("armor_defense")] [Save("armor_defense")]
public int Defense { get; set; } = 0; public int Defense { get; set; } = 0;

View File

@@ -1,31 +1,43 @@
using Chickensoft.AutoInject;
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Chickensoft.Serialization;
using Godot; using Godot;
using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Game.Ma;
[Meta, Id("consumable_item")] [Meta(typeof(IAutoNode)), Id("consumable_item")]
public partial class ConsumableItem : InventoryItem 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] [Export]
private ConsumableItemStats _consumableItemStats { get; set; } = new ConsumableItemStats(); [Save("consumable_item_stats")]
public ConsumableItemStats Stats { get; set; } = new ConsumableItemStats();
public override string ItemName => _consumableItemStats.Name; public override Texture2D GetTexture() => Stats.Texture;
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; }
} }

View File

@@ -8,6 +8,14 @@ namespace Zennysoft.Game.Ma;
[Meta, Id("consumable_item_stats")] [Meta, Id("consumable_item_stats")]
public partial class ConsumableItemStats : InventoryItemStats 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] [Export]
[Save("consumable_item_raise_hp")] [Save("consumable_item_raise_hp")]
public int RaiseHPAmount { get; set; } = 0; public int RaiseHPAmount { get; set; } = 0;

View File

@@ -2,7 +2,7 @@
using Chickensoft.GodotNodeInterfaces; using Chickensoft.GodotNodeInterfaces;
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Godot; using Godot;
using Zennysoft.Game.Abstractions; using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Game.Ma;
@@ -24,12 +24,12 @@ public partial class DroppedItem : RigidBody3D, IDroppedItem
[Node] private Area3D Pickup { get; set; } = default!; [Node] private Area3D Pickup { get; set; } = default!;
public IInventoryItem Item { get; set; } public InventoryItem Item { get; set; }
public void OnResolved() public void OnResolved()
{ {
ContactMonitor = true; ContactMonitor = true;
Sprite.Texture = ((InventoryItem)Item).ItemStats.Texture; Sprite.Texture = Item.GetTexture();
} }
public async void Drop() public async void Drop()

View File

@@ -1,28 +1,39 @@
using Chickensoft.Introspection; using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using Chickensoft.Serialization;
using Godot; using Godot;
using Zennysoft.Ma.Godot.Adapter; using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Game.Ma;
[Meta, Id("effect_item")] [Meta(typeof(IAutoNode)), Id("effect_item")]
public partial class EffectItem : InventoryItem 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] [Export]
private EffectItemStats _effectItemStats { get; set; } = new EffectItemStats(); [Save("effect_item_stats")]
public EffectItemStats Stats { get; set; } = new EffectItemStats();
public override string ItemName => _effectItemStats.Name; public override Texture2D GetTexture() => Stats.Texture;
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; }
} }

View File

@@ -1,7 +1,7 @@
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Chickensoft.Serialization; using Chickensoft.Serialization;
using Godot; using Godot;
using Zennysoft.Ma.Godot.Adapter; using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Game.Ma;
@@ -9,6 +9,14 @@ namespace Zennysoft.Game.Ma;
[Meta, Id("effect_item_stats")] [Meta, Id("effect_item_stats")]
public partial class EffectItemStats : InventoryItemStats 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] [Export]
[Save("effect_item_tag")] [Save("effect_item_tag")]
public UsableItemTag UsableItemTag { get; set; } = UsableItemTag.None; public UsableItemTag UsableItemTag { get; set; } = UsableItemTag.None;

View File

@@ -1,38 +1,49 @@
using Chickensoft.AutoInject;
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Chickensoft.Serialization;
using Godot; using Godot;
using Zennysoft.Ma.Godot.Adapter; using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Game.Ma;
[Meta, Id("throwable_item")] [Meta(typeof(IAutoNode)), Id("throwable_item")]
public partial class ThrowableItem : InventoryItem public partial class ThrowableItem : InventoryItem
{ {
[Export] public override void _Notification(int what) => this.Notify(what);
private ThrowableItemStats _throwableItemStats { get; set; }
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 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;
} }

View File

@@ -1,7 +1,7 @@
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Chickensoft.Serialization; using Chickensoft.Serialization;
using Godot; using Godot;
using Zennysoft.Ma.Godot.Adapter; using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Game.Ma;
@@ -9,6 +9,14 @@ namespace Zennysoft.Game.Ma;
[Meta, Id("throwable_item_stats")] [Meta, Id("throwable_item_stats")]
public partial class ThrowableItemStats : InventoryItemStats 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] [Export]
[Save("throwable_item_tag")] [Save("throwable_item_tag")]
public ThrowableItemTag ThrowableItemTag { get; set; } = ThrowableItemTag.None; public ThrowableItemTag ThrowableItemTag { get; set; } = ThrowableItemTag.None;

Some files were not shown because too many files have changed in this diff Show More