//////////////////////////////////////////////////////////////////////////////
//
// AVP_ServerEntity_Team.h
//
// Copyright (C) 2007 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 __AVP_SERVERENTITY_TEAM_H__
#define __AVP_SERVERENTITY_TEAM_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 "Entity/Asura_Entity.h"
#include "Network/Asura_Guid.h"

// F O R W A R D   D E C L A R A T I O N S ///////////////////////////////////

class Asura_Blueprint;
class Asura_Chunk_Stream;
class AVP_Brain_Team;

//////////////////////////////////////////////////////////////////////////////
//
// AVP_ServerEntity_Team
//
//////////////////////////////////////////////////////////////////////////////

class AVP_ServerEntity_Team : public Asura_Entity_Server
{
    typedef Asura_Entity_Server PARENT;

public:
    AVP_ServerEntity_Team( Asura_Guid uGuid );
    virtual ~AVP_ServerEntity_Team();

    virtual bool HasClientEntities() const { return false; }
    virtual bool IsFilledFromChunkBuffer() const { return false; }
    virtual bool CanBeSavedToChunk()       const { return true;  }
    virtual void ReadFromChunkStream( Asura_Chunk_Stream& xStream );
    virtual void WriteToChunkStream( Asura_Chunk_Stream& xStream ) const;

    virtual void Register( const Asura_Guid uGuid );
    virtual void Unregister( const Asura_Guid uGuid );
    bool HasMember( const Asura_Guid uGuid ) const;

    u_short           GetNumMembers()  const { return m_usNumMembers; }
    const Asura_Guid* GetMemberGuids() const { return m_puMemberGuids; }

protected:
    virtual void InitialiseFromBlueprint( const Asura_Blueprint& xBlueprint );

    AVP_Brain_Team* GetTeamBrain() const { return m_pxBrain; }

protected:
    AVP_Brain_Team* m_pxBrain;

private:
    bool UpdateStorageSize( const u_short usRequiredSize );

private:
    // Member data.
    u_short     m_usNumMembers;
    u_short     m_usStorageSize;
    Asura_Guid* m_puMemberGuids;

    enum { CURRENT_CHUNK_VERSION = 0 };
};

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

#endif //__AVP_SERVERENTITY_TEAM_H__
