Cache and entities update
added cache system similar to others that are readily available. Included beginings of reworked rebound entities
This commit is contained in:
1 parent
b9842eedfe
commit
89858c6d73
16 files changed
+589
-207
No files matched your search
@@ -1,35 +1,45 @@
|
||||
-- local ReboundEntities = ReboundEntities or Require("shared/rebound_entities.lua")
|
||||
-- local Actions = Actions or Require("shared/actions.lua")
|
||||
-- local LA = LA or Require("shared/la.lua")
|
||||
local ReboundEntities = ReboundEntities or Require("lib/utility/shared/rebound_entities.lua") -- Fixed path
|
||||
local Action = Action or Require("lib/entities/shared/actions.lua") -- Fixed path and name
|
||||
local LA = LA or Require("lib/utility/shared/la.lua") -- Fixed path
|
||||
|
||||
-- REA = {}
|
||||
REA = {}
|
||||
|
||||
-- if not IsDuplicityVersion() then goto client end
|
||||
if not IsDuplicityVersion() then goto client end
|
||||
|
||||
|
||||
|
||||
-- if IsDuplicityVersion() then return end
|
||||
-- ::client::
|
||||
if IsDuplicityVersion() then return end
|
||||
::client::
|
||||
|
||||
-- local ActionsInProgress = {}
|
||||
local ActionsInProgress = {}
|
||||
|
||||
|
||||
-- Action.Create("LerpToPosition", function(reboundId, start, position, duration, shouldRepeat, overrideStartTime)
|
||||
-- local re = ReboundEntities.Get(reboundId)
|
||||
-- assert(re, "Rebound entity not found")
|
||||
-- local entity = re and re.entity
|
||||
-- if not entity then return end
|
||||
-- local startTime = GetGameTimer()
|
||||
-- local endTime = overrideStartTime or startTime + duration
|
||||
-- ActionsInProgress[reboundId] = {reboundId, start, position, duration, shouldRepeat, startTime}
|
||||
-- local t = 0
|
||||
-- CreateThread(function()
|
||||
-- while shouldRepeat or t < 1 do
|
||||
-- t = (GetGameTimer() - startTime) / duration
|
||||
-- local lerpPosition = LA.LerpVector(start, position, t)
|
||||
-- SetEntityCoords(entity, lerpPosition)
|
||||
-- Wait(0)
|
||||
|
||||
-- end
|
||||
-- end)
|
||||
-- end)
|
||||
Action.Create("LerpToPosition", function(reboundId, start, position, duration, shouldRepeat, overrideStartTime)
|
||||
local re = ReboundEntities.GetById(reboundId) -- Use GetById
|
||||
assert(re, "Rebound entity not found")
|
||||
local entity = re and re.entity
|
||||
if not entity or not DoesEntityExist(entity) then return end -- Check existence
|
||||
local startTime = GetGameTimer()
|
||||
local endTime = overrideStartTime or startTime + duration
|
||||
ActionsInProgress[reboundId] = {reboundId, start, position, duration, shouldRepeat, startTime}
|
||||
local t = 0
|
||||
CreateThread(function()
|
||||
while shouldRepeat or t < 1 do
|
||||
-- Check if entity still exists
|
||||
if not re.entity or not DoesEntityExist(re.entity) then
|
||||
ActionsInProgress[reboundId] = nil
|
||||
break
|
||||
end
|
||||
entity = re.entity -- Update entity handle in case it changed (unlikely but safe)
|
||||
t = (GetGameTimer() - startTime) / duration
|
||||
local lerpPosition = LA.LerpVector(start, position, t)
|
||||
SetEntityCoordsNoOffset(entity, lerpPosition.x, lerpPosition.y, lerpPosition.z, false, false, false) -- Use NoOffset
|
||||
Wait(0)
|
||||
end
|
||||
-- Set final position if not repeating
|
||||
if not shouldRepeat and re.entity and DoesEntityExist(re.entity) then
|
||||
SetEntityCoordsNoOffset(re.entity, position.x, position.y, position.z, false, false, false)
|
||||
end
|
||||
ActionsInProgress[reboundId] = nil -- Clear when done
|
||||
end)
|
||||
end)
|
||||
Reference in new issue
Block a user