mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +09:00
Changed warp area to fit the radius
This commit is contained in:
@@ -29,13 +29,24 @@ return {
|
||||
|
||||
-- Warp area generation
|
||||
entities = { --- @setting entities The entities which are created for warp areas
|
||||
{'small-lamp',-3,-2},{'small-lamp',-3,2},{'small-lamp',3,-2},{'small-lamp',3,2},
|
||||
{'small-lamp',-2,-3},{'small-lamp',2,-3},{'small-lamp',-2,3},{'small-lamp',2,3},
|
||||
{'small-electric-pole',-3,-3},{'small-electric-pole',3,3},{'small-electric-pole',-3,3},{'small-electric-pole',3,-3}
|
||||
{'small-lamp', -4, -2}, {'small-lamp', -2, -4}, {'small-electric-pole',-3,-3}, -- Top left corner
|
||||
{'small-lamp', 3, -2}, {'small-lamp', 1, -4}, {'small-electric-pole',2,-3}, -- Top right corner
|
||||
{'small-lamp', 3, 1}, {'small-lamp', 1, 3}, {'small-electric-pole',2,2}, -- Bottom right corner
|
||||
{'small-lamp', -4, 1}, {'small-lamp', -2, 3}, {'small-electric-pole',-3,2}, -- Bottom left corner
|
||||
},
|
||||
base_tile = 'tutorial-grid', --- @setting base_tile The tile which is used for the warp areas
|
||||
tiles = { --- @setting tiles The tiles which are created for warp areas
|
||||
{-3,-2},{-3,-1},{-3,0},{-3,1},{-3,2},{3,-2},{3,-1},{3,0},{3,1},{3,2},
|
||||
{-2,-3},{-1,-3},{0,-3},{1,-3},{2,-3},{-2,3},{-1,3},{0,3},{1,3},{2,3}
|
||||
{"black-refined-concrete",-4,-2},{"black-refined-concrete",-4,-1},{"black-refined-concrete",-4,0},{"black-refined-concrete",-4,1},
|
||||
{"black-refined-concrete",-3,-3},{"purple-refined-concrete",-3,-2},{"purple-refined-concrete",-3,-1},{"purple-refined-concrete",-3,0},
|
||||
{"purple-refined-concrete",-3,1},{"black-refined-concrete",-3,2},{"black-refined-concrete",-2,-4},{"purple-refined-concrete",-2,-3},
|
||||
{"purple-refined-concrete",-2,-2},{"purple-refined-concrete",-2,-1},{"purple-refined-concrete",-2,0},{"purple-refined-concrete",-2,1},
|
||||
{"purple-refined-concrete",-2,2},{"black-refined-concrete",-2,3},{"black-refined-concrete",-1,-4},{"purple-refined-concrete",-1,-3},
|
||||
{"purple-refined-concrete",-1,-2},{"purple-refined-concrete",-1,-1},{"purple-refined-concrete",-1,0},{"purple-refined-concrete",-1,1},
|
||||
{"purple-refined-concrete",-1,2},{"black-refined-concrete",-1,3},{"black-refined-concrete",0,-4},{"purple-refined-concrete",0,-3},
|
||||
{"purple-refined-concrete",0,-2},{"purple-refined-concrete",0,-1},{"purple-refined-concrete",0,0},{"purple-refined-concrete",0,1},
|
||||
{"purple-refined-concrete",0,2},{"black-refined-concrete",0,3},{"black-refined-concrete",1,-4},{"purple-refined-concrete",1,-3},
|
||||
{"purple-refined-concrete",1,-2},{"purple-refined-concrete",1,-1},{"purple-refined-concrete",1,0},{"purple-refined-concrete",1,1},
|
||||
{"purple-refined-concrete",1,2},{"black-refined-concrete",1,3},{"black-refined-concrete",2,-3},{"purple-refined-concrete",2,-2},
|
||||
{"purple-refined-concrete",2,-1},{"purple-refined-concrete",2,0},{"purple-refined-concrete",2,1},{"black-refined-concrete",2,2},
|
||||
{"black-refined-concrete",3,-2},{"black-refined-concrete",3,-1},{"black-refined-concrete",3,0},{"black-refined-concrete",3,1}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,31 +148,15 @@ function Warps.make_warp_area(warp_id)
|
||||
local position = warp.position
|
||||
local posx = position.x
|
||||
local posy = position.y
|
||||
local radius = config.standard_proximity_radius
|
||||
local radius2 = radius^2
|
||||
|
||||
-- Get the tile that is being replaced, store.update not needed as we dont want it to trigger
|
||||
local old_tile = surface.get_tile(position).name
|
||||
warp.old_tile = old_tile
|
||||
|
||||
-- Make a circle that acts as a base for the warp structure
|
||||
local base_tile = config.base_tile
|
||||
local base_tiles = {}
|
||||
for x = -radius, radius do
|
||||
local x2 = x^2
|
||||
for y = -radius, radius do
|
||||
local y2 = y^2
|
||||
if x2+y2 < radius2 then
|
||||
table.insert(base_tiles, {name=base_tile, position={x+posx, y+posy}})
|
||||
end
|
||||
end
|
||||
end
|
||||
surface.set_tiles(base_tiles)
|
||||
|
||||
-- Add a tile pattern on top of the base
|
||||
local tiles = {}
|
||||
for _, pos in pairs(config.tiles) do
|
||||
table.insert(tiles, {name=base_tile, position={pos[1]+posx, pos[2]+posy}})
|
||||
for _, tile in pairs(config.tiles) do
|
||||
table.insert(tiles, {name=tile[1], position={tile[2]+posx, tile[3]+posy}})
|
||||
end
|
||||
surface.set_tiles(tiles)
|
||||
|
||||
@@ -193,6 +177,10 @@ function Warps.make_warp_area(warp_id)
|
||||
warp.electric_pole = entity
|
||||
end
|
||||
end
|
||||
|
||||
local radius = config.standard_proximity_radius
|
||||
rendering.draw_circle{ color = {0,1,0,.5}, radius = 0.1, filled = true, target = position, surface = surface, draw_on_ground = true }
|
||||
rendering.draw_circle{ color = {0,1,0,.5}, radius = radius, filled = false, target = position, surface = surface, draw_on_ground = true }
|
||||
end
|
||||
|
||||
--[[-- Remove the warp area for a warp
|
||||
@@ -207,22 +195,15 @@ function Warps.remove_warp_area(warp_id)
|
||||
local position = warp.position
|
||||
local surface = warp.surface
|
||||
local radius = config.standard_proximity_radius
|
||||
local radius2 = radius^2
|
||||
|
||||
-- Check that a warp area was created previously
|
||||
local base_tile = warp.old_tile
|
||||
if not base_tile then return end
|
||||
|
||||
-- Reset all the tiles that were replaced
|
||||
-- Loop over warp tiles and set them to the old tile that was below
|
||||
local tiles = {}
|
||||
for x = -radius, radius do
|
||||
local x2 = x^2
|
||||
for y = -radius, radius do
|
||||
local y2 = y^2
|
||||
if x2+y2 < radius2 then
|
||||
table.insert(tiles, {name=base_tile, position={x+position.x, y+position.y}})
|
||||
end
|
||||
end
|
||||
for _, tile in pairs(config.tiles) do
|
||||
table.insert(tiles, {name=base_tile, position={tile[2]+position.x, tile[3]+position.y}})
|
||||
end
|
||||
surface.set_tiles(tiles)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user