From 91fd5d80808fd177f97c4cc7e78b704efb5d6ce3 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 24 Jul 2026 23:33:46 +0200 Subject: improved stats resource, weapon now uses dmg from player stats --- Bullet.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'Bullet.cs') diff --git a/Bullet.cs b/Bullet.cs index e613849..4ca9520 100644 --- a/Bullet.cs +++ b/Bullet.cs @@ -1,14 +1,17 @@ using Godot; - +using testing.interfaces; public partial class Bullet : Area2D { [Export] public float Speed { get; set; } = 600.0f; + [Export] public float Damage { get; set; } = 10.0f; public Vector2 Direction { get; set; } = Vector2.Zero; public override void _Ready() { // Subscribe to the built-in BodyEntered event when the bullet is spawned BodyEntered += OnBodyEntered; + + Rotation = Direction.Angle(); } public override void _PhysicsProcess(double delta) @@ -19,7 +22,10 @@ public partial class Bullet : Area2D // This method is triggered automatically when the bullet hits a physics body private void OnBodyEntered(Node2D body) { - // QueueFree safely deletes this node and all its children at the end of the current frame - QueueFree(); + if (body is IDamageable target) + { + // If it does, deal damage! + target.TakeDamage(Damage); + } } } -- cgit v1.2.3