Esempio n. 1
0
    def remove(self, component_class):
        """Removes the Componenet of the specified type. Since there is only
		ever one component of one type, we don't need an instance reference.
		returns the removed component"""
        component_class_index = ComponentType.get_index_for(component_class)
        remove_component = self.components[component_class_index]

        if remove_component != None:
            del self.components[component_class_index]
            self.components_array.remove(remove_component)
            self.component_bits.clear(index=component_class_index)

            self.component_removed(self)
Esempio n. 2
0
	def remove(self, component_class):
		"""Removes the Componenet of the specified type. Since there is only
		ever one component of one type, we don't need an instance reference.
		returns the removed component"""
		component_class_index = ComponentType.get_index_for(component_class)
		remove_component = self.components[component_class_index]

		if remove_component != None:
			del self.components[component_class_index]
			self.components_array.remove(remove_component)
			self.component_bits.clear(index=component_class_index)

			self.component_removed(self)
Esempio n. 3
0
    def add(self, component):
        """Adds a Component to this Entity. If a Component of the same type already exists,
		it will be replaced.
		Returns self for easy chaining"""
        component_class = component.__class__
        for c in self.components_array:
            if c.__class__ == component_class:
                del self.components_array[c]
                break

        component_class_index = ComponentType.get_index_for(component_class)
        self.components[component_class_index] = component
        self.components_array.append(component)

        self.component_bits.set(component_class_index)

        self.component_added(self)
        return self
Esempio n. 4
0
	def add(self, component):
		"""Adds a Component to this Entity. If a Component of the same type already exists,
		it will be replaced.
		Returns self for easy chaining"""
		component_class = component.__class__
		for c in self.components_array:
			if c.__class__ == component_class:
				del self.components_array[c]
				break

		component_class_index = ComponentType.get_index_for(component_class)
		self.components[component_class_index] = component
		self.components_array.append(component)

		self.component_bits.set(component_class_index)

		self.component_added(self)
		return self