Files
roblox-project/bunsik-tycoon/src/client/Decorate.luau
EJClaw fdc5c05c2c feat(bunsik): 가게 꾸미기 3D 투명 미리보기·회전, 테이블·의자 따로 배치, 아래 [사기] 막대 → 튜토리얼, 손님 느리게, 2배 돈 "이미 보유" 수정
- 아래 추천 [사기] 막대를 없애고 튜토리얼 말풍선을 아래 가운데로. 튜토리얼 3단계는 [가게 꾸미기]에서 의자 놓기
- 상점에서 꾸미기 탭을 빼고 따로 [가게 꾸미기] 버튼·창. 카드를 고르면 캐릭터 앞에 투명 미리보기가 붙어 다니고
  [돌리기](R)·[놓기](F)로 그 자리에 놓음(놓을 때 돈). [옮기기]로 놓은 물건·조리대를 들어서 옮김
- 의자를 테이블에서 떼어 {x,z,f,r}로 저장(등받이로 방향 보임). 의자는 보는 쪽 앞에 테이블이 있어야 하고,
  테이블을 옮기거나 돌리면 그 테이블을 보는 의자도 같이. 예전 {t,s} 저장은 자동 변환. 새 요청 buyAt
- 테이블은 의자 없이 따로 판매(20 + 15×테이블 수²)
- 손님 간격 10초 → 20초(손님 속도 갈래도 2배), 대신 음식값 2배로 1분 매출 유지. 실내 11분·2층 50분(봇)
- 2배 돈: 게임 주인은 게임패스를 자동 보유하는데 [처음부터]·2배 끄기 뒤 버튼이 결제 창을 띄워 "이미 보유"가 나옴.
  누르면 먼저 보유를 확인해 바로 켜고, [처음부터]도 2배를 유지
- 검사 위치 0.5칸 자리 길 검사 오류 수정(touches가 막힌 칸 안쪽을 보던 문제)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 05:22:17 +09:00

769 lines
22 KiB
Lua

