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

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