def add_component(self, entity: int, component_instance: Any) -> None:
component_type = type(component_instance)<EOL>if component_type not in self._components:<EOL><INDENT>self._components[component_type] = set()<EOL><DEDENT>self._components[component_type].add(entity)<EOL>if entity not in self._entities:<EOL><INDENT>self._entities[entity] = {}<EOL><DEDENT>self._entities[entity][component_type] = component_instance<EOL>self.clear_cache()<EOL>
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.