fixed last mess

This commit is contained in:
Mr.Crowley committed 2025-08-27 06:13:02 -05:00
1 parent e06e04a2c6
commit 495b24e53f
6 files changed
+55 -236

No files matched your search

@@ -1,56 +0,0 @@
Utility = Utility or Require("lib/utility/client/utility.lua")
local ParticlesBehaviors = {
tag = "particles",
default = {
dict = "cut_exile3",
ptfx = "cs_ex3_wheel_spin",
offset = vector3(0, 0, 0),
rotation = vector3(0, 0, 0),
size = 1.0,
color = vector3(255, 255, 255),
loopLength = 5000,
}
}
function ParticlesBehaviors.OnSpawn(entityData)
if not entityData.particles then return end
if entityData.particles.dict then -- single particle
entityData.particles = {entityData.particles}
end
for _, particleData in ipairs(entityData.particles) do
local position = vector3(entityData.coords.x, entityData.coords.y, entityData.coords.z)
local rotation = vector3(entityData.rotation.x, entityData.rotation.y, entityData.rotation.z)
position = position + (particleData.offset?.xyz or vector3(0, 0, 0))
rotation = rotation + (particleData.rotation?.xyz or vector3(0, 0, 0))
particleData.playing = Particle.Play(
particleData.dict or ParticlesBehaviors.default.dict,
particleData.ptfx or ParticlesBehaviors.default.ptfx,
position,
rotation,
particleData.size or ParticlesBehaviors.default.size,
particleData.color or ParticlesBehaviors.default.color,
particleData.looped,
particleData.loopLength or ParticlesBehaviors.default.loopLength
)
end
end
function ParticlesBehaviors.OnRemove(entityData)
if not entityData.particles then return end
for _, particleData in ipairs(entityData.particles) do
if particleData.playing then
Particle.Stop(particleData.playing)
particleData.playing = nil
end
end
end
-- function ParticlesBehaviors.OnUpdate(entityData)
-- if not entityData.particles then return end
-- end
return ParticlesBehaviors
-54
View File
@@ -1,54 +0,0 @@
local Targets = {
tag = "targets",
default = {
label = "Default Target Label",
distance = 2,
}
}
function Targets.OnSpawn(entityData)
if not entityData.spawned or not entityData.target then return end
if entityData.targets?.label then
entityData.newTargets = {entityData.targets}
else
entityData.newTargets = entityData.targets or {}
end
for k, v in pairs(entityData.newTargets) do
local onSelect = v.onSelect
if onSelect then
v.onSelect = function(entity)
onSelect(entityData, entity)
end
end
end
Target.AddLocalEntity(entityData.spawned, entityData.newTargets)
entityData.oldTargets = entityData.newTargets
end
function Targets.OnRemove(entityData)
if not entityData.spawned or not entityData.newTargets then return end
Target.RemoveLocalEntity(entityData.spawned)
end
function Targets.OnUpdate(entityData)
if not entityData.spawned or not entityData.newTargets then return end
for i, target in ipairs(entityData.oldTargets) do
local newTarget = entityData.targets.label
if newTarget then
entityData.newTargets = {entityData.targets}
end
newTarget = entityData.newTargets[i]
if newTarget
and target.label ~= newTarget.label
or target.distance ~= newTarget.distance
or target.description ~= newTarget.description
then
Targets.OnRemove(entityData)
Targets.OnSpawn(entityData)
end
end
end
return Targets
+16 -3
View File
@@ -1,9 +1,11 @@
Utility = Utility or Require("lib/utility/client/utility.lua")
Ids = Ids or Require("lib/utility/shared/ids.lua")
Point = Point or Require("lib/points/client/points.lua")
Behaviors = Behaviors or Require("lib/entities/client/behaviors.lua")
Behaviors = Behaviors or Require("lib/entities/shared/behaviors.lua")
local Entities = {} -- Stores entity data received from server
ClientEntity = {} -- Renamed from BaseEntity
ClientEntity = {
Invoked = {}
} -- Renamed from BaseEntity
ClientEntity.Behaviors = Behaviors
@@ -113,6 +115,9 @@ function ClientEntity.Create(entityData)
local entityPoint = Point.Register(entityData.id, entityData.coords, entityData.spawnDistance or 50.0, entityData, SpawnEntity, RemoveEntity, UpdateEntity)
Entities[entityData.id] = entityPoint
entityData.invoked = GetInvokingResource() or "community_bridge"
ClientEntity.Invoked[entityData.invoked] = ClientEntity.Invoked[entityData.invoked] or {}
ClientEntity.Invoked[entityData.invoked][entityData.id] = entityData
Behaviors.Trigger("OnCreate", entityPoint)
return entityPoint
end
@@ -146,7 +151,9 @@ function ClientEntity.Destroy(id)
end
ClientEntity.Unregister = ClientEntity.Destroy
function ClientEntity.RegisterBehavior(id, behavior)
Behaviors.Create(id, behavior)
end
function ClientEntity.Set(id, key, value)
local entityData = ClientEntity.Get(id)
@@ -307,6 +314,12 @@ AddEventHandler('onResourceStop', function(resourceName)
RemoveEntity(entityData) -- Clean up spawned game entity
end
Entities = {} -- Clear local cache
else
for id, entityData in pairs(ClientEntity.Invoked[resourceName] or {}) do
Point.Remove(id) -- Clean up point registration
RemoveEntity(entityData) -- Clean up spawned game entity
Entities[id] = nil
end
end
end)