Good night

Basic entity/rendering done
This commit is contained in:
William Wallace 2014-07-07 02:37:47 +01:00
parent 630310bdfe
commit 8dd0cd5f72
3 changed files with 84 additions and 0 deletions

View 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

View File

@ -0,0 +1,4 @@
AddCSLuaFile "cl_init.lua"
AddCSLuaFile "sh_init.lua"
include "sh_init.lua"

View 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