///////////////////////////////////////////////////////////////////////////////
//
// File: ToolsAVP_Entity_Container.cpp
//
// Created by Martin G.Harris (20/8/2008)
// 
// Copyright (C) 2008 Rebellion, All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

#include "Core/Asura.h"
#include "Entity/Container/ToolsAVP_Entity_Container.h"

#ifdef ASURA_USE_CONTAINER_SYSTEM

// Asura
#include "Entity/Container/Asura_ServerEntity_Container.h"
#include "Interface/Asura_Overlay_System.h"
#include "Network/Asura_Message.h"

#include "Entity/Container/AVP_ServerEntity_Container.h"

// Tools
#include "Entity/Container/Tools_Container.h"
#include "Entity/Container/Tools_ContainerRegistry.h"
#include "Entity/Container/Tools_ContainerState.h"
#include "Entity/Container/Tools_Mode_Container.h"
#include "Entity/Container/Tools_Container_System.h"
#include "Misc/Tools_Timed_Messages.h"

// Register the Tools entity.
Tools_ContainerRegisterToolsEntity<ToolsAVP_Entity_Container> xRegisterEntity;

///////////////////////////////////////////////////////////////////////////////
// ToolsAVP_Entity_Container
///////////////////////////////////////////////////////////////////////////////

// ToolsAVP_Entity_Container
ToolsAVP_Entity_Container::ToolsAVP_Entity_Container(Asura_Entity* pxEntity)
: Tools_Entity_Container(pxEntity)
{
}

ToolsAVP_Entity_Container::~ToolsAVP_Entity_Container()
{
}

void ToolsAVP_Entity_Container::UpdatePositionInAsuraData( bool bUpdateLinkedObjects )
{
	PARENT::UpdatePositionInAsuraData( bUpdateLinkedObjects );

	AVP_ServerEntity_Container* pxContainer = static_cast < AVP_ServerEntity_Container* >( m_pxServerEntity );

	if ( pxContainer )
	{
		pxContainer->InvalidateLightingBB();
	}
}

////////////////////////
// HandlesThisMessage //
////////////////////////
bool ToolsAVP_Entity_Container::HandlesThisMessage(int iMessageID)
{
	return PARENT::HandlesThisMessage(iMessageID);
}

///////////////////////////////
// AddProjectOverlayControls //
///////////////////////////////
void ToolsAVP_Entity_Container::AddProjectOverlayControls(Asura_Overlay* pxOverlay, Asura_Vector_2& xOffset)
{
	Asura_ServerEntity_Container* const pxServer = GetServerEntity();
	if (!pxServer) return;

	AVP_ServerEntity_Container* const pxAVPServer = static_cast<AVP_ServerEntity_Container*>(pxServer);

	Asura_Dialog* pxDialog = 0;

	pxDialog = new Asura_FlagTickbox_Dialog("Ignore For Surface Reorientation", xOffset, &pxAVPServer->m_uProjectFlags, 0x00000001, &Changed);
	pxDialog->SetHelpText("This object should be ignored for reorientation (alien movement)");
	pxOverlay->AddDialog(pxDialog);
	xOffset.y += Asura_Dialog::DefaultSpacing();
}

#endif //#ifdef ASURA_USE_CONTAINER_SYSTEM
