package com.bitdecay.game.pattern;

import com.badlogic.gdx.math.Vector2;
import com.bitdecay.game.component.*;
import com.bitdecay.game.gameobject.MyGameObject;
import com.bitdecay.game.gameobject.MyGameObjectFromConf;
import com.bitdecay.game.util.VectorMath;

import java.util.Collections;
import java.util.List;
import java.util.Random;

public class SingleRandomSprayBulletPattern extends AbstractBulletPattern {
    private float sprayDegrees = 25;
    private Random rnd = new Random();

    public SingleRandomSprayBulletPattern(){ }

    public SingleRandomSprayBulletPattern(float sprayDegrees){
        this.sprayDegrees = sprayDegrees;
    }

    @Override
    public List<MyGameObject> generateBulletPattern(PositionComponent pos, ShootComponent shoot, WeaponComponent weapon){
        Vector2 direction = VectorMath.rotatePointByDegreesAroundZero(shoot.toVector2(), (0.5f - rnd.nextFloat()) * sprayDegrees);

        MyGameObject bullet = MyGameObjectFromConf.objectFromConf(weapon.bullet, pos.x, pos.y);
        bullet.forEach(VelocityComponent.class, velocity -> bullet.forEach(SpeedComponent.class, speed -> {
            velocity.x = direction.x * speed.speed;
            velocity.y = direction.y * speed.speed;
        }));
        return Collections.singletonList(bullet);
    }
}
@@ -102,17 +102,33 @@
 mponent.
-*
+PositionComponent
 ;%0Aimport
@@ -146,38 +146,91 @@
 ay.game.
-gameobject.MyGameObjec
+component.ShootComponent;%0Aimport com.bitdecay.game.component.WeaponComponen
 t;%0Aimpor
@@ -272,24 +272,16 @@
 meObject
-FromConf
 ;%0Aimport
@@ -989,368 +989,93 @@
     
-MyGameObject bullet = MyGameObjectFromConf.objectFromConf(weapon.bullet, pos.x, pos.y);%0A        bullet.forEach(VelocityComponent.class, velocity -%3E bullet.forEach(SpeedComponent.class, speed -%3E %7B%0A            velocity.x = direction.x * speed.speed;%0A            velocity.y = direction.y * speed.speed;%0A        %7D));%0A        return Collections.singletonList(bullet
+return Collections.singletonList(createBullet(weapon.bullet, pos.x, pos.y, direction)
 );%0A 

use createBullet properly