コード例 #1
0
    def add_sponge(self, w, x, y, z):
        # Track this sponge.
        self.sponges[x, y, z] = True

        # Destroy the water! Destroy!
        for coords in itercube(x, y, z, 2):
            try:
                target = w.sync_get_block(coords)
                if target == self.spring:
                    if (coords[0], coords[2]) in self.springs:
                        del self.springs[coords[0],
                            coords[2]]
                    w.sync_destroy(coords)
                elif target == self.fluid:
                    w.sync_destroy(coords)
            except ChunkNotLoaded:
                pass

        # And now mark our surroundings so that they can be
        # updated appropriately.
        for coords in itercube(x, y, z, 3):
            if coords != (x, y, z):
                self.new.add(coords)
コード例 #2
0
    def dig_hook(self, chunk, x, y, z, block):
        """
        Check for neighboring water that might want to spread.

        Also check to see whether we are, for example, dug ice that has turned
        back into water.
        """

        x += chunk.x * 16
        z += chunk.z * 16

        # Check for sponges first, since they will mark the entirety of the
        # area.
        if block == self.sponge:
            for coords in itercube(x, y, z, 3):
                self.tracked.add(coords)

        else:
            for coords in iterneighbors(x, y, z):
                test_block = yield self.factory.world.get_block(coords)
                if test_block in (self.spring, self.fluid):
                    self.tracked.add(coords)

        self.schedule()
コード例 #3
0
ファイル: test_coords.py プロジェクト: KingPsychopath/bravo
    def test_no_cube(self):
        x, y, z, r = 0, -2, 0, 1

        self.assertEqual(list(itercube(x, y, z, r)), [])
コード例 #4
0
 def remove_sponge(self, x, y, z):
     # The evil sponge tyrant is gone. Flow, minions, flow!
     for coords in itercube(x, y, z, 3):
         if coords != (x, y, z):
             self.new.add(coords)