package shadersmod.transform;

import static shadersmod.transform.Names.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;

public class NamerObf extends NamerSrg {

	ArrayList<String> obfNames;
	int obfNamesIndex;

	@Override
	public void beginSetNames() {
		BufferedReader reader = new BufferedReader(new InputStreamReader(this.getClass().getClassLoader().getResourceAsStream("shadersmod/transform/obfnames.txt"),StandardCharsets.UTF_8));
		obfNames = new ArrayList();
		try {
			String s;
			while ((s = reader.readLine())!=null) {
				obfNames.add(s);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		try {
			reader.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		reader = null;
		obfNamesIndex = 0;
	}
	
	@Override
	public void endSetNames() {
		obfNames = null;
	}
	
	@Override
	Clas c(String name) {
		return super.c(obfNames.get(obfNamesIndex++));
	}

	@Override
	Fiel f(Clas clas, String name, String desc) {
		return super.f(clas, obfNames.get(obfNamesIndex++), desc);
	}

	@Override
	Meth m(Clas clas, String name, String desc) {
		return super.m(clas, obfNames.get(obfNamesIndex++), desc);
	}

}
