Refactor entity behavior to use Bridge.Entity

Replaces all usage of Bridge.ClientEntity and Bridge.ServerEntity with Bridge.Entity across shared behavior modules. Updates initialization in lib/init.lua to use cLib.Entity and marks cLib.ClientEntity and cLib.ServerEntity as deprecated for consistency and future maintainability.
This commit is contained in:
Mr.Crowley committed 2025-09-03 04:06:31 -05:00
1 parent cb9dbdf610
commit dff4622a94
11 files changed
+52 -43

No files matched your search

+6 -4
View File
@@ -14,7 +14,7 @@ function Attach.OnSpawn(entityData)
local entity = entityData.spawned
local targetEntity = entityData.attach.target
if type(targetEntity) == "string" then
targetEntity = Bridge.ClientEntity.Get(targetEntity)?.spawned or targetEntity
targetEntity = Bridge.Entity.Get(targetEntity)?.spawned or targetEntity
else
local player = GetPlayerFromServerId(targetEntity)
if player and player ~= -1 then
@@ -27,13 +27,13 @@ function Attach.OnSpawn(entityData)
local offset = entityData.attach.offset or Attach.default.offset
local rotation = entityData.attach.rotation or Attach.default.rotation
AttachEntityToEntity(entity, targetEntity, GetPedBoneIndex(targetEntity, bone), offset.x, offset.y, offset.z, rotation.x, rotation.y, rotation.z, true, true, false, true, 1, true)
Bridge.ClientEntity.Set(entityData.id, "attach", entityData.attach)
Bridge.Entity.Set(entityData.id, "attach", entityData.attach)
end
function Attach.Detach(entityData)
if not entityData.spawned or not IsEntityAttached(entityData.spawned) then return end
DetachEntity(entityData.spawned, true, true)
Bridge.ClientEntity.Set(entityData.id, "attach", entityData.attach)
Bridge.Entity.Set(entityData.id, "attach", entityData.attach)
end
function Attach.OnUpdate(entityData)
@@ -42,9 +42,11 @@ function Attach.OnUpdate(entityData)
return Attach.Detach(entityData)
end
local entity = entityData.spawned
local coords = GetEntityCoords(entity)
Bridge.Entity.Set(entityData.id, "coords", vector3(coords.x, coords.y, coords.z))
if IsEntityAttached(entity) then return end
Attach.OnSpawn(entityData)
end
Bridge.ClientEntity.RegisterBehavior("attach", Attach)
Bridge.Entity.RegisterBehavior("attach", Attach)
return Attach