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

View File

@@ -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" />

View File

@@ -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()

View File

@@ -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;

View File

@@ -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;

View File

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

View File

@@ -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;

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);

View File

@@ -1,17 +0,0 @@
using Chickensoft.Introspection;
using Chickensoft.Serialization;
namespace Zennysoft.Game.Ma;
[Meta, Id("game_data")]
public partial record GameData
{
[Save("player_data")]
public required PlayerData PlayerData { get; init; }
[Save("map_data")]
public required MapData MapData { get; init; }
[Save("rescued_items")]
public required RescuedItemDatabase RescuedItems { get; init; }
}

View File

@@ -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();

View File

@@ -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)

View File

@@ -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!;
}

View File

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

View File

@@ -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;
}

View File

@@ -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; }

View File

@@ -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);

View File

@@ -1,27 +0,0 @@
using Chickensoft.Introspection;
using Chickensoft.Serialization;
using Godot;
using System;
using Zennysoft.Game.Abstractions;
namespace Zennysoft.Game.Ma;
[Meta]
public abstract partial class InventoryItem : Node3D, IInventoryItem
{
[Save("inventory_item_id")]
public Guid ID => Guid.NewGuid();
public abstract string ItemName { get; }
public abstract string Description { get; }
[Save("inventory_item_spawn_rate")]
public abstract float SpawnRate { get; }
[Save("inventory_item_throw_damage")]
public abstract double ThrowDamage { get; }
[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; }
}

View File

@@ -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; }
}

View File

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

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="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")

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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()

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -10,10 +10,10 @@ ElementType = 0
UsableItemTag = 0
Name = "Gospel of Dimension"
Description = "Teleports target to a random location."
Texture = ExtResource("1_xt2mp")
SpawnRate = 0.1
ThrowSpeed = 20.0
HealHPAmount = 0
HealVTAmount = 0
ThrowDamage = 20
ItemTag = 0
Texture = ExtResource("1_xt2mp")

View File

@@ -10,11 +10,11 @@ ElementType = 0
UsableItemTag = 0
Name = "Gospel of Escape"
Description = "Warps target to the exit. No effect on player if exit has not been found."
Texture = ExtResource("1_26kno")
SpawnRate = 0.5
ThrowSpeed = 12.0
HealHPAmount = 0
HealVTAmount = 0
ThrowDamage = 5
ItemTag = 0
Texture = ExtResource("1_26kno")
metadata/_custom_type_script = "uid://d3wlunkcuv2w2"

View File

@@ -5,15 +5,17 @@
[resource]
script = ExtResource("1_s3pq7")
Name = "Spell Sign: Knowledge"
Description = "Doubles experience points earned. Effect is temporary."
ThrowableItemTag = 1
ElementType = 0
UsableItemTag = 0
Name = "Spell Sign: Knowledge"
Description = "Doubles experience points earned. Effect is temporary."
Texture = ExtResource("1_3605p")
SpawnRate = 0.1
ThrowSpeed = 12.0
HealHPAmount = 0
HealVTAmount = 0
ThrowDamage = 5
ItemTag = 0
Texture = ExtResource("1_3605p")

View File

@@ -1,8 +1,7 @@
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using Godot;
using Zennysoft.Ma.Godot.Adapter;
using Zennysoft.Game.Abstractions;
using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma;
@@ -15,7 +14,7 @@ public partial class ThrownItem : RigidBody3D
[Dependency] public IGame Game => this.DependOn<IGame>();
public IInventoryItem ItemThatIsThrown;
public InventoryItem ItemThatIsThrown;
private EffectService _effectService;
@@ -25,7 +24,7 @@ public partial class ThrownItem : RigidBody3D
{
BodyEntered += ThrownItem_BodyEntered;
GlobalPosition = Player.CurrentPosition;
Sprite.Texture = ((InventoryItem)ItemThatIsThrown).ItemStats.Texture;
Sprite.Texture = ItemThatIsThrown.GetTexture();
AddCollisionExceptionWith((Node)Player);
}
@@ -39,7 +38,7 @@ public partial class ThrownItem : RigidBody3D
public void Throw(EffectService effectService)
{
_effectService = effectService;
ApplyCentralImpulse(-Player.CurrentBasis.Z.Normalized() * ((InventoryItem)ItemThatIsThrown).ThrowSpeed);
ApplyCentralImpulse(-Player.CurrentBasis.Z.Normalized() * ItemThatIsThrown.ThrowSpeed);
}
public void RescueItem()

