// CameraStateEngine.h **********************************************//
// Created     Owner     Modification                                //
// Copyright Microsoft Corporation, 2002                             //
// --------    ------    -------------                               //
// 3/7/2002  sdemar    provides FSM for spectator camera mgt         //
//*******************************************************************//

#if !defined(MSR_CAMERA_STATE_ENGINE_)
#define MSR_CAMERA_STATE_ENGINE_

#include "SpectatorTimer.hpp"
#include "MW4\MW4Headers.hpp"
#include "Adept\GlobalPointerManager.hpp"
using namespace Adept;
#include <GameOS\GameOS.hpp>



//**************************************************
namespace MSRSpectator
{
	class CCameraStateEngine
	{
		public:
			// public methods
			CCameraStateEngine();						  // ctor
			~CCameraStateEngine();						  // dtor
			int GetCameraStateToExecute(bool& stateChanged, int& cameraDist); // returns camera shot specific state to game engine
			void StateTransitionExecute(bool fIsSamePairing, float distanceBetween);  // fIsSamePairing is an overide condition for overShoulder stuff
			bool GetIsTimeToSelectNewShot();			  // gets boolean if new shot initialized
			void ForceStateChange();                      // triggers an overidden state change for special cases
			void BumpStateTimer(double addAmt);           // when transitioning in overshoulder shots, may need to add time to complete transition
			double GetDampTimerRemaining();               // returns the amount of time remaining for current camera transition
			void InitDampTimer(double);                   // initializes the current camera transition timer
			void ExpireDampTimer();                       // expires the current camera transition timer
			bool fIsValidSideDistance(float dist) const;  // true if distance value legal for side camera aspect view
			void NullSpectatorState();                    // shifts camera state to std observermode when no enemy of interest

			static CCameraStateEngine* GetInstance()      // required to support MW4's global pointer manager
			{
				return reinterpret_cast<CCameraStateEngine*>( GlobalPointers::GetGlobalPointer(CameraStateEnginePointerIndex));
			};

			void TestInstance(void) const;   // required to support MW4'S Check_Object()

			// public data
			enum							 // exposed state constants
			{
				STATE_FRONT_SHOT,
				STATE_OVERSHOULDER_SHOT,
				STATE_FIXED_TRACKING_SHOT,
				STATE_SIDE_SHOT,
				STATE_STD_OBSERVERMODE,
                STATE_DEATH_SEQUENCE_START,
                STATE_DEATH_SEQUENCE_TRANS,
                STATE_DEATH_SEQUENCE_SHOT,
			};
            enum
            {
			NO_RANGE = -1,
			CLOSESHOT = 0,
			MEDIUMSHOT = 1,
			LONGSHOT = 2,
            };


		private:
			// private data
			CSpectatorTimer m_stateTimer;	// determines when to transition to new camera state
			CSpectatorTimer m_dampTimer;    // used for camera damping transitions in overshoulder shots
			int m_cameraState;				// current camera state
            int m_cameraDist;
			bool m_fSelectState;			// true if need to get new state
			bool m_fNewShot;				// true only when shot is first initialized
			bool m_fPrevWasOverShoulder;    // true if last camera was an over shoulder shot type
			float m_distanceBetween;		// distance between entities, used to determine camera shots

			enum {MAX_SIDE_DIST = 90};      // maximum distance between hero and enemy for side shots

			char bigThing[256];             // MW4 memory allocation doesn't like small things

	};
}

#endif // !defined(MSR_CAMERA_STATE_ENGINE_)