package electrosphere.game.data.object.type.model;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import electrosphere.game.data.object.type.ObjectData;

/**
 * An interface for grabbing data about objects available to the game engine
 */
public class ObjectTypeLoader {

    //the map that stores all object types by name
    Map<String,ObjectData> objectMap = new HashMap<String,ObjectData>();

    //the list of all object data
    List<ObjectData> objectList = new LinkedList<ObjectData>();

    /**
     * Gets the list of all object types loaded into memory
     * @return The list
     */
    public List<ObjectData> getAllObjectTypes(){
        return objectList;
    }

    /**
     * Puts an object in the map
     * @param name The name of the object
     * @param type The object type data
     */
    public void putObject(String name, ObjectData type){
        objectMap.put(name,type);
        objectList.add(type);
    }

    /**
     * Gets object data by its name
     * @param name The name of the object type
     * @return The object data if it exists, otherwise null
     */
    public ObjectData getObject(String name){
        return objectMap.get(name);
    }

}
