Fix up item usage

This commit is contained in:
2025-03-07 18:40:14 -08:00
parent 93c04440d4
commit fe3c539a62
15 changed files with 125 additions and 65 deletions

View File

@@ -3,6 +3,7 @@ using Chickensoft.Introspection;
using Zennysoft.Game.Ma.src.items;
using Godot;
using Zennysoft.Game.Ma.Implementation;
using Zennysoft.Game.Abstractions;
namespace Zennysoft.Game.Ma;
@@ -15,7 +16,7 @@ public partial class ThrownItem : RigidBody3D
[Dependency] public IGame Game => this.DependOn<IGame>();
public InventoryItem ItemThatIsThrown;
public IInventoryItem ItemThatIsThrown;
private EffectService _effectService;
@@ -25,7 +26,7 @@ public partial class ThrownItem : RigidBody3D
{
BodyEntered += ThrownItem_BodyEntered;
GlobalPosition = Player.CurrentPosition;
Sprite.Texture = ItemThatIsThrown.ItemStats.Texture;
Sprite.Texture = ((InventoryItem)ItemThatIsThrown).ItemStats.Texture;
AddCollisionExceptionWith((Node)Player);
}
@@ -39,7 +40,7 @@ public partial class ThrownItem : RigidBody3D
public void Throw(EffectService effectService)
{
_effectService = effectService;
ApplyCentralImpulse(-Player.CurrentBasis.Z.Normalized() * ItemThatIsThrown.ThrowSpeed);
ApplyCentralImpulse(-Player.CurrentBasis.Z.Normalized() * ((InventoryItem)ItemThatIsThrown).ThrowSpeed);
}
public void RescueItem()
@@ -100,6 +101,6 @@ public partial class ThrownItem : RigidBody3D
}
}
else
enemy.TakeDamage(ItemThatIsThrown.ThrowDamage);
enemy.TakeDamage(((InventoryItem)ItemThatIsThrown).ThrowDamage);
}
}