From 435b4594bec6d4d730c12c8e01f8726331ceacc6 Mon Sep 17 00:00:00 2001 From: Sevii Date: Sun, 22 Dec 2024 15:38:43 +0100 Subject: [PATCH] starfall getclipdata --- README.md | 1 + lua/starfall/libs_sv/proper_clipping.lua | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/README.md b/README.md index 8cfe04c..fa93d53 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ StarfallEx: - ENTITY.clipExists - ENTITY.getClipIndex - ENTITY.physicsClipsLeft +- ENTITY.getClipData Expression2: - ENTITY.addClip diff --git a/lua/starfall/libs_sv/proper_clipping.lua b/lua/starfall/libs_sv/proper_clipping.lua index 0ba4953..6f16583 100644 --- a/lua/starfall/libs_sv/proper_clipping.lua +++ b/lua/starfall/libs_sv/proper_clipping.lua @@ -132,4 +132,25 @@ function ents_methods:physicsClipsLeft() return ProperClipping.PhysicsClipsLeft(ent) end +--- Returns the clip data +-- @return Table array of clip data (distance, normal, isInside, isPhysics), nil if it doesn't exist +function ents_methods:getClipData() + local ent = getent(self) + if ent.ClipData == nil then + return nil + end + + local rtn = {} + for i, clip in ipairs(ent.ClipData) do + rtn[i] = { + distance = isnumber(clip.dist) and clip.dist or 0, + normal = vwrap(isvector(clip.norm) and clip.norm or Vector()), + isInside = isbool(clip.inside) and clip.inside or false, + isPhysics = isbool(clip.physics) and clip.physics or false, + } + end + + return rtn +end + end \ No newline at end of file