destroy method

void destroy()

Destroy an entity which will lead to following steps:

  1. Remove all components
  2. Remove from the system
  3. Set isDestroyed to true

Implementation

void destroy() {
  for (var comp in components.value.values.toList()) {
    var _ = this - comp.runtimeType;
  }
  system.destroyed(this);
  // Add to sink that we are destroyed.
  isDestroyed.add(true);
  isDestroyed.close();
}