Ability for enemies to shoot when controlled

This commit is contained in:
Marco 2025-02-25 17:29:24 +01:00
commit 2d6bcc5f00
10 changed files with 93 additions and 34 deletions

View file

@ -67,7 +67,7 @@ public partial class Weapon : Node2D
}
}
public void Shoot()
public void Shoot(BulletOwner? ownerOverride = null)
{
// Waiting on reload or Rate of Fire cooldown?
if (!_cooldownTimer.IsStopped())
@ -106,8 +106,14 @@ public partial class Weapon : Node2D
GD.PrintErr("Bullet is null, not shooting");
return;
};
var bulletData = WeaponData.MakeBullet(_muzzle.GlobalPosition);
if (ownerOverride.HasValue)
{
bulletData.Owner = ownerOverride.Value;
}
bullet.Initialize(WeaponData.MakeBullet(_muzzle.GlobalPosition), _gameManager);
bullet.Initialize(bulletData, _gameManager);
//bullet.SetDirection(ShootDirection);
bullet.SetDirection(spreadDirection);