#ifndef	AI_TASK_H
#define	AI_TASK_H

//////////////////////////////////////////////////////////////////////
//	task stack
//
//	used to keep track of non-temporary tasks
//////////////////////////////////////////////////////////////////////

#include	"world.h"

//////////////////////////////////////////////////////////////////////
//	defines
//////////////////////////////////////////////////////////////////////

#define	TASK_STAND			0x00000001		//	duh
#define	TASK_CHASE			0x00000002		//	chasing down an enemy
#define	TASK_WANDER			0x00000004		//	random wandering
#define	TASK_SWITCH			0x00000008		//	using a switch
#define	TASK_DOOR			0x00000010		//	going to an activated door
#define	TASK_PLAT			0x00000020		//	going to an activated plat
#define	TASK_ACQUIRE		0x00000040		//	going for an item
#define	TASK_ATTACK			0x00000080		//	attacking an enemy, only active while attacking
											//	always popped off when attack is completed or chasing begins
#define	TASK_NODE_WANDER	0x00000100		//	wandering from node to node
#define	TASK_PATH_WANDER	0x00000200		//	wandering on monster_path_corner
#define	TASK_RIDE_PLAT		0x00000400		//	riding a platform or door up or down
#define	TASK_FOLLOW			0x00000800		//	following hook->owner

//////////////////////////////////////////////////////////////////////
//	typedefs
//////////////////////////////////////////////////////////////////////

//	taskData_t	
typedef	struct	taskData_s
{
	userEntity_t	*object;	//	object of this task -- switch, enemy, etc.
	vec3_t			obj_origin;	//	origin of the object, if static.

	mapNode_t		*base_node;	//	node bot was at when this task was implemented
	mapNode_t		*goal_node;	//	node bot needs to reach to use object
								//	if object is a door/plat then this is the node that
								//	the bot will wait all until object achieves obj_desire_state
	mapNode_t		*final_node;//	for plats/doors, the node that can't be reached until
								//	door/plat reaches obj_desired_state

	int				obj_state;			//	starting state of object if plat/door
	int				obj_desired_state;	//	state bot must wait for before using

	int				goal_type;
} taskData_t;

/*
//	bot is pressing a switch
typedef	struct	taskSwitch_s
{
	vec3_t			origin;		//	origin of the switch

	mapNode_t		*base_node;	//	node bot was at when switch was first targetted
	mapNode_t		*node;		//	node bot needs to reach to use switch
	
	pathNode_t		*path;		//	path to get to next node
	int				path_len;	//	length of path

	userEntity_t	*sw;		//	the switch
} taskSwitch_t;

//	bot is chasing/attacking an enemy
typedef	struct	taskChase_s
{
	pathNode_t		*path;		//	last path to enemy
	int				path_len;	//	length of path

	userEntity_t	*enemy;		//	the switch
} taskChase_t;
*/

//////////////////////////////////////////////////////////////////////
//	function prototypes
//////////////////////////////////////////////////////////////////////

void		task_current (taskStack_t *stack, taskData_t **task_data, int *task_type);
int			task_current_type (taskStack_t *stack);
taskData_t	*task_current_data (taskStack_t *stack);
void		task_update_goal (taskStack_t *stack, mapNode_t *goal_node);

void		task_clear (taskStack_t **stack);
void		task_push (taskStack_t **stack, taskData_t *task_data, int task_type);
void		task_pop (taskStack_t **stack);
void		task_pop_thru (taskStack_t **stack, userEntity_t *object, int thru_type);

//	task types
void		task_chase (userEntity_t *self, userEntity_t *enemy);
void		task_switch (userEntity_t *self, userEntity_t *sw);
void		task_stand (userEntity_t *self);
void		task_plat (userEntity_t *self, userEntity_t *plat, mapNode_t *base_node, mapNode_t *goal_node);
void		task_door (userEntity_t *self, userEntity_t *door, mapNode_t *base_node, mapNode_t *goal_node);
void		task_attack (userEntity_t *self, userEntity_t *enemy);
void		task_wander (userEntity_t *self);
void		task_node_wander (userEntity_t *self);
void		task_path_wander (userEntity_t *self);
void		task_ride_plat (userEntity_t *self, userEntity_t *plat, mapNode_t *goal_node);
void		task_follow (userEntity_t *self, userEntity_t *owner);

#endif