mirror of
https://github.com/Dadido3/noita-mapcap.git
synced 2024-11-22 21:17:33 +00:00
Replace hardcoded capture areas
We now retrieve the correct biome size and offsets from the game itself.
This commit is contained in:
parent
1936dc100c
commit
44ed26952c
@ -770,8 +770,9 @@ function Capture:StartCapturing()
|
||||
|
||||
self:StartCapturingAreaScan(topLeft, bottomRight, captureGridSize, outputPixelScale, captureDelay)
|
||||
else
|
||||
local predefinedArea = Config.CaptureArea[area]
|
||||
if predefinedArea then
|
||||
local predefinedAreaFunction = Config.CaptureArea[area]
|
||||
if predefinedAreaFunction then
|
||||
local predefinedArea = predefinedAreaFunction()
|
||||
self:StartCapturingAreaScan(predefinedArea.TopLeft, predefinedArea.BottomRight, captureGridSize, outputPixelScale, captureDelay)
|
||||
else
|
||||
Message:ShowRuntimeError("PredefinedArea", string.format("Unknown predefined capturing area %q", tostring(area)))
|
||||
|
@ -3,6 +3,7 @@
|
||||
-- This software is released under the MIT License.
|
||||
-- https://opensource.org/licenses/MIT
|
||||
|
||||
local NXML = require("luanxml.nxml")
|
||||
local Vec2 = require("noita-api.vec2")
|
||||
|
||||
-- List of components that will be disabled on every encountered entity.
|
||||
@ -27,40 +28,65 @@ Config.ComponentsToDisable = {
|
||||
--"AudioComponent",
|
||||
}
|
||||
|
||||
local CHUNK_SIZE = 512
|
||||
|
||||
---Returns the rectangle of the base area as two vectors.
|
||||
---@return Vec2 TopLeft Top left corner in world coordinates.
|
||||
---@return Vec2 BottomRight Bottom right corner in world coordinates. This pixel is not included in the final rectangle.
|
||||
local function getBaseArea()
|
||||
local xml = NXML.parse(ModTextFileGetContent("data/biome/_biomes_all.xml"))
|
||||
local width, height = BiomeMapGetSize()
|
||||
local offsetX, offsetY = math.floor(width/2), xml.attr.biome_offset_y -- TODO: This may not be right. Check what Noita is really doing when we have a biome map with an odd width.
|
||||
return Vec2(-offsetX, -offsetY)*CHUNK_SIZE, Vec2(-offsetX+width, -offsetY+height)*CHUNK_SIZE
|
||||
--return Vec2(-17920, -7168), Vec2(17920, 17408) -- Coordinates for a "New Game" without mods or anything.
|
||||
end
|
||||
|
||||
---A list of capture areas.
|
||||
---This contains functions that determine the capture area based on the biome size and other parameters.
|
||||
---The returned vectors are the top left corner, and the bottom right corner of the capture area in world coordinates.
|
||||
---The bottom right corner pixel is not included in the rectangle.
|
||||
---@type table<string, fun():Vec2, Vec2>
|
||||
Config.CaptureArea = {
|
||||
-- Base layout: Every part outside this is based on a similar layout, but uses different materials/seeds.
|
||||
["1x1"] = {
|
||||
TopLeft = Vec2(-17920, -7168), -- in world coordinates.
|
||||
BottomRight = Vec2(17920, 17408), -- in world coordinates. This pixel is not included in the rectangle.
|
||||
},
|
||||
["1x1"] = getBaseArea,
|
||||
|
||||
-- Main world: The main world with 3 parts: sky, normal and hell.
|
||||
["1x3"] = {
|
||||
TopLeft = Vec2(-17920, -31744), -- in world coordinates.
|
||||
BottomRight = Vec2(17920, 41984), -- in world coordinates. This pixel is not included in the rectangle.
|
||||
},
|
||||
["1x3"] = function()
|
||||
local width, height = BiomeMapGetSize()
|
||||
local topLeft, bottomRight = getBaseArea()
|
||||
return topLeft + Vec2(0, -height)*CHUNK_SIZE, bottomRight + Vec2(0, height)*CHUNK_SIZE
|
||||
--return Vec2(-17920, -31744), Vec2(17920, 41984) -- Coordinates for a "New Game" without mods or anything.
|
||||
end,
|
||||
|
||||
-- -1 parallel world: The parallel world with 3 parts: sky, normal and hell.
|
||||
["1x3 -1"] = {
|
||||
TopLeft = Vec2(-17920, -31744) + Vec2(-35840, 0), -- in world coordinates.
|
||||
BottomRight = Vec2(17920, 41984) + Vec2(-35840, 0), -- in world coordinates. This pixel is not included in the rectangle.
|
||||
},
|
||||
["1x3 -1"] = function()
|
||||
local width, height = BiomeMapGetSize()
|
||||
local topLeft, bottomRight = getBaseArea()
|
||||
return topLeft + Vec2(-width, -height)*CHUNK_SIZE, bottomRight + Vec2(-width, height)*CHUNK_SIZE
|
||||
--return Vec2(-17920, -31744) + Vec2(-35840, 0), Vec2(17920, 41984) + Vec2(-35840, 0) -- Coordinates for a "New Game" without mods or anything.
|
||||
end,
|
||||
|
||||
-- +1 parallel world: The parallel world with 3 parts: sky, normal and hell.
|
||||
["1x3 +1"] = {
|
||||
TopLeft = Vec2(-17920, -31744) + Vec2(35840, 0), -- in world coordinates.
|
||||
BottomRight = Vec2(17920, 41984) + Vec2(35840, 0), -- in world coordinates. This pixel is not included in the rectangle.
|
||||
},
|
||||
["1x3 +1"] = function()
|
||||
local width, height = BiomeMapGetSize()
|
||||
local topLeft, bottomRight = getBaseArea()
|
||||
return topLeft + Vec2(width, -height)*CHUNK_SIZE, bottomRight + Vec2(width, height)*CHUNK_SIZE
|
||||
--return Vec2(-17920, -31744) + Vec2(35840, 0), Vec2(17920, 41984) + Vec2(35840, 0) -- Coordinates for a "New Game" without mods or anything.
|
||||
end,
|
||||
|
||||
-- Extended: Main world + a fraction of the parallel worlds to the left and right.
|
||||
["1.5x3"] = {
|
||||
TopLeft = Vec2(-25600, -31744), -- in world coordinates.
|
||||
BottomRight = Vec2(25600, 41984), -- in world coordinates. This pixel is not included in the rectangle.
|
||||
},
|
||||
["1.5x3"] = function()
|
||||
local width, height = BiomeMapGetSize()
|
||||
local topLeft, bottomRight = getBaseArea()
|
||||
return topLeft + Vec2(-math.floor(0.25*width), -height)*CHUNK_SIZE, bottomRight + Vec2(math.floor(0.25*width), height)*CHUNK_SIZE
|
||||
--return Vec2(-25600, -31744), Vec2(25600, 41984) -- Coordinates for a "New Game" without mods or anything. These coordinates may not exactly be 1.5 of the base width for historic reasons.
|
||||
end,
|
||||
|
||||
-- Extended: Main world + each parallel world to the left and right.
|
||||
["3x3"] = {
|
||||
TopLeft = Vec2(-53760, -31744), -- in world coordinates.
|
||||
BottomRight = Vec2(53760, 41984), -- in world coordinates. This pixel is not included in the rectangle.
|
||||
},
|
||||
["3x3"] = function()
|
||||
local width, height = BiomeMapGetSize()
|
||||
local topLeft, bottomRight = getBaseArea()
|
||||
return topLeft + Vec2(-width, -height)*CHUNK_SIZE, bottomRight + Vec2(width, height)*CHUNK_SIZE
|
||||
--return Vec2(-53760, -31744), Vec2(53760, 41984) -- Coordinates for a "New Game" without mods or anything.
|
||||
end,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user