Ejemplo n.º 1
0
void CObjects::RecurseDumpGraph(CChars* psz, CEmbeddedObject* pcIncoming, int iLevel, BOOL bEmbedded)
{
	CObject*					pcObject;
	CArrayTemplateEmbeddedObjectPtr		apcTos;
	int							i;
	CEmbeddedObject*			pcToObject;
	CBaseObject*				pcEmbeddedObject;
	CBaseObject*				pcBaseObject;

	if (!pcIncoming->IsBaseObject())
	{
		return;
	}

	pcBaseObject = (CBaseObject*)pcIncoming;

	psz->Append(' ', iLevel * 3);
	if ((pcBaseObject->miFlags & OBJECT_FLAGS_DUMPED) || (pcBaseObject->miDistToRoot < iLevel))
	{
		psz->Append('*');
		pcBaseObject->PrintObject(psz, bEmbedded);
		psz->AppendNewLine();
		return;
	}
	else
	{
		psz->Append(' ');
		pcBaseObject->PrintObject(psz, bEmbedded);
		psz->AppendNewLine();
	}

	pcBaseObject->miFlags |= OBJECT_FLAGS_DUMPED;


	apcTos.Init(1);
	pcBaseObject->BaseGetPointerTos(&apcTos);
	for (i = 0; i < apcTos.NumElements(); i++)
	{
		pcToObject = *apcTos.Get(i);
		RecurseDumpGraph(psz, pcToObject, iLevel+1, FALSE);
	}

	if (pcBaseObject->IsObject())
	{
		pcObject = (CObject*)pcBaseObject;
		for (i = 0; i < pcObject->mapEmbedded.NumElements(); i++)
		{
			pcEmbeddedObject = *pcObject->mapEmbedded.Get(i);
			RecurseDumpGraph(psz, pcEmbeddedObject, iLevel, TRUE);
		}
	}

	apcTos.Kill();
}
Ejemplo n.º 2
0
void CBaseObject::PreInit(void)
{
	CBaseObject*	pcContainer;

#ifdef DEBUG
	ValidateHasClass();
#endif

	pcContainer = GetEmbeddingContainer();
	pcContainer->ContainerPreInit();
}
Ejemplo n.º 3
0
//-----------------------------------------------------------------------------
// Purpose: Move the placement model to the current position. Return false if it's an invalid position
//-----------------------------------------------------------------------------
bool CTFWeaponBuilder::IsValidPlacement( void )
{
	if ( !m_hObjectBeingBuilt )
		return false;

	CBaseObject *pObj = m_hObjectBeingBuilt.Get();

	pObj->UpdatePlacement();

	return m_hObjectBeingBuilt->IsValidPlacement();
}
//------------------------------------------------------------------------------
// Purpose : Hate sentryguns more than other types of objects
//------------------------------------------------------------------------------
int	CNPC_Bug_Warrior::IRelationPriority( CBaseEntity *pTarget )
{
	if ( pTarget->Classify() == CLASS_MILITARY )
	{
		CBaseObject* pBaseObject = dynamic_cast<CBaseObject*>(pTarget);
		if ( pBaseObject && pBaseObject->IsSentrygun() )
			return ( BaseClass::IRelationPriority ( pTarget ) + 1 );
	}

	return BaseClass::IRelationPriority ( pTarget );
}
//-----------------------------------------------------------------------------
// Purpose: Tell all sentryguns what level of technology the Defender has
//-----------------------------------------------------------------------------
void CPlayerClassDefender::UpdateSentrygunTechnology( void )
{
	for (int i = 0; i < m_pPlayer->GetObjectCount(); i++)
	{
		CBaseObject *pObj = m_pPlayer->GetObject(i);
		if ( pObj && pObj->IsSentrygun() )
		{
			CObjectSentrygun *pSentry = static_cast<CObjectSentrygun *>(pObj);
			pSentry->SetTechnology( m_bHasSmarterSentryguns, m_bHasSensorSentryguns );
		}
	}
}
Ejemplo n.º 6
0
void CObjects::ClearValidationFlags(void)
{
	SIndexesIterator	sIter;
	CBaseObject*		pcBaseObject;

	pcBaseObject = mcMemory.StartIteration(&sIter);
	while (pcBaseObject)
	{
		pcBaseObject->SetFlag(OBJECT_FLAGS_TESTED_FOR_SANITY, FALSE);
		pcBaseObject = mcMemory.Iterate(&sIter);
	}
}
Ejemplo n.º 7
0
void C3DCanvas::ZoomAll()
{
	m_bNeedUpdate = true;
	CBaseObject* pObject = GetActor();
	if(pObject!=0)
	{
		m_bNeedUpdate = true;
		IViewClippingObject* pViewObject = pObject->GetViewClippingObject();
		float fRadius = pViewObject->GetRadius();
		m_camera.ZoomSphere(CShapeSphere(Vector3(0,fRadius/2,0), fRadius));
	}
}
Ejemplo n.º 8
0
void CObjects::KillDontFreeObjects(CArrayBlockObjectPtr* papcObjectPts)
{
	int				i;
	CBaseObject*	pcBaseObject;
	int				iNumElements;

	iNumElements = papcObjectPts->NumElements();
	for (i = 0; i < iNumElements; i++)
	{
		pcBaseObject = (CBaseObject*)(*papcObjectPts->Get(i));
		pcBaseObject->KillDontFree();
	}
}
Ejemplo n.º 9
0
void CObject::SetFlag(int iFlag, int iFlagValue)
{
	int				i;
	CBaseObject*	pcBaseObject;

	::SetFlag(&miFlags, iFlag, iFlagValue);

	for (i = 0; i < mapEmbedded.NumElements(); i++)
	{
		pcBaseObject = *mapEmbedded.Get(i);
		pcBaseObject->SetFlag(iFlag, iFlagValue);
	}
}
Ejemplo n.º 10
0
// 查找子goods
CBaseObject* CBaseObject::FindChildGoods(const CGUID& guExID)
{
	itBaseObject it;
	for (it = m_listObject.begin(); it != m_listObject.end(); it++)
	{
		CBaseObject* pObject = (*it);
		if (pObject->GetType() == TYPE_GOODS && pObject->GetExID() == guExID)
		{
			return pObject;
		}
	}
	return NULL;
}
Ejemplo n.º 11
0
CBaseObject* CBaseObject::FindChildObject(const CGUID & guid)
{
	itBaseObject it;
	for (it = m_listObject.begin(); it != m_listObject.end(); ++it)
	{
		CBaseObject* pObject = (*it);
		if (pObject && pObject->GetExID() == guid)
		{
			return pObject;
		}
	}
	return NULL;
}
Ejemplo n.º 12
0
//-----------------------------------------------------------------------------
// Compute the number of respawn stations on this team
//-----------------------------------------------------------------------------
int CSensorTFTeam::ComputeRespawnCount()
{
	int nCount = 0;
	for (int i = m_pTeam->GetNumObjects(); --i >= 0; )
	{
		CBaseObject *pObject = m_pTeam->GetObject(i);
		if ( pObject && (pObject->GetType() == OBJ_RESPAWN_STATION) )
		{
			++nCount;
		}
	}
	return nCount;
}
Ejemplo n.º 13
0
//查找子object!
CBaseObject* CBaseObject::FindChildObject(long typeID,const CGUID& gID)
{
	itBaseObject it;
	for (it = m_listObject.begin(); it != m_listObject.end(); it++)
	{
		CBaseObject* pObject = (*it);
		if (pObject->IsThisObject(typeID,gID))
		{
			return pObject;
		}
	}
	return NULL;
}
//-----------------------------------------------------------------------------
// Purpose: Find nearby objects and buff them.
//-----------------------------------------------------------------------------
void CObjectBuffStation::BuffNearbyObjects( CBaseObject *pObjectToTarget, bool bPlacing )
{
	// ROBIN: Disabled object buffing for now
	return;

	// Check for a team.
	if ( !GetTFTeam() )
		return;

	// Am I ready to power anything?
	if ( IsBuilding() || ( !bPlacing && IsPlacing() ) )
		return;

	// Am I already full?
	if ( m_nObjectCount >= BUFF_STATION_MAX_OBJECTS )
		return;

	// Do we have a specific target?
	if ( pObjectToTarget )
	{
		if( !pObjectToTarget->CanBeHookedToBuffStation() || pObjectToTarget->GetBuffStation() )
			return;

		if ( IsWithinBuffRange( pObjectToTarget ) )
		{
			AttachObject( pObjectToTarget, bPlacing );
		}
	}
	else
	{
		// Find nearby objects 
		for ( int iObject = 0; iObject < GetTFTeam()->GetNumObjects(); iObject++ )
		{
			CBaseObject *pObject = GetTFTeam()->GetObject( iObject );
			assert(pObject);

			if ( pObject == this || !pObject->CanBeHookedToBuffStation() || pObject->GetBuffStation() )
				continue;

			// Make sure it's within range
			if ( IsWithinBuffRange( pObject ) )
			{
				AttachObject( pObject, bPlacing );

				// Am I now full?
				if ( m_nObjectCount >= BUFF_STATION_MAX_OBJECTS )
					break;
			}
		}
	}
}
bool CGolem_Light::CheckCollision(IUnitInterface* pBase, bool nCanHandleCollision)
{
	if(!pBase || pBase == this ||  this->GetLayerLocation() != pBase->GetLayerLocation())
		return false;

	//If the base collides with an object or entity leave
	bool Collided = CBaseGolem::CheckCollision(pBase, nCanHandleCollision);
	if(Collided)
		return Collided;

	//Do Light Golem specific Collisions
	switch(pBase->m_nUnitType)
	{
	case OBJECT_TILE:
		{
			CBaseObject* temp = (CBaseObject*)pBase;
			if( temp->GetType() == OBJ_WATER )
			{
				if(((CWaterTile*)temp)->IsFrozen())
				{
					return false;
				}
				return true;
			}
		}
		break;

	case OBJECT_OBJECT:
		{
			CBaseObject* temp = (CBaseObject*)pBase;
			
		}
		break;

	case OBJECT_ENTITY:
		{
			//Entities cannot walk-thro other entities
			if(!nCanHandleCollision)
				return true;

			CBaseEntity* temp = (CBaseEntity*)pBase;
			if(temp->GetType() == ENT_GOLEM)
			{
				CBaseGolem* temp = (CBaseGolem*)pBase;
			}
			return true;
		}
		break;
	};
	return false;
}
void CDistCalculatorParameters::ClearTouchedFlags(void)
{
	int				i;
	int				iNumTouched;
	CBaseObject*	pcBaseObject;

	iNumTouched = NumTouched();

	for (i = 0; i < iNumTouched; i++)
	{
		pcBaseObject = GetTouched(i);
		pcBaseObject->ClearDistTouchedFlags();
	}
}
Ejemplo n.º 17
0
void CBaseObject::AddExpectedDistToRoot(CEmbeddedObject* pcPointedTo, int iExpectedDist, CDistCalculatorParameters* pcParameters)
{
	CBaseObject*		pcPointedToContainer;

	if (pcPointedTo)
	{
		pcPointedToContainer = pcPointedTo->GetEmbeddingContainer();
		if (!pcPointedToContainer->IsUpdateAttachedPointerTosDistToRoot())
		{
			pcPointedToContainer->SetDistToRoot(CLEARED_DIST_TO_ROOT);
			pcParameters->AddExpectedDist(pcPointedToContainer, iExpectedDist);
		}
	}
}
Ejemplo n.º 18
0
void CObjects::PrintMemory(CChars* psz)
{
	SIndexesIterator	sIter;
	CBaseObject*		pcBaseObject;

	pcBaseObject = mcMemory.StartIteration(&sIter);
	while (pcBaseObject)
	{
		pcBaseObject->PrintObject(psz);

		psz->Append("\n");
		pcBaseObject = mcMemory.Iterate(&sIter);
	}
}
Ejemplo n.º 19
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
CBaseObject *CBaseObject::GetObjectOfTypeOnMe( int iObjectType )
{
	for ( int iObject = 0; iObject < GetNumObjectsOnMe(); ++iObject )
	{
		CBaseObject *pObject = dynamic_cast<CBaseObject*>( m_BuildPoints[iObject].m_hObject.Get() );
		if ( pObject )
		{
			if ( pObject->GetType() == iObjectType )
				return pObject;
		}
	}

	return NULL;
}
Ejemplo n.º 20
0
void CBaseObject::CollectValidDistStartingObjectsAndSetClearedToRoot(CBaseObject* pcTo, CDistCalculatorParameters* pcParameters)
{
	//It is assumed at this point that all the tos and froms have been updated.
	//This method will only be called on an object that can find Root.

	ValidateNotEmbedded(__METHOD__);

	int								i;
	CArrayTemplateEmbeddedBaseObjectPtr		apcFroms;
	CBaseObject*					pcFrom;
	CBaseObject*					pcContainer;

	if (IsRoot())
	{
		return;
	}

	if (!IsDistToRootValid())
	{
		pcParameters->AddTouched(this);
		SetDistToRoot(CLEARED_DIST_TO_ROOT);
		SetFlag(OBJECT_FLAGS_CLEARED_DIST_TO_ROOT, TRUE);

		apcFroms.Init();
		GetHeapFroms(&apcFroms);

		if (apcFroms.NumElements() > 0)
		{
			for (i = 0; i < apcFroms.NumElements(); i ++)
			{
				pcFrom = *apcFroms.Get(i);
				pcContainer = pcFrom->GetEmbeddingContainer();
				if (!(pcContainer->miFlags & OBJECT_FLAGS_CLEARED_DIST_TO_ROOT))
				{
					pcContainer->CollectValidDistStartingObjectsAndSetClearedToRoot(this, pcParameters);
				}
			}
		}

		apcFroms.Kill();
	}
	else
	{
		if (pcTo != NULL)
		{
			pcParameters->AddExpectedDist(pcTo, miDistToRoot+1);
		}
	}
}
Ejemplo n.º 21
0
BOOL CElementListDlog::OnInitDialog() 
{
	CDialog::OnInitDialog();

	if (m_pDoc)
	{
		m_oListFilter.ResetContent();
		m_oListFilter.SetItemData(m_oListFilter.AddString("All"),-1);

		m_hDefaultIcon = LoadIcon(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDI_BOXWALL_ICON));
		HICON	hIcon;
		CBaseObject	*pTempObject;
		
		oImgeList.DeleteImageList();
		oImgeList.Create(16,16,ILC_COLOR4,5,m_pDoc->m_oWorld.GetFactoryCount()+2);

		for (int i = 0; i < m_pDoc->m_oWorld.GetFactoryCount(); i++)
		{
			pTempObject = m_pDoc->m_oWorld.GetFactory(i)->New();

			hIcon = NULL;
			if (pTempObject && pTempObject->ShowInInterface())
			{
				hIcon = (HICON)pTempObject->GetIcon();

				int iItem = m_oListFilter.AddString(m_pDoc->m_oWorld.GetFactoryName(i));
				m_oListFilter.SetItemData(iItem,i);

			}
			if (!hIcon)
				hIcon = m_hDefaultIcon;

			oImgeList.Add(hIcon);
			
			m_pDoc->m_oWorld.GetFactory(i)->Delete(pTempObject);
		}

		m_oListFilter.SetCurSel(0);
		m_oListCtl.SetImageList(&oImgeList,LVSIL_SMALL);

		OnSelchangeElementFilter();

		SetDefID(IDC_ELEMENT_FILTER);
	}

	m_bWinUp = true;
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Ejemplo n.º 22
0
void CObject::GetPointerTos(CArrayTemplateEmbeddedObjectPtr* papcTos)
{
	int				i;
	int				iNumEmbedded;
	CBaseObject*	pcEmbedded;

	BaseGetPointerTos(papcTos);

	iNumEmbedded = mapEmbedded.NumElements();
	for (i = 0; i < iNumEmbedded; i++)
	{
		pcEmbedded = *mapEmbedded.Get(i);
		pcEmbedded->GetPointerTos(papcTos);
	}
}
Ejemplo n.º 23
0
// 回调一个函数对所有查找到的对应TYPE对象做处理
void CBaseObject::DgFindObjectsByTypes( long lType, P_FUNCTION_DO p_function_do, LPARAM lparam)
{
	listBaseObject listBack = m_listObject;
	for( itBaseObject it = listBack.begin();it!=listBack.end();it++)
	{
		CBaseObject* pObject = (*it);
		if( pObject->GetType() == lType )
		{
			p_function_do((LPARAM)pObject,lparam);
		}
		else{
			pObject->DgFindObjectsByTypes(lType,p_function_do,lparam);
		}
	}
}
Ejemplo n.º 24
0
void CObject::SetPointerTosExpectedDistToRoot(int iDistToRoot)
{
	int				i;
	int				iNumEmbedded;
	CBaseObject*	pcEmbedded;

	SetPointedTosDistToRoot(iDistToRoot);

	iNumEmbedded = mapEmbedded.NumElements();
	for (i = 0; i < iNumEmbedded; i++)
	{
		pcEmbedded = *mapEmbedded.Get(i);
		pcEmbedded->SetPointerTosExpectedDistToRoot(iDistToRoot);
	}
}
Ejemplo n.º 25
0
void CObject::SetDistToStack(int iDistToStack)
{
	int				i;
	int				iNumEmbedded;
	CBaseObject*	pcEmbedded;

	CBaseObject::SetDistToStack(iDistToStack);

	iNumEmbedded = mapEmbedded.NumElements();
	for (i = 0; i < iNumEmbedded; i++)
	{
		pcEmbedded = *mapEmbedded.Get(i);
		pcEmbedded->SetDistToStack(iDistToStack);
	}
}
Ejemplo n.º 26
0
void CObject::KillDontFree(void)
{
	int					iNumEmbedded;
	CBaseObject*		pcEmbedded;
	int					i;

	iNumEmbedded = mapEmbedded.NumElements();
	for (i = 0; i < iNumEmbedded; i++)
	{
		pcEmbedded = *mapEmbedded.Get(i);
		pcEmbedded->KillDontFree();
	}

	CBaseObject::KillDontFree();
}
Ejemplo n.º 27
0
void CObject::GetHeapFroms(CArrayTemplateEmbeddedBaseObjectPtr* papcFroms)
{
	int				i;
	int				iNumEmbedded;
	CBaseObject*	pcEmbedded;

	CBaseObject::GetHeapFroms(papcFroms);

	iNumEmbedded = mapEmbedded.NumElements();
	for (i = 0; i < iNumEmbedded; i++)
	{
		pcEmbedded = *mapEmbedded.Get(i);
		pcEmbedded->GetHeapFroms(papcFroms);
	}
}
Ejemplo n.º 28
0
void CObject::UpdateAttachedEmbeddedObjectPointerTosDistToRoot(CDistCalculatorParameters* pcParameters, int iExpectedDist)
{
	int					i;
	int					iNumEmbedded;
	CBaseObject*		pcEmbedded;

	BaseUpdateAttachedEmbeddedObjectPointerTosDistToRoot(pcParameters, iExpectedDist);

	iNumEmbedded = mapEmbedded.NumElements();
	for (i = 0; i < iNumEmbedded; i++)
	{
		pcEmbedded = *mapEmbedded.Get(i);
		pcEmbedded->UpdateAttachedEmbeddedObjectPointerTosDistToRoot(pcParameters, iExpectedDist);
	}
}
Ejemplo n.º 29
0
void CObject::RemoveAllPointerTos(void)
{
	int				i;
	int				iNumEmbedded;
	CBaseObject*	pcEmbedded;

	BaseRemoveAllPointerTos();

	iNumEmbedded = mapEmbedded.NumElements();
	for (i = 0; i < iNumEmbedded; i++)
	{
		pcEmbedded = *mapEmbedded.Get(i);
		pcEmbedded->RemoveAllPointerTos();
	}
}
Ejemplo n.º 30
0
void CObject::Allocate(CObjects* pcObjects)
{
	int					iNumEmbedded;
	CBaseObject*		pcEmbedded;
	int					i;

	CBaseObject::Allocate(pcObjects);

	iNumEmbedded = mapEmbedded.NumElements();
	for (i = 0; i < iNumEmbedded; i++)
	{
		pcEmbedded = *mapEmbedded.Get(i);
		pcEmbedded->Allocate(NULL);
	}
}