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