Skip to content

Commit 26c6574

Browse files
committed
Take zone into account for spawn highlighting
1 parent 64299b0 commit 26c6574

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

lua/cfc_random_spawn/module/cl_spawns_editor.lua

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,38 @@ hook.Add( "PostDrawTranslucentRenderables", "CFC_SpawnEditor_DrawSpawnPoints", f
7777
if sky or sky3d then return end
7878

7979
if spawnTable.spawnpoints then
80-
local activeCenterPos = activeCenter and activeCenter.centerPos
81-
local activeCenterCutoff = activeCenter and activeCenter.centerCutoff or centerCutoffDefault
80+
local activeCenterPos
81+
local activeCenterCutoff
82+
local activeCenterZoneCornerA
83+
local activeCenterZoneCornerB
84+
85+
-- Cace active center stuff
86+
if activeCenter then
87+
activeCenterPos = activeCenter.centerPos
88+
activeCenterCutoff = activeCenter.centerCutoff or centerCutoffDefault
89+
90+
if spawnTable.zones then
91+
local zone = spawnTable.zones[activeCenter.zoneID]
92+
93+
if zone then
94+
activeCenterZoneCornerA = zone.cornerA
95+
activeCenterZoneCornerB = zone.cornerB
96+
end
97+
end
98+
end
8299

100+
-- Draw spawns
83101
for _, spawn in ipairs( spawnTable.spawnpoints ) do
84102
local spawnPos = spawn.spawnPos
85103
local spawnAngle = spawn.spawnAngle
86104
local color = spawnColor
87105

88106
if activeCenterPos and spawnPos:Distance( activeCenterPos ) <= activeCenterCutoff then
89-
color = spawnColorActiveCenter
107+
local isInZone = activeCenterZoneCornerA == nil or spawnPos:WithinAABox( activeCenterZoneCornerA, activeCenterZoneCornerB )
108+
109+
if isInZone then
110+
color = spawnColorActiveCenter
111+
end
90112
end
91113

92114
render.DrawWireframeBox( spawnPos, spawnAngle or emptyAngle, playerMins, playerMaxs, color, false )
@@ -413,5 +435,6 @@ net.Receive( "CFC_SpawnEditor_ActiveCenter", function()
413435
activeCenter = {
414436
centerPos = net.ReadVector(),
415437
centerCutoff = net.ReadFloat(),
438+
zoneID = net.ReadUInt( 10 ),
416439
}
417440
end )

lua/cfc_random_spawn/module/sv_player_spawning.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ local function updatePopularCenter( measurablePlayers )
467467
net.Start( "CFC_SpawnEditor_ActiveCenter" )
468468
net.WriteVector( mostPopularCenter.centerPos )
469469
net.WriteFloat( mostPopularCenter.centerCutoff or DEFAULT_CENTER_CUTOFF )
470+
net.WriteUInt( mostPopularCenter.zoneID, 10 )
470471
net.Send( editors )
471472
end
472473

0 commit comments

Comments
 (0)