Skip to content

Commit

Permalink
Added client streaming
Browse files Browse the repository at this point in the history
  • Loading branch information
blinkybool committed Aug 26, 2023
1 parent 1296eaf commit 3a4843e
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 11 deletions.
59 changes: 53 additions & 6 deletions lib/Client/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,61 @@ function Client:Start()
self.BoardAdded:Fire(board)
end

-- Bind regular metaboards
-- Bind regular metaboards with streaming radius (or based on chosen board Ancestor)

local boardAncestorValue = ReplicatedStorage:FindFirstChild("BoardAncestor")
local ATTACHED_RADIUS = 64
local ROAMING_STREAM_IN_RADIUS = 128
local ROAMING_STREAM_OUT_RADIUS = 256

for _, instance in ipairs(CollectionService:GetTagged(Config.BoardTag)) do

task.spawn(bindInstanceAsync, instance)
end
if typeof(boardAncestorValue) == "Instance" and boardAncestorValue:IsA("ObjectValue") then
task.spawn(function()
while true do
task.wait(2)

CollectionService:GetInstanceAddedSignal(Config.BoardTag):Connect(bindInstanceAsync)
local character = Players.LocalPlayer.Character
if not character or not character.PrimaryPart then
return
end
for _, instance in ipairs(CollectionService:GetTagged(Config.BoardTag)) do
if boardAncestorValue.Value then
if instance:IsDescendantOf(boardAncestorValue.Value) then
if not self.Boards[instance] then
task.spawn(bindInstanceAsync, instance)
end
--selene:allow(if_same_then_else)
elseif (instance.Position - character:GetPivot().Position).Magnitude < ATTACHED_RADIUS then
if not self.Boards[instance] then
task.spawn(bindInstanceAsync, instance)
end
else
if self.Boards[instance] then
task.spawn(onRemoved, instance)
end
end
else -- Just stream based on radius
if self.Boards[instance] and (instance.Position - character:GetPivot().Position).Magnitude >= ROAMING_STREAM_OUT_RADIUS then
task.spawn(onRemoved, instance)
elseif not self.Boards[instance] and (instance.Position - character:GetPivot().Position).Magnitude < ROAMING_STREAM_IN_RADIUS then
task.spawn(bindInstanceAsync, instance)
end

end
end
end
end)

else
if boardAncestorValue ~= nil then
warn("Bad BoardAncestor ObjectValue")
end
CollectionService:GetInstanceAddedSignal(Config.BoardTag):Connect(bindInstanceAsync)

for _, instance in CollectionService:GetTagged(Config.BoardTag) do
task.spawn(bindInstanceAsync, instance)
end
end

CollectionService:GetInstanceRemovedSignal(Config.BoardTag):Connect(onRemoved)
end

Expand Down
10 changes: 5 additions & 5 deletions wally.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ name = "blinkybool/feather"
version = "0.1.0"
dependencies = []

[[package]]
name = "blinkybool/testpackage"
version = "0.1.3-rc.5"
dependencies = [["Feather", "blinkybool/[email protected]"], ["GoodSignal", "stravant/[email protected]"], ["Promise", "evaera/[email protected]"], ["Roact", "roblox/[email protected]"], ["Sift", "csqrl/[email protected]"]]

[[package]]
name = "csqrl/sift"
version = "0.0.4"
Expand All @@ -22,6 +17,11 @@ name = "evaera/promise"
version = "4.0.0"
dependencies = []

[[package]]
name = "metauni/metaboard"
version = "1.4.1"
dependencies = [["Feather", "blinkybool/[email protected]"], ["GoodSignal", "stravant/[email protected]"], ["Promise", "evaera/[email protected]"], ["Roact", "roblox/[email protected]"], ["Sift", "csqrl/[email protected]"]]

[[package]]
name = "roblox/roact"
version = "1.4.4"
Expand Down

0 comments on commit 3a4843e

Please sign in to comment.