"use strict";

var GO_Door = function(unlocked,getDestName,relocate){
	this.sprite = new Sprite(GO_Door.spriteSheet,"Door");
	
	this.sprite.collision_flags = 
		DEFINE_SPRITE_COLLISION_FLAGS.SPRITES_PASSIVE;
	this.sprite.setBoundingBox(0,0,15,15);
	this.sprite.game_object = this; // no longer a generic GO

	this.unlocked=unlocked;
	this._getDestName = getDestName;
	this.relocate = relocate;
};
GO_Door.spriteImg = SDS_Load_Image("art/sheets/sprite/door.png");
GO_Door.spriteSheet = new TileSheet(4, 4, 1, 0, GO_Door.spriteImg);

GO_Door.prototype = new GameObject(
	new Sprite(
		GO_Door.spriteSheet,
		"Door"
	),
	"Door"
	);

	GO_Door.prototype.interactions = 
		DEFINE_GAMEOBJECT_INTERACTIONS.PORT;

	GO_Door.prototype.getDestName = function(){
		return this.unlocked ? this._getDestName() : null;
	};

	GO_Door.prototype.Update = function(){
		this.sprite.frame = this.unlocked ? 0 : 1;
	};

// Static relocation helpers

GO_Door.NullRelocate = function(sprite){};

// Static relocater constructors

GO_Door.RelocaterToPixel = function(x,y){
	return function(sprite){
		sprite.x=x;
		sprite.y=y;
	}
};
GO_Door.RelocaterToTile = function(x,y){
	return function(sprite){
		sprite.x=(x<<4);
		sprite.y=(y<<4);
	}
};

GO_Door.RelocaterByPixel = function(x,y){
	return function(sprite){
		sprite.x+=x;
		sprite.y+=y;
	}
};
GO_Door.RelocaterByTile = function(x,y){
	return function(sprite){
		sprite.x+=(x<<4);
		sprite.y+=(y<<4);
	}
};
