local a=game:GetService("\087\111\114\107\115\112\097\099\101")local d=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local T=game:GetService("\082\117\110\083\101\114\118\105\099\101")local j=require((d:WaitForChild("\080\114\111\106\101\099\116")):WaitForChild("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101"))local D=j:GetResource("\071\097\109\101\068\097\116\097\046\071\101\110\101\114\097\116\105\111\110\046\084\101\108\101\112\111\114\116\076\111\099\097\116\105\111\110\115")local p=(j:GetResource("\071\101\110\101\114\097\116\105\111\110\046\077\097\112\071\101\110\101\114\097\116\111\114")).new()p:GenerateCustomCells()for d,T in pairs(D)do local j=Instance.new("\080\097\114\116")j.Transparency=1 j.Anchored=true j.Size=Vector3.new(100,1,100)j.CFrame=CFrame.new(T[1]*100,-0.5,T[2]*100)*CFrame.Angles(0,-math.pi/2+T[3],0)j.Name=d.."\084\101\108\101\112\111\114\116\076\111\099\097\116\105\111\110"j.Parent=a end local X=a.CurrentCamera;(X:GetPropertyChangedSignal("\067\070\114\097\109\101")):Connect(function()local a=X.CFrame p:GenerateCells(math.floor(a.X/100+.5),math.floor(a.Z/100+.5))end)T.Stepped:Connect(function()p:UpdateQueuedCells()end)
--[[
TheNexusAvenger

Generates the map around the player.
--]]

local Workspace = game:GetService("Workspace")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")

local ReplicatedStorageProject = require(ReplicatedStorage:WaitForChild("Project"):WaitForChild("ReplicatedStorage"))
local TeleportLocations = ReplicatedStorageProject:GetResource("GameData.Generation.TeleportLocations")
local MapGenerator = ReplicatedStorageProject:GetResource("Generation.MapGenerator").new()
MapGenerator:GenerateCustomCells()



--Create plates under the teleport locations in case the map doesn't generate in time.
for LocationName,Location in pairs(TeleportLocations) do
    local Plate = Instance.new("Part")
    Plate.Transparency = 1
    Plate.Anchored = true
    Plate.Size = Vector3.new(100,1,100)
    Plate.CFrame = CFrame.new(Location[1] * 100,-0.5,Location[2] * 100) * CFrame.Angles(0,(-math.pi/2) + Location[3],0)
    Plate.Name = LocationName.."TeleportLocation"
    Plate.Parent = Workspace
end

--Set up changing the center to generate.
local Camera = Workspace.CurrentCamera
Camera:GetPropertyChangedSignal("CFrame"):Connect(function()
    local CameraCenter = Camera.CFrame
    MapGenerator:GenerateCells(math.floor((CameraCenter.X/100) + 0.5),math.floor((CameraCenter.Z/100) + 0.5))
end)

--Set up updating the generator.
RunService.Stepped:Connect(function()
    MapGenerator:UpdateQueuedCells()
end)