GameEntities.Unit.OnDie C# (CSharp) Method

OnDie() protected method

protected OnDie ( MapObject prejudicial ) : void
prejudicial MapObject
return void
        protected override void OnDie( MapObject prejudicial )
        {
            base.OnDie( prejudicial );

            //frag counter (for network games).
            if( ( EntitySystemWorld.Instance.IsServer() || EntitySystemWorld.Instance.IsSingle() ) &&
                PlayerManager.Instance != null )
            {
                Unit sourceUnit = null;
                {
                    Bullet bullet = prejudicial as Bullet;
                    if( bullet != null )
                        sourceUnit = bullet.SourceUnit;
                    Explosion explosion = prejudicial as Explosion;
                    if( explosion != null )
                        sourceUnit = explosion.SourceUnit;
                }

                if( sourceUnit != null )
                {
                    if( sourceUnit.Intellect != null )
                    {
                        PlayerManager.ServerOrSingle_Player player = PlayerManager.Instance.
                            ServerOrSingle_GetPlayer( sourceUnit.Intellect );
                        if( player != null )
                            player.Frags++;
                    }
                }
                else
                {
                    if( Intellect != null )
                    {
                        PlayerManager.ServerOrSingle_Player player = PlayerManager.Instance.
                            ServerOrSingle_GetPlayer( Intellect );
                        if( player != null )
                            player.Frags--;
                    }
                }
            }
        }