diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2018-11-03 18:23:45 -0400 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2018-11-03 18:23:45 -0400 |
| commit | 28affa22541b9ef251707793f6b1c1a26d663592 (patch) | |
| tree | 622754894d75c74dc5e8516ccf184ad4bf328fef /gamemode/ents/art_npc/cl_art_npc.lua | |
| parent | c639e7c7c6ab1595fdce39f56312e3d6a886bbe8 (diff) | |
| download | artery-28affa22541b9ef251707793f6b1c1a26d663592.tar.gz artery-28affa22541b9ef251707793f6b1c1a26d663592.tar.bz2 artery-28affa22541b9ef251707793f6b1c1a26d663592.zip | |
Started on new npc system
Started work on the new npc system
Diffstat (limited to 'gamemode/ents/art_npc/cl_art_npc.lua')
| -rw-r--r-- | gamemode/ents/art_npc/cl_art_npc.lua | 139 |
1 files changed, 139 insertions, 0 deletions
diff --git a/gamemode/ents/art_npc/cl_art_npc.lua b/gamemode/ents/art_npc/cl_art_npc.lua new file mode 100644 index 0000000..0233666 --- /dev/null +++ b/gamemode/ents/art_npc/cl_art_npc.lua @@ -0,0 +1,139 @@ +local ENT = nrequire("sh_art_npc.lua") +local e = nrequire("editor.lua") +local col = nrequire("colortheme.lua") +print("in cl_art_npc, ENT loaded from sh_art_npc is", ENT) + +ENT.RenderGroup = RENDERGROUP_BOTH + + +local function get_settings_info(what) + -- Settings to display next to an npc + local settings = {} + + settings["Model"] = what:GetModel() + + -- Classes that this npc inherits from, in the order it inherits + local sinh = {} + local sinhc = 1 -- Keep going, even if we encounter nil + local cursor = what + sinh[sinhc] = cursor.Name + while cursor do + cursor = getmetatable(cursor) + if type(cursor) == "table" then + sinh[sinhc] = cursor.Name or "nil" + else + sinh[sinhc] = tostring(cursor) + end + sinhc = sinhc + 1 + end + settings["Inherits from"] = string.format("[%s]",table.concat(sinh,", ")) + + return settings +end + +local settings_info = nil +function ENT:Draw() + if e.Enabled then --What to draw when "Editor" is enabled + self:DrawModel() + + if settings_info == nil then + settings_info = get_settings_info(self) + end + local pos,ang = (self:GetRight() * -32) + (self:GetUp() * 72) + self:GetPos() , self:GetAngles() + + cam.Start3D2D( pos, ang + Angle(0, 90, 90), 0.2 ) + local line = 0 + for k,v in pairs(settings_info) do + draw.DrawText(string.format("%s:%s",k,tostring(v)), "Default", 0, line * 20, col.game.npcsettings ) + line = line + 1 + end + + cam.End3D2D() + else + self:DrawModel() + end +end + +function ENT:DrawTranslucent() + + -- This is here just to make it backwards compatible. + -- You shouldn't really be drawing your model here unless it's translucent + + self:Draw() + +end + +function ENT:BuildBonePositions( NumBones, NumPhysBones ) + + -- You can use this section to position the bones of + -- any animated model using self:SetBonePosition( BoneNum, Pos, Angle ) + + -- This will override any animation data and isn't meant as a + -- replacement for animations. We're using this to position the limbs + -- of ragdolls. + +end + +function ENT:SetRagdollBones( bIn ) + + -- If this is set to true then the engine will call + -- DoRagdollBone (below) for each ragdoll bone. + -- It will then automatically fill in the rest of the bones + + self.m_bRagdollSetup = bIn + +end + +function ENT:DoRagdollBone( PhysBoneNum, BoneNum ) + + -- self:SetBonePosition( BoneNum, Pos, Angle ) + +end + +local chatframe = nil + +net.Receive("art_opennpcdialog",function() + if chatframe ~= nil and chatframe:IsValid() then + chatframe:Remove() + chatframe = nil + end + local width, height = ScrW(), ScrH() + local who = net.ReadEntity() + local chattbl = net.ReadTable() + chatframe = vgui.Create( "DFrame" ) + chatframe:SetPos( (width / 2) - (width / 4), height - (height / 4) ) + chatframe:SetSize( width / 2, height / 4 ) + chatframe:SetTitle( chattbl["Name"] ) + chatframe:SetDraggable( true ) + chatframe.OnClose = function() + net.Start("art_closenpcdialog") + net.WriteEntity(who) + net.SendToServer() + end + + local chattxt = vgui.Create( "DLabel", chatframe ) + --chattxt:SetPos( 40, 40 ) + chattxt:SetText(chattbl["Message"]) + chattxt:Dock(TOP) + + for k,v in pairs(chattbl["Options"]) do + local chatbutton = vgui.Create( "DButton",chatframe ) + --chatbutton:SetPos( 40, 40 ) + chatbutton:SetText( v ) + --chatbutton:SetSize( 120, 60 ) + chatbutton.DoClick = function() + net.Start("art_updatenpcdialog") + net.WriteEntity(who) + net.WriteString(v) + net.SendToServer() + end + chatbutton:Dock(BOTTOM) + end + chattxt:Dock(FILL) + + + + chatframe:MakePopup() +end) + +scripted_ents.Register(ENT, "art_npc") |
