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

#ifndef CARRYABLE_H_
#define CARRYABLE_H_

#include <allegro5/kcm_audio.h>
#include "../prep/res/Resources.h"
#include "Avatar.h"

class Carryable : public Entity
{
public:
	enum State {STANDING, FALLING, CARRIED};
protected:
	ALLEGRO_SAMPLE *mSndLand;

	int mState;
	Avatar *mCarrier;
	Vec mVel;

public:
	Carryable() : mCarrier(NULL)
	{
		Resources::load(mSndLand, "media/land.wav");
	};

	int state() { return mState; };
	void setState(State state) { mState = state; }

	virtual void pickup(Avatar *avatar)
	{
		if (mState == STANDING)
		{
			mState = CARRIED;
			mCarrier = avatar;
		}
	}

	virtual void release()
	{
		mState = FALLING;
		mCarrier = NULL;
	}

	virtual void toss(Vec where)
	{
		mVel = where;
		mState = FALLING;
		mCarrier = NULL;
	}

	virtual Vec velocity() { return mVel; }
};

#endif /* CARRYABLE_H_ */
