Drop item
This commit is contained in:
@@ -5,11 +5,13 @@ using Godot;
|
||||
using System;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class ConsumableItem : Node3D, IInventoryItem
|
||||
public partial class ConsumableItem : Node3D, IUsableItem, IThrowableItem
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Dependency] public IGame Game => this.DependOn<IGame>();
|
||||
[Dependency] public IGameRepo GameRepo => this.DependOn<IGameRepo>();
|
||||
[Dependency] public IGameEventDepot GameEventDepot => this.DependOn<IGameEventDepot>();
|
||||
|
||||
public InventoryItemStats Info => ConsumableItemInfo;
|
||||
|
||||
@@ -22,6 +24,21 @@ public partial class ConsumableItem : Node3D, IInventoryItem
|
||||
|
||||
public Guid ID => Guid.NewGuid();
|
||||
|
||||
public void Use()
|
||||
{
|
||||
GameEventDepot.OnHealingItemConsumed(ConsumableItemInfo);
|
||||
}
|
||||
|
||||
public void Throw()
|
||||
{
|
||||
var throwableScene = GD.Load<PackedScene>("res://src/items/thrown/ThrownItem.tscn");
|
||||
var throwable = throwableScene.Instantiate<ThrownItem>();
|
||||
throwable.ThrownItemStats = ConsumableItemInfo;
|
||||
Game.AddChild(throwable);
|
||||
throwable.Throw();
|
||||
GameRepo.PlayerData.Inventory.Remove(this);
|
||||
}
|
||||
|
||||
public void OnReady()
|
||||
{
|
||||
Sprite.Texture = ConsumableItemInfo.Texture;
|
||||
|
||||
Reference in New Issue
Block a user