mirror of
https://github.com/dvdvideo1234/TrackAssemblyTool.git
synced 2025-03-04 03:13:32 -05:00
Update: Ghost count upper limit to 2500 (#53)
Fixed: Transform POA attachment extraction crashing the game Fixed: Ghosts not being removed when count is changed Added: Current ghosts count control to tool panel Added: Duplication flag `DoNotDuplicate = true` to prevent area-duplication Added: Max ghosts count Added: Maximum ghosts count control to admin panel Changed: Bump the remove time frame to 1s Removed: Ghosting count upper limit Renamed: Callback internals Update: Ghost array count calculation Update: Ghost count upper limit to 2500 Utilize: Library function `SafeRemoveEntityDelayed`
This commit is contained in:
parent
f9a5d3f873
commit
3c39afa095
@ -85,7 +85,7 @@ local asmlib = trackasmlib; if(not asmlib) then -- Module present
|
||||
------------ CONFIGURE ASMLIB ------------
|
||||
|
||||
asmlib.InitBase("track","assembly")
|
||||
asmlib.SetOpVar("TOOL_VERSION","8.739")
|
||||
asmlib.SetOpVar("TOOL_VERSION","8.740")
|
||||
asmlib.SetIndexes("V" ,1,2,3)
|
||||
asmlib.SetIndexes("A" ,1,2,3)
|
||||
asmlib.SetIndexes("WV",1,2,3)
|
||||
@ -130,7 +130,7 @@ asmlib.SetBorder(gsToolPrefL.."enctxmenu", 0, 1)
|
||||
asmlib.SetBorder(gsToolPrefL.."endsvlock", 0, 1)
|
||||
asmlib.SetBorder(gsToolPrefL.."enwiremod", 0, 1)
|
||||
asmlib.SetBorder(gsToolPrefL.."enmultask", 0, 1)
|
||||
asmlib.SetBorder(gsToolPrefL.."ghostcnt" , 0, 200)
|
||||
asmlib.SetBorder(gsToolPrefL.."ghostcnt" , 0)
|
||||
asmlib.SetBorder(gsToolPrefL.."angsnap" , 0, gnMaxRot)
|
||||
asmlib.SetBorder(gsToolPrefL.."incsnpang", 0, gnMaxRot)
|
||||
asmlib.SetBorder(gsToolPrefL.."incsnplin", 0, 250)
|
||||
@ -144,6 +144,7 @@ asmlib.SetBorder(gsToolPrefL.."maxmass" , 1)
|
||||
asmlib.SetBorder(gsToolPrefL.."maxmenupr", 0, 10)
|
||||
asmlib.SetBorder(gsToolPrefL.."maxstatts", 1, 10)
|
||||
asmlib.SetBorder(gsToolPrefL.."maxstcnt" , 1)
|
||||
asmlib.SetBorder(gsToolPrefL.."maxghcnt" , 1)
|
||||
asmlib.SetBorder(gsToolPrefL.."maxtrmarg", 0, 1)
|
||||
asmlib.SetBorder(gsToolPrefL.."maxspmarg", -100, 100)
|
||||
asmlib.SetBorder(gsToolPrefL.."sizeucs" , 0, 50)
|
||||
@ -176,6 +177,7 @@ asmlib.MakeAsmConvar("maxlinear", 5000 , nil, gnServerControled, "Maximum linea
|
||||
asmlib.MakeAsmConvar("maxforce" , 100000, nil, gnServerControled, "Maximum force limit when creating welds")
|
||||
asmlib.MakeAsmConvar("maxactrad", 200 , nil, gnServerControled, "Maximum active radius to search for a point ID")
|
||||
asmlib.MakeAsmConvar("maxstcnt" , 200 , nil, gnServerControled, "Maximum spawned pieces in stacking mode")
|
||||
asmlib.MakeAsmConvar("maxghcnt" , 1500 , nil, gnServerControled, "Maximum ghost pieces being spawned by client")
|
||||
asmlib.MakeAsmConvar("enwiremod", 1 , nil, gnServerControled, "Toggle the wire extension on/off server side")
|
||||
asmlib.MakeAsmConvar("enmultask", 1 , nil, gnServerControled, "Toggle the spawn multitasking on/off server side")
|
||||
asmlib.MakeAsmConvar("enctxmenu", 1 , nil, gnServerControled, "Toggle the context menu on/off in general")
|
||||
@ -237,37 +239,37 @@ local conWorkMode = asmlib.GetContainer("WORK_MODE")
|
||||
------------ CALLBACKS ------------
|
||||
|
||||
local conCallBack = asmlib.GetContainer("CALLBAC_FUNC")
|
||||
conCallBack:Push({"maxtrmarg", function(sVar, vOld, vNew)
|
||||
local nM = (tonumber(vNew) or 0); nM = ((nM > 0) and nM or 0)
|
||||
conCallBack:Push({"maxtrmarg", function(sV, vO, vN)
|
||||
local nM = (tonumber(vN) or 0); nM = ((nM > 0) and nM or 0)
|
||||
asmlib.SetOpVar("TRACE_MARGIN", nM)
|
||||
end})
|
||||
conCallBack:Push({"maxspmarg", function(sVar, vOld, vNew)
|
||||
local nM = (tonumber(vNew) or 0)
|
||||
conCallBack:Push({"maxspmarg", function(sV, vO, vN)
|
||||
local nM = (tonumber(vN) or 0)
|
||||
asmlib.SetOpVar("SPAWN_MARGIN", nM)
|
||||
end})
|
||||
conCallBack:Push({"logsmax", function(sVar, vOld, vNew)
|
||||
local nM = asmlib.BorderValue((tonumber(vNew) or 0), "non-neg")
|
||||
conCallBack:Push({"logsmax", function(sV, vO, vN)
|
||||
local nM = asmlib.BorderValue((tonumber(vN) or 0), "non-neg")
|
||||
asmlib.SetOpVar("LOG_MAXLOGS", nM)
|
||||
end})
|
||||
conCallBack:Push({"logfile", function(sVar, vOld, vNew)
|
||||
asmlib.IsFlag("en_logging_file", tobool(vNew))
|
||||
conCallBack:Push({"logfile", function(sV, vO, vN)
|
||||
asmlib.IsFlag("en_logging_file", tobool(vN))
|
||||
end})
|
||||
conCallBack:Push({"endsvlock", function(sVar, vOld, vNew)
|
||||
asmlib.IsFlag("en_dsv_datalock", tobool(vNew))
|
||||
conCallBack:Push({"endsvlock", function(sV, vO, vN)
|
||||
asmlib.IsFlag("en_dsv_datalock", tobool(vN))
|
||||
end})
|
||||
conCallBack:Push({"timermode", function(sVar, vOld, vNew)
|
||||
local arTim = gsSymDir:Explode(vNew)
|
||||
conCallBack:Push({"timermode", function(sV, vO, vN)
|
||||
local arTim = gsSymDir:Explode(vN)
|
||||
local mkTab, ID = asmlib.GetBuilderID(1), 1
|
||||
while(mkTab) do local sTim = arTim[ID]
|
||||
local defTab = mkTab:GetDefinition(); mkTab:TimerSetup(sTim)
|
||||
asmlib.LogInstance("Timer apply "..asmlib.GetReport2(defTab.Nick,sTim),gtInitLogs)
|
||||
ID = ID + 1; mkTab = asmlib.GetBuilderID(ID) -- Next table on the list
|
||||
end; asmlib.LogInstance("Timer update "..asmlib.GetReport(vNew),gtInitLogs)
|
||||
end; asmlib.LogInstance("Timer update "..asmlib.GetReport(vN),gtInitLogs)
|
||||
end})
|
||||
conCallBack:Push({"dtmessage", function(sVar, vOld, vNew)
|
||||
conCallBack:Push({"dtmessage", function(sV, vO, vN)
|
||||
if(SERVER) then
|
||||
local sK = gsToolPrefL.."dtmessage"
|
||||
local nD = (tonumber(vNew) or 0)
|
||||
local nD = (tonumber(vN) or 0)
|
||||
nD = asmlib.BorderValue(nD, sK)
|
||||
asmlib.SetOpVar("MSDELTA_SEND", nD)
|
||||
end
|
||||
|
@ -74,6 +74,7 @@ local getmetatable = getmetatable
|
||||
local setmetatable = setmetatable
|
||||
local collectgarbage = collectgarbage
|
||||
local LocalToWorld = LocalToWorld
|
||||
local SafeRemoveEntityDelayed = SafeRemoveEntityDelayed
|
||||
local osClock = os and os.clock
|
||||
local osDate = os and os.date
|
||||
local bitBand = bit and bit.band
|
||||
@ -715,6 +716,7 @@ function InitBase(sName, sPurp)
|
||||
SetOpVar("TIME_STAMP",Time())
|
||||
SetOpVar("TIME_INIT",Time())
|
||||
SetOpVar("DELAY_ACTION",0.01)
|
||||
SetOpVar("DELAY_REMOVE",0.5)
|
||||
SetOpVar("MAX_ROTATION",360)
|
||||
SetOpVar("ANG_ZERO",Angle())
|
||||
SetOpVar("VEC_ZERO",Vector())
|
||||
@ -2098,6 +2100,7 @@ local function MakeEntityNone(sModel, vPos, aAng) local eNone
|
||||
local vPos = Vector(vPos or GetOpVar("VEC_ZERO"))
|
||||
local aAng = Angle(aAng or GetOpVar("ANG_ZERO"))
|
||||
eNone:SetPos(vPos); eNone:SetAngles(aAng)
|
||||
eNone.DoNotDuplicate = true -- Disable duping
|
||||
eNone:SetCollisionGroup(COLLISION_GROUP_NONE)
|
||||
eNone:SetSolid(SOLID_NONE); eNone:SetMoveType(MOVETYPE_NONE)
|
||||
eNone:SetNotSolid(true); eNone:SetNoDraw(true); eNone:SetModel(sModel)
|
||||
@ -2186,11 +2189,13 @@ function DecodePOA(sStr)
|
||||
end; return arPOA -- Return the converted string to POA
|
||||
end
|
||||
|
||||
function GetTransformOA(sModel,sKey)
|
||||
function GetTransformOA(sModel, sKey)
|
||||
if(not IsString(sModel)) then
|
||||
LogInstance("Model mismatch "..GetReport(sKey)); return nil end
|
||||
LogInstance("Model mismatch "..GetReport2(sModel, sKey)); return nil end
|
||||
if(not fileExists(sModel, "GAME")) then
|
||||
LogInstance("Model missing "..GetReport2(sModel, sKey)); return nil end
|
||||
if(not IsString(sKey)) then
|
||||
LogInstance("Key mismatch "..GetReport(sKey)..sModel); return nil end
|
||||
LogInstance("Key mismatch "..GetReport2(sModel, sKey)); return nil end
|
||||
local ePiece = GetOpVar("ENTITY_TRANSFORMPOA")
|
||||
if(ePiece and ePiece:IsValid()) then -- There is basis entity then update and extract
|
||||
if(ePiece:GetModel() ~= sModel) then ePiece:SetModel(sModel)
|
||||
@ -5000,17 +5005,9 @@ function ClearGhosts(vSiz, bCol)
|
||||
local tGho = GetOpVar("ARRAY_GHOST")
|
||||
if(not IsHere(tGho)) then return true end
|
||||
local iSiz = mathCeil(tonumber(vSiz) or tGho.Size)
|
||||
local nDer = GetOpVar("DELAY_ACTION")
|
||||
local nDer = GetOpVar("DELAY_REMOVE")
|
||||
for iD = 1, iSiz do local eGho = tGho[iD]
|
||||
if(eGho and eGho:IsValid()) then
|
||||
timerSimple(nDer, function()
|
||||
if(eGho and eGho:IsValid()) then
|
||||
eGho:SetNoDraw(true)
|
||||
eGho:Remove()
|
||||
tGho[iD] = nil
|
||||
end
|
||||
end)
|
||||
end
|
||||
SafeRemoveEntityDelayed(eGho, nDer)
|
||||
end; tGho.Size, tGho.Slot = 0, GetOpVar("MISS_NOMD")
|
||||
if(bCol) then collectgarbage() end; return true
|
||||
end
|
||||
@ -5081,11 +5078,10 @@ function MakeGhosts(nCnt, sModel) -- Only he's not a shadow, he's a green ghost!
|
||||
LogInstance("Invalid ["..iD.."]"..sModel); return false end
|
||||
end; iD = iD + 1 -- Fade all the ghosts and refresh these that must be drawn
|
||||
end -- Remove all others that must not be drawn to save memory
|
||||
for iK = iD, tGho.Size do -- Executes only when (nCnt <= tGho.Size)
|
||||
local eGho = tGho[iD] -- Read the current ghosted entity
|
||||
if(eGho and eGho:IsValid()) then -- When valid remove it
|
||||
eGho:SetNoDraw(true); eGho:Remove() -- Stop drawing and remove
|
||||
end; eGho = nil; tGho[iD] = nil -- Make sure the item is NIL
|
||||
local nDer = GetOpVar("DELAY_REMOVE")
|
||||
for iR = iD, tGho.Size do -- Executes only when (nCnt <= tGho.Size)
|
||||
local eGho = tGho[iR] -- Read the current ghosted entity
|
||||
SafeRemoveEntityDelayed(eGho, nDer) -- Make sure the item is NIL
|
||||
end; tGho.Size, tGho.Slot = nCnt, sModel; return true
|
||||
end
|
||||
|
||||
|
@ -320,7 +320,7 @@ function TOOL:GetGravity()
|
||||
end
|
||||
|
||||
function TOOL:GetGhostsCount()
|
||||
return mathClamp(self:GetClientNumber("ghostcnt", 0), 0, asmlib.GetAsmConvar("maxstcnt", "INT"))
|
||||
return mathClamp(self:GetClientNumber("ghostcnt", 0), 0, asmlib.GetAsmConvar("maxghcnt", "INT"))
|
||||
end
|
||||
|
||||
function TOOL:GetUpSpawnAnchor()
|
||||
@ -556,15 +556,12 @@ function TOOL:GetGhostsDepth()
|
||||
local stackcnt = self:GetStackCount()
|
||||
if(workmode == 1) then -- Defined by the stack count otherwise 1
|
||||
return mathMin(ghostcnt, mathMax(stackcnt, 1))
|
||||
elseif(workmode == 2) then -- Put second value 1 here
|
||||
return mathMin(ghostcnt, 1) -- to be able to disable it
|
||||
elseif(workmode == 3 or workmode == 5) then -- Track interpolation curving
|
||||
local nC = mathMin(mathMax(stackcnt, 1), ghostcnt)
|
||||
return (stackcnt > 0 and nC or ghostcnt)
|
||||
elseif(workmode == 4) then -- Put second value 1 here
|
||||
local tArr = self:GetFlipOver() -- to be used in no array
|
||||
local nLen = (tArr and #tArr or 1) -- flip-over mode snapping
|
||||
return mathMin(ghostcnt, nLen) -- Use ghosts count to disable it
|
||||
elseif(workmode == 2) then -- Intersection. Force lower bound here
|
||||
return mathMin(ghostcnt, 1) -- Force lower bound one otherwise ghosts
|
||||
elseif(workmode == 3 or workmode == 5) then -- Track curving interpolation
|
||||
return (stackcnt > 0 and mathMin(stackcnt, ghostcnt) or ghostcnt)
|
||||
elseif(workmode == 4) then local tArr = self:GetFlipOver() -- Read flip array
|
||||
return mathMin(ghostcnt, (tArr and #tArr or 1)) -- Disable via ghosts count
|
||||
end; return 0
|
||||
end
|
||||
|
||||
@ -2440,8 +2437,8 @@ function TOOL.BuildCPanel(CPanel)
|
||||
end
|
||||
|
||||
cvarsRemoveChangeCallback(sName, sName..sCall)
|
||||
cvarsAddChangeCallback(sName, function(sVar, vOld, vNew)
|
||||
pComboPhysName:SetValue(vNew) end, sName..sCall);
|
||||
cvarsAddChangeCallback(sName, function(sV, vO, vN)
|
||||
pComboPhysName:SetValue(vN) end, sName..sCall);
|
||||
asmlib.LogTable(cqProperty, "Property", sLog)
|
||||
|
||||
-- http://wiki.garrysmod.com/page/Category:DTextEntry
|
||||
@ -2454,11 +2451,12 @@ function TOOL.BuildCPanel(CPanel)
|
||||
|
||||
local sName = asmlib.GetAsmConvar("bgskids", "NAM")
|
||||
cvarsRemoveChangeCallback(sName, sName..sCall)
|
||||
cvarsAddChangeCallback(sName, function(sVar, vOld, vNew)
|
||||
pText:SetText(vNew); pText:SetValue(vNew) end, sName..sCall);
|
||||
cvarsAddChangeCallback(sName, function(sV, vO, vN)
|
||||
pText:SetText(vN); pText:SetValue(vN) end, sName..sCall);
|
||||
asmlib.SetNumSlider(CPanel, "mass" , iMaxDec, 0, asmlib.GetAsmConvar("maxmass" , "FLT"))
|
||||
asmlib.SetNumSlider(CPanel, "activrad", iMaxDec, 0, asmlib.GetAsmConvar("maxactrad", "FLT"))
|
||||
asmlib.SetNumSlider(CPanel, "stackcnt", 0 , 0, asmlib.GetAsmConvar("maxstcnt" , "INT"))
|
||||
asmlib.SetNumSlider(CPanel, "ghostcnt", 0 , 0, asmlib.GetAsmConvar("maxghcnt" , "INT"))
|
||||
asmlib.SetNumSlider(CPanel, "angsnap" , iMaxDec)
|
||||
asmlib.SetButton(CPanel, "resetvars")
|
||||
local tBAng = { -- Button interactive slider ( angle offsets )
|
||||
@ -2506,7 +2504,6 @@ if(CLIENT) then
|
||||
asmlib.SetNumSlider(CPanel, "sizeucs" , iMaxDec)
|
||||
asmlib.SetNumSlider(CPanel, "incsnplin", 0)
|
||||
asmlib.SetNumSlider(CPanel, "incsnpang", 0)
|
||||
asmlib.SetNumSlider(CPanel, "ghostcnt" , 0)
|
||||
asmlib.SetNumSlider(CPanel, "ghostblnd", iMaxDec)
|
||||
asmlib.SetNumSlider(CPanel, "crvturnlm", iMaxDec)
|
||||
asmlib.SetNumSlider(CPanel, "crvleanlm", iMaxDec)
|
||||
@ -2541,6 +2538,7 @@ if(CLIENT) then
|
||||
asmlib.SetNumSlider(CPanel, "maxforce" , iMaxDec)
|
||||
asmlib.SetNumSlider(CPanel, "maxactrad", iMaxDec)
|
||||
asmlib.SetNumSlider(CPanel, "maxstcnt" , 0)
|
||||
asmlib.SetNumSlider(CPanel, "maxghcnt" , 0)
|
||||
asmlib.SetNumSlider(CPanel, "maxstatts", 0)
|
||||
asmlib.SetNumSlider(CPanel, "maxfruse" , 0)
|
||||
asmlib.SetNumSlider(CPanel, "dtmessage", iMaxDec)
|
||||
|
@ -197,6 +197,8 @@ tool.trackassembly.maxactrad=Променете тук за да настрои
|
||||
tool.trackassembly.maxactrad_con=Граница на радиус\:
|
||||
tool.trackassembly.maxstcnt=Променете тук за да настроите максималния брой парчета в режим на натрупване
|
||||
tool.trackassembly.maxstcnt_con=Граница на натрупване\:
|
||||
tool.trackassembly.maxghcnt=Променете тук за да настроите максималния брой парчета сенки при натрупване
|
||||
tool.trackassembly.maxghcnt_con=Граница на парчета сенки\:
|
||||
tool.trackassembly.enwiremod=Когато е разрешено включва разширението за wiremod expression чипа
|
||||
tool.trackassembly.enwiremod_con=Включи wiremod expression
|
||||
tool.trackassembly.enmultask=Когато е разрешено включва многозадачната система по време на натрупване
|
||||
|
@ -197,6 +197,8 @@ tool.trackassembly.maxactrad=Change this to adjust the maximum active radius for
|
||||
tool.trackassembly.maxactrad_con=Radius limit\:
|
||||
tool.trackassembly.maxstcnt=Change this to adjust the maximum pieces to be created in stacking mode
|
||||
tool.trackassembly.maxstcnt_con=Stack limit\:
|
||||
tool.trackassembly.maxghcnt=Change this to adjust the maximum pieces to be ghosted in stacking mode
|
||||
tool.trackassembly.maxghcnt_con=Ghosts limit\:
|
||||
tool.trackassembly.enwiremod=When enabled turns on the wiremod expression chip extension
|
||||
tool.trackassembly.enwiremod_con=Enable wire expression
|
||||
tool.trackassembly.enmultask=When enabled turns on the multitasking during stacking mode
|
||||
|
Loading…
Reference in New Issue
Block a user