Skip to content

Commit 5adac6e

Browse files
committed
Use func_brush to block for changelevel that is going back
1 parent eb71b34 commit 5adac6e

2 files changed

Lines changed: 39 additions & 120 deletions

File tree

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,32 @@
1-
"LightmappedGeneric"
1+
"UnlitGeneric"
22
{
3-
"$basetexture" "lambda/blocked.vtf"
4-
"$receiveflashlight" "1"
5-
"$selfillum" "1"
6-
"$translucent" "1"
7-
"$alpha" "1"
3+
"$basetexture" "Effects/Combineshield/comshieldwall"
84

9-
Proxies
5+
"$translucent" "1"
6+
"$additive" "1"
7+
"$alpharesult" "1"
8+
"$nodecal" "1"
9+
10+
// Strong orange base color
11+
"$color" "{220 112 0}"
12+
13+
"$envmap" "env_cubemap"
14+
"$envmaptint" "[0 0 0]"
15+
16+
"Proxies"
1017
{
11-
Sine // a proxy which produces a sine wave
18+
Sine
1219
{
1320
resultVar $alpha // The shader parameter to be manipulated
1421
sineperiod 1
15-
sinemin 0.3
16-
sinemax 0.7
22+
sinemin 0.2
23+
sinemax 0.3
1724
}
18-
19-
TextureScroll
25+
"TextureScroll"
2026
{
21-
textureScrollVar $basetexturetransform
22-
textureScrollRate 0.1
23-
textureScrollAngle 70
27+
"texturescrollvar" "$basetexturetransform"
28+
"texturescrollrate" .1
29+
"texturescrollangle" 20
2430
}
25-
2631
}
27-
}
32+
}

entities/entities/lambda_trigger.lua

Lines changed: 17 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ local TRIGGER_MSG_PLAYER_COUNT = 0
1818
local TRIGGER_MSG_SHOWWAIT = 1
1919
local TRIGGER_MSG_SETBLOCKED = 2
2020
local TRIGGER_MSG_REMOVED = 3
21+
local MAT_BLOCKED = "lambda/blocked"
22+
2123
ENT.Base = "lambda_entity"
2224
ENT.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

Comments
 (0)