First builds and stuff done yipewaho

This commit is contained in:
2026-02-01 05:32:22 +02:00
parent 12c1360ae7
commit d910018b7b
62 changed files with 1886 additions and 37 deletions
+3 -2
View File
@@ -11,6 +11,7 @@ public partial class Turret : Node
[Export] private float _fireRate;
[Export] private Node2D _parent;
[Export] private ProjectilePool _projectilePool;
[Export] private AudioStreamPlayer2D _audio;
private float _fireTimer = 0f;
private HashSet<Enemy> _enemiesInRange = new HashSet<Enemy>();
@@ -26,7 +27,6 @@ public partial class Turret : Node
if (enemyHitBox is EnemyArea earea)
{
_enemiesInRange.Add(earea.Enemy);
GD.Print(earea.Name);
}
}
@@ -35,7 +35,6 @@ public partial class Turret : Node
if (enemyHitBox is EnemyArea earea)
{
_enemiesInRange.Remove(earea.Enemy);
GD.Print(earea.Name);
}
}
@@ -45,6 +44,8 @@ public partial class Turret : Node
_fireTimer += (float)delta;
if (!(_fireTimer >= 1f / _fireRate)) return;
_fireTimer = 0;
_audio?.SetPitchScale(RandomHelper.Float(0.8f, 1.2f));
_audio?.Play();
var t = Helpers.GetClosest(_parent,_enemiesInRange.ToArray());
var dir = (t.GlobalPosition - _parent.GlobalPosition).Normalized();
var proj = _projectilePool.Get();