mirror of
https://github.com/metrostroi-repo/MetrostroiAddon.git
synced 2026-05-02 00:42:29 +00:00
Merge pull request #418 from metrostroi-repo/AdditionalSignalControlLogic
Additional signal control logic
This commit is contained in:
@@ -200,6 +200,10 @@ function ENT:Initialize()
|
|||||||
self.PostInitalized = true
|
self.PostInitalized = true
|
||||||
|
|
||||||
self.Controllers = nil
|
self.Controllers = nil
|
||||||
|
self.OccupiedOld = false
|
||||||
|
self.ControllerLogicCheckOccupied = false
|
||||||
|
self.ControllerLogicOverride325Hz = false
|
||||||
|
self.Override325Hz = false
|
||||||
end
|
end
|
||||||
|
|
||||||
function ENT:PreInitalize()
|
function ENT:PreInitalize()
|
||||||
@@ -345,6 +349,7 @@ function ENT:GetRS()
|
|||||||
if self.OverrideTrackOccupied or not self.TwoToSix or not self.ARSSpeedLimit then return false end
|
if self.OverrideTrackOccupied or not self.TwoToSix or not self.ARSSpeedLimit then return false end
|
||||||
--if self.ARSSpeedLimit == 1 or self.ARSSpeedLimit == 2 then return false end
|
--if self.ARSSpeedLimit == 1 or self.ARSSpeedLimit == 2 then return false end
|
||||||
if self.ARSSpeedLimit ~= 0 and self.ARSSpeedLimit== 2 then return false end
|
if self.ARSSpeedLimit ~= 0 and self.ARSSpeedLimit== 2 then return false end
|
||||||
|
if self.ControllerLogic and self.ControllerLogicOverride325Hz then return self.Override325Hz end
|
||||||
return (self.ARSSpeedLimit > 4 or self.ARSSpeedLimit == 4 and self.Approve0) and (not self.ARSNextSpeedLimit or self.ARSNextSpeedLimit >= self.ARSSpeedLimit)
|
return (self.ARSSpeedLimit > 4 or self.ARSSpeedLimit == 4 and self.Approve0) and (not self.ARSNextSpeedLimit or self.ARSNextSpeedLimit >= self.ARSSpeedLimit)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -644,12 +649,15 @@ function ENT:Think()
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
local number = self.RouteNumberReplace or ""
|
local number = self.RouteNumberReplace or ""
|
||||||
--[[self.PrevTime = self.PrevTime or 0
|
if self.ControllerLogicCheckOccupied then
|
||||||
if (CurTime() - self.PrevTime) > 1.0 then
|
self.PrevTime = self.PrevTime or 0
|
||||||
self.PrevTime = CurTime()+math.random(0.5,1.5)
|
if (CurTime() - self.PrevTime) > 1.0 then
|
||||||
self:ARSLogic(self.PrevTime - CurTime())
|
self.PrevTime = CurTime() + math.random(0.5,1.5)
|
||||||
self:CheckOccupation()
|
if self.Node and self.TrackPosition then
|
||||||
end]]
|
self.Occupied,self.OccupiedBy,self.OccupiedByNow = Metrostroi.IsTrackOccupied(self.Node, self.TrackPosition.x,self.TrackPosition.forward,self.ARSOnly and "ars" or "light", self)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
--[[
|
--[[
|
||||||
if self.MU or self.ARSOnly or self.RouteNumberSetup and self.RouteNumberSetup ~= "" or self.RouteNumber and self.RouteNumber ~= "" then
|
if self.MU or self.ARSOnly or self.RouteNumberSetup and self.RouteNumberSetup ~= "" or self.RouteNumber and self.RouteNumber ~= "" then
|
||||||
if self.NextSignalLink then
|
if self.NextSignalLink then
|
||||||
@@ -689,6 +697,10 @@ function ENT:Think()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if self.Occupied ~= self.OccupiedOld then
|
||||||
|
hook.Run("Metrostroi.Signaling.ChangeRCState", self.Name, self.Occupied, self)
|
||||||
|
self.OccupiedOld = self.Occupied
|
||||||
|
end
|
||||||
if self.Controllers then
|
if self.Controllers then
|
||||||
for k,v in pairs(self.Controllers) do
|
for k,v in pairs(self.Controllers) do
|
||||||
if self.Sig ~= v.Sig then
|
if self.Sig ~= v.Sig then
|
||||||
@@ -738,4 +750,4 @@ net.Receive("metrostroi-signal", function(_, ply)
|
|||||||
ent:SendUpdate(ply)
|
ent:SendUpdate(ply)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
Metrostroi.OptimisationPatch()
|
Metrostroi.OptimisationPatch()
|
||||||
|
|||||||
Reference in New Issue
Block a user