Skip to content

Commit 55f97b4

Browse files
committed
fix: reversing road upgrade should now be fine #100
1 parent 0732e6d commit 55f97b4

File tree

4 files changed

+13
-97
lines changed

4 files changed

+13
-97
lines changed

ParallelRoadTool/Extensions/Vector3Extensions.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,14 @@ public static Vector3 RotateXZ(this Vector3 vector, float angle = 90)
4040
/// I guess it applies the offset to vector while also normalizing it.
4141
/// </summary>
4242
/// <param name="vector"></param>
43-
/// <param name="offset"></param>
43+
/// <param name="horizontalOffset"></param>
44+
/// <param name="verticalOffset"></param>
4445
/// <returns></returns>
45-
public static Vector3 NormalizeWithOffset(this Vector3 vector, float offset)
46+
public static Vector3 NormalizeWithOffset(this Vector3 vector, float horizontalOffset, float verticalOffset = 0)
4647
{
4748
if (vector.magnitude <= 0) return vector;
4849

49-
var offsetMagnitude = offset / vector.magnitude;
50-
return vector with { x = vector.x * offsetMagnitude, z = vector.z * offsetMagnitude };
50+
var offsetMagnitude = horizontalOffset / vector.magnitude;
51+
return vector with { x = vector.x * offsetMagnitude, y = vector.y + verticalOffset, z = vector.z * offsetMagnitude };
5152
}
5253
}

ParallelRoadTool/ParallelRoadTool.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
<Compile Include="Patches\NetAIPatch.cs" />
7070
<Compile Include="Patches\NetManagerPatch.cs" />
7171
<Compile Include="Patches\NetToolCameraPatch.cs" />
72-
<Compile Include="Patches\NetToolNodePatch.cs" />
7372
<Compile Include="Patches\NetToolsPrefabPatch.cs" />
7473
<Compile Include="Patches\ToolControllerPatch.cs" />
7574
<Compile Include="Extensions\NetInfoExtensions.cs" />

ParallelRoadTool/Patches/NetManagerPatch.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@ private static void Postfix(out ushort segment,
119119
return;
120120
}
121121

122+
if (ToolsModifierControl.GetTool<NetTool>().m_mode == NetTool.Mode.Upgrade && invert)
123+
{
124+
// HACK - [ISSUE-100] Prevent executing if user is reversing road direction using the upgrade tool
125+
Log._Debug($"[{nameof(NetManagerPatch)}.{nameof(Postfix)}] Skipping because we're reversing a road's direction using update tool.");
126+
127+
return;
128+
}
129+
122130
Log._Debug($"[{nameof(NetManagerPatch)}.{nameof(Postfix)}] Adding {Singleton<ParallelRoadToolManager>.instance.SelectedNetworkTypes.Count} parallel segments");
123131

124132
if (Singleton<ParallelRoadToolManager>.instance.IsLeftHandTraffic)

ParallelRoadTool/Patches/NetToolNodePatch.cs

Lines changed: 0 additions & 92 deletions
This file was deleted.

0 commit comments

Comments
 (0)