Skip to content

Commit

Permalink
Merge branch 'dev' into api-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
marchc1 authored Jan 17, 2025
2 parents 8ae389d + d26a777 commit 9803699
Show file tree
Hide file tree
Showing 69 changed files with 1,210 additions and 873 deletions.
2 changes: 1 addition & 1 deletion lua/acf/ballistics/ballistics_cl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ local function BulletFlight(Bullet, DeltaTime)
Debug.Line(Bullet.SimPosLast, Bullet.SimPos, 15, Yellow)
end

hook.Add("ACF_OnClock", "ACF_ManageBulletEffects", function(_, DeltaTime)
hook.Add("ACF_OnTick", "ACF_ManageBulletEffects", function(_, DeltaTime)
for _, Bullet in pairs(ACF.BulletEffect) do
BulletFlight(Bullet, DeltaTime)
end
Expand Down
28 changes: 15 additions & 13 deletions lua/acf/ballistics/ballistics_sv.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
local hook = hook
local ACF = ACF
local Ballistics = ACF.Ballistics
local Damage = ACF.Damage
Expand All @@ -10,14 +11,13 @@ Ballistics.UnusedIndexes = Ballistics.UnusedIndexes or {}
Ballistics.HighestIndex = Ballistics.HighestIndex or 0
Ballistics.SkyboxGraceZone = 100

local Bullets = Ballistics.Bullets
local Unused = Ballistics.UnusedIndexes
local IndexLimit = 2000
local SkyGraceZone = 100
local FlightTr = { start = true, endpos = true, filter = true, mask = true }
local GlobalFilter = ACF.GlobalFilter
local AmmoTypes = ACF.Classes.AmmoTypes
local HookRun = hook.Run
local Bullets = Ballistics.Bullets
local Unused = Ballistics.UnusedIndexes
local IndexLimit = 2000
local SkyGraceZone = 100
local FlightTr = { start = true, endpos = true, filter = true, mask = true }
local GlobalFilter = ACF.GlobalFilter
local AmmoTypes = ACF.Classes.AmmoTypes

-- This will create, or update, the tracer effect on the clientside
function Ballistics.BulletClient(Bullet, Type, Hit, HitPos)
Expand Down Expand Up @@ -51,7 +51,7 @@ function Ballistics.RemoveBullet(Bullet)
Bullet.Removed = true

if not next(Bullets) then
hook.Remove("ACF_OnClock", "ACF Iterate Bullets")
hook.Remove("ACF_OnTick", "ACF Iterate Bullets")
end
end

Expand Down Expand Up @@ -150,7 +150,7 @@ function Ballistics.CreateBullet(BulletData)
end

if not next(Bullets) then
hook.Add("ACF_OnClock", "ACF Iterate Bullets", Ballistics.IterateBullets)
hook.Add("ACF_OnTick", "ACF Iterate Bullets", Ballistics.IterateBullets)
end

Bullets[Index] = Bullet
Expand Down Expand Up @@ -202,7 +202,7 @@ function Ballistics.TestFilter(Entity, Bullet)

if GlobalFilter[Entity:GetClass()] then return false end

if HookRun("ACF_OnFilterBullet", Entity, Bullet) == false then return false end
if not hook.Run("ACF_OnFilterBullet", Entity, Bullet) then return false end

local EntTbl = Entity:GetTable()

Expand All @@ -218,7 +218,9 @@ function Ballistics.TestFilter(Entity, Bullet)
end

function Ballistics.DoBulletsFlight(Bullet)
if HookRun("ACF Bullet Flight", Bullet) == false then return end
local CanFly = hook.Run("ACF_PreBulletFlight", Bullet)

if not CanFly then return end

if Bullet.SkyLvL then
if Clock.CurTime - Bullet.LifeTime > 30 then
Expand Down Expand Up @@ -286,7 +288,7 @@ function Ballistics.DoBulletsFlight(Bullet)
else
local Entity = traceRes.Entity

if Ballistics.TestFilter(Entity, Bullet) == false then
if not Ballistics.TestFilter(Entity, Bullet) then
table.insert(Bullet.Filter, Entity)
timer.Simple(0, function()
Ballistics.DoBulletsFlight(Bullet) -- Retries the same trace after adding the entity to the filter; important in case something is embedded in something that shouldn't be hit
Expand Down
2 changes: 1 addition & 1 deletion lua/acf/contraption/seats_sv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ hook.Add("OnEntityCreated", "ACF_SeatLegality", function(Entity)
end)
end)

hook.Add("ACF_IsLegal", "ACF_CheckLegal_SeatLegality", function(Entity)
hook.Add("ACF_OnCheckLegal", "ACF_CheckLegal_SeatLegality", function(Entity)
if not ACF.VehicleLegalChecks then return end
if not Entity:IsVehicle() then return end

Expand Down
32 changes: 13 additions & 19 deletions lua/acf/core/classes/entities/registration.lua
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,7 @@ function Entities.AutoRegister(ENT)
UpdateEntityData(self, ClientData)
ACF.RestoreEntity(self)

hook.Run("ACF_OnEntityUpdate", Class, self, ClientData)
if self.UpdateOverlay then self:UpdateOverlay(true) end
net.Start("ACF_UpdateEntity")
net.WriteEntity(self)
net.Broadcast()
hook.Run("ACF_OnUpdateEntity", Class, self, ClientData)

return true, (self.PrintName or Class) .. " updated successfully!"
end
Expand All @@ -284,7 +280,7 @@ function Entities.AutoRegister(ENT)
end
end

local CanSpawn = hook.Run("ACF_PreEntitySpawn", Class, Player, ClientData)
local CanSpawn = hook.Run("ACF_PreSpawnEntity", Class, Player, ClientData)
if CanSpawn == false then return false end

local New = ents.Create(Class)
Expand All @@ -305,7 +301,7 @@ function Entities.AutoRegister(ENT)
New.Owner = Player -- MUST be stored on ent for PP
New.DataStore = Entities.GetArguments(Class)

hook.Run("ACF_OnEntitySpawn", Class, New, ClientData)
hook.Run("ACF_OnSpawnEntity", Class, New, ClientData)

if New.ACF_PostSpawn then
New:ACF_PostSpawn(Player, Pos, Angle, ClientData)
Expand Down Expand Up @@ -415,7 +411,6 @@ Classes.AddSimpleFunctions(Entities, Entries)
if CLIENT then return end

do -- Spawning and updating
local hook = hook
local undo = undo

--- Spawns an entity with the given parameters
Expand All @@ -435,10 +430,6 @@ do -- Spawning and updating
if not ClassData then return false, Class .. " is not a registered ACF entity class." end
if not ClassData.Spawn then return false, Class .. " doesn't have a spawn function assigned to it." end

local HookResult, HookMessage = hook.Run("ACF_CanCreateEntity", Class, Player, Position, Angles, Data)

if HookResult == false then return false, HookMessage end

local Entity = ClassData.Spawn(Player, Position, Angles, Data)

if not IsValid(Entity) then return false, "The spawn function for " .. Class .. " didn't return an entity." end
Expand Down Expand Up @@ -467,15 +458,18 @@ do -- Spawning and updating

Data = istable(Data) and Data or {}

local HookResult, HookMessage = hook.Run("ACF_CanUpdateEntity", Entity, Data)

if HookResult == false then
return false, "Couldn't update entity: " .. (HookMessage or "No reason provided.")
end

local Result, Message = Entity:Update(Data)

if not Result then
if Result then
if Entity.UpdateOverlay then
Entity:UpdateOverlay(true)
end

-- Let the client know that we've updated this entity
net.Start("ACF_UpdateEntity")
net.WriteEntity(Entity)
net.Broadcast()
else
Message = "Couldn't update entity: " .. (Message or "No reason provided.")
end

Expand Down
8 changes: 4 additions & 4 deletions lua/acf/core/classes/grouped.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function Classes.AddGroup(ID, Destiny, Data)
Group[K] = V
end

hook.Run("ACF_OnNewClassGroup", ID, Group)
hook.Run("ACF_OnCreateGroup", ID, Group)

return Group
end
Expand Down Expand Up @@ -68,7 +68,7 @@ function Classes.AddGroupItem(ID, GroupID, Destiny, Data)
Class[K] = V
end

hook.Run("ACF_OnNewGroupedClass", ID, Group, Class)
hook.Run("ACF_OnCreateGroupItem", ID, Group, Class)

return Class
end
Expand Down Expand Up @@ -188,13 +188,13 @@ function Classes.AddGroupedFunctions(Namespace, Entries)
end
end

hook.Add("ACF_OnNewClassGroup", "ACF Precache Model", function(_, Group)
hook.Add("ACF_OnCreateGroup", "ACF Precache Model", function(_, Group)
if not isstring(Group.Model) then return end

util.PrecacheModel(Group.Model)
end)

hook.Add("ACF_OnNewGroupedClass", "ACF Precache Model", function(_, _, Class)
hook.Add("ACF_OnCreateGroupItem", "ACF Precache Model", function(_, _, Class)
if not isstring(Class.Model) then return end

util.PrecacheModel(Class.Model)
Expand Down
4 changes: 2 additions & 2 deletions lua/acf/core/classes/object.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ local function AttachMetaTable(Class, Base)
Class:OnLoaded()
end

hook.Run("ACF_OnClassLoaded", Class.ID, Class)
hook.Run("ACF_OnLoadClass", Class.ID, Class)

Class.Loaded = true
end)
Expand Down Expand Up @@ -102,7 +102,7 @@ function Classes.AddObject(ID, Base, Destiny)
return Class
end

hook.Add("ACF_OnClassLoaded", "ACF Model Precache", function(_, Class)
hook.Add("ACF_OnLoadClass", "ACF Model Precache", function(_, Class)
if not isstring(Class.Model) then return end

util.PrecacheModel(Class.Model)
Expand Down
4 changes: 2 additions & 2 deletions lua/acf/core/classes/simple.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function Classes.AddSimple(ID, Destiny, Data)
Class[K] = V
end

hook.Run("ACF_OnNewSimpleClass", ID, Class)
hook.Run("ACF_OnCreateItem", ID, Class)

return Class
end
Expand Down Expand Up @@ -101,7 +101,7 @@ function Classes.AddSimpleFunctions(Namespace, Entries)
end
end

hook.Add("ACF_OnNewSimpleClass", "ACF Precache Model", function(_, Class)
hook.Add("ACF_OnCreateItem", "ACF Precache Model", function(_, Class)
if not isstring(Class.Model) then return end

util.PrecacheModel(Class.Model)
Expand Down
Loading

0 comments on commit 9803699

Please sign in to comment.