package org.studiorailgun.sim.space;

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

import org.studiorailgun.sim.character.Character;
import org.studiorailgun.sim.org.Government;

/**
 * Top level spatial container
 */
public class World {
    
    /**
     * The top level region
     */
    Region region;

    /**
     * The list of characters
     */
    List<Character> characters = new LinkedList<Character>();

    /**
     * The list of governments
     */
    List<Government> governments = new LinkedList<Government>();

    /**
     * Map of location id -> location
     */
    transient Map<Integer,Location> idLocationMap = new HashMap<Integer,Location>();

    /**
     * Gets the top level region of this world
     * @return The top level region of this world
     */
    public Region getRegion() {
        return region;
    }

    /**
     * Sets the top level region of this world
     * @param region The top level region of this world
     */
    public void setRegion(Region region) {
        this.region = region;
    }

    /**
     * Gets the list of characters in this world
     * @return The list of characters in this world
     */
    public List<Character> getCharacters() {
        return characters;
    }

    /**
     * Sets the list of characters in this world
     * @param characters The list of characters in this world
     */
    public void setCharacters(List<Character> characters) {
        this.characters = characters;
    }

    /**
     * Registers a location
     * @param location The location
     */
    public void registerLocation(Location location){
        this.idLocationMap.put(location.getId(), location);
    }

    /**
     * Gets a location based on its id
     * @param id The id of the location
     * @return The location if it exists, null otherwise
     */
    public Location getLocation(int id){
        return this.idLocationMap.get(id);
    }

    public List<Government> getGovernments() {
        return governments;
    }

    public void setGovernments(List<Government> governments) {
        this.governments = governments;
    }

    /**
     * Adds a government
     * @param gov The government
     */
    public void addGovernment(Government gov){
        this.governments.add(gov);
    }

    

    

}
