Refactor arena modes and add objective event feed
This commit is contained in:
1 parent
df6ab8efe1
commit
b87a3770a1
26 files changed
+1221
-654
No files matched your search
@@ -0,0 +1,23 @@
|
||||
--!strict
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local remote = ReplicatedStorage:WaitForChild("ArenaObjectiveEvent") :: RemoteEvent
|
||||
type Handler = (any) -> ()
|
||||
local handlers: {[string]: {Handler}} = {}
|
||||
local Router = {}
|
||||
|
||||
function Router.on(kind: string, handler: Handler): () -> ()
|
||||
local list = handlers[kind] or {}
|
||||
handlers[kind] = list
|
||||
table.insert(list, handler)
|
||||
return function()
|
||||
local index = table.find(list, handler)
|
||||
if index then table.remove(list, index) end
|
||||
end
|
||||
end
|
||||
|
||||
remote.OnClientEvent:Connect(function(kind: string, payload: any)
|
||||
if typeof(payload) ~= "table" then return end
|
||||
for _, handler in table.clone(handlers[kind] or {}) do task.spawn(handler, payload) end
|
||||
end)
|
||||
|
||||
return Router
|
||||
Reference in new issue
Block a user