Skip to content

Commit

Permalink
fixed roundabout error.
Browse files Browse the repository at this point in the history
moved to new kian commons.
  • Loading branch information
kianzarrin committed Apr 22, 2021
1 parent fcd516d commit 23776a9
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 32 deletions.
2 changes: 1 addition & 1 deletion PedestrianBridge/KianCommons
Submodule KianCommons updated 62 files
+6 −0 KianCommons.sln
+279 −0 KianCommons/Backport/GetSubArray.cs
+13 −0 KianCommons/IImplict/IMod.cs
+22 −0 KianCommons/IImplict/IMonoBehaviour.cs
+81 −60 KianCommons/KianCommons.csproj
+62 −0 KianCommons/LifeCycleBase.cs
+61 −3 KianCommons/Math/BezierUtil.cs
+21 −3 KianCommons/Math/MathUtil.cs
+38 −0 KianCommons/Math/VecetorUtils.cs
+0 −1 KianCommons/Math/Vector3D.cs
+530 −0 KianCommons/ObjUnity3D/Extensions/MeshExt.cs
+44 −0 KianCommons/ObjUnity3D/Extensions/StringExt.cs
+243 −0 KianCommons/ObjUnity3D/Extensions/Utils.cs
+18 −0 KianCommons/ObjUnity3D/Extensions/Vector3Ext.cs
+12 −0 KianCommons/ObjUnity3D/Extensions/Vector4Ext.cs
+39 −0 KianCommons/ObjUnity3D/Int32Converter.cs
+22 −0 KianCommons/ObjUnity3D/OBJData.cs
+88 −0 KianCommons/ObjUnity3D/OBJFace.cs
+26 −0 KianCommons/ObjUnity3D/OBJFaceVertex.cs
+39 −0 KianCommons/ObjUnity3D/OBJGroup.cs
+271 −0 KianCommons/ObjUnity3D/OBJLoader.cs
+42 −0 KianCommons/ObjUnity3D/OBJMaterial.cs
+184 −0 KianCommons/Patches/HarmonyUtil.cs
+18 −0 KianCommons/Patches/PrefixUtils.cs
+292 −62 KianCommons/Patches/TranspilerUtils.cs
+54 −0 KianCommons/Plugins/AdaptiveRoadsUtil.cs
+1 −1 KianCommons/Plugins/CSURUtil.cs
+258 −0 KianCommons/Plugins/PluginUtil.cs
+0 −11 KianCommons/Properties/AssemblyInfo.cs
+46 −0 KianCommons/Serialization/IOHelpers.cs
+75 −0 KianCommons/Serialization/JsonUtil.cs
+123 −0 KianCommons/Serialization/SerializationUtil.cs
+27 −0 KianCommons/Serialization/Vector3Serializable.cs
+131 −0 KianCommons/Serialization/XMLUtil.cs
+60 −54 KianCommons/UI/Helpers/UIAutoSizePanel.cs
+13 −4 KianCommons/UI/Helpers/UIButtonExt.cs
+21 −14 KianCommons/UI/Helpers/UICheckBoxExt.cs
+109 −0 KianCommons/UI/Helpers/UICheckboxDropDownExt.cs
+86 −0 KianCommons/UI/Helpers/UIDropDownExt.cs
+76 −27 KianCommons/UI/Helpers/UISliderExt.cs
+68 −10 KianCommons/UI/RenderUtil.cs
+84 −35 KianCommons/UI/TextureUtil.cs
+25 −0 KianCommons/UI/UIExtensions.cs
+42 −106 KianCommons/UI/UIKeymappingsPanel.cs
+1 −1 KianCommons/UI/UIToolButton.cs
+0 −1 KianCommons/UI/UIUtils.cs
+93 −0 KianCommons/Util/AssemblyTypeExtensions.cs
+64 −0 KianCommons/Util/Assertion.cs
+53 −0 KianCommons/Util/AuxilaryThread.cs
+121 −0 KianCommons/Util/EnumBitMaskExtensions.cs
+122 −0 KianCommons/Util/EnumerationExtensions.cs
+0 −2 KianCommons/Util/GridUtil.cs
+39 −126 KianCommons/Util/HelpersExtensions.cs
+271 −71 KianCommons/Util/Log.cs
+218 −0 KianCommons/Util/MeshUtil.cs
+371 −58 KianCommons/Util/NetUtil.cs
+0 −24 KianCommons/Util/PluginUtil.cs
+431 −0 KianCommons/Util/ReflectionHelpers.cs
+42 −0 KianCommons/Util/StackHelpers.cs
+158 −0 KianCommons/Util/StringExtensions.cs
+83 −0 Main.yml
+ libs/CSURToolBox.dll
9 changes: 7 additions & 2 deletions PedestrianBridge/PedestrianBridge.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
<None Include="KianCommons\KianCommons\Patches\TranspilerUtils.cs" />
<Compile Include="KianCommons\KianCommons\Math\Vector2D.cs" />
<Compile Include="KianCommons\KianCommons\Math\Vector3D.cs" />
<Compile Include="KianCommons\KianCommons\Plugins\PluginUtil.cs" />
<Compile Include="KianCommons\KianCommons\UI\Helpers\UIAutoSizePanel.cs" />
<Compile Include="KianCommons\KianCommons\UI\Helpers\UIButtonExt.cs" />
<Compile Include="KianCommons\KianCommons\UI\Helpers\UICheckBoxExt.cs" />
Expand All @@ -102,12 +103,16 @@
<Compile Include="KianCommons\KianCommons\UI\UIKeymappingsPanel.cs" />
<Compile Include="KianCommons\KianCommons\UI\UIToolButton.cs" />
<Compile Include="KianCommons\KianCommons\UI\UIUtils.cs" />
<Compile Include="ControlCenter.cs" />
<Compile Include="KianCommons\KianCommons\Util\Assertion.cs" />
<Compile Include="KianCommons\KianCommons\Util\EnumBitMaskExtensions.cs" />
<Compile Include="KianCommons\KianCommons\Util\EnumerationExtensions.cs" />
<Compile Include="KianCommons\KianCommons\Util\GridUtil.cs" />
<Compile Include="KianCommons\KianCommons\Util\HelpersExtensions.cs" />
<Compile Include="KianCommons\KianCommons\Util\Log.cs" />
<Compile Include="KianCommons\KianCommons\Util\NetUtil.cs" />
<Compile Include="KianCommons\KianCommons\Util\PluginUtil.cs" />
<Compile Include="ControlCenter.cs" />
<Compile Include="KianCommons\KianCommons\Util\ReflectionHelpers.cs" />
<Compile Include="KianCommons\KianCommons\Util\StringExtensions.cs" />
<Compile Include="PedestrianBridgeMod.cs" />
<Compile Include="Shapes\RoadBridge\RoadBridgeWrapper.cs" />
<Compile Include="Shapes\RoadBridge\RoadSideWrapper.cs" />
Expand Down
6 changes: 2 additions & 4 deletions PedestrianBridge/Shapes/Netwrapper/NodeWrapper.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using KianCommons;
using KianCommons.Math;
using PedestrianBridge.Util;
using System;
using UnityEngine;
using static KianCommons.HelpersExtensions;
using static KianCommons.Assertion;
using static KianCommons.NetUtil;
using static PedestrianBridge.Util.PrefabUtil;

