Basic throw works
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user