#ifdef ASURA_USE_AXON
//////////////////////////////////////////////////////////////////////////////
//
// Asura_Gamescene_Node_Base.h
//
// Created by NJD - 12 October 2006
//
// Copyright (C) 2006 Rebellion, All Rights Reserved.
//
//////////////////////////////////////////////////////////////////////////////

// B E G I N   F I L E   W R A P P E R ///////////////////////////////////////

#ifdef ASURA_USE_PRAGMA_ONCE
#pragma once
#endif

#ifndef __ASURA_GAMESCENE_NODE_BASE_H__
#define __ASURA_GAMESCENE_NODE_BASE_H__ 1

// E N D   F I L E   W R A P P E R ///////////////////////////////////////////

// I N C L U D E S ///////////////////////////////////////////////////////////

// asura
#include "Network/Asura_Guid.h"

//////////////////////////////////////////////////////////////////////////////
//
// Support enums.
//
//////////////////////////////////////////////////////////////////////////////

// (TI - 1.9.2006) - These are only the basics, more exit conditions should be done on a per-project basis
enum ASURA_GAMESCENE_EXIT_CONDITION
{
    ASURA_GAMESCENE_EXIT_NONE                            = 0,
    ASURA_GAMESCENE_EXIT_ON_ALERTED,
    ASURA_GAMESCENE_EXIT_ON_ANIMATION_SEQUENCE_FINISHED,
    ASURA_GAMESCENE_EXIT_ON_DISTANCE_FROM_ACTOR,
    ASURA_GAMESCENE_EXIT_ON_TIME_OUT,
    ASURA_GAMESCENE_EXIT_ON_SPOT_ENEMY,
	ASURA_GAMESCENE_EXIT_ON_SPOT_ALLY,
	ASURA_GAMESCENE_EXIT_ON_SPOT_SPECIFIC_GUID,
	ASURA_GAMESCENE_EXIT_ON_TAKE_DAMAGE,

    NUM_ASURA_GAMSCENE_EXIT_CONDITIONS,

    ASURA_GAMESCENE_EXIT_CONDITION_FIRST_PROJECT_SPECIFIC = 1000,
};

// (TI - 1.9.2006) - Special Actions should be done on a per-project basis
enum ASURA_GAMESCENE_SPECIAL_ACTION
{
    ASURA_GAMESCENE_SPECIAL_ACTION_NONE                   = 0,

    NUM_ASURA_GAMESCENE_SPECIAL_ACTIONS,

    ASURA_GAMESCENE_SPECIAL_ACTION_FIRST_PROJECT_SPECIFIC = 1000,
};

//////////////////////////////////////////////////////////////////////////////
//
// Asura_Gamescene_Node_Base
//
//////////////////////////////////////////////////////////////////////////////

class Asura_Gamescene_Node_Base
{
    friend class Tools_Gamescene_Base;

public:
	Asura_Gamescene_Node_Base();
	virtual ~Asura_Gamescene_Node_Base() = 0;

    bool       CanCrouch()                                     const { return m_bCanCrouch; }
    bool       CanStand()                                      const { return m_bCanStand; }
    bool       CompleteBehaviourOnDeparture()                  const { return m_bCompleteBehaviourOnDeparture; }
    bool       DisableActorCollisions()                        const { return m_bDisableActorCollisions; }
    bool       DontTestDynamicsPosition()	                   const { return m_bDontTestDynamicsPosition; }
    bool       IgnoreCombat()				                   const { return m_bIgnoreCombat; }
    int        GetAStarIndex()                                 const { return m_iAStarIndex; }
    u_int      GetExitConditions()                             const { return m_uExitConditions; }
    Asura_Guid GetRangeActorGuid()                             const { return m_uRangeActorGuid; }
    float      GetRangeFromActor()                             const { return m_fRangeFromActor; }
    bool       GetCompleteBehaviourOnDeparture()               const { return m_bCompleteBehaviourOnDeparture; }
    u_int      GetSpecialAction()                              const { return m_uSpecialAction; }
    float      GetMinExitWaitTime()                            const { return m_fMinExitWaitTime; }
    float      GetMaxExitWaitTime()                            const { return m_fMaxExitWaitTime; }
    u_int      GetAnimationSequenceID()                        const { return m_uAnimationSequenceID; }
    bool       IsFollowGround( bool bIgnoreToolsOptimisation ) const { return m_bFollowGround && ( bIgnoreToolsOptimisation || !m_bToolsCancelledFollowGround ); }

    void SetAStarIndex(const int iIndex) { m_iAStarIndex = iIndex; }

	virtual bool IsBaseOrDerivativeOf(u_short usClassification) const;
#ifdef ASURA_TOOLS
	virtual void ApplyChangesForTemplateInstance(class Tools_EntityTemplateInstance* pxInstance);

    void SetCanCrouch( const bool bBool )                    { m_bCanCrouch = bBool; }
    void SetCanStand( const bool bBool )                     { m_bCanStand = bBool; }
    void SetCompleteBehaviourOnDeparture( const bool bBool ) { m_bCompleteBehaviourOnDeparture = bBool; }
    void SetDontTestDynamicsPosition( const bool bBool )     { m_bDontTestDynamicsPosition = bBool; }
    void SetDisableActorCollisions( const bool bBool )       { m_bDisableActorCollisions = bBool; }
    void SetFollowGround( const bool bBool )                 { m_bFollowGround = bBool; }
    void SetIgnoreCombat( const bool bBool )                 { m_bIgnoreCombat = bBool; }
    void SetAnimationSequenceID( const u_int uID )           { m_uAnimationSequenceID = uID; }
#endif

    virtual void ReadFromChunkStream( class Asura_Chunk_Stream& xStream );
    virtual void WriteToChunkStream( class Asura_Chunk_Stream& xStream ) const;

protected:
	union
	{
		u_int m_uGamesceneBaseFlags;
		struct 
		{
            u_int   m_bCanCrouch                    : 1,
				    m_bCanStand						: 1,
                    m_bCompleteBehaviourOnDeparture : 1,
                    m_bDisableActorCollisions		: 1,
                    m_bDontTestDynamicsPosition		: 1,
                    m_bFollowGround					: 1,
                    m_bIgnoreCombat					: 1,
                    m_bToolsCancelledFollowGround   : 1,
                    SpareBits_GamesceneBase			: 24;
		};
	};

	int   m_iAStarIndex;
	float m_fSpecialActionChance;
	float m_fMinExitWaitTime;
	float m_fMaxExitWaitTime;
	u_int m_uAnimationSequenceID;
	u_int m_uExitConditions;
	u_int m_uSpecialAction;

	//Variables for DISTANCE_FROM_ACTOR exit condition
	float      m_fRangeFromActor;
	Asura_Guid m_uRangeActorGuid;

private:
	enum { CURRENT_CHUNK_VERSION = 2 };
};

//////////////////////////////////////////////////////////////////////////////
//
// 
//
//////////////////////////////////////////////////////////////////////////////

#endif //__ASURA_GAMESCENE_NODE_BASE_H__
#endif // ASURA_USE_AXON
