Basic throw works

This commit is contained in:
2024-09-18 02:57:13 -07:00
parent b7a982d340
commit 884f283ead
10 changed files with 234 additions and 37 deletions

View File

@@ -11,7 +11,7 @@ public partial class ThrowableItem : Node3D, IInventoryItem
[Dependency] public IGameRepo GameRepo => this.DependOn<IGameRepo>();
[Node] public IHitbox Hitbox { get; set; } = default!;
[Dependency] public IGame Game => this.DependOn<IGame>();
public InventoryItemStats Info => ThrowableItemInfo;
@@ -26,15 +26,18 @@ public partial class ThrowableItem : Node3D, IInventoryItem
[Node] public Area3D Pickup { get; set; } = default!;
public void OnReady()
public void OnResolved()
{
Sprite.Texture = ThrowableItemInfo.Texture;
Pickup.BodyEntered += OnEntered;
}
public void Throw()
public void Throw(ThrowableItemStats throwableItemStats)
{
GameRepo.PlayerData.Inventory.Remove(this);
var throwableScene = GD.Load<PackedScene>("res://src/items/throwable/ThrownItem.tscn");
var throwable = throwableScene.Instantiate<ThrownItem>();
Game.AddChild(throwable);
throwable.Throw(throwableItemStats);
}
public void Drop()
@@ -48,9 +51,4 @@ public partial class ThrowableItem : Node3D, IInventoryItem
if (isAdded)
QueueFree();
}
private void OnAnimationFinished(StringName animName)
{
QueueFree();
}
}