code: def add_component(self, entity: int, component_instance: Any) -> None:
          
          component_type = type(component_instance)
  
          if component_type not in self._components:
              self._components[component_type] = set()
  
          self._components[component_type].add(entity)
  
          if entity not in self._entities:
              self._entities[entity] = {}
  
          self._entities[entity][component_type] = component_instance
          self.clear_cache()
docs: Add a new Component instance to an Entity.
  
          Add a Component instance to an Entiy. If a Component of the same type
          is already assigned to the Entity, it will be replaced.
  
          :param entity: The Entity to associate the Component with.
          :param component_instance: A Component instance.