View File

@@ -1,40 +1,51 @@
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using Chickensoft.Serialization;
using Godot;
using Zennysoft.Ma.Godot.Adapter;
using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma;
[Meta, Id("weapon")]
[Meta(typeof(IAutoNode)), Id("weapon")]
public partial class Weapon : EquipableItem
{
public override void _Notification(int what) => this.Notify(what);
[Node] private Sprite3D _sprite { get; set; } = default!;
public override void _Ready()
{
_sprite.Texture = Stats.Texture;
}
public override string ItemName => Stats.Name;
public override string Description => Stats.Description;
public override float SpawnRate => Stats.SpawnRate;
public int Damage => Stats.Damage;
public override double ThrowDamage => Stats.ThrowDamage;
public override float ThrowSpeed => Stats.ThrowSpeed;
public double Luck => Stats.Luck;
public double AttackSpeed => Stats.AttackSpeed;
public WeaponTag WeaponTag => Stats.WeaponTag;
public override ItemTag ItemTag => Stats.ItemTag;
public ElementType WeaponElement => Stats.WeaponElement;
public double ElementalDamageBonus => Stats.ElementalDamageBonus;
public void IncreaseWeaponAttack(int bonus) => Stats.Damage += bonus;
[Export]
private WeaponStats _weaponStats { get; set; } = new WeaponStats();
public override string ItemName => _weaponStats.Name;
public override string Description => _weaponStats.Description;
public override float SpawnRate => _weaponStats.SpawnRate;
public int Damage => _weaponStats.Damage;
public override double ThrowDamage => _weaponStats.ThrowDamage;
public override float ThrowSpeed => _weaponStats.ThrowSpeed;
public double Luck => _weaponStats.Luck;
public double AttackSpeed => _weaponStats.AttackSpeed;
public WeaponTag WeaponTag => _weaponStats.WeaponTag;
public override ItemTag ItemTag => _weaponStats.ItemTag;
public ElementType WeaponElement => _weaponStats.WeaponElement;
public double ElementalDamageBonus => _weaponStats.ElementalDamageBonus;
public void IncreaseWeaponAttack(int bonus) => _weaponStats.Damage += bonus;
public override InventoryItemStats ItemStats { get => _weaponStats; set => _weaponStats = (WeaponStats)value; }
[Save("weapon_stats")]
public WeaponStats Stats { get; set; } = new WeaponStats();
public override Texture2D GetTexture() => Stats.Texture;
}

View File

@@ -1,7 +1,7 @@
using Chickensoft.Introspection;
using Chickensoft.Serialization;
using Godot;
using Zennysoft.Ma.Godot.Adapter;
using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma;
@@ -9,6 +9,14 @@ namespace Zennysoft.Game.Ma;
[Meta, Id("weapon_stat_type")]
public partial class WeaponStats : InventoryItemStats
{
[Export]
[Save("weapon_name")]
public override string Name { get; set; } = default!;
[Export(PropertyHint.MultilineText)]
[Save("weapon_description")]
public override string Description { get; set; } = default!;
[Export]
[Save("weapon_damage")]
public int Damage { get; set; } = 0;

View File

@@ -5,6 +5,7 @@ using Chickensoft.SaveFileBuilder;
using Godot;
using System.Collections.Generic;
using System.Linq;
using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma;

View File

@@ -869,7 +869,7 @@ debug_color = Color(0.937255, 0, 0.623529, 1)
[node name="PlayerSpawnPoint" type="Marker3D" parent="Spawn Points"]
unique_name_in_owner = true
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.625, -3, -1.035)
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 3.625, -3, -1.035)
[node name="ExitSpawnPoint" type="Marker3D" parent="Spawn Points"]
unique_name_in_owner = true
@@ -901,4 +901,4 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -9.00384, 1.80761, 11.3571)
[node name="ThrowableItem" parent="." instance=ExtResource("16_db2o3")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.78811, -3.32789, 0)
_throwableItemStats = ExtResource("17_ntxe5")
Stats = ExtResource("17_ntxe5")

