Example #1
0
 public void RemoveFromMap()
 {
     CleanUp();
     mapTab.flowLayoutPanelMapTrackers.Controls.Remove(this);
     parentTracker?.childTrackers.Remove(this);
     RemovedFromMap?.Invoke();
 }
Example #2
0
        /// <summary>
        /// Handler invoked at the end of a battle. If all CombatEntities in the formation this AiEntityManager controls
        /// are dead, queues this manager for destruction.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void OnEndOfBattle(object sender, EndOfBattleEventArgs args)
        {
            var areAnyEntitiesLiving = _entity.ActiveFormation.Positions
                                       .AnyTwoD(entity => entity != null && entity.Resources.CurrentHealth > 0);

            if (!areAnyEntitiesLiving)
            {
                _mapManager.RemoveEntity(_entity);
                _mapBattleManager.OnCreatedBattle -= OnCreatedBattle;
                RemovedFromMap?.Invoke(this, new RemovedFromMapEventArgs
                {
                    SpawnData = _spawnEntityData
                });
            }

            _isMovementDisabled              = !areAnyEntitiesLiving;
            _battleManager.EndOfBattleEvent -= OnEndOfBattle;
            _battleManager = null;
        }