Major Player refactor
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using GameJamDungeon;
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Collections.Immutable;
|
||||
|
||||
namespace GameJamDungeon;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class Accessory : Node3D, IEquipableItem
|
||||
@@ -13,21 +15,45 @@ public partial class Accessory : Node3D, IEquipableItem
|
||||
|
||||
[Dependency] public IGameEventDepot GameEventDepot => this.DependOn<IGameEventDepot>();
|
||||
|
||||
public InventoryItemStats Info => AccessoryStats;
|
||||
[Dependency] public IPlayer Player => this.DependOn<IPlayer>();
|
||||
|
||||
[Export]
|
||||
public AccessoryStats AccessoryStats { get; set; } = new AccessoryStats();
|
||||
[Export] private AccessoryStats _accessoryStats { get; set; } = new AccessoryStats();
|
||||
|
||||
[Node] public Sprite3D Sprite { get; set; } = default!;
|
||||
[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 ImmutableList<AccessoryTag> AccessoryTags => [.. _accessoryStats.AccessoryTags];
|
||||
|
||||
public void OnReady()
|
||||
{
|
||||
Sprite.Texture = AccessoryStats.Texture;
|
||||
Pickup.BodyEntered += OnEntered;
|
||||
Sprite.Texture = _accessoryStats.Texture;
|
||||
}
|
||||
|
||||
public void SetItemStats(InventoryItemStats inventoryItemStats)
|
||||
{
|
||||
_accessoryStats = (AccessoryStats)inventoryItemStats;
|
||||
}
|
||||
|
||||
public void Equip()
|
||||
@@ -42,12 +68,12 @@ public partial class Accessory : Node3D, IEquipableItem
|
||||
|
||||
public void Throw()
|
||||
{
|
||||
GameRepo.PlayerData.Inventory.Remove(this);
|
||||
Player.Inventory.Remove(this);
|
||||
}
|
||||
|
||||
public void OnEntered(Node3D body)
|
||||
{
|
||||
var isAdded = GameRepo.PlayerData.Inventory.TryAdd(this);
|
||||
var isAdded = Player.Inventory.TryAdd(this);
|
||||
if (isAdded)
|
||||
QueueFree();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
namespace GameJamDungeon;
|
||||
|
||||
@@ -13,7 +12,7 @@ public partial class AccessoryStats : InventoryItemStats
|
||||
public int DEFUp { get; set; } = 0;
|
||||
|
||||
[Export]
|
||||
public double LUCKUp { get; set; } = 0;
|
||||
public double LuckUp { get; set; } = 0;
|
||||
|
||||
[Export]
|
||||
public int MaxHPUp { get; set; } = 0;
|
||||
|
||||
Reference in New Issue
Block a user