Closed kianzarrin closed 1 year ago
overlay rendered by this mod : https://steamcommunity.com/sharedfiles/filedetails/?id=2883351966
the code will look like something line this:
public static bool Prefix(ref NetLane __instance, float laneOffset, float stopOffset, out Vector3 position, out Vector3 direction) {
ref Bezier3 bezier = ref __instance.m_bezier;
position = bezier.Position(laneOffset);
direction = bezier.Tangent(laneOffset);
Vector3 sideDir = Vector3.Cross(Vector3.up, direction).normalized;
// NON STOCK CODE START
const float t1 = .12f;
const float t2_0 = 0.20f;
float t2 = t1 + 0.7f / __instance.m_length;
t2 = Mathf.Max(t2, t2_0);
float t = laneOffset <= 0.5f ? laneOffset : 1 - laneOffset;
float d;
if (t < t1) {
d = 0;
} else if(t > t2) {
d = 1;
} else {
d = (t - t1) / (t2 - t1); // from 0 to 1
}
// NON STOCK CODE END
position += sideDir * stopOffset * d;
return false;
}
related: https://github.com/CitiesSkylinesMods/TMPE/issues/1020#issuecomment-716743962