Skip to content

Commit

Permalink
Added SurfaceCFrame/Soze interfaces to Boards
Browse files Browse the repository at this point in the history
  • Loading branch information
blinkybool committed Nov 1, 2023
1 parent 241fa73 commit 0f98fe4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
18 changes: 13 additions & 5 deletions lib/Client/BoardClient/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
local RunService = game:GetService("RunService")

local root = script.Parent.Parent
local Rx = require(script.Parent.Parent.Util.Rx)
local BoardUtils = require(root.BoardUtils)
local Rx = require(root.Util.Rx)
local ValueObject = require(root.Util.ValueObject)
local BoardState = require(root.BoardState)
local BaseObject = require(root.Util.BaseObject)
-- local ValueObject = require(root.Util.ValueObject)
Expand All @@ -27,8 +29,6 @@ export type BoardClient = {
Remotes: BoardRemotes.BoardRemotes,
State: BoardState.BoardState,
StateChanged: { Connect:(() -> ()) -> { Disconnect: () -> ()} },
-- SurfaceSize: { Value: Vector2 },
-- SurfaceCFrame: { Value: CFrame },

ClientState: { DrawingTasks: BoardState.DrawingTaskDict },
} & typeof(BoardClient)
Expand All @@ -46,8 +46,8 @@ function BoardClient.new(part: Part) : BoardClient
-- Fires at most once per-frame
self.StateChanged = self._maid:Add(GoodSignal.new())

-- self.SurfaceSize = self._maid:Add(ValueObject.new(BoardState.getSurfaceSizeFromPart(self._obj), "Vector2"))
-- self.SurfaceCFrame = self._maid:Add(ValueObject.new(BoardState.getSurfaceCFrameFromPart(self._obj), "CFrame"))
self.SurfaceCFrame = self._maid:Add(ValueObject.fromObservable(BoardUtils.getSurfaceCFrameFromPart(part)))
self.SurfaceSize = self._maid:Add(ValueObject.fromObservable(BoardUtils.getSurfaceSizeFromPart(part)))

-- self._maid:GiveTask(self._obj:GetPropertyChangedSignal("Size"):Connect(function()
-- self.SurfaceSize.Value = BoardState.getSurfaceSizeFromPart(self._obj)
Expand All @@ -64,6 +64,14 @@ function BoardClient:GetPart()
return self._obj
end

function BoardClient:GetSurfaceCFrame()
return self.SurfaceCFrame.Value
end

function BoardClient:GetSurfaceSize()
return self.SurfaceSize.Value
end

--[[
Connect remote event callbacks to respond to init/update/finish's of a drawing task,
as well as undo, redo, clear events.
Expand Down
11 changes: 11 additions & 0 deletions lib/Server/BoardServer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ function BoardServer.new(part: Part): BoardServer
-- When set to true, self.State should be set to a valid state
self.Loaded = self._maid:Add(ValueObject.new(false, "boolean"))

self.SurfaceCFrame = self._maid:Add(ValueObject.fromObservable(BoardUtils.getSurfaceCFrameFromPart(part)))
self.SurfaceSize = self._maid:Add(ValueObject.fromObservable(BoardUtils.getSurfaceSizeFromPart(part)))

self._persistId = part:FindFirstChild("PersistId")
if self._persistId then
assert(typeof(self._persistId) == "Instance", `Bad persistId: {self._persistId}`)
Expand Down Expand Up @@ -89,6 +92,14 @@ function BoardServer:_checkStateUpdate()
end
end

function BoardServer:GetSurfaceCFrame()
return self.SurfaceCFrame.Value
end

function BoardServer:GetSurfaceSize()
return self.SurfaceSize.Value
end

function BoardServer:GetPersistId(): number?
if self._persistId then
return self._persistId.Value
Expand Down

0 comments on commit 0f98fe4

Please sign in to comment.