View File

@@ -2,7 +2,8 @@
using Chickensoft.Collections;
using Chickensoft.SaveFileBuilder;
using Godot;
using Zennysoft.Ma.Godot.Adapter;
using Zennysoft.Game.Abstractions;
using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma;
@@ -44,7 +45,7 @@ public interface IPlayer : IKillable, IProvide<ISaveChunk<PlayerData>>
public void ModifyBonusLuck(double amount);
public Inventory Inventory { get; }
public IInventory Inventory { get; }
public PlayerStatController Stats { get; }

View File

@@ -8,7 +8,8 @@ using Godot.Collections;
using SimpleInjector;
using System;
using System.Linq;
using Zennysoft.Ma.Godot.Adapter;
using Zennysoft.Game.Abstractions;
using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma;
@@ -34,7 +35,7 @@ public partial class Player : CharacterBody3D, IPlayer
public Basis CurrentBasis => Transform.Basis;
public PlayerStatController Stats { get; set; } = default!;
public Inventory Inventory { get; private set; } = default!;
public IInventory Inventory { get; private set; } = default!;
public IAutoProp<Weapon> EquippedWeapon => _equippedWeapon;
private AutoProp<Weapon> _equippedWeapon { get; set; } = new AutoProp<Weapon>(new Weapon());
@@ -153,9 +154,9 @@ public partial class Player : CharacterBody3D, IPlayer
PlayerLogic.Set(_gameRepo);
var defaultWeapon = new Weapon();
defaultWeapon.ItemStats = _defaultWeapon;
defaultWeapon.Stats = _defaultWeapon;
var defaultArmor = new Armor();
defaultArmor.ItemStats = _defaultArmor;
defaultArmor.Stats = _defaultArmor;
Inventory.TryAdd(defaultWeapon);
Inventory.TryAdd(defaultArmor);

View File

@@ -1,22 +0,0 @@
using Chickensoft.Introspection;
using Chickensoft.Serialization;
using System.Collections.Generic;
namespace Zennysoft.Game.Ma;
[Meta, Id("player_data")]
public partial record PlayerData
{
[Save("player_stats")]
public required PlayerStats PlayerStats { get; init; }
[Save("player_inventory")]
public required Inventory Inventory { get; init; }
}
[Meta, Id("map_data")]
public partial record MapData
{
[Save("floor_list")]
public required List<string> FloorScenes { get; init; }
}

View File

