local O=.05 local c=require("\064\115\104\097\114\101\100\047\102\114\097\109\101")local M=require("\064\115\104\097\114\101\100\047\105\110\116\101\114\112\111\108\097\116\105\111\110")local y=require("\064\099\108\105\101\110\116\047\099\104\097\114\097\099\116\101\114\115")local w=require("\064\115\104\097\114\101\100\047\099\111\109\112\111\110\101\110\116\115")local J=require("\064\115\104\097\114\101\100\047\119\111\114\108\100")return c.on("\112\104\121\115\105\099\115",function()local c=M.at(os.clock()-O)if not c then return warn("\110\111 \105\110\116\101\114\112\111\108\097\116\105\111\110 \114\101\115\117\108\116\044 \102\114\111\109 \101\120\116\114\097\112\111\108\097\116\105\111\110")end for O,c in c do local M=y.from_id(O)if not M then continue end if J:has(M,w.SimulatedRig)then continue end J:set(M,w.Transform,c)end end)
local RENDER_BUFFER = 50 / 1000 -- 50ms

local frame = require("@shared/frame")
local interpolation = require("@shared/interpolation")
local characters = require("@client/characters")
local components = require("@shared/components")
local world = require("@shared/world")

return frame.on("physics", function()
	local interpolated_transforms = interpolation.at(os.clock() - RENDER_BUFFER)
	if not interpolated_transforms then
		return warn("no interpolation result, from extrapolation")
	end

	for network_id, transform in interpolated_transforms do
		local ent = characters.from_id(network_id)
		if not ent then
			continue
		end

		if world:has(ent, components.SimulatedRig) then
			continue
		end

		world:set(ent, components.Transform, transform)
	end
end)
