@@ -18,6 +18,8 @@ local TRIGGER_MSG_PLAYER_COUNT = 0
1818local TRIGGER_MSG_SHOWWAIT = 1
1919local TRIGGER_MSG_SETBLOCKED = 2
2020local TRIGGER_MSG_REMOVED = 3
21+ local MAT_BLOCKED = " lambda/blocked"
22+
2123ENT .Base = " lambda_entity"
2224ENT .Type = " brush"
2325
@@ -203,31 +205,20 @@ if SERVER then
203205 DbgPrint (util .EntityName (self ), " HandleBlockingUpdate" , wasBlocked , wantsBlocking )
204206
205207 if wasBlocked == true and wantsBlocking == false then
206- self :SetCustomCollisionCheck (false )
207-
208- if IsValid (self :GetPhysicsObject ()) then
209- self :PhysicsDestroy ()
210- end
211-
212- if self .PrevModel ~= nil then
213- self :SetModel (self .PrevModel )
208+ if IsValid (self .BlockerBrush ) then
209+ self .BlockerBrush :Remove ()
210+ self .BlockerBrush = nil
214211 end
215-
216- self :SetTrigger (true )
217- self :CollisionRulesChanged ()
218212 elseif wasBlocked == false and wantsBlocking == true then
219- self :PhysicsInit (SOLID_BSP )
220- self :SetSolid (SOLID_BSP )
221- self :SetMoveType (MOVETYPE_NONE )
222- local phys = self :GetPhysicsObject ()
223-
224- if IsValid (phys ) then
225- phys :EnableMotion (false )
226- end
227-
228- self :SetCustomCollisionCheck (true )
229- self :CollisionRulesChanged ()
230- self .PrevModel = self :GetModel ()
213+ local blocker = ents .Create (" func_brush" )
214+ blocker :SetPos (self :GetPos ())
215+ blocker :SetAngles (self :GetAngles ())
216+ blocker :SetModel (self :GetModel ())
217+ blocker :SetMaterial (MAT_BLOCKED )
218+ -- Let all NPCs pass through except players.
219+ blocker :SetKeyValue (" invert_exclusion" , " 1" )
220+ blocker :Spawn ()
221+ self .BlockerBrush = blocker
231222 end
232223
233224 self :CmdSetBlocked (nil )
@@ -637,24 +628,12 @@ if SERVER then
637628 return
638629 end
639630
640- if self :PassesTriggerFilters (ent ) == false then return end -- DbgPrint("Object " .. tostring(ent) .. " did not pass trigger filter")
641-
642631 if self :GetNWVar (" Blocked" ) == true and ent :IsPlayer () then
643- local dir = self :OBBCenter () - ent :GetPos ()
644- local ang = dir :Angle ()
645- local force = 1400
646-
647- if ent :IsOnGround () == false then
648- force = 200
649- end
650-
651- local vel = - ang :Forward () * force
652- vel .z = 0
653- ent :SetVelocity (vel )
654-
655632 return
656633 end
657634
635+ if self :PassesTriggerFilters (ent ) == false then return end -- DbgPrint("Object " .. tostring(ent) .. " did not pass trigger filter")
636+
658637 if self .OnStartTouch ~= nil and isfunction (self .OnStartTouch ) then
659638 self :OnStartTouch (ent )
660639 end
@@ -882,17 +861,7 @@ if SERVER then
882861 net .WriteUInt (TRIGGER_MSG_SETBLOCKED , 4 )
883862 net .WriteBool (blocked )
884863
885- if blocked == true then
886- local phys = self :GetPhysicsObject ()
887-
888- if IsValid (phys ) then
889- local meshData = phys :GetMesh ()
890- net .WriteTable (meshData )
891- else
892- DbgError (self , " No valid phys object while blocking!" )
893- net .WriteTable ({})
894- end
895-
864+ if blocked == true and false then
896865 net .WriteVector (self :GetPos ())
897866 net .WriteVector (self :OBBCenter ())
898867 net .WriteVector (self :OBBMins ())
@@ -975,7 +944,6 @@ else -- CLIENT
975944 local state = net .ReadBool ()
976945
977946 if state == true then
978- local meshData = net .ReadTable ()
979947 local pos = net .ReadVector ()
980948 local center = net .ReadVector ()
981949 local maxs = net .ReadVector ()
@@ -1176,60 +1144,6 @@ else -- CLIENT
11761144 end )
11771145 end
11781146
1179- local MAT_BLOCKED = Material (" lambda/blocked.vmt" )
1180-
1181- local function DrawTriggerBlockade (data )
1182- local cachedMesh = data .Mesh
1183-
1184- if cachedMesh == nil then
1185- cachedMesh = Mesh (MAT_BLOCKED )
1186- local meshData = table .Copy (data .MeshData )
1187- local texture_w = 48
1188-
1189- for i = 1 , # meshData do
1190- local v1 = meshData [i ]
1191- v1 .normal = Vector (0 , 0 , 0 )
1192- end
1193-
1194- for i = 1 , # meshData do
1195- local v1 = meshData [i ]
1196- local v2 = meshData [i + 1 ]
1197- local v3 = meshData [i + 2 ]
1198- if v1 == nil or v2 == nil or v3 == nil then continue end
1199- local e1 = v1 .pos - v2 .pos
1200- local e2 = v3 .pos - v2 .pos
1201- local no = e1 :Cross (e2 )
1202- v1 .normal = v1 .normal + no
1203- v2 .normal = v2 .normal + no
1204- v3 .normal = v3 .normal + no
1205- end
1206-
1207- for i = 1 , # meshData do
1208- local v1 = meshData [i ]
1209- v1 .normal :Normalize ()
1210- local rel = v1 .pos
1211- meshData [i ].v = (rel .y % texture_w ) / texture_w
1212- meshData [i ].u = (rel .x % texture_w ) / texture_w
1213- end
1214-
1215- cachedMesh :BuildFromTriangles (meshData )
1216- data .Mesh = cachedMesh
1217- end
1218-
1219- render .SetMaterial (MAT_BLOCKED )
1220- cachedMesh :Draw ()
1221- end
1222-
1223- hook .Add (" PostDrawTranslucentRenderables" , " LambdaTrigger" , function (bDrawingDepth , bDrawingSkybox )
1224- if bDrawingSkybox == true then return end
1225-
1226- for k , data in pairs (LAMBDA_TRIGGERS ) do
1227- if data .Blocked == true then
1228- DrawTriggerBlockade (data )
1229- end
1230- end
1231- end )
1232-
12331147 hook .Add (" HUDPaint" , " LambdaTrigger" , function ()
12341148 for k , data in pairs (LAMBDA_TRIGGERS ) do
12351149 if data .Waiting == true then
0 commit comments