Skip to content

Commit

Permalink
Added gwaterlib.applyForceField function
Browse files Browse the repository at this point in the history
Fixed gwaterlib.setParameter function
  • Loading branch information
Mikey-Mikey committed Jul 27, 2024
1 parent 524748b commit 7e81f33
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion lua/starfall/libs_cl/gwater2module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ local function main(instance)
-- @param number value
function gwater_library.setParameter(parameter, value)
if LocalPlayer() == instance.player then
SetGwaterParameter(parameter, value)
gwater2.solver:SetParameter(parameter, value)
end
end

Expand All @@ -60,6 +60,26 @@ local function main(instance)
return gwater2.solver:GetParameter(parameter)
end
end

--- Applies a force field to GWater particles
-- @client
-- @param Vector pos The position of the force field
-- @param number radius The radius of the force field
-- @param number strength The strength of the force field
-- @param number mode The mode of the force field. 0 = Attraction, 1 = Repulsion, 2 = Vortex
-- @param boolean linear Whether the force field should be the same strength regardless of distance
function gwater_library.applyForceField(pos, radius, strength, mode, linear)
if LocalPlayer() == instance.player then
gwater2.solver:AddForceField(vunwrap(pos), radius, strength, mode, linear)
end
end

--- Called before the GWater solver ticks
-- You should use this hook to apply forces to the particles
-- @name gwater2_pretick
-- @class hook
-- @client
SF.hookAdd("gwater2_pretick")
end

return main

0 comments on commit 7e81f33

Please sign in to comment.