local r=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local P=require((r: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 v=P:GetResource("\071\101\110\101\114\097\116\105\111\110\046\067\101\108\108\046\066\097\115\101\071\114\097\115\115\067\101\108\108")local f=v:Extend()f:SetClassName("\082\111\097\100\067\101\108\108")function f.__new(A,r,P,v,f,Q,b)A:InitializeSuper(r,P,v,f,Q,b)local j,Y=r*100,P*100 local u=Instance.new("\077\111\100\101\108")u.Name="\082\111\097\100"u.Parent=A.CellModel A.RoadModel=u A:CreateConcretePart(Vector3.new(90,1,90),CFrame.new(j,0,Y),BrickColor.new("\066\108\097\099\107"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j-45,.1,Y-45),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j-45,.1,Y+45),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j+45,.1,Y-45),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j+45,.1,Y+45),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))if v~="\082\111\097\100"then A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j-35,.1,Y+45),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j-25,.1,Y+45),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j-15,.1,Y+45),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j-5,.1,Y+45),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j+5,.1,Y+45),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j+15,.1,Y+45),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j+25,.1,Y+45),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j+35,.1,Y+45),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(92,2,9.6),CFrame.new(j,.05,Y+45),BrickColor.new("\068\097\114\107 \115\116\111\110\101 \103\114\101\121"))end if f~="\082\111\097\100"then A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j-35,.1,Y-45),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j-25,.1,Y-45),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j-15,.1,Y-45),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j-5,.1,Y-45),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j+5,.1,Y-45),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j+15,.1,Y-45),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j+25,.1,Y-45),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j+35,.1,Y-45),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(92,2,9.6),CFrame.new(j,.05,Y-45),BrickColor.new("\068\097\114\107 \115\116\111\110\101 \103\114\101\121"))end if Q~="\082\111\097\100"then A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j-45,.1,Y-35),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j-45,.1,Y-25),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j-45,.1,Y-15),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j-45,.1,Y-5),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j-45,.1,Y+5),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j-45,.1,Y+15),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j-45,.1,Y+25),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j-45,.1,Y+35),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.6,2,92),CFrame.new(j-45,.05,Y),BrickColor.new("\068\097\114\107 \115\116\111\110\101 \103\114\101\121"))end if b~="\082\111\097\100"then A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j+45,.1,Y-35),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j+45,.1,Y-25),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j+45,.1,Y-15),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j+45,.1,Y-5),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j+45,.1,Y+5),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j+45,.1,Y+15),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j+45,.1,Y+25),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(j+45,.1,Y+35),BrickColor.new("\077\101\100\105\117\109 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.6,2,92),CFrame.new(j+45,.05,Y),BrickColor.new("\068\097\114\107 \115\116\111\110\101 \103\114\101\121"))end if v=="\082\111\097\100"then A:CreateConcretePart(Vector3.new(9.6,2,2),CFrame.new(j-45,.05,Y+50),BrickColor.new("\068\097\114\107 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(9.6,2,2),CFrame.new(j+45,.05,Y+50),BrickColor.new("\068\097\114\107 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(90,1,10),CFrame.new(j,0,Y+50),BrickColor.new("\066\108\097\099\107"))end if b=="\082\111\097\100"then A:CreateConcretePart(Vector3.new(2,2,9.6),CFrame.new(j+50,.05,Y-45),BrickColor.new("\068\097\114\107 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(2,2,9.6),CFrame.new(j+50,.05,Y+45),BrickColor.new("\068\097\114\107 \115\116\111\110\101 \103\114\101\121"))A:CreateConcretePart(Vector3.new(10,1,90),CFrame.new(j+50,0,Y),BrickColor.new("\066\108\097\099\107"))end end function f.CreateConcretePart(f,r,P,v)local Q=Instance.new("\080\097\114\116")Q.BrickColor=v Q.Material="\067\111\110\099\114\101\116\101"Q.Anchored=true Q.Size=r Q.CFrame=P Q.TopSurface="\083\109\111\111\116\104"Q.BottomSurface="\083\109\111\111\116\104"Q.Parent=f.RoadModel end function f.Destroy(r)r.super:Destroy()r.RoadModel:Destroy()end return f
--[[
TheNexusAvenger

Generates a road cell.
--]]

local ReplicatedStorage = game:GetService("ReplicatedStorage")

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

local BaseGrassCell = ReplicatedStorageProject:GetResource("Generation.Cell.BaseGrassCell")

local RoadCell = BaseGrassCell:Extend()
RoadCell:SetClassName("RoadCell")



--[[
Creates a cell.
--]]
function RoadCell:__new(X,Y,TopCellType,BottomCellType,LeftCellType,RightCellType)
    self:InitializeSuper(X,Y,TopCellType,BottomCellType,LeftCellType,RightCellType)

    --Create the road and corner sidewalks.
    local CenterX,CenterY = X * 100,Y * 100
    local RoadModel = Instance.new("Model")
    RoadModel.Name = "Road"
    RoadModel.Parent = self.CellModel
    self.RoadModel = RoadModel

    self:CreateConcretePart(Vector3.new(90,1,90),CFrame.new(CenterX,0,CenterY),BrickColor.new("Black"))
    self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX - 45,0.1,CenterY - 45),BrickColor.new("Medium stone grey"))
    self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX - 45,0.1,CenterY + 45),BrickColor.new("Medium stone grey"))
    self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX + 45,0.1,CenterY - 45),BrickColor.new("Medium stone grey"))
    self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX + 45,0.1,CenterY + 45),BrickColor.new("Medium stone grey"))

    --Create the sidewalks.
    if TopCellType ~= "Road" then
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX - 35,0.1,CenterY + 45),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX - 25,0.1,CenterY + 45),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX - 15,0.1,CenterY + 45),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX - 5,0.1,CenterY + 45),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX + 5,0.1,CenterY + 45),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX + 15,0.1,CenterY + 45),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX + 25,0.1,CenterY + 45),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX + 35,0.1,CenterY + 45),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(92,2,9.6),CFrame.new(CenterX,0.05,CenterY + 45),BrickColor.new("Dark stone grey"))
    end
    if BottomCellType ~= "Road" then
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX - 35,0.1,CenterY - 45),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX - 25,0.1,CenterY - 45),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX - 15,0.1,CenterY - 45),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX - 5,0.1,CenterY - 45),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX + 5,0.1,CenterY - 45),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX + 15,0.1,CenterY - 45),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX + 25,0.1,CenterY - 45),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX + 35,0.1,CenterY - 45),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(92,2,9.6),CFrame.new(CenterX,0.05,CenterY - 45),BrickColor.new("Dark stone grey"))
    end
    if LeftCellType ~= "Road" then
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX - 45,0.1,CenterY - 35),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX - 45,0.1,CenterY - 25),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX - 45,0.1,CenterY - 15),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX - 45,0.1,CenterY - 5),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX - 45,0.1,CenterY + 5),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX - 45,0.1,CenterY + 15),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX - 45,0.1,CenterY + 25),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX - 45,0.1,CenterY + 35),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(9.6,2,92),CFrame.new(CenterX - 45,0.05,CenterY),BrickColor.new("Dark stone grey"))
    end
    if RightCellType ~= "Road" then
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX + 45,0.1,CenterY - 35),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX + 45,0.1,CenterY - 25),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX + 45,0.1,CenterY - 15),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX + 45,0.1,CenterY - 5),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX + 45,0.1,CenterY + 5),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX + 45,0.1,CenterY + 15),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX + 45,0.1,CenterY + 25),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(9.8,2,9.8),CFrame.new(CenterX + 45,0.1,CenterY + 35),BrickColor.new("Medium stone grey"))
        self:CreateConcretePart(Vector3.new(9.6,2,92),CFrame.new(CenterX + 45,0.05,CenterY),BrickColor.new("Dark stone grey"))
    end

    --Create the connectors to the next roads.
    if TopCellType == "Road" then
        self:CreateConcretePart(Vector3.new(9.6,2,2),CFrame.new(CenterX - 45,0.05,CenterY + 50),BrickColor.new("Dark stone grey"))
        self:CreateConcretePart(Vector3.new(9.6,2,2),CFrame.new(CenterX + 45,0.05,CenterY + 50),BrickColor.new("Dark stone grey"))
        self:CreateConcretePart(Vector3.new(90,1,10),CFrame.new(CenterX,0,CenterY + 50),BrickColor.new("Black"))
    end
    if RightCellType == "Road" then
        self:CreateConcretePart(Vector3.new(2,2,9.6),CFrame.new(CenterX + 50,0.05,CenterY - 45),BrickColor.new("Dark stone grey"))
        self:CreateConcretePart(Vector3.new(2,2,9.6),CFrame.new(CenterX + 50,0.05,CenterY + 45),BrickColor.new("Dark stone grey"))
        self:CreateConcretePart(Vector3.new(10,1,90),CFrame.new(CenterX + 50,0,CenterY),BrickColor.new("Black"))
    end
end

--[[
Creates a concrete part.
--]]
function RoadCell:CreateConcretePart(Size,CFrame,Color)
    local Part = Instance.new("Part")
    Part.BrickColor = Color
    Part.Material = "Concrete"
    Part.Anchored = true
    Part.Size = Size
    Part.CFrame = CFrame
    Part.TopSurface = "Smooth"
    Part.BottomSurface = "Smooth"
    Part.Parent = self.RoadModel
end

--[[
Destroys the cell.
--]]
function RoadCell:Destroy()
    self.super:Destroy()
    self.RoadModel:Destroy()
end



return RoadCell