Targets, entities and events, oh my!
Targets updated to have boxzone Entities dont require a model and are effectively points with on spawn on despawn onplayerloaded and onplayeriunloaded now pass source
This commit is contained in:
1 parent
3a141cb8f2
commit
34d24cb6a9
11 files changed
+61
-352
No files matched your search
+14
-20
@@ -25,7 +25,6 @@ function Anim.RequestDict(animDict)
|
||||
end
|
||||
|
||||
--- This will start the animation update loop.
|
||||
--- @return void
|
||||
function Anim.Start()
|
||||
if Anim.isUpdateLoopRunning then return end
|
||||
Anim.isUpdateLoopRunning = true
|
||||
@@ -37,15 +36,13 @@ function Anim.Start()
|
||||
end
|
||||
|
||||
if #idsToProcess == 0 then
|
||||
Wait(750)
|
||||
Wait(750)
|
||||
else
|
||||
for _, id in ipairs(idsToProcess) do
|
||||
local animData = Anim.Active[id]
|
||||
|
||||
if animData then
|
||||
local animData = Anim.Active[id]
|
||||
if animData then
|
||||
local entity = animData.entity
|
||||
local onComplete = animData.onComplete
|
||||
|
||||
local onComplete = animData.onComplete
|
||||
if not DoesEntityExist(entity) then
|
||||
if onComplete then onComplete(false, "despawned") end
|
||||
Anim.Active[id] = nil
|
||||
@@ -54,10 +51,8 @@ function Anim.Start()
|
||||
animData.startTime = GetGameTimer()
|
||||
animData.animEndTime = animData.duration > 0 and (animData.startTime + animData.duration) or -1
|
||||
animData.status = "playing"
|
||||
|
||||
elseif animData.status == "playing" then
|
||||
local animationCompletedNaturally = false
|
||||
|
||||
if animData.duration == -1 then
|
||||
if not IsEntityPlayingAnim(entity, animData.animDict, animData.animName, 3) and GetEntityAnimCurrentTime(entity, animData.animDict, animData.animName) > 0.8 then
|
||||
animationCompletedNaturally = true
|
||||
@@ -65,17 +60,16 @@ function Anim.Start()
|
||||
elseif animData.animEndTime ~= -1 and GetGameTimer() >= animData.animEndTime then
|
||||
animationCompletedNaturally = true
|
||||
end
|
||||
|
||||
if animationCompletedNaturally then
|
||||
if onComplete then onComplete(true, "completed") end
|
||||
Anim.Active[id] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Wait(100)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Wait(100)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -92,7 +86,7 @@ end
|
||||
--- @param onComplete function | nil
|
||||
--- @return string | nil
|
||||
function Anim.Play(id, entity, animDict, animName, blendIn, blendOut, duration, flag, playbackRate, onComplete)
|
||||
local newId = id or Ids.CreateUniqueId(Anim.Active)
|
||||
local newId = id or Ids.CreateUniqueId(Anim.Active)
|
||||
if Anim.Active[newId] then
|
||||
if onComplete then
|
||||
onComplete(false, "id_in_use")
|
||||
@@ -111,7 +105,7 @@ function Anim.Play(id, entity, animDict, animName, blendIn, blendOut, duration,
|
||||
if onComplete then
|
||||
onComplete(false, "dict_load_failed")
|
||||
end
|
||||
return nil
|
||||
return nil
|
||||
end
|
||||
|
||||
Anim.Active[newId] = {
|
||||
@@ -124,7 +118,7 @@ function Anim.Play(id, entity, animDict, animName, blendIn, blendOut, duration,
|
||||
flag = flag or 1,
|
||||
playbackRate = playbackRate or 0.0,
|
||||
onComplete = onComplete,
|
||||
status = "pending_task",
|
||||
status = "pending_task",
|
||||
startTime = 0,
|
||||
animEndTime = 0
|
||||
}
|
||||
@@ -139,7 +133,7 @@ function Anim.Stop(id)
|
||||
end
|
||||
|
||||
local animData = Anim.Active[id]
|
||||
|
||||
|
||||
if animData.entity and DoesEntityExist(animData.entity) and IsEntityAPed(animData.entity) then
|
||||
if animData.status == "playing" or animData.status == "pending_task" then
|
||||
StopAnimTask(animData.entity, animData.animDict, animData.animName, 1.0)
|
||||
@@ -150,7 +144,7 @@ function Anim.Stop(id)
|
||||
animData.onComplete(false, "stopped_by_id")
|
||||
end
|
||||
|
||||
Anim.Active[id] = nil
|
||||
Anim.Active[id] = nil
|
||||
local anyLeft = Anim.Active and next(Anim.Active) ~= nil
|
||||
if not anyLeft then
|
||||
Anim.isUpdateLoopRunning = false
|
||||
|
||||
Reference in new issue
Block a user