This commit is contained in:
Nikita Kruglickiy
2021-09-19 22:34:23 +06:00
parent cb9c7b73bb
commit a47d2b43f7
17 changed files with 417 additions and 47 deletions

View File

@@ -17,17 +17,17 @@ function MeshBuilder:initialize(link, modelPlaceholder)
self._firstTimeSended = false
net.receive("obj_parsed", function(len, ply)
if DEBUG_MODE then
print(string.format("%s parsed the .obj", ply:getName()))
end
net.start("obj_parsed")
net.writeEntity(ply)
net.send(owner())
self:onPlayerParsedObj(ply)
end)
net.receive("initialized", function(len, ply)
if DEBUG_MODE then
print(string.format("%s initialized", ply:getName()))
end
net.start("initialized")
net.writeEntity(ply)
net.send(owner())
table.insert(self._playersWithAccess, ply)
@@ -74,10 +74,6 @@ function MeshBuilder:initialize(link, modelPlaceholder)
self:onObjectLoaded(objData)
for object in string.gmatch(objData, "^?\n?o%s([%w_%.%-]+)") do
table.insert(self._objectsNames, object)
end
self:onObjectParsed(self._objectsNames)
return 2
@@ -93,6 +89,7 @@ function MeshBuilder:_sendObjects(target)
for _, v in pairs(self._objectsToSend) do
net.writeBit(1)
net.writeString(v.name)
net.writeTable(type(v.mat) == "table" and v.mat or { basetexture = tostring(v.mat) })
net.writeEntity(v.holo)
end
net.writeBit(0)
@@ -116,14 +113,13 @@ function MeshBuilder:build(name, pos, ang, scale, color, mat, parent, relativeTo
local holo = holograms.create(pos, ang, self.modelPlaceholder, scale)
holo:setColor(color)
holo:setMaterial(mat)
if isValid(parent) then
holo:setParent(parent)
end
table.insert(self._objects, {name = name, holo = holo})
table.insert(self._objects, {name = name, mat = mat, holo = holo})
return holo
end