Skip to content

Commit

Permalink
Slight visual improvements for armor ents
Browse files Browse the repository at this point in the history
- Changed the appearance to not require SProps materials
- Added a simple Wire overlay
- Added a model preview in the menu
- Added an Armor tool operation for the ACF Menu
  • Loading branch information
thecraftianman committed Jan 18, 2025
1 parent f62410a commit b2e58bd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
17 changes: 12 additions & 5 deletions lua/acf/menu/items_cl/fun_entities.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,15 @@ end
do -- Procedural Armor
local DensityText = "Density: %sg/cm³ (%skg/in³)"
local ArmorTypes = Classes.ArmorTypes
local PreviewSettings = {
FOV = 120,
Height = 160,
}

local function CreateMenu(Menu)
local Entries = ArmorTypes.GetEntries()

ACF.SetToolMode("acf_menu", "Spawner", "Component")
ACF.SetToolMode("acf_menu", "Spawner", "Armor")

ACF.SetClientData("PrimaryClass", "acf_armor")
ACF.SetClientData("SecondaryClass", "N/A")
Expand All @@ -139,10 +143,11 @@ do -- Procedural Armor
local SizeY = Menu:AddSlider("Plate Width (gmu)", 0.25, 420, 2)
local SizeZ = Menu:AddSlider("Plate Thickness (mm)", 5, 1000)

local ClassBase = Menu:AddCollapsible("Material Information")
local ClassName = ClassBase:AddTitle()
local ClassDesc = ClassBase:AddLabel()
local ClassDens = ClassBase:AddLabel()
local ClassBase = Menu:AddCollapsible("Material Information")
local ClassName = ClassBase:AddTitle()
local ClassDesc = ClassBase:AddLabel()
local ClassPreview = ClassBase:AddModelPreview("models/holograms/hq_rcube_thin.mdl", true)
local ClassDens = ClassBase:AddLabel()

function ClassList:OnSelect(Index, _, Data)
if self.Selected == Data then return end
Expand All @@ -154,6 +159,8 @@ do -- Procedural Armor

ClassName:SetText(Data.Name)
ClassDesc:SetText(Data.Description)
ClassPreview:UpdateModel("models/holograms/hq_rcube_thin.mdl", "phoenix_storms/metalfloor_2-3")
ClassPreview:UpdateSettings(PreviewSettings)
ClassDens:SetText(DensityText:format(Density, math.Round(Density * ACF.gCmToKgIn, 2)))

ACF.SetClientData("ArmorType", Data.ID)
Expand Down
1 change: 1 addition & 0 deletions lua/acf/menu/operations/acf_menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ ACF.CreateMenuOperation("Engine", "engine", "fuel tank")
ACF.CreateMenuOperation("Component", "component")
ACF.CreateMenuOperation("Gearbox", "gearbox")
ACF.CreateMenuOperation("Sensor", "sensor")
ACF.CreateMenuOperation("Armor", "armor plate")

ACF.CreateMenuOperation("1-Turret", "turret")
ACF.CreateMenuOperation("2-Motor", "turret motor")
Expand Down
14 changes: 12 additions & 2 deletions lua/entities/acf_armor/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ do -- Spawning and Updating
Player:AddCount("_acf_armor", Plate)
Player:AddCleanup("_acf_armor", Plate)

Plate:SetScaledModel("models/holograms/cube.mdl")
Plate:SetMaterial("sprops/textures/sprops_metal1")
Plate:SetScaledModel("models/holograms/hq_rcube_thin.mdl")
Plate:SetMaterial("phoenix_storms/metalfloor_2-3")
Plate:SetPlayer(Player)
Plate:SetAngles(Angle)
Plate:SetPos(Pos)
Expand Down Expand Up @@ -241,5 +241,15 @@ function ENT:OnRemove()
Armor.OnLast(self, Armor)
end

hook.Run("ACF_OnEntityLast", "acf_armor", self, Armor)

WireLib.Remove(self)
end

do -- Wire overlay text
local OverlayText = "Armor Type: %s\nPlate Size: %.1f x %.1f x %.1f"

function ENT:UpdateOverlayText()
return OverlayText:format(self.ArmorClass.Name, self.Size[1], self.Size[2], self.Size[3])
end
end

0 comments on commit b2e58bd

Please sign in to comment.