Modified source engine (2017) developed by valve and leaked in 2020. Not for commercial purporses
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.5 KiB

5 years ago
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "order_resourcepump.h"
#include "tf_team.h"
#include "tf_obj_resourcepump.h"
#include "tf_func_resource.h"
#include "order_helpers.h"
IMPLEMENT_SERVERCLASS_ST( COrderResourcePump, DT_OrderResourcePump )
END_SEND_TABLE()
bool COrderResourcePump::CreateOrder( CPlayerClass *pClass )
{
COrderResourcePump *pOrder = new COrderResourcePump;
if ( OrderCreator_ResourceZoneObject( pClass->GetPlayer(), OBJ_RESOURCEPUMP, pOrder ) )
{
return true;
}
else
{
UTIL_RemoveImmediate( pOrder );
return false;
}
}
bool COrderResourcePump::Update()
{
// Can they still build resource pumps?
if ( !m_hOwningPlayer.Get() || m_hOwningPlayer->CanBuild( OBJ_RESOURCEPUMP ) != CB_CAN_BUILD )
return true;
// Lost our resource zone?
if ( !GetTargetEntity() )
return true;
// Is our target zone now empty?
if ( ((CResourceZone*)GetTargetEntity())->IsEmpty() )
return true;
// Have they built a pump on this zone?
for( int i=0; i < m_hOwningPlayer->GetObjectCount(); i++ )
{
CBaseObject *pObj = m_hOwningPlayer->GetObject(i);
if( pObj && pObj->GetType() == OBJ_RESOURCEPUMP )
{
CObjectResourcePump *pPump = (CObjectResourcePump*)pObj;
CResourceZone *pZone = pPump->GetResourceZone();
if( pZone && pZone->entindex() == m_iTargetEntIndex && !pZone->IsEmpty() )
return true;
}
}
return BaseClass::Update();
}