"use strict";

// golden arrow fired by skyshrine traps
var GO_Goldbolt = function(direction){
	direction = direction<0 ? -1 : 1;
	this.sprite = new Sprite(GO_Goldbolt.spriteSheet,"Goldbolt");
	this.sprite.collision_flags = 
		DEFINE_SPRITE_COLLISION_FLAGS.SPRITES_PASSIVE |
		DEFINE_SPRITE_COLLISION_FLAGS.SPRITES_ACTIVE | // so it can hit solid e.g. carried blocks
		DEFINE_SPRITE_COLLISION_FLAGS.GROUND;
	this.sprite.setBoundingBox(
		0+(direction>0?11:0),
		1,
		4+(direction>0?11:0),
		5);
	//sprite.constraints=constraints;
	this.sprite.max_step = 0;
	this.sprite.game_object = this; // no longer a generic GO

	this.sprite.frame = (direction<0) ? 1 : 0;

	this.direction = direction;

};
GO_Goldbolt.spriteImg = SDS_Load_Image("art/sheets/sprite/goldbolt.png");
GO_Goldbolt.spriteSheet = new TileSheet(4, 3, 0, 1, GO_Goldbolt.spriteImg);

GO_Goldbolt.prototype = new GameObject(
	new Sprite(
		GO_Goldbolt.spriteSheet,
		"Goldbolt"
	),
	"Goldbolt"
	);

	GO_Goldbolt.prototype.interactions = 
		DEFINE_GAMEOBJECT_INTERACTIONS.INFLICT;

	GO_Goldbolt.prototype.inflict = function(){
		this.sprite.map_room.removeSprite(this.sprite);
		this.manager.remove(this);

		return {hp: 2, chi:0};
	};

	GO_Goldbolt.prototype.Update = function(){
		this.sprite.move(4*this.direction,0,  this._heap.spriteMoveRes);

		if (this._heap.spriteMoveRes.flags & (DEFINE_SPRITE_MOVE_RESULT_EJECTED_H | DEFINE_SPRITE_MOVE_RESULT_EJECTED_V)){
			this.sprite.map_room.removeSprite(this.sprite);
			this.manager.remove(this);
		}
	};

