package main;

import java.util.TreeSet;

public class Location
{
    private Tile ground;
    private Tile base;
    private TreeSet<Creature> creatures;
    private TreeSet<Tile> objects;
    private TreeSet<Item> items;
    public boolean passable;
    public int obstacles;
    
    public Location(final Tile ground) {
        this.ground = ground;
        this.objects = new TreeSet<Tile>();
        this.creatures = new TreeSet<Creature>();
        this.items = new TreeSet<Item>();
        this.passable = true;
        this.obstacles = 0;
    }
    
    public Tile getGround() {
        return this.ground;
    }
    
    public Tile getBase() {
        return this.base;
    }
    
    public Tile getStructure() {
        return this.base;
    }
    
    public void addObject(final Tile obj) {
        this.objects.add(obj);
    }
    
    public TreeSet<Tile> getObjects() {
        return this.objects;
    }
    
    public void addCreature(final Creature creature) {
        this.creatures.add(creature);
    }
    
    public TreeSet<Creature> getCreatures() {
        return this.creatures;
    }
    
    public void addItem(final Item item) {
        this.items.add(item);
    }
    
    public TreeSet<Item> getItems() {
        return this.items;
    }
    
    public void setGround(final Tile ground) {
        if (ground.getImg().needsBase()) {
            if (this.ground.getImg().needsBase()) {
                this.ground = ground;
            }
            else {
                this.base = this.ground;
                this.ground = ground;
            }
        }
        else {
            this.base = null;
            this.ground = ground;
        }
    }
}
