-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The correct bus types should now be spawned
- Loading branch information
1 parent
2a3dee5
commit 7ad82f7
Showing
5 changed files
with
121 additions
and
1 deletion.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
HarmonyPatches/BuildingManagerPatches/GetDepotLevelsPatch.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using ColossalFramework; | ||
using ImprovedPublicTransport2.HarmonyPatches.DepotAIPatches; | ||
using ImprovedPublicTransport2.Util; | ||
|
||
namespace ImprovedPublicTransport2.HarmonyPatches.BuildingManagerPatches | ||
{ | ||
public static class GetDepotLevelsPatch | ||
{ | ||
public static void Apply() | ||
{ | ||
PatchUtil.Patch( | ||
new PatchUtil.MethodDefinition(typeof(BuildingManager), nameof(BuildingManager.GetDepotLevels)), | ||
new PatchUtil.MethodDefinition(typeof(GetDepotLevelsPatch), nameof(Prefix)), | ||
null | ||
); | ||
} | ||
|
||
public static void Undo() | ||
{ | ||
PatchUtil.Unpatch( | ||
new PatchUtil.MethodDefinition(typeof(BuildingManager), nameof(BuildingManager.GetDepotLevels)) | ||
); | ||
} | ||
|
||
private static bool Prefix(ref TransportLine.DepotLevels __result, ushort lineID) | ||
{ | ||
var info1 = Singleton<TransportManager>.instance.m_lines.m_buffer[lineID].Info; | ||
if (info1 == null || info1.GetSubService() != ItemClass.SubService.PublicTransportBus || | ||
info1.GetClassLevel() != ItemClass.Level.Level1) | ||
{ | ||
return true; | ||
} | ||
__result = new TransportLine.DepotLevels() | ||
{ | ||
m_level1 = true, | ||
m_level2 = true | ||
}; | ||
return false; | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using ImprovedPublicTransport2.Util; | ||
|
||
namespace ImprovedPublicTransport2.HarmonyPatches.DepotAIPatches | ||
{ | ||
public static class ClassMatchesPatch | ||
{ | ||
|
||
public static void Apply() | ||
{ | ||
PatchUtil.Patch( | ||
new PatchUtil.MethodDefinition(typeof(DepotAI), "ClassMatches"), | ||
new PatchUtil.MethodDefinition(typeof(ClassMatchesPatch), | ||
nameof(Prefix)) | ||
); | ||
} | ||
|
||
public static void Undo() | ||
{ | ||
PatchUtil.Unpatch( | ||
new PatchUtil.MethodDefinition(typeof(DepotAI), "ClassMatches") | ||
); | ||
} | ||
|
||
private static bool Prefix(ref bool __result, ItemClass itemClass, ItemClass otherItemClass) | ||
{ | ||
if (itemClass.m_subService == ItemClass.SubService.PublicTransportBus | ||
&& (itemClass.m_level == ItemClass.Level.Level1 || itemClass.m_level == ItemClass.Level.Level2)) | ||
{ | ||
__result = otherItemClass.m_subService == ItemClass.SubService.PublicTransportBus && (otherItemClass.m_level == ItemClass.Level.Level1 || otherItemClass.m_level == ItemClass.Level.Level2); | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
HarmonyPatches/TransportManagerPatches/CheckTransportLineVehiclesPatch.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using ImprovedPublicTransport2.Util; | ||
|
||
namespace ImprovedPublicTransport2.HarmonyPatches.TransportManagerPatches | ||
{ | ||
public static class CheckTransportLineVehiclesPatch | ||
{ | ||
public static void Apply() | ||
{ | ||
PatchUtil.Patch( | ||
new PatchUtil.MethodDefinition(typeof(TransportManager), | ||
nameof(TransportManager.CheckTransportLineVehicles)), | ||
new PatchUtil.MethodDefinition(typeof(CheckTransportLineVehiclesPatch), | ||
nameof(Prefix)) | ||
); | ||
} | ||
|
||
public static void Undo() | ||
{ | ||
PatchUtil.Unpatch( | ||
new PatchUtil.MethodDefinition(typeof(TransportManager), | ||
nameof(TransportManager.CheckTransportLineVehicles)) | ||
); | ||
} | ||
|
||
public static bool Prefix() | ||
{ | ||
|
||
return false; //we don't want to despawn buses of the 'wrong type' | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters