+ def despawn(self, ent: Entity) -> None:
+ self.despawn_many([ent])
+
+ def despawn_many(self, ents: Iterable[Entity]) -> None:
+ archs: dict[Archetype, list[Entity]] = {}
+ for ent in ents:
+ arch = self._entities[ent]
+ if arch not in archs:
+ archs[arch] = []
+ archs[arch].append(ent)
+ for arch, lst in archs.items():
+ arch.remove(lst)
+
+ def insert[T: Components](self, ty: type[T], ent: Entity, comp: T) -> None:
+ self.insert_many(ty, [(ent, comp)])
+
+ def insert_many[T: Components](
+ self, ty: type[T], comps: Iterable[tuple[Entity, T]]
+ ) -> None:
+ archs: dict[Archetype, list[tuple[Entity, T]]] = {}
+ for ent, comp in comps:
+ arch = self._entities[ent]
+ if arch not in archs:
+ archs[arch] = []
+ archs[arch].append((ent, comp))
+
+ for arch, lst in archs.items():
+ arch.add_components(ty, lst)
+
+ def remove[T: Components](self, ty: type[T], ent: Entity) -> None:
+ self.remove_many(ty, [ent])
+
+ def remove_many[T: Components](
+ self, ty: type[T], comps: Iterable[Entity]
+ ) -> None:
+ archs: dict[Archetype, list[Entity]] = {}
+ for ent in comps:
+ arch = self._entities[ent]
+ if arch not in archs:
+ archs[arch] = []
+ archs[arch].append(ent)
+
+ for arch, lst in archs.items():
+ arch.remove_components(ty, lst)
+
+ def _sys_extractors[T](
+ self, system: System[T]
+ ) -> tuple[Callable[[], FromWorld | None], ...]: