<commit_before>package donnu.zolotarev.SpaceShip.Weapons;

import donnu.zolotarev.SpaceShip.Bullets.BulletBase;
import donnu.zolotarev.SpaceShip.Bullets.SimpleBullet;
import donnu.zolotarev.SpaceShip.Hero;
import donnu.zolotarev.SpaceShip.WeaponPos;
import org.andengine.util.adt.pool.GenericPool;

public class SimpleGun {
    private static SimpleGun instance;
    private static  GenericPool<SimpleBullet> bulletsPool;
    private final Hero hero;

    public SimpleGun(Hero h){
        hero = h;
       instance = this;
        bulletsPool = new GenericPool<SimpleBullet>() {
            @Override
            protected SimpleBullet onAllocatePoolItem() {
                return new SimpleBullet(instance);
            }
        };
    }

    private SimpleBullet GetNewBullet(final float x, final float y, final float direction){
        final SimpleBullet bullet = bulletsPool.obtainPoolItem();
        bullet.init(x, y, direction);
        return bullet;
    }

    public void fire(){
        WeaponPos[] weaponsPos = hero.getWeaponPos();
        for (WeaponPos weaponPos : weaponsPos) {
            GetNewBullet(weaponPos.x,weaponPos.y,weaponPos.anlge);
        }


    }

    public void deleteBullet(BulletBase bullet){
        bullet.setVisible(false); //это не обязательно делать здесь.
        bullet.setIgnoreUpdate(true); //можно в классе пули создать метод, например, kill()

        bulletsPool.recyclePoolItem((SimpleBullet)bullet);
    }


}<commit_msg>added correct recycle cache bullet by type<commit_after>package donnu.zolotarev.SpaceShip.Weapons;

import donnu.zolotarev.SpaceShip.Bullets.BulletBase;
import donnu.zolotarev.SpaceShip.Bullets.SimpleBullet;
import donnu.zolotarev.SpaceShip.Hero;
import donnu.zolotarev.SpaceShip.WeaponPos;
import org.andengine.util.adt.pool.GenericPool;

public class SimpleGun {
    private static SimpleGun instance;
    private static  GenericPool<SimpleBullet> bulletsPool;
    private final Hero hero;

    public SimpleGun(Hero h){
        hero = h;
       instance = this;
        bulletsPool = new GenericPool<SimpleBullet>() {
            @Override
            protected SimpleBullet onAllocatePoolItem() {
                return new SimpleBullet(instance);
            }
        };
    }

    private SimpleBullet GetNewBullet(final float x, final float y, final float direction){
        final SimpleBullet bullet = bulletsPool.obtainPoolItem();
        bullet.init(x, y, direction);
        return bullet;
    }

    public void fire(){
        WeaponPos[] weaponsPos = hero.getWeaponPos();
        for (WeaponPos weaponPos : weaponsPos) {
            GetNewBullet(weaponPos.x,weaponPos.y,weaponPos.anlge);
        }
    }

    public void deleteBullet(BulletBase bullet){
        bullet.setVisible(false); //это не обязательно делать здесь.
        bullet.setIgnoreUpdate(true); //можно в классе пули создать метод, например, kill()
        if (bullet.getClass().getSimpleName().equals(SimpleBullet.class.getSimpleName())){
            bulletsPool.recyclePoolItem((SimpleBullet)bullet);
        }


    }


}
{'fraction_non_alphanumeric': 0.09061383566092887, 'fraction_numerical': 0.0, 'mean_word_length': 2.9690721649484537, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4327923', 'n_tokens_mistral': 957, 'n_tokens_neox': 949, 'n_words': 198}