Skip to content

Commit

Permalink
Redo fuel tank appearance
Browse files Browse the repository at this point in the history
As suggested by ghosteh

This also adds an optional material parameter to the model panel's UpdateModel() since you otherwise can't draw the material on the tank
  • Loading branch information
thecraftianman committed Jan 24, 2024
1 parent 0d3b288 commit 5e0adf1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lua/acf/entities/fuel_tanks/box.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ FuelTanks.Register("FTS_B", {
Name = "Fuel Box",
Description = "Scalable fuel box; required for engines to work.",
IsScalable = true,
Model = "models/fueltank/fueltank_4x4x4.mdl",
Model = "models/holograms/hq_rcube.mdl",
Material = "models/props_canal/metalcrate001d",
Shape = "Box",
NameType = "Tank",
IsExplosive = true,
Expand Down
5 changes: 4 additions & 1 deletion lua/acf/menu/items_cl/engines.lua
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,10 @@ local function CreateMenu(Menu)

ACF.SetClientData("FuelTank", Data.ID)

FuelPreview:UpdateModel(Data.Model or ClassData.Model)
local Model = Data.Model or ClassData.Model
local Material = Data.Material or ClassData.Material

FuelPreview:UpdateModel(Model, Material)
FuelPreview:UpdateSettings(Data.Preview or ClassData.Preview)

FuelType:UpdateFuelText()
Expand Down
4 changes: 4 additions & 0 deletions lua/entities/acf_fueltank/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ do -- Spawn and Update functions
local FuelType = FuelTypes.Get(Data.FuelType)
local Limit = Class.LimitConVar.Name
local Model = Class.Model or FuelTank and FuelTank.Model
local Material = Class.Material or FuelTank and FuelTank.Model

if not Player:CheckLimit(Limit) then return end

Expand All @@ -201,6 +202,9 @@ do -- Spawn and Update functions

Tank:SetPlayer(Player)
Tank:SetScaledModel(Model)
if Material then
Tank:SetMaterial(Material)
end
Tank:SetAngles(Angle)
Tank:SetPos(Pos)
Tank:Spawn()
Expand Down
8 changes: 7 additions & 1 deletion lua/vgui/acf_panel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ function PANEL:AddModelPreview(Model, Rotate)
self.NotDrawn = not Bool
end

function Panel:UpdateModel(Path)
function Panel:UpdateModel(Path, Material)
if not isstring(Path) then
return self:DrawEntity(false)
end
Expand Down Expand Up @@ -364,6 +364,12 @@ function PANEL:AddModelPreview(Model, Rotate)
self:DrawEntity(true)
self:SetModel(Path)
self:SetCamPos(Center + Vector(-self.CamDistance, 0, 0))

if Material then
local Entity = self:GetEntity()

Entity:SetMaterial(Material)
end
end

function Panel:UpdateSettings(Data)
Expand Down

0 comments on commit 5e0adf1

Please sign in to comment.