namespace PedestrianBridge.Shapes {
public class NodeWrapper {
Expand Down Expand Up @@ -40,7 +38,7 @@ void _Create() {
}

static ushort CreateNode(Vector3 position, NetInfo info) {
HelpersExtensions.AssertNotNull(info, "info");
AssertNotNull(info, "info");
Log.Info($"creating node for {info.name} at position {position.ToString("000.000")}");
bool res = netMan.CreateNode(node: out ushort nodeID, randomizer: ref simMan.m_randomizer,
info: info, position: position, buildIndex: simMan.m_currentBuildIndex);
Expand Down
3 changes: 2 additions & 1 deletion PedestrianBridge/Shapes/Netwrapper/SegmentWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using UnityEngine;
using static KianCommons.NetUtil;
using static KianCommons.Assertion;

namespace PedestrianBridge.Shapes {
public class SegmentWrapper {
Expand Down Expand Up @@ -94,7 +95,7 @@ public static void LogSegmentDetails(ushort segmentID) {
private NetInfo GetFinalNetInfo() {
int e1 = StartNode.elevation;
int e2 = EndNode.elevation;
HelpersExtensions.Assert(!(e1 == 0 && e2 < 0), "Underground road is oppostie way arround");
Assert(!(e1 == 0 && e2 < 0), "Underground road is oppostie way arround");
int nElevated = 0;
if (e1 != 0) nElevated++;
if (e2 != 0) nElevated++;
Expand Down
7 changes: 4 additions & 3 deletions PedestrianBridge/Shapes/Roundabout/RaboutSlice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace PedestrianBridge.Shapes {
using static KianCommons.Math.VectorUtil;
using System.Collections.Generic;
using System.Linq;
using static KianCommons.Assertion;

public class RaboutSlice {
public struct Corner {
Expand Down Expand Up @@ -75,7 +76,7 @@ static bool IsIntersectionOnGround(ushort segmentID1, ushort segmentID2) {
bool IsBetweenInOut(
ushort segmentID1Main, ushort segmentID1Minor,
ushort segmentID2Main, ushort segmentID2Minor) {
KianCommons.HelpersExtensions.AssertStack();
AssertStack();
const float maxLen = 7 * MPU;
bool bShort = (corner1.Point - corner2.Point).sqrMagnitude <= maxLen * maxLen;
if (!bShort) {
Expand Down Expand Up @@ -127,8 +128,8 @@ public static ushort GetClosestSegment(Vector2 point, IEnumerable<ushort> segmen
}

public static Vector2 MirrorPoint(Vector2 point, IEnumerable<ushort> segmentList) {
HelpersExtensions.AssertNotNull(segmentList, "segmentList");
HelpersExtensions.Assert(segmentList.Count() > 0, "segmentList.Count()>0");
AssertNotNull(segmentList, "segmentList");
Assert(segmentList.Count() > 0, "segmentList.Count()>0");
ushort closestSegmentID = GetClosestSegment(point, segmentList, out Vector3 hitpos);
if (closestSegmentID != 0) {
var diff = hitpos.ToCS2D() - point;
Expand Down
5 changes: 1 addition & 4 deletions PedestrianBridge/UI/ControlPanel/ElevationSlider.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using ColossalFramework.UI;
using ICities;
using KianCommons;
using KianCommons.UI;
using System;
using System.Reflection.Emit;
using UnityEngine;

namespace PedestrianBridge.UI.ControlPanel {
Expand All @@ -25,7 +22,7 @@ public override void Start() {
started_ = true;
}

const int low = 9;
const int low = 3;
const int high = 30;
const int diff = high - low;
public float LinearValue {
Expand Down
5 changes: 2 additions & 3 deletions PedestrianBridge/UI/ControlPanel/UnderpassCheckbox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ public override void Start() {
isChecked = ControlCenter.Underground;
}

protected override void OnCheckChanged() {
public override void OnCheckChanged(UIComponent component, bool value) {
base.OnCheckChanged(component, value);
ControlCenter.Underground = isChecked;
Invalidate();
ElevationSlider.Instance.Refresh();
}

}
}
14 changes: 6 additions & 8 deletions PedestrianBridge/UI/PedestrianBridgeButton.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using ColossalFramework.UI;
using KianCommons;
using PedestrianBridge.Tool;
using PedestrianBridge.Util;
using System;
using UnityEngine;
using static KianCommons.HelpersExtensions;
using KianCommons.UI;
using KianCommons;
using static KianCommons.Assertion;


/* A lot of copy-pasting from Crossings mod by Spectra and Roundabout Mod by Strad. The sprites are partly copied as well. */
Expand Down Expand Up @@ -55,19 +53,19 @@ public override void Start() {
this.atlas = atlas;

normalBgSprite = focusedBgSprite = disabledBgSprite = PedestrianBridgeButtonBg;
hoveredBgSprite = PedestrianBridgeButtonBgHovered;
pressedBgSprite = PedestrianBridgeButtonBgPressed;
hoveredBgSprite = PedestrianBridgeButtonBgHovered;
pressedBgSprite = PedestrianBridgeButtonBgPressed;

normalFgSprite = disabledFgSprite = hoveredFgSprite = pressedFgSprite = PedestrianBridgeIcon;
focusedFgSprite = PedestrianBridgeIconPressed;

relativePosition = new Vector3(33, 38);
relativePosition = new Vector3(33, 38);
size = new Vector2(SIZE, SIZE);
Show();
Log.Info("PedestrianBridgeButton button created sucessfully.");
}

public static UIButton CreateButton() {
public static UIButton CreateButton() {
Log.Info("PedestrianBridgeButton.CreateButton() called");
return GetPanel().AddUIComponent<PedestrianBridgeButton>();
}
Expand Down
2 changes: 1 addition & 1 deletion PedestrianBridge/Util/PrefabUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static NetInfo GetSlope(this NetInfo info) {

public static int GetInfoPrioirty(NetInfo info, NetInfo baseInfo = null) {
PedestrianPathAI baseAI = baseInfo?.m_netAI as PedestrianPathAI;
HelpersExtensions.AssertNotNull(baseAI, "baseAI");
Assertion.AssertNotNull(baseAI, "baseAI");
if (info == baseAI.m_info) return 0;
if (info == baseAI.m_elevatedInfo) return 1;
if (info == baseAI.m_slopeInfo) return 1;
Expand Down
18 changes: 13 additions & 5 deletions PedestrianBridge/Util/RoundAboutUtil.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
namespace PedestrianBridge.Util {
using CSUtil.Commons;
using System.Collections.Generic;
using System;
using System.Linq;
Expand All @@ -10,6 +9,7 @@ namespace PedestrianBridge.Util {
using static TMPEUtil;
using ColossalFramework.Math;
using Log = KianCommons.Log;
using KianCommons;

public class RoundaboutUtil {
public static RoundaboutUtil Instance_render = new RoundaboutUtil();
Expand Down Expand Up @@ -163,10 +163,18 @@ private bool TraverseAroundRecursive(ushort segmentId) {

private static ushort GetNextSegment(ushort segmentID) {
ushort headNodeId = GetHeadNode(segmentID);
ushort ret = GetCWSegList(headNodeId).Where(
nextSegmentID => IsPartofRoundabout(nextSegmentID, segmentID)).
FirstOrDefault();
return ret;
for(int whatchdog=0; whatchdog < 8; ++ whatchdog) {
// get next inward segment:
ushort nextSegmentID = RHT
? segmentID.ToSegment().GetLeftSegment(headNodeId)
: segmentID.ToSegment().GetRightSegment(headNodeId);
if (nextSegmentID == segmentID)
break;
if (IsPartofRoundabout(nextSegmentID, segmentID))
return nextSegmentID;
}

return 0;
}

/// <summary>
Expand Down

0 comments on commit 23776a9

Please sign in to comment.