Files
roblox-project/bunsik-tycoon/tests/cloud/dump_scene.luau

113 lines
3.5 KiB
Lua

-- 미리보기용 장면 덤프: 맵과 가게 두 곳(1단계 중간, 2단계 전부 산 상태)을 짓고 모든 파트를 JSON으로 돌려줍니다.
-- python3 tools/cloud.py run tests/cloud/dump_scene.luau --version N --out .cache/scene.json
-- python3 tools/render.py .cache/scene.json
local HttpService = game:GetService("HttpService")
local Players = game:GetService("Players")
local ServerScriptService = game:GetService("ServerScriptService")
local Server = ServerScriptService.Server
local World = require(Server.World)
local Npc = require(Server.Npc)
local PlotController = require(Server.PlotController)
local PlotBuilder = require(Server.PlotBuilder)
local Data = require(Server.Data)
local Floor = require(game:GetService("ReplicatedStorage").Shared.Floor)
local slots = World.build()
Npc.preload()
-- 예전 구매 수(bought)로 크기를 정하고, 단계(stage)·디자인을 맞춘 가게를 짓습니다.
local function shop(slot, bought: number, stage: number, design: string, withChar: boolean, extra: number?)
local data: any = table.clone(Data.TEMPLATE)
data.PurchaseIdCache = {}
data.Bought = bought
data.TutorialDone = true
Data.migrate(data, 1)
data.Levels.Stage = stage - 1
data.Levels.Staff = 1
data.Staff = { Cook = 1, Server = 1, Promoter = 1 }
data.Design = design
data.Money = 1e9
local owner = Instance.new("Folder")
owner.Parent = ServerScriptService
local char: Model? = nil
local c = PlotController.new(slot, owner, {
userId = slot.index,
displayName = "Player" .. slot.index,
data = data,
now = 0,
getCharacter = function()
return char
end,
})
c:setDesignOwned(design, true)
c:setDesign(design)
for _ = 1, extra or 0 do
c:buyTable()
c:buySeat(nil)
end
c:buyDecor("Plant")
c:buyDecor("Balloons")
c:buyDecor("Teddy")
if withChar then
char = Players:CreateHumanoidModelFromDescription(Instance.new("HumanoidDescription"), Enum.HumanoidRigType.R15)
local cm = char :: Model
cm.Parent = workspace
local root = cm:FindFirstChild("HumanoidRootPart") :: BasePart
root.Anchored = true
local pos = PlotBuilder.stallPoint(slot.refs, Floor.STOVE_FRONT)
local look = PlotBuilder.stallPoint(slot.refs, { x = 0, z = 12 })
cm:PivotTo(CFrame.lookAt(pos + Vector3.new(0, 3, 0), look + Vector3.new(0, 3, 0)))
end
-- 손님을 채우고 몇 명은 먹는 중으로
local t = 0
for _ = 1, 300 do
t += 0.1
c:update(t)
end
if withChar then
c.shop.counter = {}
c:cook()
end
return c
end
local mode = "all"
shop(slots[1], 6, 1, "Basic", true, 1)
shop(slots[2], 20, 2, "Candy", false, 2)
shop(slots[3], 20, 3, "Hanok", false, 6)
shop(slots[4], 14, 2, "Brick", false, 1)
shop(slots[5], 14, 2, "Mint", false, 1)
shop(slots[6], 20, 3, "Basic", false, 6)
print("mode", mode)
task.wait(0.5)
local parts = {}
for _, d in workspace:GetDescendants() do
if d:IsA("BasePart") and d.Transparency < 0.95 then
local shape = "Block"
if d:IsA("Part") then
shape = d.Shape.Name
elseif d:IsA("WedgePart") then
shape = "Wedge"
end
local cf = d.CFrame
local x, y, z, r00, r01, r02, r10, r11, r12, r20, r21, r22 = cf:GetComponents()
local col = d.Color
table.insert(parts, {
s = shape,
c = { x, y, z, r00, r01, r02, r10, r11, r12, r20, r21, r22 },
z = { d.Size.X, d.Size.Y, d.Size.Z },
k = { math.floor(col.R * 255), math.floor(col.G * 255), math.floor(col.B * 255) },
t = d.Transparency,
m = d.Material.Name,
})
end
end
print("parts", #parts)
local json = HttpService:JSONEncode(parts)
return {
BinaryOutput = buffer.fromstring(json),
ReturnValues = { #parts },
}