#ifndef __CEILINGSTEERING_H__
#define __CEILINGSTEERING_H__

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

class Actor;

class 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 void CeilingObstacleAvoidance::Archive (Archiver &arc)	
{
	Steering::Archive( arc );
	
	arc.WriteBoolean( avoidwalls );
}

inline void CeilingObstacleAvoidance::Unarchive (Archiver &arc)	
{
	Steering::Unarchive( arc );
	
	avoidwalls = arc.ReadBoolean();
}

class 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 void CeilingObstacleAvoidance2::Archive (Archiver &arc)	
{
	Steering::Archive( arc );
	
	arc.WriteBoolean( avoidwalls );
}

inline void CeilingObstacleAvoidance2::Unarchive (Archiver &arc)
{
	Steering::Unarchive( arc );
	
	avoidwalls = arc.ReadBoolean();
}

class 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 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 void CeilingChase::Unarchive (Archiver &arc)	
{
	Steering::Unarchive( arc );
	
	arc.ReadObject( &seek );
	arc.ReadVector( &goal );
	arc.ReadSafePointer( &goalent );
	arc.ReadObject( &avoid );
	avoidtime = arc.ReadFloat();
	usegoal = arc.ReadBoolean();
	arc.ReadVector( &wanderstart );
	wander = arc.ReadInteger();
	wandertime = arc.ReadFloat();
	arc.ReadObject( &turnto );
	arc.ReadString( &anim );
	stuck = arc.ReadInteger();
	arc.ReadVector( &avoidvec );
}

#endif /* ceilingsteering.h */
