-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds refill effects to fuel tanks, adds the ability to customize ammo/fuel refill colors, and marks the beginning of a new effects library (to be worked on later)
- Loading branch information
1 parent
e0c0210
commit 22d540d
Showing
6 changed files
with
141 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
local ACF = ACF | ||
local Refills = {} | ||
|
||
ACF.Utilities.Effects.Refills = Refills | ||
|
||
do -- Resupply effect (applies to ammo and fuel) | ||
local render = render | ||
local Distance = ACF.RefillDistance | ||
|
||
local function DrawSpheres(bDrawingDepth, _, isDraw3DSkybox) | ||
if bDrawingDepth or isDraw3DSkybox then return end | ||
render.SetColorMaterial() | ||
|
||
for Entity in pairs(Refills) do | ||
local Pos = Entity:GetPos() | ||
local RefillColor | ||
|
||
if Entity:GetClass() == "acf_fueltank" then | ||
RefillColor = ACF.FuelRefillColor | ||
else | ||
RefillColor = ACF.AmmoRefillColor | ||
end | ||
|
||
render.DrawSphere(Pos, Distance, 50, 50, RefillColor) | ||
render.DrawSphere(Pos, -Distance, 50, 50, RefillColor) | ||
end | ||
end | ||
|
||
local function Remove(Entity) | ||
if not IsValid(Entity) then return end | ||
|
||
Refills[Entity] = nil | ||
|
||
Entity:RemoveCallOnRemove("ACF_Refill") | ||
|
||
if not next(Refills) then | ||
hook.Remove("PostDrawOpaqueRenderables", "ACF_Refill") | ||
end | ||
end | ||
|
||
local function Add(Entity) | ||
if not IsValid(Entity) then return end | ||
|
||
if not next(Refills) then | ||
hook.Add("PostDrawOpaqueRenderables", "ACF_Refill", DrawSpheres) | ||
end | ||
|
||
Refills[Entity] = true | ||
|
||
Entity:CallOnRemove("ACF_Refill", Remove) | ||
end | ||
|
||
net.Receive("ACF_RefillEffect", function() | ||
local Entity = net.ReadEntity() | ||
|
||
Add(Entity) | ||
end) | ||
|
||
net.Receive("ACF_StopRefillEffect", function() | ||
local Entity = net.ReadEntity() | ||
|
||
Remove(Entity) | ||
end) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters