2024-08-07 16:45:56 +00:00
|
|
|
--!strict
|
|
|
|
--!native
|
|
|
|
--!optimize 2
|
|
|
|
--!nolint LocalShadow
|
|
|
|
--#selene: allow(shadowing)
|
|
|
|
-- File generated by Blink v0.14.1 (https://github.com/1Axen/Blink)
|
|
|
|
-- This file is not meant to be edited
|
|
|
|
|
|
|
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
|
|
|
local RunService = game:GetService("RunService")
|
|
|
|
|
|
|
|
if not RunService:IsClient() then
|
2024-10-12 20:18:11 +00:00
|
|
|
error("Client network module can only be required from the client.")
|
2024-08-07 16:45:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
local Reliable: RemoteEvent = ReplicatedStorage:WaitForChild("BLINK_RELIABLE_REMOTE") :: RemoteEvent
|
2024-10-12 20:18:11 +00:00
|
|
|
local Unreliable: UnreliableRemoteEvent =
|
|
|
|
ReplicatedStorage:WaitForChild("BLINK_UNRELIABLE_REMOTE") :: UnreliableRemoteEvent
|
2024-08-07 16:45:56 +00:00
|
|
|
|
|
|
|
local Invocations = 0
|
|
|
|
|
|
|
|
local SendSize = 64
|
|
|
|
local SendOffset = 0
|
|
|
|
local SendCursor = 0
|
|
|
|
local SendBuffer = buffer.create(64)
|
|
|
|
local SendInstances = {}
|
|
|
|
|
|
|
|
local RecieveCursor = 0
|
|
|
|
local RecieveBuffer = buffer.create(64)
|
|
|
|
|
|
|
|
local RecieveInstances = {}
|
|
|
|
local RecieveInstanceCursor = 0
|
|
|
|
|
|
|
|
type Entry = {
|
2024-10-12 20:18:11 +00:00
|
|
|
value: any,
|
|
|
|
next: Entry?,
|
2024-08-07 16:45:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Queue = {
|
2024-10-12 20:18:11 +00:00
|
|
|
head: Entry?,
|
|
|
|
tail: Entry?,
|
2024-08-07 16:45:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type BufferSave = {
|
2024-10-12 20:18:11 +00:00
|
|
|
Size: number,
|
|
|
|
Cursor: number,
|
|
|
|
Buffer: buffer,
|
|
|
|
Instances: { Instance },
|
2024-08-07 16:45:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
local function Read(Bytes: number)
|
2024-10-12 20:18:11 +00:00
|
|
|
local Offset = RecieveCursor
|
|
|
|
RecieveCursor += Bytes
|
|
|
|
return Offset
|
2024-08-07 16:45:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
local function Save(): BufferSave
|
2024-10-12 20:18:11 +00:00
|
|
|
return {
|
|
|
|
Size = SendSize,
|
|
|
|
Cursor = SendCursor,
|
|
|
|
Buffer = SendBuffer,
|
|
|
|
Instances = SendInstances,
|
|
|
|
}
|
2024-08-07 16:45:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
local function Load(Save: BufferSave?)
|
2024-10-12 20:18:11 +00:00
|
|
|
if Save then
|
|
|
|
SendSize = Save.Size
|
|
|
|
SendCursor = Save.Cursor
|
|
|
|
SendOffset = Save.Cursor
|
|
|
|
SendBuffer = Save.Buffer
|
|
|
|
SendInstances = Save.Instances
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
SendSize = 64
|
|
|
|
SendCursor = 0
|
|
|
|
SendOffset = 0
|
|
|
|
SendBuffer = buffer.create(64)
|
|
|
|
SendInstances = {}
|
2024-08-07 16:45:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
local function Invoke()
|
2024-10-12 20:18:11 +00:00
|
|
|
if Invocations == 255 then
|
|
|
|
Invocations = 0
|
|
|
|
end
|
2024-08-07 16:45:56 +00:00
|
|
|
|
2024-10-12 20:18:11 +00:00
|
|
|
local Invocation = Invocations
|
|
|
|
Invocations += 1
|
|
|
|
return Invocation
|
2024-08-07 16:45:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
local function Allocate(Bytes: number)
|
2024-10-12 20:18:11 +00:00
|
|
|
local InUse = (SendCursor + Bytes)
|
|
|
|
if InUse > SendSize then
|
|
|
|
--> Avoid resizing the buffer for every write
|
|
|
|
while InUse > SendSize do
|
|
|
|
SendSize *= 1.5
|
|
|
|
end
|
|
|
|
|
|
|
|
local Buffer = buffer.create(SendSize)
|
|
|
|
buffer.copy(Buffer, 0, SendBuffer, 0, SendCursor)
|
|
|
|
SendBuffer = Buffer
|
|
|
|
end
|
|
|
|
|
|
|
|
SendOffset = SendCursor
|
|
|
|
SendCursor += Bytes
|
|
|
|
|
|
|
|
return SendOffset
|
2024-08-07 16:45:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
local function CreateQueue(): Queue
|
2024-10-12 20:18:11 +00:00
|
|
|
return {
|
|
|
|
head = nil,
|
|
|
|
tail = nil,
|
|
|
|
}
|
2024-08-07 16:45:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
local function Pop(queue: Queue): any
|
2024-10-12 20:18:11 +00:00
|
|
|
local head = queue.head
|
|
|
|
if head == nil then
|
|
|
|
return
|
|
|
|
end
|
2024-08-07 16:45:56 +00:00
|
|
|
|
2024-10-12 20:18:11 +00:00
|
|
|
queue.head = head.next
|
|
|
|
return head.value
|
2024-08-07 16:45:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
local function Push(queue: Queue, value: any)
|
2024-10-12 20:18:11 +00:00
|
|
|
local entry: Entry = {
|
|
|
|
value = value,
|
|
|
|
next = nil,
|
|
|
|
}
|
2024-08-07 16:45:56 +00:00
|
|
|
|
2024-10-12 20:18:11 +00:00
|
|
|
if queue.tail ~= nil then
|
|
|
|
queue.tail.next = entry
|
|
|
|
end
|
2024-08-07 16:45:56 +00:00
|
|
|
|
2024-10-12 20:18:11 +00:00
|
|
|
queue.tail = entry
|
2024-08-07 16:45:56 +00:00
|
|
|
|
2024-10-12 20:18:11 +00:00
|
|
|
if queue.head == nil then
|
|
|
|
queue.head = entry
|
|
|
|
end
|
2024-08-07 16:45:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
local Types = {}
|
|
|
|
local Calls = table.create(256)
|
|
|
|
|
|
|
|
local Events: any = {
|
2024-10-12 20:18:11 +00:00
|
|
|
Reliable = table.create(256),
|
|
|
|
Unreliable = table.create(256),
|
2024-08-07 16:45:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
local Queue: any = {
|
2024-10-12 20:18:11 +00:00
|
|
|
Reliable = table.create(256),
|
|
|
|
Unreliable = table.create(256),
|
2024-08-07 16:45:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Queue.Unreliable[0] = CreateQueue()
|
|
|
|
Queue.Reliable[0] = CreateQueue()
|
|
|
|
|
|
|
|
function Types.ReadEVENT_UpdateTransform(): (number, CFrame)
|
|
|
|
-- Read BLOCK: 32 bytes
|
|
|
|
local BLOCK_START = Read(32)
|
|
|
|
local Value1 = buffer.readf64(RecieveBuffer, BLOCK_START + 0)
|
|
|
|
local X = buffer.readf32(RecieveBuffer, BLOCK_START + 8)
|
|
|
|
local Y = buffer.readf32(RecieveBuffer, BLOCK_START + 12)
|
|
|
|
local Z = buffer.readf32(RecieveBuffer, BLOCK_START + 16)
|
|
|
|
local Position = Vector3.new(X, Y, Z)
|
|
|
|
local rX = buffer.readf32(RecieveBuffer, BLOCK_START + 20)
|
|
|
|
local rY = buffer.readf32(RecieveBuffer, BLOCK_START + 24)
|
|
|
|
local rZ = buffer.readf32(RecieveBuffer, BLOCK_START + 28)
|
|
|
|
local Value2 = CFrame.new(Position) * CFrame.fromOrientation(rX, rY, rZ)
|
|
|
|
return Value1, Value2
|
|
|
|
end
|
|
|
|
|
|
|
|
function Types.WriteEVENT_UpdateTransform(Value1: number, Value2: CFrame): ()
|
|
|
|
-- Allocate BLOCK: 33 bytes
|
|
|
|
local BLOCK_START = Allocate(33)
|
|
|
|
buffer.writeu8(SendBuffer, BLOCK_START + 0, 0)
|
|
|
|
buffer.writef64(SendBuffer, BLOCK_START + 1, Value1)
|
|
|
|
local Vector = Value2.Position
|
|
|
|
buffer.writef32(SendBuffer, BLOCK_START + 9, Vector.X)
|
|
|
|
buffer.writef32(SendBuffer, BLOCK_START + 13, Vector.Y)
|
|
|
|
buffer.writef32(SendBuffer, BLOCK_START + 17, Vector.Z)
|
|
|
|
local rX, rY, rZ = Value2:ToOrientation()
|
|
|
|
buffer.writef32(SendBuffer, BLOCK_START + 21, rX)
|
|
|
|
buffer.writef32(SendBuffer, BLOCK_START + 25, rY)
|
|
|
|
buffer.writef32(SendBuffer, BLOCK_START + 29, rZ)
|
|
|
|
end
|
|
|
|
|
|
|
|
function Types.ReadEVENT_SpawnMob(): (number, CFrame, number)
|
|
|
|
-- Read BLOCK: 33 bytes
|
|
|
|
local BLOCK_START = Read(33)
|
|
|
|
local Value1 = buffer.readf64(RecieveBuffer, BLOCK_START + 0)
|
|
|
|
local X = buffer.readf32(RecieveBuffer, BLOCK_START + 8)
|
|
|
|
local Y = buffer.readf32(RecieveBuffer, BLOCK_START + 12)
|
|
|
|
local Z = buffer.readf32(RecieveBuffer, BLOCK_START + 16)
|
|
|
|
local Position = Vector3.new(X, Y, Z)
|
|
|
|
local rX = buffer.readf32(RecieveBuffer, BLOCK_START + 20)
|
|
|
|
local rY = buffer.readf32(RecieveBuffer, BLOCK_START + 24)
|
|
|
|
local rZ = buffer.readf32(RecieveBuffer, BLOCK_START + 28)
|
|
|
|
local Value2 = CFrame.new(Position) * CFrame.fromOrientation(rX, rY, rZ)
|
|
|
|
local Value3 = buffer.readu8(RecieveBuffer, BLOCK_START + 32)
|
|
|
|
return Value1, Value2, Value3
|
|
|
|
end
|
|
|
|
|
|
|
|
function Types.WriteEVENT_SpawnMob(Value1: number, Value2: CFrame, Value3: number): ()
|
|
|
|
-- Allocate BLOCK: 34 bytes
|
|
|
|
local BLOCK_START = Allocate(34)
|
|
|
|
buffer.writeu8(SendBuffer, BLOCK_START + 0, 0)
|
|
|
|
buffer.writef64(SendBuffer, BLOCK_START + 1, Value1)
|
|
|
|
local Vector = Value2.Position
|
|
|
|
buffer.writef32(SendBuffer, BLOCK_START + 9, Vector.X)
|
|
|
|
buffer.writef32(SendBuffer, BLOCK_START + 13, Vector.Y)
|
|
|
|
buffer.writef32(SendBuffer, BLOCK_START + 17, Vector.Z)
|
|
|
|
local rX, rY, rZ = Value2:ToOrientation()
|
|
|
|
buffer.writef32(SendBuffer, BLOCK_START + 21, rX)
|
|
|
|
buffer.writef32(SendBuffer, BLOCK_START + 25, rY)
|
|
|
|
buffer.writef32(SendBuffer, BLOCK_START + 29, rZ)
|
|
|
|
buffer.writeu8(SendBuffer, BLOCK_START + 33, Value3)
|
|
|
|
end
|
|
|
|
|
|
|
|
local function StepReplication()
|
2024-10-12 20:18:11 +00:00
|
|
|
if SendCursor <= 0 then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local Buffer = buffer.create(SendCursor)
|
|
|
|
buffer.copy(Buffer, 0, SendBuffer, 0, SendCursor)
|
|
|
|
Reliable:FireServer(Buffer, SendInstances)
|
|
|
|
|
|
|
|
SendSize = 64
|
|
|
|
SendCursor = 0
|
|
|
|
SendOffset = 0
|
|
|
|
SendBuffer = buffer.create(64)
|
|
|
|
table.clear(SendInstances)
|
2024-08-07 16:45:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
local Elapsed = 0
|
|
|
|
RunService.Heartbeat:Connect(function(DeltaTime: number)
|
|
|
|
Elapsed += DeltaTime
|
|
|
|
if Elapsed >= (1 / 61) then
|
|
|
|
Elapsed -= (1 / 61)
|
|
|
|
StepReplication()
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
2024-10-12 20:18:11 +00:00
|
|
|
Reliable.OnClientEvent:Connect(function(Buffer: buffer, Instances: { Instance })
|
2024-08-07 16:45:56 +00:00
|
|
|
RecieveCursor = 0
|
|
|
|
RecieveBuffer = Buffer
|
|
|
|
RecieveInstances = Instances
|
|
|
|
RecieveInstanceCursor = 0
|
|
|
|
local Size = buffer.len(RecieveBuffer)
|
2024-10-12 20:18:11 +00:00
|
|
|
while RecieveCursor < Size do
|
2024-08-07 16:45:56 +00:00
|
|
|
-- Read BLOCK: 1 bytes
|
|
|
|
local BLOCK_START = Read(1)
|
|
|
|
local Index = buffer.readu8(RecieveBuffer, BLOCK_START + 0)
|
|
|
|
if Index == 0 then
|
|
|
|
Push(Queue.Reliable[0], table.pack(Types.ReadEVENT_SpawnMob()))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
2024-10-12 20:18:11 +00:00
|
|
|
Unreliable.OnClientEvent:Connect(function(Buffer: buffer, Instances: { Instance })
|
2024-08-07 16:45:56 +00:00
|
|
|
RecieveCursor = 0
|
|
|
|
RecieveBuffer = Buffer
|
|
|
|
RecieveInstances = Instances
|
|
|
|
RecieveInstanceCursor = 0
|
|
|
|
local Size = buffer.len(RecieveBuffer)
|
2024-10-12 20:18:11 +00:00
|
|
|
while RecieveCursor < Size do
|
2024-08-07 16:45:56 +00:00
|
|
|
-- Read BLOCK: 1 bytes
|
|
|
|
local BLOCK_START = Read(1)
|
|
|
|
local Index = buffer.readu8(RecieveBuffer, BLOCK_START + 0)
|
|
|
|
if Index == 0 then
|
|
|
|
Push(Queue.Unreliable[0], table.pack(Types.ReadEVENT_UpdateTransform()))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
return {
|
|
|
|
StepReplication = StepReplication,
|
|
|
|
|
|
|
|
UpdateTransform = {
|
|
|
|
Iter = function(): () -> (number, number, CFrame)
|
|
|
|
local index = 0
|
|
|
|
local queue = Queue.Unreliable[0]
|
2024-10-12 20:18:11 +00:00
|
|
|
return function(): (number, number, CFrame)
|
2024-08-07 16:45:56 +00:00
|
|
|
index += 1
|
|
|
|
local arguments = Pop(queue)
|
|
|
|
if arguments ~= nil then
|
|
|
|
return index, unpack(arguments, 1, arguments.n)
|
|
|
|
end
|
2024-10-12 20:18:11 +00:00
|
|
|
return
|
2024-08-07 16:45:56 +00:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
Next = function(): () -> (number, number, CFrame)
|
|
|
|
local index = 0
|
|
|
|
local queue = Queue.Unreliable[0]
|
2024-10-12 20:18:11 +00:00
|
|
|
return function(): (number, number, CFrame)
|
2024-08-07 16:45:56 +00:00
|
|
|
index += 1
|
|
|
|
local arguments = Pop(queue)
|
|
|
|
if arguments ~= nil then
|
|
|
|
return index, unpack(arguments, 1, arguments.n)
|
|
|
|
end
|
2024-10-12 20:18:11 +00:00
|
|
|
return
|
2024-08-07 16:45:56 +00:00
|
|
|
end
|
2024-10-12 20:18:11 +00:00
|
|
|
end,
|
2024-08-07 16:45:56 +00:00
|
|
|
},
|
|
|
|
SpawnMob = {
|
|
|
|
Iter = function(): () -> (number, number, CFrame, number)
|
|
|
|
local index = 0
|
|
|
|
local queue = Queue.Reliable[0]
|
2024-10-12 20:18:11 +00:00
|
|
|
return function(): (number, number, CFrame, number)
|
2024-08-07 16:45:56 +00:00
|
|
|
index += 1
|
|
|
|
local arguments = Pop(queue)
|
|
|
|
if arguments ~= nil then
|
|
|
|
return index, unpack(arguments, 1, arguments.n)
|
|
|
|
end
|
2024-10-12 20:18:11 +00:00
|
|
|
return
|
2024-08-07 16:45:56 +00:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
Next = function(): () -> (number, number, CFrame, number)
|
|
|
|
local index = 0
|
|
|
|
local queue = Queue.Reliable[0]
|
2024-10-12 20:18:11 +00:00
|
|
|
return function(): (number, number, CFrame, number)
|
2024-08-07 16:45:56 +00:00
|
|
|
index += 1
|
|
|
|
local arguments = Pop(queue)
|
|
|
|
if arguments ~= nil then
|
|
|
|
return index, unpack(arguments, 1, arguments.n)
|
|
|
|
end
|
2024-10-12 20:18:11 +00:00
|
|
|
return
|
2024-08-07 16:45:56 +00:00
|
|
|
end
|
2024-10-12 20:18:11 +00:00
|
|
|
end,
|
2024-08-07 16:45:56 +00:00
|
|
|
},
|
2024-10-12 20:18:11 +00:00
|
|
|
}
|