using Godot; public partial class Weapon : Node2D { [Export] public PackedScene BulletScene { get; set; } // Future-proofing: Different weapons can have different damage multipliers! [Export] public float DamageMultiplier { get; set; } = 1.0f; public override void _Process(double delta) { LookAt(GetGlobalMousePosition()); GD.Print("Weapon rotation is running!"); // Add this line } public void Fire(Vector2 targetPosition) { if (BulletScene == null) return; // 1. The weapon itself looks up to find the player's stats component // (Assuming the weapon is a child of the Player, GetParent() gets the Player) var statsComponent = GetParent().GetNodeOrNull("StatsComponent"); float finalDamage = 10.0f; // Fallback default if (statsComponent?.RuntimeStats != null) { // 2. The weapon reads the player's base damage and applies its own modifier finalDamage = statsComponent.RuntimeStats.Damage * DamageMultiplier; } // 3. Instantiate and configure the bullet Bullet bullet = (Bullet)BulletScene.Instantiate(); bullet.GlobalPosition = GlobalPosition; // Spawns right where the weapon node is! bullet.Direction = Vector2.Right.Rotated(GlobalRotation); bullet.Damage = finalDamage; // 4. Add it to the world GetTree().Root.AddChild(bullet); } }