mirror of
https://github.com/willox/gmod-keypad.git
synced 2025-03-04 03:13:31 -05:00
Good night
Basic entity/rendering done
This commit is contained in:
parent
630310bdfe
commit
8dd0cd5f72
41
lua/entities/keypad/cl_init.lua
Normal file
41
lua/entities/keypad/cl_init.lua
Normal file
@ -0,0 +1,41 @@
|
||||
include "sh_init.lua"
|
||||
|
||||
local mat = CreateMaterial("keypad_aaaaaaaaaaaaaaaaaaaaabaaaaaaaaaasaae", "VertexLitGeneric", {
|
||||
["$basetexture"] = "white",
|
||||
["$color"] = "{ 42 42 42 }",
|
||||
})
|
||||
|
||||
local VECTOR_X = Vector(1, 0, 0)
|
||||
local VECTOR_Y = Vector(0, 1, 0)
|
||||
local VECTOR_Z = Vector(0, 0, 1)
|
||||
|
||||
function ENT:Draw()
|
||||
render.SetMaterial(mat)
|
||||
|
||||
render.DrawBox(self:GetPos(), self:GetAngles(), self.Mins, self.Maxs, color_white, true)
|
||||
|
||||
local pos = self:GetPos()
|
||||
pos:Add(self:GetForward() * self.Maxs.x) -- Translate to front
|
||||
pos:Add(self:GetRight() * self.Maxs.y) -- Translate to left
|
||||
pos:Add(self:GetUp() * self.Maxs.z) -- Translate to top
|
||||
|
||||
pos:Add(self:GetForward() * 0.01) -- Pop out of front to stop culling
|
||||
pos:Add(self:GetRight() * -0.03) -- Left margin
|
||||
|
||||
local ang = self:GetAngles()
|
||||
ang:RotateAroundAxis(ang:Right(), -90)
|
||||
ang:RotateAroundAxis(ang:Up(), 90)
|
||||
|
||||
local w, h = 130, 230 -- :(
|
||||
|
||||
--print(util.IntersectRayWithPlane(EyePos(), LocalPlayer():GetAimVector(), pos, ang:Forward()))
|
||||
|
||||
cam.Start3D2D(pos, ang, 0.05)
|
||||
self:Paint(w, h)
|
||||
cam.End3D2D()
|
||||
end
|
||||
|
||||
function ENT:Paint(w, h, mousex, mousey)
|
||||
surface.SetDrawColor(Color(255, 0, 0, 20))
|
||||
surface.DrawRect(4, 4, w - 8, h - 8)
|
||||
end
|
4
lua/entities/keypad/init.lua
Normal file
4
lua/entities/keypad/init.lua
Normal file
@ -0,0 +1,4 @@
|
||||
AddCSLuaFile "cl_init.lua"
|
||||
AddCSLuaFile "sh_init.lua"
|
||||
|
||||
include "sh_init.lua"
|
39
lua/entities/keypad/sh_init.lua
Normal file
39
lua/entities/keypad/sh_init.lua
Normal file
@ -0,0 +1,39 @@
|
||||
ENT.Base = "base_anim"
|
||||
|
||||
ENT.Model = Model("models/props_lab/keypad.mdl")
|
||||
|
||||
ENT.Spawnable = true
|
||||
|
||||
ENT.Status_None = 0
|
||||
ENT.Status_Granted = 1
|
||||
ENT.Status_Denied = 2
|
||||
|
||||
ENT.Command_Enter = 0
|
||||
ENT.Command_Accept = 1
|
||||
ENT.Command_Reset = 2
|
||||
|
||||
|
||||
function ENT:Initialize()
|
||||
self:SetModel(self.Model)
|
||||
|
||||
self.Mins = self:OBBMins()
|
||||
self.Maxs = self:OBBMaxs()
|
||||
|
||||
if SERVER then
|
||||
self:PhysicsInit(SOLID_VPHYSICS)
|
||||
|
||||
local phys = self:GetPhysicsObject()
|
||||
|
||||
if IsValid(phys) then
|
||||
phys:Wake()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:SetupDataTables()
|
||||
self:NetworkVar( "String", 0, "Text" )
|
||||
|
||||
self:NetworkVar( "Int", 0, "Status" )
|
||||
|
||||
self:NetworkVar( "Bool", 0, "Secure" )
|
||||
end
|
Loading…
Reference in New Issue
Block a user