/*
 * Container.h
 *
 *  Created on: 2009-07-10
 *      Author: wasyl
 */

#ifndef CONTAINER_H_
#define CONTAINER_H_

#include <allegro5/allegro.h>
#include <allegro5/a5_font.h>
#include <allegro5/kcm_audio.h>
#include "../prep/misc/Vector2D.h"
#include "../prep/ent/Entity.h"
#include "../prep/res/Sheet.h"

class Container : public Entity
{
private:
	int mRequired;
	Sheet *mSprite;
	ALLEGRO_FONT *mFont;
	ALLEGRO_SAMPLE *mSndClang;

public:
	Container(Vec pos, int required);
	virtual ~Container();

	int *indices()
	{
		static int ind[] = {ID("entt"), ID("rndr"), ID("dyna"), ID("posi"), ID("cont"), 0};
		return ind;
	}

	int order(int index)
	{
		if (index == ID("rndr"))
			return 25;
		else
			return (int)this;
	}

	void update(double dt);
	void render();
	Rect bbox();

	Entity *clone() { return new Container(mPos, mRequired); }
	const char *code() { return "ct"; }
	void load(FILE *f);
	void save(FILE *f);
	std::string edString() { return SPrintF::format("container(%d)", mRequired); }

	bool happy() { return mRequired == 0; }
};

#endif /* CONTAINER_H_ */
