package Megumin.Nodes;

import java.awt.Graphics2D;
import java.util.Iterator;
import java.util.concurrent.CopyOnWriteArrayList;

public class Layer {
    private CopyOnWriteArrayList<Sprite> sprites;
    private String name;

    public Layer() {
        sprites = new CopyOnWriteArrayList<Sprite>();
        name = "";
    }

    public void addSprite(Sprite sprite) {
        sprites.add(sprite);
    }

    public void removeSprite(Sprite sprite) {
        sprites.remove(sprite);
    }

    public Sprite getSpriteByName(String name) {
        Iterator it = sprites.iterator();
        while (it.hasNext()) {
            Sprite sprite = (Sprite)it.next();
            if (sprite.getName().equals(name)) {
                return sprite;
            }
        }

        return null;
    }

    public void render(Graphics2D g) {
        Iterator it = sprites.iterator();
        while (it.hasNext()) {
            Sprite sprite = (Sprite)it.next();
            sprite.render(g);
        }
    }

    public CopyOnWriteArrayList<Sprite> getSprites() {
        return sprites;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}

@@ -288,19 +288,13 @@
 ist%3C
-Sprite
 %3E();%0A
+
     
@@ -432,32 +432,32 @@
 prite sprite) %7B%0A
-
         sprites.
@@ -471,32 +471,345 @@
 sprite);%0A    %7D%0A%0A
+    public void removeSpriteByName(String name) %7B%0A        Iterator it = sprites.iterator();%0A        while (it.hasNext()) %7B%0A            Sprite sprite = (Sprite)it.next();%0A            if (sprite.getName().equals(name)) %7B%0A                sprites.remove(sprite);%0A                break;%0A            %7D%0A        %7D%0A    %7D%0A%0A
     public Sprit

add remove sprite by name in layer