|
| 1 | +TOOL.Category = "Contraption Framework" |
| 2 | +TOOL.Name = "CFW Tool" |
| 3 | +TOOL.AddToMenu = false |
| 4 | + |
| 5 | + |
| 6 | +--[[ |
| 7 | + To access this, use 'gmod_tool cfw_tool' |
| 8 | + Hidden because this relies on developer 1, so not for use by normal means, for now |
| 9 | + Eventually this will get fleshed out with multiple debug modes |
| 10 | +
|
| 11 | + For example: |
| 12 | + Op 1 - Show entity's links via link table |
| 13 | + Op 2 - Show contraption that this entity is a part of |
| 14 | + Op 3 - ? |
| 15 | +
|
| 16 | + Tool screen should reflect mode of the tool as well |
| 17 | + When this happens, maybe allow normal use of the tool as well? |
| 18 | +]] |
| 19 | + |
| 20 | + |
| 21 | +TOOL.Entity = nil |
| 22 | + |
| 23 | +function TOOL:LeftClick(tr) |
| 24 | + if not IsFirstTimePredicted() then return end |
| 25 | + if CLIENT then return true end |
| 26 | + |
| 27 | + if (not IsValid(tr.Entity)) or tr.Entity:IsWorld() then |
| 28 | + self.Entity = nil |
| 29 | + else |
| 30 | + self.Entity = tr.Entity |
| 31 | + end |
| 32 | + |
| 33 | + return true |
| 34 | +end |
| 35 | + |
| 36 | +function TOOL:Reload() |
| 37 | + if not IsFirstTimePredicted() then return end |
| 38 | + if CLIENT then return end |
| 39 | + |
| 40 | + self.Entity = nil |
| 41 | +end |
| 42 | + |
| 43 | +function TOOL:Think() |
| 44 | + local ent = self.Entity |
| 45 | + if not IsValid(ent) then return end |
| 46 | + local selftbl = ent:GetTable() |
| 47 | + |
| 48 | + if not selftbl._links then return end |
| 49 | + |
| 50 | + local tick = engine.TickInterval() + 0.05 |
| 51 | + |
| 52 | + local Rendered = {} |
| 53 | + for _, link in pairs(selftbl._links) do |
| 54 | + local entA, entB = link.entA, link.entB |
| 55 | + debugoverlay.Line(entA:GetPos(),entB:GetPos(),tick,link.color,true) |
| 56 | + |
| 57 | + if not Rendered[entA] then |
| 58 | + debugoverlay.Text(entA:GetPos(),"A",tick,false) |
| 59 | + |
| 60 | + Rendered[entA] = true |
| 61 | + end |
| 62 | + |
| 63 | + if not Rendered[entB] then |
| 64 | + debugoverlay.Text(entB:GetPos(),"B",tick,false) |
| 65 | + Rendered[entB] = true |
| 66 | + end |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | + end |
| 71 | +end |
| 72 | + |
0 commit comments