<commit_before>package alfredo;

import alfredo.gfx.Renderer;
import alfredo.phx.Physics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.util.HashMap;

/**
 *
 * @author TheMonsterOfTheDeep
 */
public class Scene {
    private static HashMap<String, Scene> sceneMap;
    private static Scene current = null;
    
    public static void add(Scene s) {
        if(s == null) { return; }
        if(sceneMap == null) {
            sceneMap = new HashMap();
        }
        if(sceneMap.containsKey(s.name)) {
            throw new IllegalStateException("Scene named " + s.name + " already exists!");
        }
        sceneMap.put(s.name, s);
    }
    
    private static void open(Scene s) {
        current = s;
    }
    
    public static void open(String name) {
        if(name == null) { throw new NullPointerException("Scene name cannot be null!"); }
        if(sceneMap == null) { return; }
        Scene next = sceneMap.get(name);
        if(next == null) { throw new IllegalArgumentException("No scene named " + name + " exists!"); }
        open(next);
    }
    
    public static void begin(Scene s) {
        if(s == null) { return; }
        if(current != null) {
            throw new IllegalStateException("Trying to begin with scene " + s.name + ", but a scene is already loaded!");
        }
        add(s);
        open(s);
    }
    
    public static Scene getCurrent() { return current; }
    
    private final String name;
    
    protected Scene(String name) {
        this.name = name;
    }
    
    public final String getName() { return name; }
    
    public void render(Canvas c) {
        c.clear();
        
        Entity[] all = Entity.getAllEntities();
        Renderer r;
        for(Entity e : all) {
            r = e.getComponent(Renderer.class);
            if(r == null) { continue; }
            c.draw(r.graphic, e.position.x, e.position.y);
        }
        
        draw(c);
    }
    
    public void loop() {
        Physics.tick();
    }
    
    public void tick() { }
    public void draw(Canvas c) { }
}<commit_msg>Update scene to use getClass() so its easier<commit_after>package alfredo;

import alfredo.gfx.Renderer;
import alfredo.phx.Physics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author TheMonsterOfTheDeep
 */
public class Scene {
    
    private static ArrayList<Scene> scenes;
    private static Scene current = null;
    
    public static <T extends Scene> void open(Class<T> sceneClass) {
        if(scenes == null) {
            scenes = new ArrayList();
        }
        else {
            for(Scene s : scenes) {
                if(s.getClass() == sceneClass) {
                    current = s;
                    return;
                }
            }
        }
        try {
            current = sceneClass.newInstance();
        } catch (InstantiationException | IllegalAccessException ex) {
            System.out.println("Error setting scene: " + ex);
        }
        scenes.add(current);
    }
    
    public static Scene getCurrent() { return current; }
    
    public Scene() { }
    
    public void render(Canvas c) {
        c.clear();
        
        Entity[] all = Entity.getAllEntities();
        Renderer r;
        for(Entity e : all) {
            r = e.getComponent(Renderer.class);
            if(r == null) { continue; }
            c.draw(r.graphic, e.position.x, e.position.y);
        }
        
        draw(c);
    }
    
    public void loop() {
        Physics.tick();
    }
    
    public void tick() { }
    public void draw(Canvas c) { }
}
{'fraction_non_alphanumeric': 0.11649179445789615, 'fraction_numerical': 0.0005380683346785041, 'mean_word_length': 1.8578016910069177, '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': '6681818', 'n_tokens_mistral': 1097, 'n_tokens_neox': 1087, 'n_words': 282}