diff --git a/Scripts/GameManager.cs b/Scripts/GameManager.cs index 0e0ee9b4..56771feb 100644 --- a/Scripts/GameManager.cs +++ b/Scripts/GameManager.cs @@ -48,6 +48,9 @@ public partial class GameManager : Node2D [Signal] public delegate void GameStateChangeEventHandler(GameState state); + [Signal] + public delegate void PlayerRespawnedEventHandler(); + // Called when the node enters the scene tree for the first time. public override void _Ready() { @@ -77,6 +80,8 @@ public partial class GameManager : Node2D _inventoryManager.ItemRemoved += (item, currentAmount) => _hud.RemoveInventoryItem(item, currentAmount); } + PlayerRespawned += OnPlayerRespawned; + GameState = GameState.Playing; //_ = DelayPlayerSpawn(); @@ -84,6 +89,11 @@ public partial class GameManager : Node2D CallDeferred(MethodName.DelayPlayerSpawn); } + private void OnPlayerRespawned() + { + this.ClearBullets(); + } + public void ApplyMapStartData(MapStartDataResource mapStartData) { MapStartData = mapStartData; @@ -326,6 +336,15 @@ public partial class GameManager : Node2D break; } } + + public void ClearBullets() + { + if (_bulletsContainer is null) return; + foreach (var node in _bulletsContainer.GetChildren()) + { + node.QueueFree(); + } + } } public enum GameState