//----------------------------------------------------------------------------- // 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); }
void LinkChild( CBaseEntity *pParent, CBaseEntity *pChild ) { EHANDLE hParent; hParent.Set( pParent ); pChild->m_hMovePeer.Set( pParent->FirstMoveChild() ); pParent->m_hMoveChild.Set( pChild ); pChild->m_hMoveParent = hParent; pChild->NetworkProp()->SetNetworkParent( hParent ); pChild->DispatchUpdateTransmitState(); pChild->OnEntityEvent( ENTITY_EVENT_PARENT_CHANGED, NULL ); pParent->RecalcHasPlayerChildBit(); }