/// <summary> /// Enqueues an item to the Concurrent ReadyQueue /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void Fire(object sender, AddBulletEventArgs e) { if (sender is not Bullet) { throw new Exception("Fire event Invoked with non-bullet sender"); } if (e.Parent is Player) { Player p = (Player)e.Parent; if (p.Invincible && !p.GodMode) { return; } } else { if (e.Parent.Invincible) { return; } } Bullet b = (Bullet)sender; readyQueue.Enqueue(e); }
/// <summary> /// Add a bullet by EventArgs passed from the EventManager Concurrent Queue /// </summary> /// <param name="e"></param> private void ReadBullet(AddBulletEventArgs e) { Bullet b = e.Bullet; b.Dispose += this.eventManager.Dispose; if (e.Parent is Player) { this.player_bullets.Add(b); } else { this.enemy_bullets.Add(b); } }