def _light_offset(self, x, y, offset, dropoff, intensity, iteration, is_corner=False): """ Call light function with given offset """ _ox, _oy = offset if _ox != 0 or _oy != 0: # No need to light same point light = self.world.get_light(x + _ox, y + _oy) if light is None: return # "None" means "out of world" dist = sqrt(_ox * _ox + _oy * _oy) target_intensity = ubyte(intensity * pow(dropoff, dist)) # Calculate next block light level (ubyte - unsigned byte) if light < target_intensity: chunk = self.world.get_chunk(x + _ox, y + _oy) try: Shadow.add_updated(chunk.shadow) self._light_block(x, y, _ox, _oy, intensity=target_intensity, iteration=iteration + 1, is_corner=is_corner) except Exception as e: if type(e) is not Exception: traceback.print_exc()
def _unlight_offset(self, x, y, ix, iy, offset, unlit_blocks, is_corner=False): """ Call unlight function with given offset """ _ox, _oy = offset if _ox != 0 or _oy != 0: # No need to unlight same point nlight = self.world.get_light(x + _ox, y + _oy) light = self.world.get_light(x, y) if light is None or nlight is None: return # "None" means "out of world" if nlight < light: chunk = self.world.get_chunk(x + _ox, y + _oy) try: Shadow.add_updated(chunk.shadow) self._unlight_block(x + _ox, y + _oy, ix, iy, unlit_blocks, _ox, _oy, is_corner=is_corner) except Exception as e: if type(e) is not Exception: traceback.print_exc()