Example #1
0
    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
Example #2
0
    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
Example #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)
Example #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)