MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / clearComponents

Method clearComponents

Engine/source/T3D/entity.cpp:1283–1312  ·  view source on GitHub ↗

///////////////////////////////////////////////////////////////////// NOTE: The actor class calls this and flags the deletion of the behaviors to false so that behaviors that should no longer be attached during a network update will indeed be removed from the object. The reason it doesn't delete them is because when clearing the local behavior list, it would delete them, purging the ghost, and cau

Source from the content-addressed store, hash-verified

1281//list, it would delete them, purging the ghost, and causing a crash when the unpack update tried to fetch any existing behaviors' ghosts
1282//to re-add them. Need to implement a clean clear function that will clear the local list, and only delete unused behaviors during an update.
1283void Entity::clearComponents(bool deleteComponents)
1284{
1285 bool srv = isServerObject();
1286 if (!deleteComponents)
1287 {
1288 while (mComponents.size() > 0)
1289 {
1290 removeComponent(mComponents.first(), deleteComponents);
1291 }
1292 }
1293 else
1294 {
1295 while (mComponents.size() > 0)
1296 {
1297 Component* comp = mComponents.first();
1298
1299 if (comp)
1300 {
1301 comp->onComponentRemove(); //in case the behavior needs to do cleanup on the owner
1302
1303 bool removed = mComponents.remove(comp);
1304
1305 //we only need to delete them on the server side. they'll be cleaned up on the client side
1306 //via the ghosting system for us
1307 if (isServerObject())
1308 comp->deleteObject();
1309 }
1310 }
1311 }
1312}
1313
1314//////////////////////////////////////////////////////////////////////////
1315Component *Entity::getComponent(const U32 index) const

Callers 1

entity.cppFile · 0.80

Calls 5

firstMethod · 0.80
sizeMethod · 0.45
onComponentRemoveMethod · 0.45
removeMethod · 0.45
deleteObjectMethod · 0.45

Tested by

no test coverage detected