/*
 * Baddie.h
 *
 *  Created on: 2009-07-12
 *      Author: wasyl
 */

#ifndef BADDIE_H_
#define BADDIE_H_

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

class Baddie : public Carryable
{
protected:
	Sheet *mSheet;
	ALLEGRO_SAMPLE *mSndDie;

	bool mFeral;
	bool mFlip;

	int mAnim;
	double mTime;

	void animate(double dt);
public:
	Baddie(bool feral);
	~Baddie();

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

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

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

	Entity *clone() { return new Baddie(mFeral); };
	const char *code() { return "bd"; };
	std::string edString() { return SPrintF::format("baddie(%s)", mFeral ? "feral" : "tame"); }

	void load(FILE *f);
	void save(FILE *f);
};

#endif /* BADDIE_H_ */
