//////////////////////////////////////////////////////////////////////////////////////////
//
// FILE : Asura_ServerEntity_Actor.cpp
//
// Inherits from Asura_ServerEntity_PhysicalObject.
// Base class for actors (humans, vehicles, tanks, animals etc).
//
// AUTHORS : Martin G. Harris
//
// Copyright (C) 2002 Rebellion, All Rights Reserved.
//
//////////////////////////////////////////////////////////////////////////////////////////

//////////////
// INCLUDES //
//////////////

#include "Core/Asura.h"

#include "Entity/PhysicalObject/Asura_ServerEntity_Actor.h"

#include "ChunkSystem/Asura_Chunk_Macros.h"
#include "Debugging/Asura_Assert.h"

// static variable instances
Asura_Hashed_List<Asura_ServerEntity_Actor> Asura_ServerEntity_Actor::s_xList;

//////////////////////////////
// Asura_ServerEntity_Actor //
//////////////////////////////
Asura_ServerEntity_Actor::Asura_ServerEntity_Actor()
: Asura_Entity_Server(ASURA_GUID_UNREGISTERED) // ignored
{
	// Currently doesn't have its own classification, so derived classes will have to set it.
	m_pxDynamicObject = Asura_Physics_Object::Create(ASURA_PHYSICS_OBJECT_ACTOR);
	m_pxDynamicObject->SetAssociatedEntityGuid(GetGuid());
	
	s_xList.AddToList(this);
}

Asura_ServerEntity_Actor::~Asura_ServerEntity_Actor()
{
	s_xList.RemoveFromList(this);
}

///////////////////////
// Chunk buffer code //
///////////////////////
void Asura_ServerEntity_Actor::FillInChunkBuffer(char*& pcChunkBuffer) 
{
	ChunkData xData;
	xData.m_iVersion = ChunkData::CURRENT_VERSION;
	// Can get away with FILLANDVERIFY here because in this instance ChunkData is only an int
	ASURA_CHUNK_FILLANDVERIFY(pcChunkBuffer, xData, ChunkData);
}

void Asura_ServerEntity_Actor::InitialiseFromChunkBuffer(const char*& pcChunkBuffer)
{
	ChunkData xData;
	ASURA_CHUNK_EXTRACT(pcChunkBuffer, xData, ChunkData);
	Asura_Assert(xData.m_iVersion == ChunkData::CURRENT_VERSION, "");
}
