mirror of
https://github.com/jimathy/jim_bridge.git
synced 2026-08-17 05:56:02 +01:00
Enhance Distance based props and cleanup
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
local Props = {}
|
||||
local distProps = {}
|
||||
|
||||
--- Creates a prop (object) in the game world at specified coordinates.
|
||||
---
|
||||
@@ -57,17 +58,21 @@ end
|
||||
--- }
|
||||
--- makeDistProp(propData, true, false)
|
||||
--- ```
|
||||
function makeDistProp(data, freeze, synced, range)
|
||||
function makeDistProp(data, freeze, synced, range, func)
|
||||
local name = keyGen()..keyGen()
|
||||
createCirclePoly({
|
||||
distProps[#distProps + 1] = createCirclePoly({
|
||||
name = name,
|
||||
coords = vec3(data.coords.x, data.coords.y, data.coords.z - 1.03),
|
||||
radius = range or 50.0,
|
||||
onEnter = function()
|
||||
Props[name] = makeProp(data, freeze, synced)
|
||||
if func then
|
||||
func(Props[name])
|
||||
end
|
||||
end,
|
||||
onExit = function()
|
||||
destroyProp(Props[name])
|
||||
Props[name] = nil
|
||||
end,
|
||||
debug = debugMode,
|
||||
})
|
||||
@@ -92,6 +97,16 @@ function destroyProp(entity)
|
||||
end
|
||||
end
|
||||
|
||||
onPlayerUnloaded(function()
|
||||
for k in pairs(Props) do
|
||||
DeleteObject(Props[k])
|
||||
end
|
||||
for i = 1, #distProps do
|
||||
removeZoneTarget(distProps[i])
|
||||
end
|
||||
distProps = {}
|
||||
end)
|
||||
|
||||
--- Cleans up all created props when the resource stops.
|
||||
onResourceStop(function()
|
||||
for k in pairs(Props) do
|
||||
|
||||
Reference in New Issue
Block a user