mirror of
https://github.com/metrostroi-repo/MetrostroiAddon.git
synced 2026-05-02 00:42:29 +00:00
Pass Distance
This commit is contained in:
@@ -297,6 +297,7 @@ end
|
||||
|
||||
local C_DisableHUD = GetConVar("metrostroi_disablehud")
|
||||
local C_RenderDistance = GetConVar("metrostroi_renderdistance")
|
||||
local C_PassRenderDistance = GetConVar("metrostroi_passengers_distance")
|
||||
local C_SoftDraw = GetConVar("metrostroi_softdrawmultipier")
|
||||
local C_ScreenshotMode = GetConVar("metrostroi_screenshotmode")
|
||||
local C_DrawDebug = GetConVar("metrostroi_drawdebug")
|
||||
@@ -865,7 +866,7 @@ function ENT:OnRemove(nfinal)
|
||||
end
|
||||
end
|
||||
for _,v in pairs(self.PassengerEnts or {}) do
|
||||
SafeRemoveEntity(v)
|
||||
SafeRemoveEntity(v.ent)
|
||||
end
|
||||
for _,v in pairs(self.PassengerEntsStucked or {}) do
|
||||
SafeRemoveEntity(v)
|
||||
@@ -1363,7 +1364,7 @@ function ENT:Think()
|
||||
else
|
||||
self:PlayOnceFromPos("PassStuckL"..i,"subway_trains/common/door/pass_stuck.mp3",5,0.9+math.random()*0.2,150,400,v)
|
||||
end
|
||||
elseif not self:GetPackedBool("DoorLS"..i) and IsValid(stucked[i]) then
|
||||
elseif IsValid(stucked[i]) and (not self:GetPackedBool("DoorLS"..i) or stucked[i]:IsDormant()) then
|
||||
SafeRemoveEntity(stucked[i])
|
||||
end
|
||||
end
|
||||
@@ -1386,17 +1387,17 @@ function ENT:Think()
|
||||
else
|
||||
self:PlayOnceFromPos("PassStuckR"..i,"subway_trains/common/door/pass_stuck.mp3",5,0.9+math.random()*0.2,150,400,v)
|
||||
end
|
||||
elseif not self:GetPackedBool("DoorRS"..i) and IsValid(stucked[-i]) then
|
||||
elseif IsValid(stucked[-i]) and (not self:GetPackedBool("DoorRS"..i) or stucked[-i]:IsDormant()) then
|
||||
SafeRemoveEntity(stucked[-i])
|
||||
end
|
||||
end
|
||||
if #self.PassengerEnts ~= self:GetNW2Float("PassengerCount") then
|
||||
-- Passengers go out
|
||||
while #self.PassengerEnts > self:GetNW2Float("PassengerCount") do
|
||||
local ent = self.PassengerEnts[#self.PassengerEnts]
|
||||
local tbl = self.PassengerEnts[#self.PassengerEnts]
|
||||
table.remove(self.PassengerPositions,#self.PassengerPositions)
|
||||
table.remove(self.PassengerEnts,#self.PassengerEnts)
|
||||
ent:Remove()
|
||||
SafeRemoveEntity(tbl.ent)
|
||||
end
|
||||
-- Passengers go in
|
||||
while #self.PassengerEnts < self:GetNW2Float("PassengerCount") do
|
||||
@@ -1405,10 +1406,10 @@ function ENT:Think()
|
||||
|
||||
--local ent = ents.CreateClientProp("models/metrostroi/81-717/reverser.mdl")
|
||||
--ent:SetModel(table.Random(self.PassengerModels))
|
||||
local ent = ClientsideModel(table.Random(self.PassengerModels),RENDERGROUP_OPAQUE)
|
||||
if not IsValid(ent) then break end
|
||||
ent:SetPos(self:LocalToWorld(pos))
|
||||
ent:SetAngles(Angle(0,math.random(0,360),0))
|
||||
local tbl = {}
|
||||
tbl.mdl = table.Random(self.PassengerModels)
|
||||
tbl.pos = pos
|
||||
tbl.ang = Angle(0,math.random(0,360),0)
|
||||
--[[
|
||||
hook.Add("MetrostroiBigLag",ent,function(ent)
|
||||
ent:SetPos(self:LocalToWorld(pos))
|
||||
@@ -1416,11 +1417,29 @@ function ENT:Think()
|
||||
--if ent.Spawned then hook.Remove("MetrostroiBigLag",ent) end
|
||||
--ent.Spawned = true
|
||||
end)]]
|
||||
ent:SetSkin(math.floor(ent:SkinCount()*math.random()))
|
||||
ent:SetModelScale(0.98 + (-0.02+0.04*math.random()),0)
|
||||
ent:SetParent(self)
|
||||
tbl.scale = 0.98 + (-0.02+0.04*math.random())
|
||||
table.insert(self.PassengerPositions,pos)
|
||||
table.insert(self.PassengerEnts,ent)
|
||||
table.insert(self.PassengerEnts,tbl)
|
||||
end
|
||||
end
|
||||
if (CurTime() - (self.ModelCheckTimer or 0) > 1.0) then
|
||||
self.ModelCheckTimer = CurTime()
|
||||
local plyPos = LocalPlayer():GetPos()
|
||||
local dist = C_PassRenderDistance:GetInt()/0.01905
|
||||
for _,tbl in pairs(self.PassengerEnts) do
|
||||
if not IsValid(tbl.ent) and plyPos:Distance(tbl.pos) <= dist then
|
||||
local ent = ClientsideModel(tbl.mdl, RENDERGROUP_OPAQUE)
|
||||
if not IsValid(ent) then continue end
|
||||
ent:SetPos(self:LocalToWorld(tbl.pos))
|
||||
ent:SetAngles(self:LocalToWorldAngles(tbl.ang))
|
||||
if not tbl.skin then tbl.skin = math.floor(ent:SkinCount()*math.random()) end
|
||||
ent:SetSkin(tbl.skin)
|
||||
ent:SetModelScale(tbl.scale,0)
|
||||
ent:SetParent(self)
|
||||
tbl.ent = ent
|
||||
elseif IsValid(tbl.ent) and (plyPos:Distance(tbl.pos) > dist or tbl.ent:IsDormant()) then
|
||||
SafeRemoveEntity(tbl.ent)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -2644,6 +2663,7 @@ function ENT:SetLightPower(index,power,brightness)
|
||||
-- Create light
|
||||
if lightData[1] == "light" or lightData[1] == "glow" then
|
||||
local light = ents.CreateClientside("gmod_train_sprite")
|
||||
if not IsValid(light) then return end
|
||||
light:SetPos(self:LocalToWorld(lightData[2]))
|
||||
--light:SetLocalAngles(lightData[3])
|
||||
|
||||
@@ -2690,6 +2710,7 @@ function ENT:SetLightPower(index,power,brightness)
|
||||
self.GlowingLights[index] = light
|
||||
elseif lightData[1] == "dynamiclight" then
|
||||
local light = ents.CreateClientside("gmod_train_dlight")
|
||||
if not IsValid(light) then return end
|
||||
light:SetParent(self)
|
||||
|
||||
-- Set position
|
||||
|
||||
@@ -57,6 +57,7 @@ function ENT:OnRemove()
|
||||
for k,v in pairs(self.ClientModels) do SafeRemoveEntity(v) end
|
||||
self.ClientModels = {}
|
||||
self.ClientsideModels = {}
|
||||
for k,v in pairs(self.CleanupModels) do SafeRemoveEntity(v.ent) end
|
||||
self.CleanupModels = {}
|
||||
self.Pool = nil
|
||||
self.PassengersLeft = nil
|
||||
@@ -149,6 +150,7 @@ function ENT:PopulatePlatform(platformStart,platformEnd,stationCenter)
|
||||
end
|
||||
end
|
||||
|
||||
local C_PassRenderDistance = GetConVar("metrostroi_passengers_distance")
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Think loop that manages clientside models
|
||||
@@ -164,7 +166,7 @@ function ENT:Think()
|
||||
self.PrevTime = self.PrevTime or CurTime()
|
||||
self.DeltaTime = (CurTime() - self.PrevTime)
|
||||
self.PrevTime = CurTime()
|
||||
if self:IsDormant() then
|
||||
if self:IsDormant() or Metrostroi and Metrostroi.ReloadClientside then
|
||||
if self.Pool then
|
||||
self:OnRemove()
|
||||
end
|
||||
@@ -214,10 +216,12 @@ function ENT:Think()
|
||||
self:PopulatePlatform(platformStart,platformEnd,stationCenter)
|
||||
end
|
||||
|
||||
local plyPos = LocalPlayer():GetPos()
|
||||
local modelCount = 0
|
||||
-- Check if set of models changed
|
||||
if (CurTime() - (self.ModelCheckTimer or 0) > 1.0) and poolReady then
|
||||
self.ModelCheckTimer = CurTime()
|
||||
local dist = C_PassRenderDistance:GetInt()/0.01905
|
||||
|
||||
local WindowStart = self:GetNW2Int("WindowStart")
|
||||
local WindowEnd = self:GetNW2Int("WindowEnd")
|
||||
@@ -227,7 +231,7 @@ function ENT:Think()
|
||||
if WindowStart > WindowEnd then in_bounds = (i >= WindowStart) or (i <= WindowEnd) end
|
||||
if in_bounds then
|
||||
-- Model in window
|
||||
if not self.ClientModels[i] then
|
||||
if not self.ClientModels[i] and plyPos:Distance(self.Pool[i].pos) <= dist then
|
||||
--self.ClientModels[i] = ents.CreateClientProp("models/metrostroi/81-717/reverser.mdl")
|
||||
--self.ClientModels[i]:SetModel(self.Pool[i].model)
|
||||
--hook.Add("MetrostroiBigLag",self.ClientModels[i],function(ent)
|
||||
@@ -247,6 +251,8 @@ function ENT:Think()
|
||||
self.ClientModels[i]:DrawShadow(false)
|
||||
modelCount = modelCount + 1
|
||||
if modelCount > 15 then poolReady = false self.ModelCheckTimer = self.ModelCheckTimer - 0.9 break end
|
||||
elseif IsValid(self.ClientModels[i]) and (plyPos:Distance(self.Pool[i].pos) > dist or self.ClientModels[i]:IsDormant()) then
|
||||
SafeRemoveEntity(self.ClientModels[i])
|
||||
end
|
||||
else
|
||||
-- Model found that is not in window
|
||||
@@ -323,6 +329,10 @@ function ENT:Think()
|
||||
if not IsValid(v.ent) then
|
||||
self.CleanupModels[k] = nil
|
||||
continue
|
||||
elseif v.ent:IsDormant() then
|
||||
v.ent:Remove()
|
||||
self.CleanupModels[k] = nil
|
||||
continue
|
||||
end
|
||||
-- Get pos and target in XY plane
|
||||
local pos = v.ent:GetPos()
|
||||
@@ -333,7 +343,7 @@ function ENT:Think()
|
||||
local distance = pos:DistToSqr(target)
|
||||
local count = self:GetNW2Int("TrainDoorCount",0)
|
||||
-- Delete if reached the target point
|
||||
if distance < 2*256--[[threshold]] or math.abs(LocalPlayer():GetPos().z - v.ent:GetPos().z) > 256 or count == 0 then
|
||||
if distance < 2*256--[[threshold]] or math.abs(plyPos.z - v.ent:GetPos().z) > 256 or count == 0 then
|
||||
v.ent:Remove()
|
||||
self.CleanupModels[k] = nil
|
||||
continue
|
||||
|
||||
@@ -461,11 +461,13 @@ net.Receive("metrostroi_bogey_contact",function()
|
||||
util.Effect("stunstickimpact", effectdata, true, true)
|
||||
|
||||
local light = ents.CreateClientside("gmod_train_dlight")
|
||||
if IsValid(light) then
|
||||
light:SetPos(effectdata:GetOrigin())
|
||||
light:SetDColor(Color(100,220,255))
|
||||
light:SetSize(256)
|
||||
light:SetBrightness(5)
|
||||
light:Spawn()
|
||||
SafeRemoveEntityDelayed(light,0.1)
|
||||
end
|
||||
sound.Play("subway_trains/bogey/spark.mp3",effectdata:GetOrigin(),75,math.random(100,150),volume)
|
||||
end)
|
||||
@@ -43,6 +43,7 @@ local function ClientPanel(panel)
|
||||
panel:NumSlider(Metrostroi.GetPhrase("Panel.Z"),"metrostroi_cabz",-10,10)
|
||||
panel:NumSlider(Metrostroi.GetPhrase("Panel.RenderDistance"),"metrostroi_renderdistance",960,3072)
|
||||
panel:NumSlider(Metrostroi.GetPhrase("Panel.RenderSignals"),"metrostroi_signal_distance",6144,16384)
|
||||
panel:NumSlider(Metrostroi.GetPhrase("Panel.RenderPassengers"),"metrostroi_passengers_distance",40,110)
|
||||
panel:Button(Metrostroi.GetPhrase("Panel.ReloadClient"),"metrostroi_reload_client",true)
|
||||
|
||||
function DRouteNumber:OnChange()
|
||||
|
||||
@@ -102,6 +102,7 @@ CreateClientConVar("metrostroi_debugger_data_timeout",2,true,false)
|
||||
CreateClientConVar("metrostroi_disablehud",0,true)
|
||||
CreateClientConVar("metrostroi_renderdistance",1024,true)
|
||||
CreateClientConVar("metrostroi_signal_distance",8192,true)
|
||||
CreateClientConVar("metrostroi_passengers_distance",75,true)
|
||||
CreateClientConVar("metrostroi_screenshotmode",0,true)
|
||||
CreateClientConVar("metrostroi_disableseatshadows",0,true)
|
||||
CreateClientConVar("metrostroi_softdrawmultipier",100,true)
|
||||
|
||||
@@ -44,6 +44,7 @@ Panel.FOV = FOV
|
||||
Panel.Z = Výška kamery
|
||||
Panel.RenderDistance = Vykreslovací\nvzdálenost
|
||||
Panel.RenderSignals = Traced signals #NEW #FIXME
|
||||
Panel.RenderPassengers = Traced passengers #NEW #FIXME
|
||||
Panel.ReloadClient = Znovu načíst klienta
|
||||
|
||||
Panel.ClientAdvanced = Klient (pokročilý)
|
||||
|
||||
@@ -44,6 +44,7 @@ Panel.FOV = Sichtfeld
|
||||
Panel.Z = Camera height #NEW
|
||||
Panel.RenderDistance = Render distanz
|
||||
Panel.RenderSignals = Traced signals #NEW #FIXME
|
||||
Panel.RenderPassengers = Traced passengers #NEW #FIXME
|
||||
Panel.ReloadClient = Clientseitig neuladen
|
||||
|
||||
Panel.ClientAdvanced = Client (Fortgeschritten)
|
||||
|
||||
@@ -53,6 +53,7 @@ Panel.FOV = FOV
|
||||
Panel.Z = Camera height #NEW
|
||||
Panel.RenderDistance = Render distance
|
||||
Panel.RenderSignals = Traced signals #NEW #FIXME
|
||||
Panel.RenderPassengers = Traced passengers #NEW #FIXME
|
||||
Panel.ReloadClient = Reload client side
|
||||
|
||||
Panel.ClientAdvanced = Client (advanced)
|
||||
|
||||
@@ -44,6 +44,7 @@ Panel.FOV = Champ de vision (FOV)
|
||||
Panel.Z = Hauteur de caméra
|
||||
Panel.RenderDistance = Rendu à distance
|
||||
Panel.RenderSignals = Traced signals #NEW #FIXME
|
||||
Panel.RenderPassengers = Traced passengers #NEW #FIXME
|
||||
Panel.ReloadClient = Redémarrer le client
|
||||
|
||||
Panel.ClientAdvanced = Client (avancé)
|
||||
|
||||
@@ -42,6 +42,7 @@ Panel.FOV = FOV
|
||||
Panel.Z = Kamera magassága
|
||||
Panel.RenderDistance = Renderelési távolság
|
||||
Panel.RenderSignals = Traced signals #NEW #FIXME
|
||||
Panel.RenderPassengers = Traced passengers #NEW #FIXME
|
||||
Panel.ReloadClient = Kliens oldal újraindítása
|
||||
|
||||
Panel.ClientAdvanced = Kliens (haladó)
|
||||
|
||||
@@ -41,6 +41,7 @@ Panel.FOV = FOV
|
||||
Panel.Z = Altezza della videocamera
|
||||
Panel.RenderDistance = Distanza di rendering
|
||||
Panel.RenderSignals = Traced signals #NEW #FIXME
|
||||
Panel.RenderPassengers = Traced passengers #NEW #FIXME
|
||||
Panel.ReloadClient = Ricarica lato utente
|
||||
|
||||
Panel.ClientAdvanced = Utente (Avanzato)
|
||||
|
||||
@@ -42,6 +42,7 @@ Panel.FOV = 시야각(FOV)
|
||||
Panel.Z = 시점 높이
|
||||
Panel.RenderDistance = 렌더링 거리
|
||||
Panel.RenderSignals = Traced signals #NEW #FIXME
|
||||
Panel.RenderPassengers = Traced passengers #NEW #FIXME
|
||||
Panel.ReloadClient = 사용자 시스템 다시 불러오기
|
||||
|
||||
Panel.ClientAdvanced = 사용자 (고급설정)
|
||||
|
||||
@@ -44,6 +44,7 @@ Panel.FOV = FOV (pole widzenia)
|
||||
Panel.Z = Camera height #NEW
|
||||
Panel.RenderDistance = Odległość rysowania
|
||||
Panel.RenderSignals = Traced signals #NEW #FIXME
|
||||
Panel.RenderPassengers = Traced passengers #NEW #FIXME
|
||||
Panel.ReloadClient = Przeładuj zasoby (klient)
|
||||
|
||||
Panel.ClientAdvanced = Klient (zaawansowane)
|
||||
|
||||
@@ -53,6 +53,7 @@ Panel.FOV = Поле зрения
|
||||
Panel.Z = Высота камеры
|
||||
Panel.RenderDistance = Дальность прорисовки
|
||||
Panel.RenderSignals = Прорисовка светофоров
|
||||
Panel.RenderPassengers = Прорисовка пассажиров
|
||||
Panel.ReloadClient = Перезагрузить клиентскую часть
|
||||
|
||||
Panel.ClientAdvanced = Клиент (дополнительно)
|
||||
|
||||
Reference in New Issue
Block a user