Skip to content

Commit

Permalink
Fix #31: Batch Commands apply outside buildable area
Browse files Browse the repository at this point in the history
  • Loading branch information
Craxy committed Jul 23, 2017
1 parent fd1a66a commit 4448961
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/ToggleTrafficLights/ToggleTrafficLights.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<RootNamespace>Craxy.CitiesSkylines.ToggleTrafficLights</RootNamespace>
</PropertyGroup>
<PropertyGroup>
<Version>0.10.1</Version>
<Version>0.10.2</Version>
<AssemblyVersion>$(Version)</AssemblyVersion>
<FileVersion>$(Version)</FileVersion>
<Product>Toggle Traffic Lights</Product>
Expand Down
2 changes: 1 addition & 1 deletion src/ToggleTrafficLights/Tools/JunctionTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private void DetectHoveredElements()
if (id != 0)
{
var node = Singleton<NetManager>.instance.m_nodes.m_buffer[id];
if (!Singleton<GameAreaManager>.instance.PointOutOfArea(node.m_position))
if (!GameAreaManager.instance.PointOutOfArea(node.m_position))
{
_hoveredNodeId = id;
}
Expand Down
10 changes: 9 additions & 1 deletion src/ToggleTrafficLights/Tools/TrafficLights.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
{
Expand Down
3 changes: 3 additions & 0 deletions src/ToggleTrafficLights/Utils/NetNodeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4448961

Please sign in to comment.