File size: 7,101 Bytes
0712d5f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | -- src/ServerScriptService/BiomeGeneratorManager.server.lua
-- Simple flat baseplate-style world with colored biome regions
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CollectionService = game:GetService("CollectionService")
local BiomeConfig = require(ReplicatedStorage:WaitForChild("Shared"):WaitForChild("BiomeConfig"))
local GameConfig = require(ReplicatedStorage:WaitForChild("Shared"):WaitForChild("GameConfig"))
-- Create folders
local biomeZonesFolder = Instance.new("Folder")
biomeZonesFolder.Name = "BiomeZones"
biomeZonesFolder.Parent = workspace
local worldFolder = Instance.new("Folder")
worldFolder.Name = "WorldStructures"
worldFolder.Parent = workspace
-- Biome color map (distinct flat colors, no grass)
local BiomeColors = {
Forest = Color3.fromRGB(80, 130, 60),
PineWoods = Color3.fromRGB(50, 100, 45),
Swamp = Color3.fromRGB(65, 85, 50),
Desert = Color3.fromRGB(210, 190, 130),
Volcanic = Color3.fromRGB(70, 40, 35),
IcePeak = Color3.fromRGB(190, 210, 230),
TropicalRainforest = Color3.fromRGB(35, 110, 40),
Meadow = Color3.fromRGB(140, 180, 80),
}
local function createBiomePlate(biomeName, biomeData)
local region = biomeData.Region
local regionWidth = region.MaxX - region.MinX
local regionDepth = region.MaxZ - region.MinZ
local centerX = (region.MinX + region.MaxX) / 2
local centerZ = (region.MinZ + region.MaxZ) / 2
-- Flat baseplate for this biome
local plate = Instance.new("Part")
plate.Name = biomeName .. "_Plate"
plate.Size = Vector3.new(regionWidth, 1, regionDepth)
plate.Position = Vector3.new(centerX, -0.5, centerZ) -- Top surface at Y=0
plate.Anchored = true
plate.Material = Enum.Material.SmoothPlastic
plate.Color = BiomeColors[biomeName] or Color3.fromRGB(100, 100, 100)
plate.TopSurface = Enum.SurfaceType.Smooth
plate.BottomSurface = Enum.SurfaceType.Smooth
plate.Parent = biomeZonesFolder
-- Invisible detection zone (taller, for biome detection)
local zonePart = Instance.new("Part")
zonePart.Name = biomeName .. "_Zone"
zonePart.Size = Vector3.new(regionWidth, 50, regionDepth)
zonePart.Position = Vector3.new(centerX, 25, centerZ)
zonePart.Anchored = true
zonePart.CanCollide = false
zonePart.Transparency = 1
zonePart:SetAttribute("BiomeName", biomeName)
CollectionService:AddTag(zonePart, "BiomeZone")
zonePart.Parent = biomeZonesFolder
-- Hazard zone if applicable
if biomeData.HazardType then
local hazardZone = Instance.new("Part")
hazardZone.Name = biomeName .. "_Hazard"
hazardZone.Size = Vector3.new(regionWidth * 0.8, 20, regionDepth * 0.8)
hazardZone.Position = Vector3.new(centerX, 10, centerZ)
hazardZone.Anchored = true
hazardZone.CanCollide = false
hazardZone.Transparency = 0.95
hazardZone.BrickColor = BrickColor.new("Bright red")
if biomeData.HazardAttribute then
hazardZone:SetAttribute("HazardType", biomeData.HazardAttribute)
end
CollectionService:AddTag(hazardZone, biomeData.HazardType)
hazardZone.Parent = biomeZonesFolder
end
-- Biome label sign at center
local signPart = Instance.new("Part")
signPart.Name = biomeName .. "_Sign"
signPart.Size = Vector3.new(8, 4, 0.5)
signPart.Position = Vector3.new(centerX, 4, centerZ)
signPart.Anchored = true
signPart.Material = Enum.Material.Wood
signPart.BrickColor = BrickColor.new("Reddish brown")
signPart.Parent = biomeZonesFolder
local signGui = Instance.new("SurfaceGui")
signGui.Face = Enum.NormalId.Front
signGui.Parent = signPart
local signLabel = Instance.new("TextLabel")
signLabel.Size = UDim2.new(1, 0, 1, 0)
signLabel.BackgroundTransparency = 1
signLabel.Text = biomeName
signLabel.TextColor3 = Color3.new(1, 1, 1)
signLabel.TextScaled = true
signLabel.Font = Enum.Font.GothamBold
signLabel.Parent = signGui
print("Biome plate created:", biomeName)
end
-- Create spawn platform (elevated slightly so it is distinct)
local function createSpawnPlatform()
local platform = Instance.new("Part")
platform.Name = "SpawnPlatform"
platform.Size = Vector3.new(GameConfig.SpawnPlatformSize.X, 0.2, GameConfig.SpawnPlatformSize.Z)
platform.Position = Vector3.new(GameConfig.SpawnPosition.X, 0.1, GameConfig.SpawnPosition.Z) -- rests slightly above biome plate
platform.Anchored = true
platform.Material = Enum.Material.SmoothPlastic
platform.Color = Color3.fromRGB(160, 160, 165)
platform.TopSurface = Enum.SurfaceType.Smooth
platform.BottomSurface = Enum.SurfaceType.Smooth
CollectionService:AddTag(platform, "SpawnPlatform")
platform.Parent = worldFolder
local spawn = Instance.new("SpawnLocation")
spawn.Size = Vector3.new(6, 1, 6)
spawn.Position = Vector3.new(GameConfig.SpawnPosition.X, 0.5, GameConfig.SpawnPosition.Z)
spawn.Anchored = true
spawn.CanCollide = false
spawn.Transparency = 1
spawn.Parent = worldFolder
end
-- World boundaries
local function createWorldBoundaries()
local bounds = GameConfig.WorldBounds
local height = 200
local thickness = 5
local walls = {
{pos = Vector3.new(0, height/2, bounds.MinZ), size = Vector3.new(bounds.MaxX - bounds.MinX, height, thickness)},
{pos = Vector3.new(0, height/2, bounds.MaxZ), size = Vector3.new(bounds.MaxX - bounds.MinX, height, thickness)},
{pos = Vector3.new(bounds.MinX, height/2, 0), size = Vector3.new(thickness, height, bounds.MaxZ - bounds.MinZ)},
{pos = Vector3.new(bounds.MaxX, height/2, 0), size = Vector3.new(thickness, height, bounds.MaxZ - bounds.MinZ)},
}
for i, wallData in ipairs(walls) do
local wall = Instance.new("Part")
wall.Name = "WorldBoundary_" .. i
wall.Size = wallData.size
wall.Position = wallData.pos
wall.Anchored = true
wall.Transparency = 1
wall.CanCollide = true
CollectionService:AddTag(wall, "WorldBoundary")
wall.Parent = worldFolder
end
end
-- Plot areas
local function createPlots()
local plotsFolder = Instance.new("Folder")
plotsFolder.Name = "Plots"
plotsFolder.Parent = worldFolder
for i, pos in ipairs(GameConfig.PlotPositions) do
local plot = Instance.new("Part")
plot.Name = "Plot_" .. i
plot.Size = Vector3.new(200, 0.2, 200)
plot.Position = Vector3.new(pos.X, 0.1, pos.Z) -- elevate slightly to prevent z-fighting
plot.Anchored = true
plot.Material = Enum.Material.SmoothPlastic
plot.Color = Color3.fromRGB(90, 90, 95)
plot.TopSurface = Enum.SurfaceType.Smooth
plot.BottomSurface = Enum.SurfaceType.Smooth
plot.Transparency = 1 -- fully invisible as requested
CollectionService:AddTag(plot, "EmptyPlot")
plot.Parent = plotsFolder
end
end
-- Execute world generation
task.spawn(function()
print("=== Timberbound Expeditions: World Generation Starting ===")
createSpawnPlatform()
createWorldBoundaries()
createPlots()
-- Create flat biome plates (no terrain, no elevation)
for biomeName, biomeData in pairs(BiomeConfig.Biomes) do
createBiomePlate(biomeName, biomeData)
end
print("=== World Generation Complete ===")
_G.BiomeGenerationComplete = true
end)
|