diff --git a/src/ToggleTrafficLights/ToggleTrafficLights.csproj b/src/ToggleTrafficLights/ToggleTrafficLights.csproj index 2886537..9556728 100644 --- a/src/ToggleTrafficLights/ToggleTrafficLights.csproj +++ b/src/ToggleTrafficLights/ToggleTrafficLights.csproj @@ -9,7 +9,7 @@ Craxy.CitiesSkylines.ToggleTrafficLights - 0.10.1 + 0.10.2 $(Version) $(Version) Toggle Traffic Lights diff --git a/src/ToggleTrafficLights/Tools/JunctionTool.cs b/src/ToggleTrafficLights/Tools/JunctionTool.cs index 8df8ee4..45d9b9d 100644 --- a/src/ToggleTrafficLights/Tools/JunctionTool.cs +++ b/src/ToggleTrafficLights/Tools/JunctionTool.cs @@ -104,7 +104,7 @@ private void DetectHoveredElements() if (id != 0) { var node = Singleton.instance.m_nodes.m_buffer[id]; - if (!Singleton.instance.PointOutOfArea(node.m_position)) + if (!GameAreaManager.instance.PointOutOfArea(node.m_position)) { _hoveredNodeId = id; } diff --git a/src/ToggleTrafficLights/Tools/TrafficLights.cs b/src/ToggleTrafficLights/Tools/TrafficLights.cs index 0f0b744..67ad077 100644 --- a/src/ToggleTrafficLights/Tools/TrafficLights.cs +++ b/src/ToggleTrafficLights/Tools/TrafficLights.cs @@ -95,6 +95,10 @@ public static void Change(ushort nodeId, ref NetNode node, ChangeMode mode, ref { return; } + if (!Node.IsInsideBuildableArea(nodeId, ref node)) + { + return; + } var ai = node.Info.GetAI() as RoadBaseAI; if (ai == null) @@ -228,12 +232,16 @@ public static void ChangeFast(ushort nodeId, ref NetNode node, ChangeMode mode) { return; } + if (!Node.IsInsideBuildableArea(nodeId, ref node)) + { + return; + } var ai = node.Info.m_netAI as RoadBaseAI; if (ai == null) { return; } - + //todo: tests pre set faster than always set? switch (mode) { diff --git a/src/ToggleTrafficLights/Utils/NetNodeHelper.cs b/src/ToggleTrafficLights/Utils/NetNodeHelper.cs index afcb2b3..90537a6 100644 --- a/src/ToggleTrafficLights/Utils/NetNodeHelper.cs +++ b/src/ToggleTrafficLights/Utils/NetNodeHelper.cs @@ -63,6 +63,9 @@ public static bool IntersectionCanHaveTrafficLights(ushort nodeId, ref NetNode n public static bool IsValidIntersection(ushort nodeId, ref NetNode node) => TryGetRoadAiIfValidIntersection(nodeId, ref node, out var _); + public static bool IsInsideBuildableArea(ushort nodeId, ref NetNode node) + => !GameAreaManager.instance.PointOutOfArea(node.m_position); + public static bool TryGetRoadAiIfValidIntersection(ushort nodeId, ref NetNode node, out RoadBaseAI ai) { ai = default(RoadBaseAI);