removeComponents method
Implementation
void removeComponents(EntityID entityID, {required List<Type> components}) {
final record = _entityIndex[entityID];
if (record == null) return;
final componentIDs = <ComponentID>{};
for (final type in components) {
final id = _componentTypes[type];
if (id != null) {
componentIDs.add(id);
}
}
if (componentIDs.isEmpty) return;
final oldArchetype = record.archetype;
final setHash = oldArchetype.setHash.copy();
if (!setHash.removeAll(componentIDs)) return;
if (setHash.isEmpty) {
_removeEntityFromArchetype(entityID, oldArchetype, record.entityRow);
} else {
final archetype = _getOrCreateArchetype(setHash);
_moveEntity(
entityID,
oldArchetype,
record.entityRow,
archetype,
toRemove: componentIDs,
);
}
}