This was crowleys commit and work - Refactor entity behaviors and improve particle handling

Refactored entity behavior triggers to simplify argument passing and added OnSet handler for particle behaviors. Improved particle effect management and event handling, updated locale and lib initialization in several modules, and fixed skill metadata access. Also streamlined point zone logic and menu/zone system initialization for better reliability.
This commit is contained in:
MrNewb committed 2025-10-26 16:20:27 -04:00
1 parent 179c3bad85
commit 444040dd39
13 files changed
+71 -64

No files matched your search

+17 -4
View File
@@ -80,9 +80,9 @@ local function UpdateEntity(_entityData)
entityData.oldCoords = entityData.oldCoords and vector3(entityData.oldCoords.x, entityData.oldCoords.y, entityData.oldCoords.z) or coords
local dist = #(coords - entityData.oldCoords)
if entityData.oldCoords and dist > 0.5 then
if entityData.spawned then
SetEntityCoords(entityData.spawned, coords.x, coords.y, coords.z, false, false, false, false)
end
-- if entityData.spawned then
-- SetEntityCoords(entityData.spawned, coords.x, coords.y, coords.z, false, false, false, false)
-- end
-- ClientEntity.UpdateCoords(entityData.id, entityData.coords)
if entityData.OnMove then
pcall(function (...)
@@ -167,7 +167,20 @@ end
function ClientEntity.Set(id, key, value)
local entityData = ClientEntity.Get(id)
if not entityData then return print(string.format("[ClientEntity] SetKey: Entity %s does not exist", id)) end
entityData[key] = value
local oldData = entityData[key]
if oldData == value then return end
if entityData.OnSet then
pcall(function (...)
return entityData.OnSet(entityData, key, value, oldData)
end)
end
if value then
entityData[key] = value
Behaviors.Trigger("OnSet", entityData, key, value, oldData)
return
end
Behaviors.Trigger("OnSet", entityData, key, value, oldData)
entityData[key] = nil
end
function ClientEntity.Get(id)
+2 -2
View File
@@ -51,7 +51,7 @@ function Behaviors.Trigger(actionName, clientEntityData, ...)
for property, behavior in pairs(Behaviors.All[invoking] or {}) do
local hasBehaviorArgs = Behaviors.Has(property, clientEntityData) -- this is everything that's contained inside the object's individual property
if hasBehaviorArgs and behavior[actionName] then
local success, result = pcall(behavior[actionName], clientEntityData, hasBehaviorArgs, ...)
local success, result = pcall(behavior[actionName], clientEntityData, ...)
if not success then
print(string.format("[ClientEntity] Behavior %s failed: %s", property, result))
end
@@ -60,7 +60,7 @@ function Behaviors.Trigger(actionName, clientEntityData, ...)
for property, behavior in pairs(Behaviors.All['community_bridge'] or {}) do
local hasBehaviorArgs = Behaviors.Has(property, clientEntityData) -- this is everything that's contained inside the object's individual property
if hasBehaviorArgs and behavior[actionName] and not Behaviors.All[invoking]?[actionName] then
local success, result = pcall(behavior[actionName], clientEntityData, hasBehaviorArgs, ...)
local success, result = pcall(behavior[actionName], clientEntityData, ...)
if not success then
print(string.format("[ClientEntity] Behavior %s failed: %s", property, result))
end
+15 -1
View File
@@ -11,7 +11,6 @@ local ParticlesBehaviors = {
color = vector3(255, 255, 255),
loopLength = 5000,
}
}
function ParticlesBehaviors.Start(entityData)
@@ -76,5 +75,20 @@ function ParticlesBehaviors.OnMove(entityData)
end
end
function ParticlesBehaviors.OnSet(entityData, key, value, oldValue)
if key ~= "particles" then return end
if oldValue then
ParticlesBehaviors.OnRemove(entityData)
end
if value then
if value.dict then -- single particle
entityData.particles = {value}
else
entityData.particles = value
end
ParticlesBehaviors.Start(entityData)
end
end
Bridge.Entity.RegisterBehavior("particles", ParticlesBehaviors)
return ParticlesBehaviors