//-----------------------------------------------------------------------------
//
//  $Logfile:: /game/viewthing.h                                             $
// $Revision:: 2                                                              $
//   $Author:: Burgermac                                                      $
//     $Date:: 12/27/00 7:15 PM                                               $
//
// Copyright (C) 1997 by Ritual Entertainment, Inc.
// All rights reserved.
//
// This source is may not be distributed and/or modified without
// expressly written permission by Ritual Entertainment, Inc.
//
// DESCRIPTION:
// Actor code for the viewthing.
//

#ifndef __VIEWTHING_H__
#define __VIEWTHING_H__

#include "entity.h"
#include "archive.h"

class ViewMaster : public Listener
{
public:
	CLASS_PROTOTYPE( ViewMaster );

	int current_viewthing;

	ViewMaster();
	void Next( Event* ev );
	void Prev( Event* ev );
	void DeleteAll( Event* ev );
	void Spawn( Event* ev );
	void SetModelEvent( Event* ev );
	void PassEvent( Event* ev );

	virtual void Archive( Archiver& arc );
	virtual void Unarchive( Archiver& arc );
};

inline void ViewMaster::Archive( Archiver& arc )
{
	Listener::Archive( arc );

	arc.WriteInteger( current_viewthing );
}

inline void ViewMaster::Unarchive( Archiver& arc )
{
	Listener::Unarchive( arc );

	current_viewthing = arc.ReadInteger();
}

extern ViewMaster Viewmodel;

class Viewthing : public Entity
{
public:
	CLASS_PROTOTYPE( Viewthing );

	int animstate;
	Vector baseorigin;

	/*Viewthing::*/ Viewthing();
	void                    Think( Event* ev );
	void                    LastFrameEvent( Event* ev );
	void                    ToggleAnimateEvent( Event* ev );
	void                    SetModelEvent( Event* ev );
	void                    NextFrameEvent( Event* ev );
	void                    PrevFrameEvent( Event* ev );
	void                    NextAnimEvent( Event* ev );
	void                    PrevAnimEvent( Event* ev );
	void                    ScaleUpEvent( Event* ev );
	void                    ScaleDownEvent( Event* ev );
	void                    SetScaleEvent( Event* ev );
	void                    SetYawEvent( Event* ev );
	void                    SetPitchEvent( Event* ev );
	void                    SetRollEvent( Event* ev );
	void                    SetAnglesEvent( Event* ev );
	void              AttachModel( Event* ev );
	void              Delete( Event* ev );
	void              DetachAll( Event* ev );
	void              BoneGroup( Event* ev );
	void              BoneNum( Event* ev );
	void              ChangeOrigin( Event* ev );
	void              ChangeBoneAngles( Event* ev );
	void              NextSkinEvent( Event* ev );
	void              PrevSkinEvent( Event* ev );
	void              AutoAnimateEvent( Event* ev );

	virtual void      Archive( Archiver& arc );
	virtual void      Unarchive( Archiver& arc );
};

inline void Viewthing::Archive( Archiver& arc )
{
	Entity::Archive( arc );

	arc.WriteInteger( animstate );
	arc.WriteVector( baseorigin );
}

inline void Viewthing::Unarchive( Archiver& arc )
{
	Entity::Unarchive( arc );

	animstate = arc.ReadInteger();
	arc.ReadVector( &baseorigin );
}

#endif /* viewthing.h */
