"use strict";

var GO_SmokeVent = function(launch_dir){
	this.sprite = new Sprite(null,"Trigger");
	this.sprite.collision_flags = 
		DEFINE_SPRITE_COLLISION_FLAGS.SPRITES_PASSIVE;
	this.sprite.setBoundingBox(0,0,7,7);
	this.sprite.game_object = this; // no longer a generic GO
	
	this.plugged=false;
	this.plugged_countdown=0;
	this.emit_countdown=0;
	this.emit_delay=10; // frames

	this.launch_dir = launch_dir ? launch_dir : {x:0, y:-1};
};

GO_SmokeVent.prototype = new GameObject(
	new Sprite(
		null,
		"Trigger"
	),
	"SmokeVent"
	);

	GO_SmokeVent.prototype.interactions = 
		DEFINE_GAMEOBJECT_INTERACTIONS.DAMAGE;

	GO_SmokeVent.prototype.damage = function(sourceGO){
		this.plugged=true;
		this.plugged_countdown=30;
		return true; // always "die" for purposes of not destroying blocks
	}

	GO_SmokeVent.prototype.Update = function(){
		if (this.plugged_countdown>0){
			this.plugged_countdown--;
		}
		else this.plugged=false;

		if (!this.plugged){
			this.emit_countdown--;
			if (this.emit_countdown<=0){
				this._heap.smoke = new GO_Smoke(GO_Smoke.SPEEDS.VENT,true,0); // slower, silent, 0 hold time
				this._heap.smoke.launch_dir = this.launch_dir;
				this._heap.smoke.spawnOnSprite(this.sprite,this.manager);
				this._heap.smoke=null;//pending pooling

				this.emit_countdown=this.emit_delay;
			}
		}
	}
	