Skip to content
Merged
5 changes: 3 additions & 2 deletions lua/pac3/core/client/parts/model.lua
Original file line number Diff line number Diff line change
Expand Up @@ -800,10 +800,11 @@ function PART:ApplyMatrix()
StandingHullHeight = self.StandingHullHeight,
CrouchingHullHeight = self.CrouchingHullHeight,
HullWidth = self.HullWidth,
OverrideStepSize = self.OverrideStepSize,
OverrideView = self.OverrideView,
StepSize = self.StepSize,
StandingViewOffset = self.StandingViewOffset,
CrouchingViewOffset = self.CrouchingViewOffset,
OverrideStepAndView = self.OverrideStepAndView
CrouchingViewOffset = self.CrouchingViewOffset
})

if self.Size == 1 and self.Scale == vec_one then
Expand Down
34 changes: 25 additions & 9 deletions lua/pac3/core/client/parts/model/entity.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ BUILDER:StartStorableVars()
:GetSet("NoDraw", false)
:GetSet("DrawShadow", true)
:GetSet("InverseKinematics", true)

:SetPropertyGroup("hull")
:GetSet("StandingHullHeight", 72, {editor_panel = "hull"})
:GetSet("CrouchingHullHeight", 36, {editor_panel = "hull", crouch = true})
:GetSet("HullWidth", 32, {editor_panel = "hull"})
:GetSet("OverrideStepAndView", false, {description = "When changing size, pac scales the step size and view offsets together. This overrides that."})
:GetSet("StepSize", 18, {description = "Height that you can step up or down without jumping. Slightly tricky and may create view transition issues."})
:GetSet("StandingViewOffset", 64, {description = "Eye height when standing"})
:GetSet("CrouchingViewOffset", 28, {description = "Eye height when crouching"})
:SetPropertyGroup("step size and view offset")
:GetSet("OverrideStepAndView", false, {hidden = true}) --legacy property, now split in two
:GetSet("OverrideStepSize", false, {description = "When changing size, pac scales the step size. This overrides that."})
:GetSet("StepSize", 18, {description = "Height that you can step up or down without jumping. Slightly tricky and may create view transition issues.", editor_panel = "hull", step = true})
:GetSet("OverrideView", false, {description = "When changing size, pac scales the view offsets. This overrides that."})
:GetSet("StandingViewOffset", 64, {description = "Eye height when standing", editor_panel = "hull", view = true})
:GetSet("CrouchingViewOffset", 28, {description = "Eye height when crouching", editor_panel = "hull", crouch = true, view = true})
:EndStorableVars()

BUILDER:RemoveProperty("BoneMerge")
Expand Down Expand Up @@ -62,6 +64,24 @@ function PART:SetHullWidth(val)
self.HullWidth = val
self:ApplyMatrix()
end
function PART:SetOverrideView(b)
self.OverrideView = b
self:ApplyMatrix()
end
function PART:SetOverrideStepSize(b)
self.OverrideStepSize = b
self:ApplyMatrix()
end

--backward compatibility
function PART:SetOverrideStepAndView(b)
if b == true then
self.OverrideStepSize = b
self.OverrideView = b
self:ApplyMatrix()
end
end

function PART:SetStandingViewOffset(val)
self.StandingViewOffset = val
self:ApplyMatrix()
Expand All @@ -74,10 +94,6 @@ function PART:SetStepSize(val)
self.StepSize = val
self:ApplyMatrix()
end
function PART:SetOverrideStepAndView(b)
self.OverrideStepAndView = b
self:ApplyMatrix()
end

