package common.entity.types;

import common.entity.DamageSource;
import common.entity.EntityType;
import common.entity.npc.EntityNPC;
import common.init.Config;
import common.world.World;

public abstract class EntityWaterMob extends EntityLiving
{
    public EntityWaterMob(World worldIn)
    {
        super(worldIn);
    }

//    public boolean canBreatheUnderwater()
//    {
//        return true;
//    }

//    /**
//     * Checks if the entity's current position is a valid location to spawn this entity.
//     */
//    public boolean getCanSpawnHere()
//    {
//        return true;
//    }

//    /**
//     * Checks that the entity is not colliding with any blocks / liquids
//     */
//    public boolean isNotColliding()
//    {
//        return this.worldObj.checkNoEntityCollision(this.getEntityBoundingBox(), this) && 
//        		this.worldObj.getCollidingBoundingBoxes(this, this.getEntityBoundingBox()).isEmpty(); //TODO: check
//    }
    
    public boolean canSpawnInLiquid() {
    	return true;
    }

    /**
     * Get number of ticks, at least during which the living entity will be silent.
     */
    public int getTalkInterval()
    {
        return 120;
    }

//    /**
//     * Determines if an entity can be despawned, used on idle far away entities
//     */
//    protected boolean canDespawn()
//    {
//        return true;
//    }

    /**
     * Get the experience points the entity currently has.
     */
    protected int getExperiencePoints(EntityNPC player)
    {
        return this.worldObj.rand.roll(3);
    }

    /**
     * Gets called every tick from main Entity class
     */
    public void onEntityUpdate()
    {
//        int i = this.getAir();
        super.onEntityUpdate();

        if (this.isEntityAlive() && (this.worldObj.client || Config.waterMobDry) && !this.isInLiquid() && this.rand.chance(30))
        {
//            --i;
//            this.setAir(i);
//
//            if (this.getAir() == -20)
//            {
//                this.setAir(0);
            this.attackEntityFrom(DamageSource.dry, 2);
//            }
        }
//        else
//        {
//            this.setAir(300);
//        }
    }

    public boolean isPushedByWater()
    {
        return false;
    }
    
    public int getTrackingRange() {
    	return 64;
    }
    
    public int getUpdateFrequency() {
    	return 3;
    }
    
    public boolean isSendingVeloUpdates() {
    	return true;
    }
    
    public boolean getCanSpawnHere()
    {
        return this.posY > 45.0D && this.posY < (double)this.worldObj.getSeaLevel();
    }
    
    public EntityType getType() {
    	return EntityType.ANIMAL;
    }
}
