"use strict";

var GO_SubDoor = function(unlocked,getDestName,relocate){
	this.sprite = new Sprite(GO_SubDoor.spriteSheet,"SubDoor");
	
	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;
	if (this.unlocked) this.interactions=DEFINE_GAMEOBJECT_INTERACTIONS.PORT;
	this._getDestName = getDestName;
	this.relocate = relocate;

	this.sprite.frame = this.unlocked ? 0 : 1;
};
GO_SubDoor.spriteImg = SDS_Load_Image("art/sheets/sprite/subdoor.png");
GO_SubDoor.spriteSheet = new TileSheet(4, 4, 1, 0, GO_SubDoor.spriteImg);

GO_SubDoor.prototype = new GameObject(
	new Sprite(
		GO_SubDoor.spriteSheet,
		"SubDoor"
	),
	"SubDoor"
	);

	GO_SubDoor.prototype.interactions = 
		//DEFINE_GAMEOBJECT_INTERACTIONS.PORT;
		DEFINE_GAMEOBJECT_INTERACTIONS.CHECK;

	GO_SubDoor.prototype.checkEvent = function(){
		if (GLOBAL_DIARY.check(2,"HELP_MELODY")){
			this.interactions=DEFINE_GAMEOBJECT_INTERACTIONS.PORT;
			this.unlocked=true;
			return "GD_Nautilus_door_unlocked";
		}
		else{
			return "GD_Nautilus_door_locked";
		}
		return this.unlocked ? this._getDestName() : null;
	};

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

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