package common.entity.npc;

import common.ai.AISmallFireballAttack;
import common.init.SoundEvent;
import common.model.ParticleType;
import common.rng.Random;
import common.world.AWorldClient;
import common.world.World;

public class EntityDarkMage extends EntityHoveringNPC {
	public EntityDarkMage(World worldIn) {
		super(worldIn);
		this.tasks.addTask(7, new AISmallFireballAttack(this));
	}

//	public boolean isAggressive() {
//		return true;
//	}
//
//	public boolean isPeaceful() {
//		return false;
//	}

//	public boolean isAggressive(Class<? extends EntityNPC> clazz) {
//		return false;
//	}

	public boolean isPeaceful(Class<? extends EntityNPC> clazz) {
		return clazz == EntityFireDemon.class;
	}

//	public boolean canInfight(Alignment align) {
//		return false;
//	}
//
//	public boolean canMurder(Alignment align) {
//		return false;
//	}

	public boolean canUseMagic() {
		return true;
	}

	public int getBaseHealth(Random rand) {
		return rand.range(34, 66);
	}

//	public int getBaseEnergy(Random rand) {
//		return 0;
//	}

    public float getHeightDeviationMin() {
    	return -0.2f;
    }

    public float getHeightDeviationMax() {
    	return 0.2f;
    }
    
    public float getSpeciesBaseSize() {
    	return 1.85f;
    }

	public Alignment getNaturalAlign() {
		return Alignment.CHAOTIC_EVIL;
	}

	public boolean isImmuneToFire() {
		return true;
	}
    
	public int getColor() {
		return 0xeec800;
	}
    
//    public boolean canAmbush(EntityLiving entity) {
//    	return true;
//    }
    
    public boolean isBurning() {
        return super.isBurning() || this.isAttacking();
    }
    
    public void onLivingUpdate()
    {
		if(this.worldObj.client && this.isAttacking()) {
			if(this.rand.chance(24)) { // && !this.isSilent()) {
				((AWorldClient)this.worldObj).playSound(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D, SoundEvent.FIRE, 
						1.0F + this.rand.floatv());
			}
			for(int i = 0; i < 2; ++i) {
				this.worldObj.spawnParticle(ParticleType.SMOKE_LARGE, this.posX + (this.rand.doublev() - 0.5D) * (double)this.width,
						this.posY + this.rand.doublev() * (double)this.height, 
						this.posZ + (this.rand.doublev() - 0.5D) * (double)this.width, 0.0D, 0.0D, 0.0D);
			}
		}
		super.onLivingUpdate();
    }
}
