예제 #1
0
파일: factory.py 프로젝트: JDShu/bravo
    def create_entity(self, x, y, z, name, **kwargs):
        """
        Spawn an entirely new entity at the specified block coordinates.

        Handles entity registration as well as instantiation.
        """

        bigx = x // 16
        bigz = z // 16

        location = Location.at_block(x, y, z)
        entity = entities[name](eid=0, location=location, **kwargs)

        self.register_entity(entity)

        d = self.world.request_chunk(bigx, bigz)

        @d.addCallback
        def cb(chunk):
            chunk.entities.add(entity)
            log.msg("Created entity %s" % entity)
            # XXX Maybe just send the entity object to the manager instead of
            # the following?
            if hasattr(entity, 'loop'):
                self.world.mob_manager.start_mob(entity)

        return entity
예제 #2
0
파일: factory.py 프로젝트: JDShu/bravo
    def create_entity(self, x, y, z, name, **kwargs):
        """
        Spawn an entirely new entity at the specified block coordinates.

        Handles entity registration as well as instantiation.
        """

        bigx = x // 16
        bigz = z // 16

        location = Location.at_block(x, y, z)
        entity = entities[name](eid=0, location=location, **kwargs)

        self.register_entity(entity)

        d = self.world.request_chunk(bigx, bigz)
        @d.addCallback
        def cb(chunk):
            chunk.entities.add(entity)
            log.msg("Created entity %s" % entity)
            # XXX Maybe just send the entity object to the manager instead of
            # the following?
            if hasattr(entity,'loop'):
                self.world.mob_manager.start_mob(entity)

        return entity
예제 #3
0
 def test_at_block(self):
     l = Location.at_block(3, 4, 5)
     self.assertEqual(l.pos.x, 96)
     self.assertEqual(l.pos.y, 128)
     self.assertEqual(l.pos.z, 160)
예제 #4
0
 def test_at_block(self):
     l = Location.at_block(3, 4, 5)
     self.assertEqual(l.pos.x, 96)
     self.assertEqual(l.pos.y, 128)
     self.assertEqual(l.pos.z, 160)