#ifndef __CEILINGSTEERING_H__
#define __CEILINGSTEERING_H__

#include "g_local.h"
#include "entity.h"
#include "steering.h"
//#include "path.h"

class Actor;

class EXPORT_FROM_DLL CeilingObstacleAvoidance : public Steering
{
protected:
	qboolean avoidwalls;

public:
	CLASS_PROTOTYPE( CeilingObstacleAvoidance );

	CeilingObstacleAvoidance();
	void AvoidWalls( qboolean );
	void                 ShowInfo( Actor &self );
	qboolean                    Evaluate( Actor &self );
	virtual void         Archive( Archiver &arc );
	virtual void         Unarchive( Archiver &arc );
};

inline EXPORT_FROM_DLL void CeilingObstacleAvoidance::Archive( Archiver &arc )
{
	Steering::Archive( arc );

	arc.WriteBoolean( avoidwalls );
}

inline EXPORT_FROM_DLL void CeilingObstacleAvoidance::Unarchive( Archiver &arc )
{
	Steering::Unarchive( arc );

	arc.ReadBoolean( &avoidwalls );
}

class EXPORT_FROM_DLL CeilingObstacleAvoidance2 : public Steering
{
protected:
	qboolean avoidwalls;

public:
	CLASS_PROTOTYPE( CeilingObstacleAvoidance2 );

	CeilingObstacleAvoidance2();
	void AvoidWalls( qboolean );
	void                 ShowInfo( Actor &self );
	qboolean                    Evaluate( Actor &self );
	virtual void         Archive( Archiver &arc );
	virtual void         Unarchive( Archiver &arc );
};

inline EXPORT_FROM_DLL void CeilingObstacleAvoidance2::Archive( Archiver &arc )
{
	Steering::Archive( arc );

	arc.WriteBoolean( avoidwalls );
}

inline EXPORT_FROM_DLL void CeilingObstacleAvoidance2::Unarchive( Archiver &arc )
{
	Steering::Unarchive( arc );

	arc.ReadBoolean( &avoidwalls );
}

class EXPORT_FROM_DLL CeilingChase : public Steering
{
private:
	Seek seek;
//	FollowPath				follow;
//	float						nextpathtime;
//	PathPtr					path;
	Vector goal;
	EntityPtr goalent;
//	PathNodePtr          goalnode;
	CeilingObstacleAvoidance avoid;
	float avoidtime;
	qboolean usegoal;
//	float                newpathrate;

	Vector wanderstart;
	int wander;
	float wandertime;
	Turn turnto;
	str anim;
	int stuck;
	Vector avoidvec;

public:
	CLASS_PROTOTYPE( CeilingChase );

	CeilingChase();
//	void						SetPath( Path *newpath );
	void                        SetGoalPos( Vector pos );
//	void						SetGoal( PathNode *node );
	void                        SetTarget( Entity *ent );
//	void                 SetPathRate( float rate );
	void                 ShowInfo( Actor &self );
	Vector               ChooseRandomDirection( Actor &self );
	void                        Begin( Actor &self );
	qboolean                    Evaluate( Actor &self );
	void                        End( Actor &self );
	virtual void         Archive( Archiver &arc );
	virtual void         Unarchive( Archiver &arc );
};

inline EXPORT_FROM_DLL void CeilingChase::Archive( Archiver &arc )
{
	Steering::Archive( arc );

	arc.WriteObject( &seek );
//	arc.WriteObject( &follow );
//	arc.WriteFloat( nextpathtime );
//	arc.WriteSafePointer( path );
	arc.WriteVector( goal );
	arc.WriteSafePointer( goalent );
//	arc.WriteSafePointer( goalnode );
	arc.WriteObject( &avoid );
	arc.WriteFloat( avoidtime );
	arc.WriteBoolean( usegoal );
//	arc.WriteFloat( newpathrate );
	arc.WriteVector( wanderstart );
	arc.WriteInteger( wander );
	arc.WriteFloat( wandertime );
	arc.WriteObject( &turnto );
	arc.WriteString( anim );
	arc.WriteInteger( stuck );
	arc.WriteVector( avoidvec );
}

inline EXPORT_FROM_DLL void CeilingChase::Unarchive( Archiver &arc )
{
	Steering::Unarchive( arc );

	arc.ReadObject( &seek );
//	arc.ReadObject( &follow );
//	arc.ReadFloat( &nextpathtime );
//	arc.ReadSafePointer( &path );
	arc.ReadVector( &goal );
	arc.ReadSafePointer( &goalent );
//	arc.ReadSafePointer( &goalnode );
	arc.ReadObject( &avoid );
	arc.ReadFloat( &avoidtime );
	arc.ReadBoolean( &usegoal );
//	arc.ReadFloat( &newpathrate );
	arc.ReadVector( &wanderstart );
	arc.ReadInteger( &wander );
	arc.ReadFloat( &wandertime );
	arc.ReadObject( &turnto );
	arc.ReadString( &anim );
	arc.ReadInteger( &stuck );
	arc.ReadVector( &avoidvec );
}

#endif /* ceilingsteering.h */
