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=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 j=T:GetResource("\078\101\120\117\115\065\100\109\105\110\067\108\105\101\110\116")j.Registry:LoadCommand({Keyword="\115\104\111\119\114\111\097\100\103\114\097\112\104";Prefix=j.Configuration.CommandPrefix;Category="\071\097\109\101\068\101\098\117\103",Description="\068\105\115\112\108\097\121\115 \116\104\101 \103\114\097\112\104 \111\102 \116\104\101 \114\111\097\100\115 \097\098\111\118\101 \116\104\101 \112\108\097\121\101\114\046 \084\104\101 \103\114\097\112\104 \105\115 \117\115\101\100 \102\111\114 \100\101\116\101\114\109\105\110\105\110\103 \116\104\101 \122\111\110\101\115 \111\102 \104\111\117\115\101\115\046";AdminLevel=-1,Run=function(d,j,D)if not d.CommandWasRun then d.CommandWasRun=true local j=T:GetResource("\083\116\097\116\101\046\090\111\110\101\115")for d,T in pairs(j.MapGraph.Nodes)do local j=Instance.new("\080\097\114\116")j.Name="\068\101\098\117\103\082\111\097\100\086\101\114\116\101\120"j.Color=Color3.new(0,1,0)j.Size=Vector3.new(20,20,20)j.CFrame=CFrame.new(T.X*100,100,T.Y*100)j.Anchored=true j.CanCollide=false j.Shape=Enum.PartType.Ball j.TopSurface=Enum.SurfaceType.Smooth j.BottomSurface=Enum.SurfaceType.Smooth j.Parent=a end local D={}for d,T in pairs(j.MapGraph.Edges)do D[d]=true local p=j.MapGraph.Nodes[d]for T,D in pairs(T)do local X=j.MapGraph.Nodes[D]local G=j.MapGraph:GetDistance(d,D)local B=Instance.new("\080\097\114\116")B.Name="\068\101\098\117\103\082\111\097\100\069\100\103\101"B.Color=Color3.new(1,1,0)B.Size=Vector3.new(10,10,100)B.CFrame=CFrame.new(Vector3.new(p.X*100,100,p.Y*100),Vector3.new(X.X*100,100,X.Y*100))*CFrame.new(0,0,-(G*100)/2)B.Anchored=true B.CanCollide=false B.TopSurface=Enum.SurfaceType.Smooth B.BottomSurface=Enum.SurfaceType.Smooth B.Parent=a local g=Instance.new("\083\112\101\099\105\097\108\077\101\115\104")g.MeshType=Enum.MeshType.Brick g.Scale=Vector3.new(1,1,G)g.Parent=B end end return"\086\101\114\116\105\099\105\101\115 \097\110\100 \101\100\103\101\115 \119\105\108\108 \110\111\119 \097\112\112\101\097\114 \097\098\111\118\101\046"else return"\067\111\109\109\097\110\100 \097\108\114\101\097\100\121 \114\097\110\046"end end})
--[[
TheNexusAvenger

Registers a command for showing the road graph.
--]]

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

local ReplicatedStorageProject = require(ReplicatedStorage:WaitForChild("Project"):WaitForChild("ReplicatedStorage"))

local NexusAdminAPI = ReplicatedStorageProject:GetResource("NexusAdminClient")



NexusAdminAPI.Registry:LoadCommand({
    Keyword = "showroadgraph",
    Prefix = NexusAdminAPI.Configuration.CommandPrefix,
    Category = "GameDebug",
    Description = "Displays the graph of the roads above the player. The graph is used for determining the zones of houses.",
    AdminLevel = -1,
    Run = function(self,CommandContext,ShowMapConfidence)
        if not self.CommandWasRun then
            self.CommandWasRun = true

            --Set up the zones.
            --Done here in case the client doesn't create the graph elsewhere to save memory.
            local Zones = ReplicatedStorageProject:GetResource("State.Zones")

            --Draw the vertices.
            for _,Vertex in pairs(Zones.MapGraph.Nodes) do
                local VertexPart = Instance.new("Part")
                VertexPart.Name = "DebugRoadVertex"
                VertexPart.Color = Color3.new(0,1,0)
                VertexPart.Size = Vector3.new(20,20,20)
                VertexPart.CFrame = CFrame.new(Vertex.X * 100,100,Vertex.Y * 100)
                VertexPart.Anchored = true
                VertexPart.CanCollide = false
                VertexPart.Shape = Enum.PartType.Ball
                VertexPart.TopSurface = Enum.SurfaceType.Smooth
                VertexPart.BottomSurface = Enum.SurfaceType.Smooth
                VertexPart.Parent = Workspace
            end

            --Draw the edges.
            local DrawnVertices = {}
            for StartVertexId,EndVertexIds in pairs(Zones.MapGraph.Edges) do
                DrawnVertices[StartVertexId] = true
                local StartVertex = Zones.MapGraph.Nodes[StartVertexId]
                for _,EndVertexId in pairs(EndVertexIds) do
                    local EndVertex = Zones.MapGraph.Nodes[EndVertexId]
                    local Distance = Zones.MapGraph:GetDistance(StartVertexId,EndVertexId)
                    local EdgePart = Instance.new("Part")
                    EdgePart.Name = "DebugRoadEdge"
                    EdgePart.Color = Color3.new(1,1,0)
                    EdgePart.Size = Vector3.new(10,10,100)
                    EdgePart.CFrame = CFrame.new(Vector3.new(StartVertex.X * 100,100,StartVertex.Y * 100),Vector3.new(EndVertex.X * 100,100,EndVertex.Y * 100)) * CFrame.new(0,0,-(Distance * 100)/2)
                    EdgePart.Anchored = true
                    EdgePart.CanCollide = false
                    EdgePart.TopSurface = Enum.SurfaceType.Smooth
                    EdgePart.BottomSurface = Enum.SurfaceType.Smooth
                    EdgePart.Parent = Workspace

                    local EdgeMesh = Instance.new("SpecialMesh")
                    EdgeMesh.MeshType = Enum.MeshType.Brick
                    EdgeMesh.Scale = Vector3.new(1,1,Distance)
                    EdgeMesh.Parent = EdgePart
                end
            end

            return "Verticies and edges will now appear above."
        else
            return "Command already ran."
        end
    end,
})