package simogl.gameobjects.building;

import simogl.effect.particle.custom.ChimneySmoke;
import simogl.gameobjects.character.Farmer;
import simogl.level.AbstractLevel;
import simogl.model.building.MD2Farm;
import simogl.model.character.MD2Civilian;

/**
 * This class represents a farm in the game
 * @author Frank Bruns
 *
 */
public class Farm extends AbstractBuilding
{
	
	private int foodProduction = 0;
	
	/**
	 * Creates a new farm
	 * @param x x-coordinate
	 * @param y y-coordinate
	 * @param z z-coordinate
	 */
	public Farm(float x, float y, float z)
	{
		super(AbstractBuilding.FARM,x,y,z,20,6,0,0);
		this.md2Model = new MD2Farm(this.getX(),this.getY(),this.getZ());
		this.name = "farm";
		this.foodProduction = 20;
		
		this.centerBuildingOnConstructionPoint();
		
		// Add a particle effet to the chimney area
		ChimneySmoke smoke = new ChimneySmoke(this.getX()+3f,
				this.getY()+5.7f, this.getZ()-6.2f,25,700,30);
		this.partEffects.add(smoke);
		AbstractLevel.partEffects.add(smoke);
		
		// add a farmer to the scene
		this.character = new Farmer(this.getX()+this.getModel().getCurrentAnim().getCurrentFrame().getMesh().getBoundingBox().getWidth(),
				this.getY(), this.getZ());
		this.character.getModel().setAnimationState(MD2Civilian.STAND);
		AbstractLevel.characters.add(this.character);
	}
	
	/**
	 * Returns the amount of food this building is producing every time intervall
	 * @return amount of food this building produces
	 */
	public int getFoodProduction()
	{
		return this.foodProduction;
	}
	
	/**
	 * Sets the amount of food that is produced by the building every time
	 * intervall to the specified value
	 * @param amount amount of food to produce every time intervall
	 */
	public void setFoodProduction(int amount)
	{
		this.foodProduction = amount;
	}
}
