77 lines
1.9 KiB
C#
77 lines
1.9 KiB
C#
using Chickensoft.AutoInject;
|
|
using Chickensoft.Introspection;
|
|
using Godot;
|
|
using System;
|
|
using System.Collections.Immutable;
|
|
|
|
namespace GameJamDungeon;
|
|
|
|
[Meta(typeof(IAutoNode))]
|
|
public partial class Accessory : Node3D, IEquipableItem
|
|
{
|
|
public override void _Notification(int what) => this.Notify(what);
|
|
|
|
[Dependency] public IGameEventDepot GameEventDepot => this.DependOn<IGameEventDepot>();
|
|
|
|
[Dependency] public IPlayer Player => this.DependOn<IPlayer>();
|
|
|
|
[Export] private AccessoryStats _accessoryStats { get; set; } = new AccessoryStats();
|
|
|
|
[Node] private Sprite3D Sprite { get; set; } = new Sprite3D();
|
|
|
|
[Node] public Area3D Pickup { get; set; } = default!;
|
|
|
|
public Guid ID => Guid.NewGuid();
|
|
|
|
public string ItemName => _accessoryStats.Name;
|
|
|
|
public string Description => _accessoryStats.Description;
|
|
|
|
public float SpawnRate => _accessoryStats.SpawnRate;
|
|
|
|
public Texture2D GetTexture() => _accessoryStats.Texture;
|
|
|
|
public double ThrowDamage => _accessoryStats.ThrowDamage;
|
|
|
|
public float ThrowSpeed => _accessoryStats.ThrowSpeed;
|
|
|
|
public int MaxHPUp => _accessoryStats.MaxHPUp;
|
|
|
|
public int MaxVTUp => _accessoryStats.MaxVTUp;
|
|
|
|
public double LuckUp => _accessoryStats.LuckUp;
|
|
|
|
public int ATKUp => _accessoryStats.ATKUp;
|
|
|
|
public int DEFUp => _accessoryStats.DEFUp;
|
|
|
|
public ImmutableList<AccessoryTag> AccessoryTags => [.. _accessoryStats.AccessoryTags];
|
|
|
|
public ImmutableList<ItemTag> ItemTags => [.. _accessoryStats.ItemTags];
|
|
|
|
public bool IsEquipped { get; set; }
|
|
|
|
public void OnReady()
|
|
{
|
|
Pickup.BodyEntered += OnEntered;
|
|
Sprite.Texture = _accessoryStats.Texture;
|
|
}
|
|
|
|
public void SetItemStats(InventoryItemStats inventoryItemStats)
|
|
{
|
|
_accessoryStats = (AccessoryStats)inventoryItemStats;
|
|
}
|
|
|
|
public void Throw()
|
|
{
|
|
Player.Inventory.Remove(this);
|
|
}
|
|
|
|
public void OnEntered(Node3D body)
|
|
{
|
|
var isAdded = Player.Inventory.TryAdd(this);
|
|
if (isAdded)
|
|
QueueFree();
|
|
}
|
|
}
|