mirror of
https://github.com/Refactorio/RedMew.git
synced 2024-12-12 10:04:40 +02:00
removed math.sqrt from SimpleRoomGenerator
This commit is contained in:
parent
e6beb157a9
commit
11ac8e666c
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user