From 11ac8e666c7b54907b87efe42d28fc90d506fe51 Mon Sep 17 00:00:00 2001 From: Maik Wild Date: Wed, 3 Oct 2018 00:59:05 +0200 Subject: [PATCH] removed math.sqrt from SimpleRoomGenerator --- map_gen/Diggy/Feature/SimpleRoomGenerator.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/map_gen/Diggy/Feature/SimpleRoomGenerator.lua b/map_gen/Diggy/Feature/SimpleRoomGenerator.lua index f1c27f52..e7ade49f 100644 --- a/map_gen/Diggy/Feature/SimpleRoomGenerator.lua +++ b/map_gen/Diggy/Feature/SimpleRoomGenerator.lua @@ -55,9 +55,14 @@ end --[[-- Registers all event handlers. ]] + +local room_noise_minimum_distance_sq + function SimpleRoomGenerator.register(cfg) local config = cfg.features.SimpleRoomGenerator + room_noise_minimum_distance_sq = config.room_noise_minimum_distance * config.room_noise_minimum_distance + local function get_noise(surface, x, y) local seed = surface.map_gen_settings.seed + surface.index return Perlin.noise(x * config.noise_variance, y * config.noise_variance, seed) @@ -65,9 +70,9 @@ function SimpleRoomGenerator.register(cfg) Event.add(Template.events.on_void_removed, function (event) local position = event.old_tile.position - local distance = math.floor(math.sqrt(position.x^2 + position.y^2)) + local distance_sq = position.x^2 + position.y^2 - if (distance < config.room_noise_minimum_distance) then + if (distance_sq <= room_noise_minimum_distance_sq) then return end @@ -97,7 +102,6 @@ end @param config Table {@see Diggy.Config}. ]] function SimpleRoomGenerator.initialize(config) - end return SimpleRoomGenerator