class RenderingSystem(IteratingSystem): family = Family.get_for_classes(GraphicsComponent) def __init__(self): super(RenderingSystem, self).__init__(self.family) def process_entity(self, entity, deltatime): print(entity, deltatime)
def test_component(self): global COMPONENT_REMOVED global COMPONENT_ADDED Engine.reset_indices() engine = Engine() e1 = Entity() c = VelocityComponent() e1.component_added.append(TestComponentAddedListener()) e1.component_removed.append(TestComponentRemovedListener()) engine.add_entity(e1) e1.add(c) self.assertEqual(COMPONENT_ADDED, e1) reset_component_listener_test() family = Family.get_for_bits(ComponentType.get_bits_for(VelocityComponent)) entities = engine.get_entities_for(family) self.assertEqual(entities[0], e1) e1.remove(VelocityComponent) self.assertEqual(COMPONENT_REMOVED, e1) reset_component_listener_test()
def test_component(self): global COMPONENT_REMOVED global COMPONENT_ADDED Engine.reset_indices() engine = Engine() e1 = Entity() c = VelocityComponent() e1.component_added.append(TestComponentAddedListener()) e1.component_removed.append(TestComponentRemovedListener()) engine.add_entity(e1) e1.add(c) self.assertEqual(COMPONENT_ADDED, e1) reset_component_listener_test() family = Family.get_for_bits( ComponentType.get_bits_for(VelocityComponent)) entities = engine.get_entities_for(family) self.assertEqual(entities[0], e1) e1.remove(VelocityComponent) self.assertEqual(COMPONENT_REMOVED, e1) reset_component_listener_test()
def __init__(self): self.family = Family.get_for_classes(PositionComponent, VelocityComponent) super(TestIteratingSystem, self).__init__(self.family) self.pm = ComponentMapper.get_for(PositionComponent) self.vm = ComponentMapper.get_for(VelocityComponent)
class SailSystem(IteratingSystem): family = Family.get_for_classes(SailComponent)