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
@@ -258,7 +258,7 @@ LA.EaseVector = function(inout, a, b, t, easingType)
|
||||
elseif inout == "inout" then
|
||||
return LA.EaseInOutVector(a, b, t, easingType)
|
||||
end
|
||||
Assert(false, "Invalid type")
|
||||
assert(false, "Invalid type")
|
||||
end
|
||||
|
||||
LA.EaseOnAxis = function(inout, a, b, t, easingType, axis)
|
||||
@@ -293,15 +293,15 @@ LA.DistanceCheck = function(pointA, pointB)
|
||||
end
|
||||
|
||||
LA.Chance = function(chance)
|
||||
Assert(chance, "Chance must be passed")
|
||||
Assert(type(chance) == "number", "Chance must be a number")
|
||||
Assert(chance >= 0 and chance <= 100, "Chance must be between 0 and 100")
|
||||
assert(chance, "Chance must be passed")
|
||||
assert(type(chance) == "number", "Chance must be a number")
|
||||
assert(chance >= 0 and chance <= 100, "Chance must be between 0 and 100")
|
||||
return math.random(1, 100) <= chance
|
||||
end
|
||||
|
||||
LA.Vector4To3 = function(vector4)
|
||||
Assert(vector4, "Vector4 must be passed")
|
||||
Assert(type(vector4) == "vector4", "Vector4 must be a vector4")
|
||||
assert(vector4, "Vector4 must be passed")
|
||||
assert(type(vector4) == "vector4", "Vector4 must be a vector4")
|
||||
return vector3(vector4.x, vector4.y, vector4.z), vector4.w
|
||||
end
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ if isServer then return ReboundEntities end
|
||||
|
||||
function ReboundEntities.LoadModel(model)
|
||||
assert(model, "Model is nil")
|
||||
model = type(model) == "number" and model or GetHashKey(model)
|
||||
model = type(model) == "number" and model or GetHashKey(model) -- Corrected to GetHashKey
|
||||
RequestModel(model)
|
||||
for i = 1, 100 do
|
||||
if HasModelLoaded(model) then return model end
|
||||
|
||||
@@ -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