@@ -1,152 +0,0 @@
using Chickensoft.Collections;
using Chickensoft.Introspection;
using Chickensoft.Serialization;
using Godot;
namespace Zennysoft.Game.Ma;
[Meta, Id("player_stats")]
public partial record PlayerStats
{
[Save("currentHP")]
public int CurrentHP { get; init; }
[Save("maximumHP")]
public int MaximumHP { get; init; }
[Save("currentVT")]
public int CurrentVT { get; init; }
[Save("maximumVT")]
public int MaximumVT { get; init; }
[Save("currentExp")]
public double CurrentExp { get; init; }
[Save("currentLevel")]
public int CurrentLevel { get; init; }
[Save("currentAttack")]
public int CurrentAttack { get; init; }
[Save("bonusAttack")]
public int BonusAttack { get; init; }
[Save("maxAttack")]
public int MaxAttack { get; init; }
[Save("currentDefense")]
public int CurrentDefense { get; init; }
[Save("bonusDefense")]
public int BonusDefense { get; init; }
[Save("maxDefense")]
public int MaxDefense { get; init; }
[Save("expToNextLevel")]
public int ExpToNextLevel { get; init; }
[Save("luck")]
public double Luck { get; init; }
}
public class PlayerStatController
{
public void Init(PlayerStats playerStats)
{
_currentHP.OnNext(playerStats.CurrentHP);
_maximumHP.OnNext(playerStats.MaximumHP);
_currentVT.OnNext(playerStats.CurrentVT);
_maximumVT.OnNext(playerStats.MaximumVT);
_currentExp.OnNext(playerStats.CurrentExp);
_currentLevel.OnNext(playerStats.CurrentLevel);
_currentAttack.OnNext(playerStats.CurrentAttack);
_bonusAttack.OnNext(playerStats.BonusAttack);
_maxAttack.OnNext(playerStats.MaxAttack);
_currentDefense.OnNext(playerStats.CurrentDefense);
_bonusDefense.OnNext(playerStats.BonusDefense);
_maxDefense.OnNext(playerStats.MaxDefense);
_expToNextLevel.OnNext(playerStats.ExpToNextLevel);
_luck.OnNext(playerStats.Luck);
}
public IAutoProp<int> CurrentHP => _currentHP;
public IAutoProp<int> MaximumHP => _maximumHP;
public IAutoProp<int> CurrentVT => _currentVT;
public IAutoProp<int> MaximumVT => _maximumVT;
public IAutoProp<int> CurrentAttack => _currentAttack;
public IAutoProp<int> MaxAttack => _maxAttack;
public IAutoProp<int> BonusAttack => _bonusAttack;
public IAutoProp<int> CurrentDefense => _currentDefense;
public IAutoProp<int> MaxDefense => _maxDefense;
public IAutoProp<int> BonusDefense => _bonusDefense;
public IAutoProp<double> CurrentExp => _currentExp;
public IAutoProp<int> ExpToNextLevel => _expToNextLevel;
public IAutoProp<int> CurrentLevel => _currentLevel;
public IAutoProp<double> Luck => _luck;
public void SetCurrentHP(int newValue)
{
var clampedValue = Mathf.Clamp(newValue, 0, MaximumHP.Value);
_currentHP.OnNext(clampedValue);
}
public void SetMaximumHP(int newValue)
{
_maximumHP.OnNext(newValue);
}
public void SetCurrentVT(int newValue)
{
var clampedValue = Mathf.Clamp(newValue, 0, MaximumVT.Value);
_currentVT.OnNext(clampedValue);
}
public void SetMaximumVT(int newValue)
{
_maximumVT.OnNext(newValue);
}
public void SetCurrentExp(double newValue)
{
_currentExp.OnNext(newValue);
}
public void SetCurrentLevel(int newValue)
{
_currentLevel.OnNext(newValue);
}
public void SetCurrentAttack(int newValue)
{
var clampedValue = Mathf.Clamp(newValue, 0, MaxAttack.Value);
_currentAttack.OnNext(clampedValue);
}
public void SetBonusAttack(int newValue)
{
_bonusAttack.OnNext(newValue);
}
public void SetMaxAttack(int newValue)
{
_maxAttack.OnNext(newValue);
}
public void SetCurrentDefense(int newValue)
{
var clampedValue = Mathf.Clamp(newValue, 0, MaxDefense.Value);
_currentDefense.OnNext(clampedValue);
}
public void SetBonusDefense(int newValue)
{
_bonusDefense.OnNext(newValue);
}
public void SetMaxDefense(int newValue)
{
_maxDefense.OnNext(newValue);
}
public void SetExpToNextLevel(int newValue)
{
_expToNextLevel.OnNext(newValue);
}
public void SetLuck(double newValue)
{
var clampedValue = Mathf.Clamp(newValue, 0, 1.0);
_luck.OnNext(clampedValue);
}
private readonly AutoProp<int> _currentHP = new(-1);
private readonly AutoProp<int> _maximumHP = new(-1);
private readonly AutoProp<int> _currentVT = new(-1);
private readonly AutoProp<int> _maximumVT = new(-1);
private readonly AutoProp<double> _currentExp = new(-1);
private readonly AutoProp<int> _currentLevel = new(-1);
private readonly AutoProp<int> _currentAttack = new(-1);
private readonly AutoProp<int> _bonusAttack = new(-1);
private readonly AutoProp<int> _maxAttack = new(-1);
private readonly AutoProp<int> _currentDefense = new(-1);
private readonly AutoProp<int> _bonusDefense = new(-1);
private readonly AutoProp<int> _maxDefense = new(-1);
private readonly AutoProp<int> _expToNextLevel = new(-1);
private readonly AutoProp<double> _luck = new(-1);
}

View File

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

View File

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