예제 #1
0
//-----------------------------------------------------------------------------
// Purpose: Does the linked list work of removing a child object from the hierarchy.
// Input  : pParent - 
//			pChild - 
//-----------------------------------------------------------------------------
void UnlinkChild( CBaseEntity *pParent, CBaseEntity *pChild )
{
	CBaseEntity *pList;
	EHANDLE *pPrev;

	pList = pParent->m_hMoveChild;
	pPrev = &pParent->m_hMoveChild;
	while ( pList )
	{
		CBaseEntity *pNext = pList->m_hMovePeer;
		if ( pList == pChild )
		{
			// patch up the list
			pPrev->Set( pNext );

			// Clear hierarchy bits for this guy
			pList->m_hMoveParent.Set( NULL );
			pList->m_hMovePeer.Set( NULL );
			pList->DispatchUpdateTransmitState();	
			pList->OnEntityEvent( ENTITY_EVENT_PARENT_CHANGED, NULL );
			
			pParent->RecalcHasPlayerChildBit();
			return;
		}
		else
		{
			pPrev = &pList->m_hMovePeer;
			pList = pNext;
		}
	}

	// This only happens if the child wasn't found in the parent's child list
	Assert(0);
}
예제 #2
0
void CRopeKeyframe::SetParent( CBaseEntity *pNewParent, int iAttachment )
{
	CBaseEntity *pCurParent = GetMoveParent();
	if ( pCurParent )
	{
		pCurParent->DecrementTransmitStateOwnedCounter();
		pCurParent->DispatchUpdateTransmitState();
	}

	// Make sure our move parent always transmits or we get asserts on the client.
	if ( pNewParent	)
	{
		pNewParent->IncrementTransmitStateOwnedCounter();
		pNewParent->SetTransmitState( FL_EDICT_ALWAYS );
	}

	BaseClass::SetParent( pNewParent, iAttachment );
}
예제 #3
0
void CRopeKeyframe::SetAttachmentPoint( CBaseHandle &hOutEnt, short &iOutAttachment, CBaseEntity *pEnt, int iAttachment )
{
	// Unforce our previously attached entity from transmitting.
	CBaseEntity *pCurEnt = gEntList.GetBaseEntity( hOutEnt );
	if ( pCurEnt && pCurEnt->edict() )
	{
		pCurEnt->DecrementTransmitStateOwnedCounter();
		pCurEnt->DispatchUpdateTransmitState();
	}
	
	hOutEnt = pEnt;
	iOutAttachment = iAttachment;

	// Force this entity to transmit.
	if ( pEnt )
	{
		pEnt->SetTransmitState( FL_EDICT_ALWAYS );
		pEnt->IncrementTransmitStateOwnedCounter();
	}

	EndpointsChanged();
}