Skip to content

Commit

Permalink
Release Candidate
Browse files Browse the repository at this point in the history
  • Loading branch information
andreharv committed Sep 15, 2022
2 parents a61e1e1 + 1e39a7a commit 9d4b33d
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 76 deletions.
110 changes: 61 additions & 49 deletions NetworkExtensions2/AI/TinyRoadZoneBlocksCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ public void CreateZoneBlocks(NetInfo info, ushort segmentId, ref NetSegment segm

if (isCurve)
{
CreateZoneBlocksTiny_Curve(info, randomizer, ref segment);
CreateZoneBlocksTiny_Curve(info, randomizer, segmentId, ref segment);
}
else
{
CreateZoneBlocksTiny_Straight(info, randomizer, ref segment, startNode, endNode);
CreateZoneBlocksTiny_Straight(info, randomizer, segmentId, ref segment, startNode, endNode);
}
}

private static void CreateZoneBlocksTiny_Curve(NetInfo info, Randomizer randomizer, ref NetSegment segment)
private static void CreateZoneBlocksTiny_Curve(NetInfo info, Randomizer randomizer, ushort segmentId, ref NetSegment segment)
{
var minHalfWidth = MIN_HALFWIDTH_TINY_CURVE;

Expand Down Expand Up @@ -96,21 +96,23 @@ private static void CreateZoneBlocksTiny_Curve(NetInfo info, Randomizer randomiz
if (flag2)
{
Singleton<ZoneManager>.instance.CreateBlock(
out segment.m_blockStartRight,
ref randomizer,
position3,
angle,
num8,
out segment.m_blockStartRight,
ref randomizer,
segmentId,
position3,
angle,
num8,
distance,
segment.m_buildIndex);
}
else
{
Singleton<ZoneManager>.instance.CreateBlock(
out segment.m_blockStartLeft,
ref randomizer,
position3,
angle,
out segment.m_blockStartLeft,
ref randomizer,
segmentId,
position3,
angle,
num8,
distance,
segment.m_buildIndex);
Expand All @@ -128,21 +130,23 @@ private static void CreateZoneBlocksTiny_Curve(NetInfo info, Randomizer randomiz
if (flag2)
{
Singleton<ZoneManager>.instance.CreateBlock(
out segment.m_blockEndRight,
ref randomizer,
position4,
angle2,
out segment.m_blockEndRight,
ref randomizer,
segmentId,
position4,
angle2,
num8,
distance,
segment.m_buildIndex + 1u);
}
else
{
Singleton<ZoneManager>.instance.CreateBlock(
out segment.m_blockEndLeft,
ref randomizer,
position4,
angle2,
out segment.m_blockEndLeft,
ref randomizer,
segmentId,
position4,
angle2,
num8,
distance,
segment.m_buildIndex + 1u);
Expand Down Expand Up @@ -187,21 +191,23 @@ private static void CreateZoneBlocksTiny_Curve(NetInfo info, Randomizer randomiz
if (flag2)
{
Singleton<ZoneManager>.instance.CreateBlock(
out segment.m_blockStartLeft,
ref randomizer,
position5,
angle3,
out segment.m_blockStartLeft,
ref randomizer,
segmentId,
position5,
angle3,
num12,
distance,
segment.m_buildIndex);
}
else
{
Singleton<ZoneManager>.instance.CreateBlock(
out segment.m_blockStartRight,
ref randomizer,
position5,
angle3,
out segment.m_blockStartRight,
ref randomizer,
segmentId,
position5,
angle3,
num12,
distance,
segment.m_buildIndex);
Expand All @@ -217,29 +223,31 @@ private static void CreateZoneBlocksTiny_Curve(NetInfo info, Randomizer randomiz
if (flag2)
{
Singleton<ZoneManager>.instance.CreateBlock(
out segment.m_blockEndLeft,
ref randomizer,
position6,
angle4,
out segment.m_blockEndLeft,
ref randomizer,
segmentId,
position6,
angle4,
num12,
distance,
segment.m_buildIndex + 1u);
}
else
{
Singleton<ZoneManager>.instance.CreateBlock(
out segment.m_blockEndRight,
ref randomizer,
position6,
angle4,
out segment.m_blockEndRight,
ref randomizer,
segmentId,
position6,
angle4,
num12,
distance,
segment.m_buildIndex + 1u);
}
}
}

private static void CreateZoneBlocksTiny_Straight(NetInfo info, Randomizer randomizer, ref NetSegment segment, NetNode startNode, NetNode endNode)
private static void CreateZoneBlocksTiny_Straight(NetInfo info, Randomizer randomizer, ushort segmentId, ref NetSegment segment, NetNode startNode, NetNode endNode)
{
var minHalfWidth = MIN_HALFWIDTH_TINY_STRAIGHT;
float num2 = Mathf.Max(minHalfWidth, info.m_halfWidth) + 32f;
Expand Down Expand Up @@ -270,27 +278,29 @@ private static void CreateZoneBlocksTiny_Straight(NetInfo info, Randomizer rando
{

Vector3 position = startPosition + new Vector3(
startDirection.x * 32f - startDirection.z * num2,
0f,
startDirection.x * 32f - startDirection.z * num2,
0f,
startDirection.z * 32f + startDirection.x * num2);
Singleton<ZoneManager>.instance.CreateBlock(
out segment.m_blockStartLeft,
ref randomizer,
position,
startAngle,
out segment.m_blockStartLeft,
ref randomizer,
segmentId,
position,
startAngle,
startRows,
distance,
segment.m_buildIndex);

position = startPosition + new Vector3(
startDirection.x * (float)(startRows - 4) * 8f + startDirection.z * num2,
0f,
startDirection.x * (float)(startRows - 4) * 8f + startDirection.z * num2,
0f,
startDirection.z * (float)(startRows - 4) * 8f - startDirection.x * num2);
Singleton<ZoneManager>.instance.CreateBlock(
out segment.m_blockStartRight,
ref randomizer,
position,
startAngle + 3.14159274f,
out segment.m_blockStartRight,
ref randomizer,
segmentId,
position,
startAngle + 3.14159274f,
startRows,
distance,
segment.m_buildIndex);
Expand All @@ -307,6 +317,7 @@ private static void CreateZoneBlocksTiny_Straight(NetInfo info, Randomizer rando
Singleton<ZoneManager>.instance.CreateBlock(
out segment.m_blockEndLeft,
ref randomizer,
segmentId,
position,
endAngle,
endRows,
Expand All @@ -320,6 +331,7 @@ private static void CreateZoneBlocksTiny_Straight(NetInfo info, Randomizer rando
Singleton<ZoneManager>.instance.CreateBlock(
out segment.m_blockEndRight,
ref randomizer,
segmentId,
position,
endAngle + 3.14159274f,
endRows,
Expand Down
2 changes: 2 additions & 0 deletions NetworkExtensions2/Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ public static ConflictingModFlag ConflictingMods()
m_ConflictingModNeedPerformSearch = false;
foreach (PluginManager.PluginInfo plugin in PluginManager.instance.GetPluginsInfo())
{
UnityEngine.Debug.Log("Plugin Namex: " + plugin.name);
foreach (Assembly assembly in plugin.GetAssemblies())
{
UnityEngine.Debug.Log("Assembly Namex: " + assembly.GetName().Name);
switch (assembly.GetName().Name)
{
case "ZoningAdjuster":
Expand Down
2 changes: 0 additions & 2 deletions NetworkExtensions2/Patching/Patcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ internal class Patcher
private static Harmony harmony => new Harmony("andreharv.CSL.NetworkExtensions2");
internal static void PatchAll()
{
if (!Mod.FoundZoningAdjuster)
CreateZoneBlocksPatch.Apply(harmony);
CheckBuildPositionPatch.Apply(harmony);
GetLengthSnapPatch.Apply(harmony);
GetCategoryOrderPatch.Apply(harmony);
Expand Down
4 changes: 2 additions & 2 deletions NetworkExtensions2/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.2.2")]
[assembly: AssemblyFileVersion("1.1.2.2")]
[assembly: AssemblyVersion("1.2.0.2")]
[assembly: AssemblyFileVersion("1.2.0.2")]
21 changes: 5 additions & 16 deletions NetworkExtensions2/RExModule.Install.Roads.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,10 @@ private static void InstallPropInfos(RExModule host)

Loading.QueueAction(() =>
{
var props = host._props = host._container.AddComponent<PropCollection>();
props.name = PROP_COLLECTION_NAME;
if (newInfos.Count > 0)
{
props.m_prefabs = newInfos.ToArray();
PrefabCollection<PropInfo>.InitializePrefabs(props.name, props.m_prefabs, new string[] { });
PrefabCollection<PropInfo>.BindPrefabs();
}
PrefabCollection<PropInfo>.InitializePrefabs(PROP_COLLECTION_NAME, newInfos.ToArray(), null);
PrefabCollection<PropInfo>.BindPrefabs();
});

}
private static readonly Dictionary<string, NetInfo> m_BasedPrefabs = new Dictionary<string, NetInfo>();
private static readonly Dictionary<NetInfoVersion, NetInfo> m_Infos = new Dictionary<NetInfoVersion, NetInfo>();
Expand Down Expand Up @@ -239,14 +234,8 @@ private void InstallNetInfos(RExModule host)

Loading.QueueAction(() =>
{
var roads = host._roads = host._container.AddComponent<NetCollection>();
roads.name = NET_COLLECTION_NAME;
if (newInfos.Count > 0)
{
roads.m_prefabs = newInfos.ToArray();
PrefabCollection<NetInfo>.InitializePrefabs(roads.name, roads.m_prefabs, new string[] { });
PrefabCollection<NetInfo>.BindPrefabs();
}
PrefabCollection<NetInfo>.InitializePrefabs(NET_COLLECTION_NAME, newInfos.ToArray(), null);
PrefabCollection<NetInfo>.BindPrefabs();
});

Loading.QueueAction(() =>
Expand Down
6 changes: 3 additions & 3 deletions NetworkExtensions2/ToolModule.Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public enum ModOptions : long
public override void OnSettingsUI(UIHelperBase helper)
{
var zoneModifierCheckbox = helper.AddCheckbox(
"Road Zone Modifier " + (Mod.FoundZoningAdjuster ? "(*disabled: Zoning Adjuster Detected*)" : ""),
Mod.FoundZoningAdjuster ? "Zoning Adjuster Detected. This feature will be disabled*":"Press SHIFT (or SHIFT+CTRL) on the Upgrade Road tool to use",
s_activeOptions.IsFlagSet(ModOptions.RoadZoneModifier) && !Mod.FoundZoningAdjuster,
"Road Zone Modifier " + (Mod.FoundZoningAdjuster ? "*disabled: Zoning Adjuster Detected*" : ""),
Mod.FoundZoningAdjuster ? "Zoning Adjuster Detected. This feature will be disabled*" : "Press SHIFT (or SHIFT+CTRL) on the Upgrade Road tool to use",
s_activeOptions.IsFlagSet(ModOptions.RoadZoneModifier) && !Mod.FoundZoningAdjuster,
isChecked =>
{
if (isChecked && !Mod.FoundZoningAdjuster)
Expand Down
20 changes: 16 additions & 4 deletions NetworkExtensions2/ToolModule.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
using Transit.Framework.Modularity;
using HarmonyLib;
using ICities;
using NetworkExtensions;
using NetworkExtensions2.Patching;
using Transit.Framework.Modularity;

namespace Transit.Addon.Tools
{
[Module("Transit.Addon.Mod", "NetworkExtensions.Mod")]
public partial class ToolModule : ModuleBase
{

private Harmony harmony => new Harmony("andreharv.CSL.NetworkExtensions2");
public override string Name
{
get { return "Tools"; }
}

// Hack For FileManager, deprecated

// Hack For FileManager, deprecated
public override void OnCreated(ILoading loading)
{
if (!Mod.FoundZoningAdjuster)
CreateZoneBlocksPatch.Apply(harmony);
}
public override void OnReleased()
{
harmony.UnpatchAll();
}
public override string AssetPath { get { return InternalAssetPath; } set { InternalAssetPath = value; } }
internal static string InternalAssetPath { get; private set; }
}
Expand Down
Binary file modified References/Assembly-CSharp.dll
Binary file not shown.
Binary file modified References/ColossalManaged.dll
Binary file not shown.
Binary file modified References/ICities.dll
Binary file not shown.

0 comments on commit 9d4b33d

Please sign in to comment.