///////////////////////////////////////////////////////////////////// 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
| 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. |
| 1283 | void 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 | ////////////////////////////////////////////////////////////////////////// |
| 1315 | Component *Entity::getComponent(const U32 index) const |
no test coverage detected