Ejemplo n.º 1
0
void AINodeGuard::Init()
{
	super::Init();

	// Get the guarded nodes.
	// Guarded nodes will be owned by this guard node.  Nodes that are
	// owned may only be used by the AI assigned to this guard node.

	HSTRING hstrNodeName;
	HSTRING_LIST::iterator it;
	for ( it = m_lstGuardedNodeNames.begin(); it != m_lstGuardedNodeNames.end(); ++it )
	{
		hstrNodeName = *it;
		AINode* pNode = g_pAINodeMgr->GetNode( hstrNodeName );

		if ( pNode )
		{
			m_lstGuardedNodes.push_back( pNode->m_hObject );
			pNode->SetNodeOwner( m_hObject );
		}
		else
		{
			AIASSERT1( 0, m_hObject, "AINodeGuard::Init: Cannot find guarded node \"%s\"", ::ToString( hstrNodeName ));
		}

		FREE_HSTRING( hstrNodeName );
	}
	
	m_lstGuardedNodeNames.clear();
}
Ejemplo n.º 2
0
void CAIGoalGuard::SetGuardNode(AINode* pGuardNode)
{
	if( pGuardNode && ( pGuardNode->GetType() != m_eNodeType ))
	{
		AIASSERT( 0, m_pAI->m_hObject, "CAIGoalGuard::SetGuardNode: Wrong node type.");
		return;
	}

	if( m_hGuardNode )
	{
		AINode* pNode = (AINode*)g_pLTServer->HandleToObject(m_hGuardNode);
		if( pNode )
		{
			pNode->SetNodeOwner( LTNULL );
			pNode->Unlock( m_pAI->m_hObject );
		}
		m_hGuardNode = LTNULL;
	}

	if( pGuardNode )
	{
		m_hGuardNode = pGuardNode->m_hObject;
		pGuardNode->Lock( m_pAI->m_hObject );
		pGuardNode->SetNodeOwner( m_pAI->m_hObject );
	}
}