c4_HandlerSeq::~c4_HandlerSeq() { const bool rootLevel = _parent == this; c4_Persist *pers = _persist; if (rootLevel && pers != 0) { pers->DoAutoCommit(); } DetachFromParent(); DetachFromStorage(true); for (int i = 0; i < NumHandlers(); ++i) { delete &NthHandler(i); } _handlers.SetSize(0); ClearCache(); if (rootLevel) { delete _field; d4_assert(pers != 0); delete pers; } }
// this unlinks the part from its parent..it will do so by calling // sSlotMap unlink in the 2 slot maps, and by removing itself from the parent // array of pointer void VDSBuildingBlock::Detach() { // if there is no parent..return if ( !m_pParent ) { return; } // unlink upper slots here from lower slots of parent // and unlink lower slots her from upper slots of parent // if the parent is up.. // unlink the upper slots here, and the down slots in the parent if ( m_bParentIsUp ) { m_pParent->m_DownSlots.UnLink( m_UpSlots ); } else { m_pParent->m_UpSlots.UnLink( m_DownSlots ); } // get the parent matrix and remove the translation data and invert it TSRMatrix4 parentmat; m_pParent->m_BoundBox.GetWorldMatrix( parentmat ); parentmat._41 = 0.0f; parentmat._42 = 0.0f; parentmat._43 = 0.0f; m_BoundBox.m_Transform.Multiply( m_BoundBox.m_Transform, parentmat ); // and remove yourself from parent as well DetachFromParent(); // now remove the bounding box here from its parent m_BoundBox.DetachFromParent(); // the new pivot it the same start m_PivotX = m_UpSlots.m_StartX; m_PivotY = m_UpSlots.m_StartY; // recompute the bounding box ComputeBBox(); }
//remove CObject from the world void ReleaseObject (short nObject) { if ((nObject <= 0) || (nObject >= LEVEL_OBJECTS)) return; int nParent; CObject *objP = OBJECTS + nObject; if (objP->info.nType == OBJ_WEAPON) { if (gameData.demo.nVcrState != ND_STATE_PLAYBACK) RespawnDestroyedWeapon (nObject); if (objP->info.nId == GUIDEDMSL_ID) { nParent = OBJECTS [objP->cType.laserInfo.parent.nObject].info.nId; if (nParent != gameData.multiplayer.nLocalPlayer) gameData.objs.guidedMissile [nParent].objP = NULL; else if (gameData.demo.nState == ND_STATE_RECORDING) NDRecordGuidedEnd (); } } if (objP == gameData.objs.viewerP) //deleting the viewerP? gameData.objs.viewerP = gameData.objs.consoleP; //..make the CPlayerData the viewerP if (objP->info.nFlags & OF_ATTACHED) //detach this from CObject DetachFromParent (objP); if (objP->info.nAttachedObj != -1) //detach all OBJECTS from this DetachChildObjects (objP); if (objP->info.nType == OBJ_DEBRIS) gameData.objs.nDebris--; OBJECTS [nObject].UnlinkFromSeg (); Assert (OBJECTS [0].info.nNextInSeg != 0); if ((objP->info.nType == OBJ_ROBOT) || (objP->info.nType == OBJ_REACTOR) || (objP->info.nType == OBJ_POWERUP) || (objP->info.nType == OBJ_HOSTAGE)) ExecObjTriggers (nObject, 0); objP->info.nType = OBJ_NONE; //unused! objP->info.nSignature = -1; objP->info.nSegment = -1; // zero it! try { FreeObject (nObject); } catch (...) { PrintLog ("Error freeing an object\n"); } SpawnLeftoverPowerups (nObject); }
void GameObjectNode::SetParent(GameObjectNode* parentNode) { DetachFromParent(); parent = parentNode; parentNode->children.push_back(this); }
//------------------------------------------------------------------------------ //dettaches all OBJECTS from this CObject void DetachChildObjects (CObject *parentP) { while (parentP->info.nAttachedObj != -1) DetachFromParent (OBJECTS + parentP->info.nAttachedObj); }