/**
 * \file Myself.h
 * \date 12.04.2003
 *
 * Interface for the Myself object class
 */

#ifndef COMMON_WORLD_MYSELF_H
#define COMMON_WORLD_MYSELF_H

#include "Player/World/Player.h"
#include "Common/World/Point.h"
#include "Common/World/Angle.h"
#include "Common/World/Vector.h"

/**
 * \class Myself
 * \author Matus Horvath
 * \brief Memory object class for this player
 */
class Myself : public Player
{
public:
	void ResetRecovery();
	float GetRecovery();
	void SetRecovery(float rec);
// Construction and destruction
	Myself(World* w);
	Myself(const Myself&);
	virtual Myself& operator=(const Myself&);
	virtual ~Myself();

// Player features
	virtual int GetAge() const { return 0; }
	virtual void SetAge(unsigned) {}

	virtual Side GetSide() const { return OUR; }
	virtual void SetSide(Side s) {side = s;}

	float GetAskedForSubst() const { return askedForSubst; }

	float GetEffort() const { return effort; }
	float GetStamina() const { return stamina; }
	ViewWidth GetViewWidth() const { return vwidth; }
	
	Point GetLastSeenPos() const { return lastSeenPos; }
	int GetLastSeenTime() const { return lastSeenTime; }
	int GetSeeCount() const { return seeCount; }

	void SetAskedForSubst(bool ask) { askedForSubst = ask; }

	void SetEffort(float e) { effort = e; }
	void SetStamina(float s) { stamina = s; }
	void SetViewWidth(ViewWidth w) { vwidth = w; }

// Operations
	// Is player looking at this point?
	bool IsLookingAt(Point point) const;

// Internal operations
	// Calculate absolute position, direction and speed from seen lines and flags
	bool Recalculate(const SENSE_BODY* sb, const VISUAL_INFO* vi);

	// Reset stamina and effort to maximum
	inline void ResetStamina();
	inline void ResetEffort();
	
	// Save lastSeenPos and lastSeenTime
	inline void SaveLastSeenData();
	
	// Predict my state in next step
	void Step();

	float effort;
	float stamina;

	ViewWidth vwidth;
private:
	// Last position and time, when we have actually seen anything (???)
	Point lastSeenPos;
	int lastSeenTime;
	int seeCount;
	bool askedForSubst;
	float recovery;
	
};

#include "Player/World/World.h"

void Myself::ResetStamina()
{
	stamina = world->params->server->stamina_max;
}

void Myself::ResetEffort()
{
	effort = type->effort_max;
}

void Myself::SaveLastSeenData()
{
	lastSeenPos = pos;
	lastSeenTime = world->state->GetSimTime();
	seeCount++;
}

#endif // COMMON_WORLD_MYSELF_H