--!strict
-- 꾸미기(놓기) 화면: 화면의 [가게 꾸미기] 창에서 물건을 고르거나 [옮기기]를 누르면 시작합니다.
-- - 들기: 고른 물건의 투명한 미리보기가 내 캐릭터 바로 앞에 붙어 다닙니다. 걸어 다니며 자리를 잡고
-- [돌리기](PC: R)로 방향을 바꾼 뒤 [놓기](PC: F)를 누르면 그 자리에 놓습니다.
-- 놓을 수 있으면 초록, 안 되면 빨강과 이유(문 앞, 겹침, 길이 막힘, 의자 앞에 테이블 없음, 돈 부족 등)가 나옵니다.
-- 검사는 서버와 같은 Floor.add / Floor.move이고, 서버가 다시 검사합니다. 새 물건 값은 놓을 때 나갑니다.
-- - 옮기기: 내 가게의 테이블·의자·소품·조리대를 누르면 그 물건을 듭니다(원래 물건은 내 화면에서만 숨김).
-- 테이블을 들면 그 테이블을 보는 의자도 같이 들리고, [돌리기]는 의자들을 테이블 둘레로 돌립니다.
-- - 층은 캐릭터가 서 있는 층(2층 건물이면 계단으로 올라가서 놓음)입니다.
-- 캐릭터는 그대로 움직이고, 다른 화면 UI와 조리대 버튼은 Main이 onOpen/onClose로 숨깁니다.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Shared = ReplicatedStorage:WaitForChild("Shared")
local Economy = require(Shared:WaitForChild("Economy"))
local Floor = require(Shared:WaitForChild("Floor"))
local Locale = require(Shared:WaitForChild("Locale"))
local Info = require(script.Parent:WaitForChild("Info"))
local Layout = require(script.Parent:WaitForChild("Layout"))
local Theme = require(script.Parent:WaitForChild("Theme"))
local Decorate = {}
export type Handle = {
gui: ScreenGui,
-- kind = "table" | "chair" | "decor"(k = 소품 종류)이면 새 물건 들기, "move"면 옮길 물건 고르기
start: (kind: string, k: string?) -> (),
close: () -> (),
isOpen: () -> boolean,
holding: () -> boolean, -- 물건을 들고 있으면 true(PC 마우스 회전은 그대로)
onOpen: (fn: () -> ()) -> (),
-- 끝날 때. placed = 새 물건을 놓으려고 보냈으면 "new", 옮기기를 보냈으면 "move", 그냥 나가면 nil
onClose: (fn: (placed: string?) -> ()) -> (),
setLayout: (lay: Layout.Result) -> (),
notify: (key: string, args: { [string]: any }?) -> (),
destroy: () -> (),
}
type Hold = {
new: boolean,
kind: string, -- "table" | "chair" | "decor" | "stove"
k: string?, -- 새 소품 종류
i: number, -- 옮기는 물건 번호(새 물건이면 0)
r: number, -- 회전(테이블은 지금 자리 기준 돌린 횟수)
}
type Piece = { kind: string, index: number, clone: Model, from: CFrame?, pivot: CFrame }
local GOOD = Color3.fromRGB(70, 220, 120)
local BAD = Color3.fromRGB(255, 70, 70)
local function snap(v: number): number
return math.floor(v * 2 + 0.5) / 2
end
-- 캐릭터 가운데에서 미리보기 가운데까지 거리(물건 크기에 맞춤)
local function holdDistance(h: Hold, layout: Floor.Layout): number
if h.kind == "table" then
return 6
elseif h.kind == "chair" then
return 3.5
elseif h.kind == "stove" then
return 11
end
local k = h.k
if not k and layout.decor[h.i] then
k = layout.decor[h.i].k
end
local fp = k and Floor.FOOTPRINT[k]
return if fp then math.max(fp.w, fp.d) / 2 + 2.5 else 3.5
end
-- 배치 속 물건 하나의 놓는 자리(x, z, 층, 회전)
local function spot(layout: Floor.Layout, kind: string, i: number): (number?, number?, number?, number?)
if kind == "stove" then
local s = layout.stove
return s.x, s.z, 1, s.r
elseif kind == "table" then
local t = layout.tables[i]
if t then
return t.x, t.z, t.f, 0
end
elseif kind == "chair" then
local c = layout.chairs[i]
if c then
return c.x, c.z, c.f, c.r
end
elseif kind == "decor" then
local d = layout.decor[i]
if d then
return d.x, d.z, d.f, d.r
end
end
return nil
end
-- 미리보기용으로 복사한 모형 정리: 부딪히지 않고, 빛·소리·버튼 없이 반투명하게
local function ghostify(m: Model)
for _, d in m:GetDescendants() do
if d:IsA("BasePart") then
d.Anchored = true
d.CanCollide = false
d.CanQuery = false
d.CanTouch = false
d.CastShadow = false
d.Transparency = 0.45 + d.Transparency * 0.55
elseif d:IsA("Decal") then
d.Transparency = 0.45 + d.Transparency * 0.55
elseif
d:IsA("ProximityPrompt")
or d:IsA("Sound")
or d:IsA("Light")
or d:IsA("ParticleEmitter")
or d:IsA("Fire")
or d:IsA("Smoke")
or d:IsA("Sparkles")
or d:IsA("BillboardGui")
or d:IsA("Highlight")
or d:IsA("BaseScript")
then
d:Destroy()
end
end
for name in m:GetAttributes() do
m:SetAttribute(name, nil)
end
end
function Decorate.build(parent: Instance, state: Instance, plot: Model, send: (string, any?) -> ()): Handle
local function lang(): string
return Info.attr(state, "Lang", "ko")
end
local function L(key: string, args: { [string]: any }?): string
return Locale.t(lang(), key, args)
end
local player = state :: any
local gui = Instance.new("ScreenGui")
gui.Name = "BunsikDecorate"
gui.ResetOnSpawn = false
gui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
gui.DisplayOrder = 5
gui.Enabled = false
gui.Parent = parent
local root = Theme.frame(gui, "Root")
local scale = Instance.new("UIScale")
scale.Parent = root
local exitBtn, exitLabel = Theme.iconButton(root, "Exit", Theme.RED, "close")
local infoBox = Theme.frame(root, "Info", Theme.WHITE)
Theme.round(infoBox)
local infoStroke = Theme.stroke(infoBox, Theme.edge(Theme.MINT), 4)
local infoIcon = Info.glyph(infoBox, "Icon", "hand")
infoIcon.frame.AnchorPoint = Vector2.new(0, 0.5)
infoIcon.frame.Position = UDim2.new(0, 10, 0.5, 0)
infoIcon.frame.Size = UDim2.new(0, 48, 0.8, 0)
local infoText = Theme.text(infoBox, "Text")
infoText.Position = UDim2.new(0, 64, 0.12, 0)
infoText.Size = UDim2.new(1, -80, 0.76, 0)
infoText.ZIndex = 2
local rotateBtn, rotateLabel = Theme.textButton(root, "Rotate", Theme.LAVENDER, 22)
local cancelBtn, cancelLabel = Theme.textButton(root, "Cancel", Theme.GRAY, 22)
local okBtn, okLabel = Theme.textButton(root, "Place", Theme.MINT, 22)
-- 미리보기 모형(내 화면에만)
local ghost = Instance.new("Model")
ghost.Name = "BunsikDecorateGhost"
local highlight = Instance.new("Highlight")
highlight.FillTransparency = 0.55
highlight.OutlineColor = Theme.WHITE
highlight.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop
highlight.Parent = ghost
local plates: { BasePart } = {}
local isOpen = false
local hold: Hold? = nil
local pieces: { Piece } = {}
local hiddenParts: { [BasePart]: boolean } = {} -- 옮기는 원래 물건(내 화면에서만 숨김) -> 원래 CanCollide
local target: { x: number, z: number, f: number }? = nil
local valid = false
local why: string? = nil
local message: string? = nil
local messageToken = 0
local openFns: { () -> () } = {}
local closeFns: { (string?) -> () } = {}
local conns: { RBXScriptConnection } = {}
-- 배치는 속성이 바뀔 때만 다시 읽습니다(매 프레임 JSON을 풀지 않게).
local layoutNow = Info.layout(state)
local function curLayout(): Floor.Layout
return layoutNow
end
local function origin(): CFrame?
local o = plot:GetAttribute("Origin")
return if typeof(o) == "CFrame" then o else nil
end
local function stage(): number
return Info.attr(state, "Stage", 1)
end
local function floorY(f: number): number
return Floor.BASE_Y + (if f == 2 then Floor.FLOOR2_Y else 0)
end
local function placeCF(o: CFrame, x: number, z: number, f: number, r: number): CFrame
return o * CFrame.new(x, floorY(f), z) * CFrame.Angles(0, r * math.pi / 2, 0)
end
-- 물건 모형 찾기(조리대는 수레 모형)
local function itemModel(kind: string, i: number): Model?
if kind == "stove" then
local base = plot:FindFirstChild("Base")
local stall = base and base:FindFirstChild("Stall")
return if stall and stall:IsA("Model") then stall else nil
end
local up = plot:FindFirstChild("Upgrades")
local furniture = up and up:FindFirstChild("Furniture")
if not furniture then
return nil
end
for _, d in furniture:GetChildren() do
if d:IsA("Model") and d:GetAttribute("ItemKind") == kind and d:GetAttribute("ItemIndex") == i then
return d
end
end
return nil
end
local function cost(h: Hold): number?
if not h.new then
return nil
end
if h.kind == "chair" then
return Economy.seatCost(Info.attr(state, "Seats", 1) + 1)
elseif h.kind == "table" then
return Economy.tableCost(Info.attr(state, "Tables", 1))
end
local d = h.k and Economy.decor(h.k)
return d and d.cost
end
local function itemName(h: Hold, layout: Floor.Layout): (string, string)
if h.kind == "stove" then
return L("stoveObject"), "flame"
elseif h.kind == "table" then
return L("thing_Table"), "table"
elseif h.kind == "chair" then
return L("thing_Seat"), Info.SEAT_ICON
end
local k = h.k or (layout.decor[h.i] and layout.decor[h.i].k) or ""
return L("decor_" .. k), Info.DECOR_ICON[k] or "sparkle"
end
-- 원래 물건 숨기기/되돌리기(옮기는 동안 내 화면에서만, 지나갈 수 있게)
local function hideModel(m: Model)
for _, d in m:GetDescendants() do
if d:IsA("BasePart") and hiddenParts[d] == nil then
hiddenParts[d] = d.CanCollide
d.LocalTransparencyModifier = 1
d.CanCollide = false
end
end
end
local function unhideAll()
for p, collide in hiddenParts do
if p.Parent then
p.LocalTransparencyModifier = 0
p.CanCollide = collide
end
end
table.clear(hiddenParts)
end
local function clearGhost()
for _, pc in pieces do
pc.clone:Destroy()
end
table.clear(pieces)
for _, p in plates do
p:Destroy()
end
table.clear(plates)
ghost.Parent = nil
unhideAll()
end
-- 든 물건의 미리보기 모형 만들기
local function buildGhost(h: Hold)
clearGhost()
local layout = curLayout()
local function addPiece(kind: string, index: number, source: Model?, from: CFrame?)
if not source then
return
end
local c = source:Clone()
ghostify(c)
c.Parent = ghost
table.insert(pieces, { kind = kind, index = index, clone = c, from = from, pivot = source:GetPivot() })
end
local o = origin()
if not o then
return
end
if h.new then
local templates = ReplicatedStorage:FindFirstChild("BunsikTemplates")
local name = if h.kind == "table"
then "Table"
elseif h.kind == "chair" then "Chair"
else "Decor_" .. (h.k or "")
local src = templates and templates:FindFirstChild(name)
addPiece(h.kind, 0, if src and src:IsA("Model") then src else nil, nil)
else
local function addExisting(kind: string, i: number)
local m = itemModel(kind, i)
local x, z, f, r = spot(layout, kind, i)
if m and x then
addPiece(kind, i, m, placeCF(o, x, z :: number, f :: number, r :: number))
hideModel(m)
end
end
addExisting(h.kind, h.i)
if h.kind == "table" then
local attached: { number } = Floor.chairsByTable(layout)[h.i] or {}
for _, ci in attached do
addExisting("chair", ci)
end
end
end
ghost.Parent = workspace
end
-- 지금 들고 있는 물건을 target 자리에 둔 배치(검사 없이)와 새 물건 번호
local function preview(
h: Hold,
layout: Floor.Layout,
t: { x: number, z: number, f: number }
): (Floor.Layout?, number?)
if h.new then
return Floor.applyAdd(layout, { kind = h.kind, k = h.k, x = t.x, z = t.z, f = t.f, r = h.r })
end
return Floor.applyMove(layout, { kind = h.kind, i = h.i, x = t.x, z = t.z, f = t.f, r = h.r }), h.i
end
local function drawPlates(o: CFrame, test: Floor.Layout, h: Hold, index: number?)
for _, p in plates do
p:Destroy()
end
table.clear(plates)
local mine: { [string]: boolean } = {}
for _, pc in pieces do
mine[`{pc.kind}:{if h.new then index or 0 else pc.index}`] = true
end
for _, pc in Floor.pieces(test) do
if mine[`{pc.kind}:{pc.index}`] then
local r = pc.rect
local p = Instance.new("Part")
p.Name = "Plate"
p.Anchored = true
p.CanCollide = false
p.CanQuery = false
p.CanTouch = false
p.CastShadow = false
p.Material = Enum.Material.Neon
p.Color = if valid then GOOD else BAD
p.Transparency = 0.55
p.Size = Vector3.new(math.max(0.2, r.x1 - r.x0), 0.12, math.max(0.2, r.z1 - r.z0))
p.CFrame = o * CFrame.new((r.x0 + r.x1) / 2, floorY(r.f) + 0.08, (r.z0 + r.z1) / 2)
p.Parent = ghost
table.insert(plates, p)
end
end
end
-- 안내 글과 버튼
local function redraw()
exitLabel.Text = L("exit")
rotateLabel.Text = L("rotate")
cancelLabel.Text = L("cancel")
okLabel.Text = L("placeIt")
local h = hold
local layout = curLayout()
rotateBtn.button.Visible = h ~= nil and not (h.new and h.kind == "table")
cancelBtn.button.Visible = h ~= nil
okBtn.button.Visible = h ~= nil
okBtn.setColor(if h and valid then Theme.MINT else Theme.GRAY)
local text: string
local color = Theme.MINT
if message then
text = message
color = Theme.ORANGE
elseif not h then
text = L("decoPick")
infoIcon.set("hand")
elseif not valid then
text = L("why_" .. (why or "none"))
color = Theme.RED
else
text = L("decoOk")
end
if h then
local name, icon = itemName(h, layout)
infoIcon.set(icon)
local c = cost(h)
if c then
name = `{name} {Locale.number(c)}`
end
text = `{name} · {text}`
if UserInputService.KeyboardEnabled and not message then
text ..= " " .. L("decoKeys")
end
end
infoText.Text = text
infoText.TextColor3 = if color == Theme.RED then Theme.edge(Theme.RED) else Theme.TEXT
infoStroke.Color = Theme.edge(color)
highlight.FillColor = if valid then GOOD else BAD
highlight.OutlineColor = if valid then Theme.WHITE else BAD
end
-- 캐릭터 앞 자리 계산 → 바뀌면 다시 검사
local lastKey = ""
local function update(force: boolean?)
local h = hold
local o = origin()
local char = player.Character
local rootPart = char and char:FindFirstChild("HumanoidRootPart") :: BasePart?
if not h or not o or not rootPart then
return
end
local layout = curLayout()
local lp = o:PointToObjectSpace(rootPart.Position)
local look = o:VectorToObjectSpace(rootPart.CFrame.LookVector)
local flat = Vector2.new(look.X, look.Z)
flat = if flat.Magnitude > 1e-3 then flat.Unit else Vector2.new(0, -1)
local dist = holdDistance(h, layout)
local f = if stage() >= 3 and lp.Y > Floor.BASE_Y + Floor.FLOOR2_Y - 4 then 2 else 1
local t = { x = snap(lp.X + flat.X * dist), z = snap(lp.Z + flat.Y * dist), f = f }
local key = `{t.x},{t.z},{t.f},{h.r}`
if key == lastKey and not force then
return
end
lastKey = key
target = t
local test, index = preview(h, layout, t)
if not test then
valid, why = false, "none"
elseif h.kind == "stove" and f == 2 then
valid, why = false, "floor"
else
why = Floor.validate(test, stage())
valid = why == nil
local c = cost(h)
if valid and c and Info.attr(state, "Money", 0) < c then
valid, why = false, "money"
end
end
-- 미리보기 모형 옮기기
if test then
for _, pc in pieces do
local idx = if h.new then index or 0 else pc.index
local x, z, pf, r = spot(test, pc.kind, idx)
if x then
local to = placeCF(o, x, z :: number, pf :: number, r :: number)
pc.clone:PivotTo(if pc.from then to * pc.from:Inverse() * pc.pivot else to)
end
end
drawPlates(o, test, h, index)
end
redraw()
end
local function showMessage(text: string)
message = text
messageToken += 1
local token = messageToken
redraw()
task.delay(3, function()
if token == messageToken then
message = nil
if isOpen then
redraw()
end
end
end)
end
local renderConn: RBXScriptConnection? = nil
local function close(placed: string?)
if not isOpen then
return
end
isOpen = false
gui.Enabled = false
hold = nil
target = nil
clearGhost()
if renderConn then
renderConn:Disconnect()
renderConn = nil
end
for _, fn in closeFns do
fn(placed)
end
end
local function beginHold(h: Hold)
hold = h
valid = false
why = nil
message = nil
lastKey = ""
buildGhost(h)
update(true)
end
local function open()
if isOpen then
return
end
isOpen = true
gui.Enabled = true
renderConn = RunService.RenderStepped:Connect(function()
update()
end)
for _, fn in openFns do
fn()
end
end
local function start(kind: string, k: string?)
if not origin() then
return
end
open()
if kind == "move" then
hold = nil
clearGhost()
redraw()
else
-- 새 의자는 캐릭터가 보는 쪽(앞의 테이블 쪽)을 보게 들고 시작합니다.
local r = 0
local o = origin()
local char = player.Character
local rootPart = char and char:FindFirstChild("HumanoidRootPart") :: BasePart?
if kind == "chair" and o and rootPart then
local look = o:VectorToObjectSpace(rootPart.CFrame.LookVector)
local best = -math.huge
for cr = 0, 3 do
local fx, fz = Floor.facing(cr)
local d = fx * look.X + fz * look.Z
if d > best then
best, r = d, cr
end
end
end
beginHold({ new = true, kind = kind, k = k, i = 0, r = r })
end
end
-- 옮길 물건 고르기(누른 곳의 내 가게 물건)
-- screen = true면 상단 바를 뺀 화면 좌표(터치), 아니면 뷰포트 좌표(마우스)
local function pickItem(sx: number, sy: number, screen: boolean): (string?, number?)
local camera = workspace.CurrentCamera
if not camera then
return nil, nil
end
local list: { Instance } = {}
local up = plot:FindFirstChild("Upgrades")
local furniture = up and up:FindFirstChild("Furniture")
if furniture then
for _, d in furniture:GetChildren() do
if d:IsA("Model") and typeof(d:GetAttribute("ItemKind")) == "string" then
table.insert(list, d)
end
end
end
local stall = itemModel("stove", 1)
if stall then
table.insert(list, stall)
end
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Include
params.FilterDescendantsInstances = list
local ray = if screen then camera:ScreenPointToRay(sx, sy) else camera:ViewportPointToRay(sx, sy)
local res = workspace:Raycast(ray.Origin, ray.Direction * 1000, params)
local inst: Instance? = res and res.Instance
while inst and inst ~= plot do
if inst == stall then
return "stove", 1
end
local kind = inst:GetAttribute("ItemKind")
local i = inst:GetAttribute("ItemIndex")
if inst:IsA("Model") and typeof(kind) == "string" and typeof(i) == "number" then
return kind, i
end
inst = inst.Parent
end
return nil, nil
end
local function tryPick(sx: number, sy: number, screen: boolean)
if not isOpen or hold then
return
end
local kind, i = pickItem(sx, sy, screen)
if kind and i then
local layout = curLayout()
local _, _, _, r = spot(layout, kind, i)
beginHold({ new = false, kind = kind, i = i, r = if kind == "table" then 0 else r or 0 })
end
end
local function rotate()
local h = hold
if h and not (h.new and h.kind == "table") then
h.r = (h.r + 1) % 4
update(true)
end
end
local function placeNow()
local h = hold
local t = target
if not h or not t then
return
end
if not valid then
-- 왜 안 되는지 한 번 더 크게 보여 줍니다.
showMessage(L("why_" .. (why or "none")))
return
end
if h.new then
send("buyAt", { kind = h.kind, k = h.k, x = t.x, z = t.z, f = t.f, r = h.r })
close("new")
else
send("move", { kind = h.kind, i = h.i, x = t.x, z = t.z, f = t.f, r = h.r })
-- 옮기기는 계속 다른 물건을 고를 수 있게 고르기로 돌아갑니다.
hold = nil
target = nil
clearGhost()
redraw()
end
end
local function cancel()
if hold and not hold.new then
hold = nil
target = nil
clearGhost()
redraw()
else
close(nil)
end
end
-- 입력: 누르기(옮길 물건 고르기), R 돌리기, F 놓기
table.insert(
conns,
UserInputService.InputBegan:Connect(function(io: InputObject, processed: boolean)
if not isOpen or processed then
return
end
if io.UserInputType == Enum.UserInputType.MouseButton1 then
local p = UserInputService:GetMouseLocation()
tryPick(p.X, p.Y, false)
elseif io.KeyCode == Enum.KeyCode.R then
rotate()
elseif io.KeyCode == Enum.KeyCode.F then
placeNow()
end
end)
)
table.insert(
conns,
UserInputService.TouchTapInWorld:Connect(function(pos: Vector2, processed: boolean)
if not processed then
tryPick(pos.X, pos.Y, true)
end
end)
)
table.insert(
conns,
exitBtn.button.Activated:Connect(function()
close(nil)
end)
)
table.insert(conns, rotateBtn.button.Activated:Connect(rotate))
table.insert(conns, cancelBtn.button.Activated:Connect(cancel))
table.insert(conns, okBtn.button.Activated:Connect(placeNow))
table.insert(
conns,
state.AttributeChanged:Connect(function(key: string)
if not isOpen then
return
end
if key == "Layout" or key == "Stage" or key == "Money" or key == "Seats" or key == "Tables" then
if key == "Layout" then
layoutNow = Info.layout(state)
end
local h = hold
-- 옮기던 물건이 없어졌으면 내려놓기
if h and not h.new and not spot(curLayout(), h.kind, h.i) then
hold = nil
clearGhost()
elseif h and not h.new and key == "Layout" then
-- 서버가 가구를 다시 지었으면 새 모형을 다시 숨기고 미리보기를 새로 만듭니다.
buildGhost(h)
end
update(true)
redraw()
elseif key == "Lang" then
redraw()
end
end)
)
return {
gui = gui,
start = start,
close = function()
close(nil)
end,
isOpen = function()
return isOpen
end,
holding = function()
return hold ~= nil
end,
onOpen = function(fn)
table.insert(openFns, fn)
end,
onClose = function(fn)
table.insert(closeFns, fn)
end,
setLayout = function(lay: Layout.Result)
scale.Scale = lay.scale
root.Size = UDim2.fromOffset(math.ceil(lay.width), math.ceil(lay.height))
local d = lay.deco
local function place(o: GuiObject, r: Layout.Rect)
o.AnchorPoint = Vector2.new(0.5, 0.5)
o.Position = UDim2.fromOffset(r.x + r.w / 2, r.y + r.h / 2)
o.Size = UDim2.fromOffset(r.w, r.h)
end
place(exitBtn.button, d.exit)
place(infoBox, d.info)
place(rotateBtn.button, d.tools[1])
place(cancelBtn.button, d.tools[2])
place(okBtn.button, d.tools[3])
end,
notify = function(key: string, args: { [string]: any }?)
if isOpen then
showMessage(Info.toast(lang(), key, args))
end
end,
destroy = function()
close(nil)
for _, c in conns do
c:Disconnect()
end
ghost:Destroy()
gui:Destroy()
end,
}
end
return Decorate