function PART:GetNiceName()
local str = pac.PrettifyName(("/" .. self:GetModel()):match(".+/(.-)%.")) or self:GetModel()
Expand Down
59 changes: 37 additions & 22 deletions lua/pac3/core/shared/entity_mutators/size.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,25 @@ local allow_viewoffset = CreateConVar("pac_modifier_viewoffset", "0", CLIENT and

function MUTATOR:WriteArguments(multiplier, other)
net.WriteFloat(multiplier)
if other and (other.StandingHullHeight ~= nil and other.CrouchingHullHeight ~= nil and other.HullWidth ~= nil and other.StandingHullHeight ~= nil and other.StepSize ~= nil and other.StandingViewOffset ~= nil and other.CrouchingViewOffset ~= nil) then
if other then
net.WriteBool(true)
net.WriteFloat(other.StandingHullHeight)
net.WriteFloat(other.CrouchingHullHeight)
net.WriteFloat(other.HullWidth)
if other.OverrideStepAndView and (allow_step:GetBool() or allow_viewoffset:GetBool()) then
net.WriteBool(true)
net.WriteFloat(other.StepSize)
net.WriteFloat(other.StandingViewOffset)
net.WriteFloat(other.CrouchingViewOffset)
if allow_step:GetBool() then
if other.OverrideStepSize ~= nil and other.StepSize ~= nil then
net.WriteBool(other.OverrideStepSize)
net.WriteFloat(other.StepSize)
end
else
net.WriteBool(false)
end
if allow_viewoffset:GetBool() then
if other.OverrideView ~= nil and other.StandingViewOffset ~= nil and other.CrouchingViewOffset ~= nil then
net.WriteBool(other.OverrideView)
net.WriteFloat(other.StandingViewOffset)
net.WriteFloat(other.CrouchingViewOffset)
end
else
net.WriteBool(false)
end
Expand Down Expand Up @@ -48,9 +57,12 @@ function MUTATOR:ReadArguments()
other.StandingHullHeight = net.ReadFloat()
other.CrouchingHullHeight = net.ReadFloat()
other.HullWidth = net.ReadFloat()
other.OverrideStepAndView = net.ReadBool()
if other.OverrideStepAndView then
other.OverrideStepSize = net.ReadBool()
if allow_step:GetBool() then
other.StepSize = net.ReadFloat()
end
other.OverrideView = net.ReadBool()
if allow_viewoffset:GetBool() then
other.StandingViewOffset = net.ReadFloat()
other.CrouchingViewOffset = net.ReadFloat()
end
Expand Down Expand Up @@ -79,7 +91,7 @@ end
local functions = {
"ViewOffset",
"ViewOffsetDucked",
"StepSize",
"StepSize"
}

function MUTATOR:Mutate(multiplier, other, hidden_state)
Expand Down Expand Up @@ -131,26 +143,29 @@ function MUTATOR:Mutate(multiplier, other, hidden_state)
ent:SetHull(smin, smax)
ent:SetHullDuck(cmin, cmax)

if other.OverrideStepAndView then
if ent.SetStepSize and allow_step:GetBool() then
ent:SetStepSize(math.max(other.StepSize,0))
if other.OverrideStepSize then
local SSize = other.StepSize
if ent.SetStepSize then
ent:SetStepSize(math.max(SSize,0))
end
end
if other.OverrideView then
local soffset = other.StandingViewOffset
local coffset = other.CrouchingViewOffset
if ent.SetViewOffset then
ent:SetViewOffset(Vector(0,0,soffset))
end
if allow_viewoffset:GetBool() then
local soffset = other.StandingViewOffset
if ent.SetViewOffset then
ent:SetViewOffset(Vector(0,0,soffset))
end
local coffset = other.CrouchingViewOffset
if ent.SetViewOffsetDucked then
ent:SetViewOffsetDucked(Vector(0,0,coffset))
end
if ent.SetViewOffsetDucked then
ent:SetViewOffsetDucked(Vector(0,0,coffset))
end
end

else

ent:ResetHull()

end
end
end

pac.emut.Register(MUTATOR)
pac.emut.Register(MUTATOR)
97 changes: 80 additions & 17 deletions lua/pac3/editor/client/panels/extra_properties.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
menu:MakePopup()

local list = {}
for k,v in pairs(bones) do

Check warning on line 69 in lua/pac3/editor/client/panels/extra_properties.lua

View workflow job for this annotation

GitHub Actions / lint

"Space after comma"

Style: Please add a space after the comma
table.insert(list, v.friendly)
end

Expand Down Expand Up @@ -140,7 +140,7 @@

if self.CurrentKey == "TargetEntityUID" then
if part.Owner:IsValid() then
local owner = part:GetOwner()

Check warning on line 143 in lua/pac3/editor/client/panels/extra_properties.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: owner
self:SetText(" " .. part:GetName())
else
local owner = part:GetOwner()
Expand Down Expand Up @@ -175,9 +175,9 @@
function PANEL:PerformLayout()
if not IsValid(self.Icon) then return end
self:SetTextInset(11, 0)
self.Icon:SetPos(4,0)

Check warning on line 178 in lua/pac3/editor/client/panels/extra_properties.lua

View workflow job for this annotation

GitHub Actions / lint

"Space after comma"

Style: Please add a space after the comma
surface.SetFont(pace.CurrentFont)
local w,h = surface.GetTextSize(".")

Check warning on line 180 in lua/pac3/editor/client/panels/extra_properties.lua

View workflow job for this annotation

GitHub Actions / lint

"Space after comma"

Style: Please add a space after the comma

Check warning on line 180 in lua/pac3/editor/client/panels/extra_properties.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: w
h = h / 1.5
self.Icon:SetSize(h, h)
self.Icon:CenterVertical()
Expand Down Expand Up @@ -398,7 +398,7 @@

pace.PopulateProperties(pace.current_part)

for k,v in ipairs(pace.properties.List) do

Check warning on line 401 in lua/pac3/editor/client/panels/extra_properties.lua

View workflow job for this annotation

GitHub Actions / lint

"Space after comma"

Style: Please add a space after the comma
if v.panel and v.panel.part == part and v.key == key then
self = v.panel
break
Expand Down Expand Up @@ -466,7 +466,7 @@
function PANEL:MoreOptionsRightClick()
pace.SafeRemoveSpecialPanel()

local pnl = pace.CreatePanel("mat_browser")

Check warning on line 469 in lua/pac3/editor/client/panels/extra_properties.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of 'single quoted strings' and 'double quoted strings'

pace.ShowSpecial(pnl, self, 300)

Expand Down Expand Up @@ -511,13 +511,13 @@
if self.isShownTexture then return end

if not pace_material_display then
pace_material_display = CreateMaterial('pace_material_display', "UnlitGeneric", {})

Check warning on line 514 in lua/pac3/editor/client/panels/extra_properties.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of 'single quoted strings' and 'double quoted strings'
end

if pace.current_part[self.CurrentKey] then
if pace.current_part[self.CurrentKey] == "" then
pace_material_display:SetTexture("$basetexture", "models/debug/debugwhite")

Check warning on line 519 in lua/pac3/editor/client/panels/extra_properties.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of 'single quoted strings' and 'double quoted strings'
elseif not string.find(pace.current_part[self.CurrentKey], '^https?://') then

Check warning on line 520 in lua/pac3/editor/client/panels/extra_properties.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of 'single quoted strings' and 'double quoted strings'
pace_material_display:SetTexture("$basetexture", pace.current_part[self.CurrentKey])
else
local function callback(mat, tex)
Expand Down Expand Up @@ -1348,40 +1348,103 @@

PANEL.ClassName = "properties_hull"
PANEL.Base = "pace_properties_number"
local hull_color = Color(255, 204, 51, 255)

function PANEL:OnValueSet()
local function stop()
RunConsoleCommand("-duck")
hook.Remove("PostDrawOpaqueRenderables", "pace_draw_hull")
hook.Remove("PostDrawOpaqueRenderables", "pace_draw_hull2")
hook.Remove("PostDrawOpaqueRenderables", "pace_draw_hull3")
end

local time = os.clock() + 3

hook.Add("PostDrawOpaqueRenderables", "pace_draw_hull", function()
local udata = self.udata
if udata then
if udata.step then
if not self.first_time then self.first_time = true return end
hook.Add("PostDrawOpaqueRenderables", "pace_draw_hull3", function()

if not pace.current_part:IsValid() then stop() return end
if pace.current_part.ClassName ~= "entity2" then stop() return end
if not pace.current_part:IsValid() then stop() return end
if pace.current_part.ClassName ~= "entity2" then stop() return end

local ent = pace.current_part:GetOwner()
if not ent.GetHull then stop() return end
if not ent.GetHullDuck then stop() return end
local ent = pace.current_part:GetOwner()
if not ent.GetHull then stop() return end
if not ent.GetHullDuck then stop() return end

local min, max = ent:GetHull()
local min, max = ent:GetHull()

if self.udata and self.udata.crouch then
min, max = ent:GetHullDuck()
RunConsoleCommand("+duck")
end
local part = pace.current_part
local height = part.StepSize
min = Vector(-part.HullWidth/2,-part.HullWidth/2,0)
max = Vector(part.HullWidth/2,part.HullWidth/2,0)
render.DrawWireframeBox( ent:GetPos() + Vector(0,0,height), Angle(0), min, max, hull_color, true )

min = min * ent:GetModelScale()
max = max * ent:GetModelScale()
if time < os.clock() then
stop()
end
end)
elseif udata.view then
if not self.first_time then self.first_time = true return end
hook.Add("PostDrawOpaqueRenderables", "pace_draw_hull2", function()

render.DrawWireframeBox( ent:GetPos(), Angle(0), min, max, Color(255, 204, 51, 255), true )
if not pace.current_part:IsValid() then stop() return end
if pace.current_part.ClassName ~= "entity2" then stop() return end

if time < os.clock() then
stop()
local ent = pace.current_part:GetOwner()
if not ent.GetHull then stop() return end
if not ent.GetHullDuck then stop() return end

local min, max = ent:GetHull()

if udata.crouch then
min, max = ent:GetHullDuck()
RunConsoleCommand("+duck")
end

min = min * ent:GetModelScale()
max = max * ent:GetModelScale()

local part = pace.current_part
local height = part.StandingViewOffset
if udata.crouch then
height = part.CrouchingViewOffset
end
render.DrawWireframeSphere( ent:GetPos() + Vector(0, 0, height), 8, 8, 8, hull_color, true )

if time < os.clock() then
stop()
end
end)
else
hook.Add("PostDrawOpaqueRenderables", "pace_draw_hull", function()

if not pace.current_part:IsValid() then stop() return end
if pace.current_part.ClassName ~= "entity2" then stop() return end

local ent = pace.current_part:GetOwner()
if not ent.GetHull then stop() return end
if not ent.GetHullDuck then stop() return end

local min, max = ent:GetHull()

if udata.crouch then
min, max = ent:GetHullDuck()
RunConsoleCommand("+duck")
end

min = min * ent:GetModelScale()
max = max * ent:GetModelScale()

render.DrawWireframeBox( ent:GetPos(), Angle(0), min, max, hull_color, true )

if time < os.clock() then
stop()
end
end)
end
end)
end
end

pace.RegisterPanel(PANEL)
Expand Down
Loading