function FlyingSpawner( x , z , player )
{
    this.building = new Building( x , z , player , FLYING_SPAWNER );
    this.lasttime = Date.now();

    this.building.setHP( 40 );

    this.entityDamageUpgrade = 0;
    this.entityHPUpgrade = 0;
    this.entitySpeedUpgrade = 0;
}



FlyingSpawner.prototype.update = function()
{
    this.building.update();
    if ( this.building.isDead() ) return;

    if ( Date.now() > this.lasttime+5000 )
    {
        var enemyPlayer = aiPlayer;
        if ( this.building.player == aiPlayer ) enemyPlayer = player;

        var entity = new Entity( this.building.worldPosition.x , this.building.worldPosition.y , this.building.player , enemyPlayer );
        entity.modelFilename = "models/wyvern.glb";
        entity.type = FLYER;
        entity.b_flying = true;
        entity.setSpeed( 1.1+this.entitySpeedUpgrade );

        entity.damage = 5+this.entityDamageUpgrade;
        entity.coreDamage = 1+this.entityDamageUpgrade;
        entity.buildingDamage = 1+this.entityDamageUpgrade;
        
        entity.setHP( 25+this.entityHPUpgrade );

        entity.spawn();
        entities.push( entity );
        this.lasttime = Date.now();
    }
}



FlyingSpawner.prototype.build = function( scene )
{
    var pthis = this;
    this.model = null;
    loadModel( "models/wyvern_nest.glb" , "spawner" , scene , function( model )
    {
        pthis.model = model;
        pthis.model.position.x = pthis.building.worldPosition.x;
        pthis.model.position.z = pthis.building.worldPosition.y;
        pthis.building.healthBar = new HealthBar( scene , pthis.model , 0.4 , 0.03 , -0.5 );
        for ( var i = 0 ; i < pthis.model._children.length ; ++i )
        {
            pthis.model._children[i].name = pthis.building.ID;
        }
    } );
}



FlyingSpawner.prototype.remove = function()
{
    this.building.b_modelRemoved = true;
    this.model.dispose();
}