Fix texture stuff
This commit is contained in:
12
Ma.sln
12
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
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace Zennysoft.Game.Abstractions;
|
||||
|
||||
public interface IInventoryItem
|
||||
{
|
||||
string ItemName { get; }
|
||||
|
||||
string Description { get; }
|
||||
}
|
||||
@@ -1,16 +1,15 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization.Metadata;
|
||||
|
||||
namespace Zennysoft.Game.Abstractions;
|
||||
|
||||
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);
|
||||
public Task<T?> ReadFromFile(string filePath, params IJsonTypeInfoResolver?[] resolvers);
|
||||
}
|
||||
|
||||
@@ -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<T> : ISaveFileManager<T>
|
||||
{
|
||||
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<T> : ISaveFileManager<T>
|
||||
_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<T> : ISaveFileManager<T>
|
||||
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<T?> ReadFromFile()
|
||||
public Task<T?> ReadFromFile(params IJsonTypeInfoResolver?[] resolvers)
|
||||
{
|
||||
if (!_fileSystem.File.Exists(_defaultSaveLocation))
|
||||
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))
|
||||
throw new FileNotFoundException();
|
||||
|
||||
var json = await _fileSystem.File.ReadAllTextAsync(filePath);
|
||||
|
||||
var resolver = new SerializableTypeResolver();
|
||||
_jsonOptions.TypeInfoResolver = JsonTypeInfoResolver.Combine([resolver, .. resolvers]);
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
70
Zennysoft.Game.Godot.Implementation/cspell.json
Normal file
70
Zennysoft.Game.Godot.Implementation/cspell.json
Normal 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"
|
||||
]
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using Zennysoft.Game.Abstractions;
|
||||
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public class AppRepo : IAppRepo
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class AppLogic
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class AppLogic
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class AppLogic
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class AppLogic
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public interface IAppLogic : ILogicBlock<AppLogic.State>;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using Chickensoft.LogicBlocks;
|
||||
using Zennysoft.Game.Abstractions;
|
||||
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class AppLogic
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using Chickensoft.LogicBlocks;
|
||||
using Zennysoft.Game.Abstractions;
|
||||
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class AppLogic
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
@@ -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
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class GameLogic
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class GameLogic
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class GameLogic
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public interface IGameLogic : ILogicBlock<GameLogic.State>;
|
||||
|
||||
|
||||
@@ -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<IInventoryItem>? RemoveItemFromInventoryEvent;
|
||||
event Action<InventoryItem>? 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<string>? AnnounceMessageInInventoryEvent;
|
||||
public event Action<int>? DoubleExpTimeStart;
|
||||
public event Action? DoubleExpTimeEnd;
|
||||
public event Action<IInventoryItem>? RemoveItemFromInventoryEvent;
|
||||
public event Action<InventoryItem>? RemoveItemFromInventoryEvent;
|
||||
|
||||
public IAutoProp<bool> IsPaused => _isPaused;
|
||||
private readonly AutoProp<bool> _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);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Chickensoft.Introspection;
|
||||
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class GameLogic
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Chickensoft.Introspection;
|
||||
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class GameLogic
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
using Chickensoft.Introspection;
|
||||
using Zennysoft.Game.Abstractions;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class GameLogic
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Chickensoft.Introspection;
|
||||
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class GameLogic
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class GameLogic
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
12
Zennysoft.Game.Ma.Implementation/Item/IInventory.cs
Normal file
12
Zennysoft.Game.Ma.Implementation/Item/IInventory.cs
Normal 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();
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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<IInventoryItem> Items { get; init; }
|
||||
public List<InventoryItem> Items { get; init; }
|
||||
|
||||
public RescuedItemDatabase()
|
||||
{
|
||||
Items = new List<IInventoryItem>();
|
||||
Items = new List<InventoryItem>();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public enum AccessoryTag
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public enum BoxItemTag
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public enum ElementType
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public enum ItemTag
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public enum ThrowableItemTag
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public enum UsableItemTag
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public enum WeaponTag
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
18
Zennysoft.Game.Ma.Implementation/Module/Module.cs
Normal file
18
Zennysoft.Game.Ma.Implementation/Module/Module.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
@@ -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")]
|
||||
@@ -1,6 +1,6 @@
|
||||
using Godot;
|
||||
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class PlayerLogic
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class PlayerLogic
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class PlayerLogic
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class PlayerLogic
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public interface IPlayerLogic : ILogicBlock<PlayerLogic.State>;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Chickensoft.Introspection;
|
||||
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class PlayerLogic
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class PlayerLogic
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class PlayerLogic
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Chickensoft.Introspection;
|
||||
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class PlayerLogic
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Zennysoft.Game.Abstractions;
|
||||
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class PlayerLogic
|
||||
{
|
||||
|
||||
31
Zennysoft.Game.Ma.Implementation/Save/MaSaveFileManager.cs
Normal file
31
Zennysoft.Game.Ma.Implementation/Save/MaSaveFileManager.cs
Normal 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]);
|
||||
}
|
||||
@@ -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));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public interface IInGameUILogic : ILogicBlock<InGameUILogic.State>;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
public partial class InGameUILogic
|
||||
{
|
||||
public static class Input
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Chickensoft.Introspection;
|
||||
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class InGameUILogic
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Chickensoft.Introspection;
|
||||
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class InGameUILogic
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Chickensoft.Introspection;
|
||||
|
||||
namespace Zennysoft.Ma.Godot.Adapter;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class InGameUILogic
|
||||
{
|
||||
|
||||
@@ -13,11 +13,13 @@
|
||||
<PackageReference Include="Chickensoft.LogicBlocks" Version="5.16.0" />
|
||||
<PackageReference Include="Chickensoft.Serialization.Godot" Version="0.7.6" />
|
||||
<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" />
|
||||
</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>
|
||||
|
||||
</Project>
|
||||
70
Zennysoft.Game.Ma.Implementation/cspell.json
Normal file
70
Zennysoft.Game.Ma.Implementation/cspell.json
Normal 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"
|
||||
]
|
||||
}
|
||||
@@ -36,8 +36,8 @@
|
||||
<None Include=".editorconfig" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Zennysoft.Game.Abstractions\Zennysoft.Game.Abstractions.csproj" />
|
||||
<ProjectReference Include="..\Zennysoft.Game.Ma.Implementation\Zennysoft.Ma.Godot.Adapter.csproj" />
|
||||
<ProjectReference Include="..\Zennysoft.Game.Godot.Implementation\Zennysoft.Game.Implementation.csproj" />
|
||||
<ProjectReference Include="..\Zennysoft.Game.Ma.Implementation\Zennysoft.Ma.Adapter.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Update="Godot.SourceGenerators" Version="4.4.0-dev.2" />
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Godot;
|
||||
using Zennysoft.Ma.Godot.Adapter;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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<IFileSystem, FileSystem>();
|
||||
_container.Register<ISaveFileManager<GameData>, SaveFileManager<GameData>>();
|
||||
_container.Register<IGameRepo, GameRepo>(Lifestyle.Singleton);
|
||||
_container.Register<IGameLogic, GameLogic>(Lifestyle.Singleton);
|
||||
Module.Bootstrap(_container);
|
||||
_container.Verify();
|
||||
|
||||
GameRepo = _container.GetInstance<IGameRepo>();
|
||||
@@ -146,15 +141,15 @@ public partial class Game : Node3D, IGame
|
||||
|
||||
public void OnResolved()
|
||||
{
|
||||
var saveFileManager = _container.GetInstance<ISaveFileManager<GameData>>();
|
||||
var saveFileManager = _container.GetInstance<IMaSaveFileManager<GameData>>();
|
||||
SaveFile = new SaveFile<GameData>(
|
||||
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<PackedScene>("res://src/items/dropped/DroppedItem.tscn");
|
||||
var dropped = droppedScene.Instantiate<DroppedItem>();
|
||||
@@ -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<PackedScene>("res://src/items/thrown/ThrownItem.tscn");
|
||||
var thrown = thrownScene.Instantiate<ThrownItem>();
|
||||
thrown.ItemThatIsThrown = item;
|
||||
thrown.ItemThatIsThrown = (InventoryItem)item;
|
||||
AddChild(thrown);
|
||||
thrown.Position += new Vector3(0, 1.5f, 0);
|
||||
thrown.Throw(_effectService);
|
||||
|
||||
@@ -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<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 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();
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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!;
|
||||
}
|
||||
|
||||
@@ -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<ConsumableItemStats>($"{consumableFolder}/resources/{randomResource}");
|
||||
consumable.ItemStats = randomFile;
|
||||
consumable.Stats = randomFile;
|
||||
_game.AddChild(consumable);
|
||||
consumable.GlobalPosition = vector;
|
||||
}
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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<IInventoryItem> 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<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)
|
||||
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<Weapon>().Where(x => x.IsEquipped).Cast<IInventoryItem>();
|
||||
var equippedArmor = Items.OfType<Armor>().Where(x => x.IsEquipped).Cast<IInventoryItem>();
|
||||
var equippedAccessory = Items.OfType<Accessory>().Where(x => x.IsEquipped).Cast<IInventoryItem>();
|
||||
var equippedItems = new List<IInventoryItem>();
|
||||
var equippedWeapon = Items.OfType<Weapon>().Where(x => x.IsEquipped);
|
||||
var equippedArmor = Items.OfType<Armor>().Where(x => x.IsEquipped);
|
||||
var equippedAccessory = Items.OfType<Accessory>().Where(x => x.IsEquipped);
|
||||
var equippedItems = new List<InventoryItem>();
|
||||
equippedItems.AddRange(equippedWeapon);
|
||||
equippedItems.AddRange(equippedArmor);
|
||||
equippedItems.AddRange(equippedAccessory);
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
@@ -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<InventoryItem>();
|
||||
@@ -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<ArmorStats>($"res://src/items/armor/resources/{armor}");
|
||||
var armorScene = ArmorScene.Instantiate<Armor>();
|
||||
armorScene.ItemStats = armorInfo;
|
||||
armorScene.Sprite = armorScene.GetNode<Sprite3D>("%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<WeaponStats>($"res://src/items/weapons/resources/{weapon}");
|
||||
var weaponScene = WeaponScene.Instantiate<Weapon>();
|
||||
weaponScene.ItemStats = weaponInfo;
|
||||
weaponScene.Sprite = weaponScene.GetNode<Sprite3D>("%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<AccessoryStats>($"res://src/items/accessory/resources/{accessory}");
|
||||
var accessoryScene = AccessoryScene.Instantiate<Accessory>();
|
||||
accessoryScene.ItemStats = accessoryInfo;
|
||||
accessoryScene.Sprite = accessoryScene.GetNode<Sprite3D>("%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<ThrowableItemStats>($"res://src/items/throwable/resources/{throwable}");
|
||||
var throwableItemScene = ThrowableItemScene.Instantiate<ThrowableItem>();
|
||||
throwableItemScene.ItemStats = throwableItemInfo;
|
||||
throwableItemScene.Sprite = throwableItemScene.GetNode<Sprite3D>("%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<ConsumableItemStats>($"res://src/items/consumable/resources/{consumable}");
|
||||
var consumableItemScene = ConsumableItemScene.Instantiate<ConsumableItem>();
|
||||
consumableItemScene.ItemStats = consumableItemInfo;
|
||||
consumableItemScene.Sprite = consumableItemScene.GetNode<Sprite3D>("%Sprite");
|
||||
consumableItemScene.Sprite.Texture = consumableItemInfo.Texture;
|
||||
consumableItemScene.Stats = consumableItemInfo;
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user