Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

partial migration of VehicleAI.StartPathFind into harmony. #943

Merged
merged 39 commits into from
Jun 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
44bf23f
Harmony2 - manual patch
kianzarrin Apr 25, 2020
51294ca
Harmony2 working
kianzarrin Apr 25, 2020
2eabc1b
Cities Harmony is woring.
kianzarrin Apr 25, 2020
206f306
new LifeCycle directory.
kianzarrin Apr 25, 2020
85f9d95
kianzarrin Apr 25, 2020
def7b65
revived vehcileAI commented out code with TODO issue number.
kianzarrin Apr 25, 2020
008c8d6
fixed post build script.
kianzarrin Apr 25, 2020
4bdc0ed
Undid move to LifeCycle to reduce the size of PR
kianzarrin May 18, 2020
f8d2cc0
kianzarrin May 18, 2020
331cccf
kianzarrin May 18, 2020
32ca486
Merge remote-tracking branch 'origin/master' into harmony2-2
kianzarrin May 18, 2020
187da37
merged with trunk
kianzarrin May 18, 2020
8df57a0
added harmony_Id to unpatchall().
kianzarrin May 19, 2020
8b02f94
kianzarrin May 19, 2020
26036af
Moved BusAI and AmbulanceAI to harmony.
kianzarrin May 20, 2020
0e7ab52
merged with master
kianzarrin Jun 9, 2020
d550a64
intermidate
kianzarrin Jun 9, 2020
817ddee
Completed several AI's and fixed bugs from others.
kianzarrin Jun 10, 2020
84f66a8
fixed TargetMethod
kianzarrin Jun 11, 2020
337e137
Merge remote-tracking branch 'origin/master' into 895-VehcileAI-to-ha…
kianzarrin Jun 12, 2020
4a43936
merge with master.
kianzarrin Jun 12, 2020
5b72de9
update submodules
kianzarrin Jun 12, 2020
109f585
Merge branch 'major-feature-harmony2-migration' of https://github.com…
kianzarrin Jun 12, 2020
7ad3a96
fixed CargoTruckAI transpiler.
kianzarrin Jun 12, 2020
9a95abb
Merge branch 'major-feature-harmony2-migration' into 895-VehcileAI-to…
kianzarrin Jun 12, 2020
bd90a0f
kianzarrin Jun 12, 2020
c5d1832
soft reset
kianzarrin Jun 13, 2020
1311aca
reverted options framework to master.
kianzarrin Jun 13, 2020
b797ca9
migrated CustomTramBaseAI.CustomStartPathFind to harmony
kianzarrin Jun 13, 2020
b5a4ea6
added tram and trolly bus AI
kianzarrin Jun 13, 2020
53ceeee
bug fixes
kianzarrin Jun 13, 2020
92c9bf8
comments
kianzarrin Jun 13, 2020
c7f7d1a
fixed patch errors.
kianzarrin Jun 13, 2020
54fbfcd
kianzarrin Jun 13, 2020
ebbda78
minor pr fixes.
kianzarrin Jun 13, 2020
9aa767c
Merge branch 'major-feature-harmony2-migration' into 895-VehcileAI-to…
kianzarrin Jun 13, 2020
08dbad9
minor pr fix
kianzarrin Jun 13, 2020
43d6058
Merge branch '895-VehcileAI-to-harmony' of https://github.com/CitiesS…
kianzarrin Jun 13, 2020
f864e02
pr fixes
kianzarrin Jun 14, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TLM/OptionsFramework
107 changes: 0 additions & 107 deletions TLM/TLM/Custom/AI/CustomAmbulanceAI.cs

This file was deleted.

102 changes: 0 additions & 102 deletions TLM/TLM/Custom/AI/CustomBusAI.cs

This file was deleted.

120 changes: 0 additions & 120 deletions TLM/TLM/Custom/AI/CustomCarAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -443,126 +443,6 @@ public void CustomCalculateSegmentPosition(ushort vehicleId,
// NON-STOCK CODE END
}

[RedirectMethod]
[UsedImplicitly]
public bool CustomStartPathFind(ushort vehicleId,
ref Vehicle vehicleData,
Vector3 startPos,
Vector3 endPos,
bool startBothWays,
bool endBothWays,
bool undergroundTarget) {
#if DEBUG
bool vehDebug = DebugSettings.VehicleId == 0
|| DebugSettings.VehicleId == vehicleId;
bool logParkingAi = DebugSwitch.BasicParkingAILog.Get() && vehDebug;
#else
var logParkingAi = false;
#endif
Log._DebugOnlyWarningIf(
logParkingAi,
() => $"CustomCarAI.CustomStartPathFind({vehicleId}): called for vehicle " +
$"{vehicleId}, startPos={startPos}, endPos={endPos}, " +
$"startBothWays={startBothWays}, endBothWays={endBothWays}, " +
$"undergroundTarget={undergroundTarget}");

ExtVehicleType vehicleType;

vehicleType = ExtVehicleManager.Instance.OnStartPathFind(vehicleId, ref vehicleData, null);
if (vehicleType == ExtVehicleType.None) {
Log._DebugOnlyWarning(
$"CustomCarAI.CustomStartPathFind({vehicleId}): Vehicle {vehicleId} " +
"does not have a valid vehicle type!");
vehicleType = ExtVehicleType.RoadVehicle;
}

VehicleInfo info = m_info;
bool allowUnderground = (vehicleData.m_flags & (Vehicle.Flags.Underground
| Vehicle.Flags.Transition)) != 0;

if (!PathManager.FindPathPosition(
startPos,
ItemClass.Service.Road,
NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle,
info.m_vehicleType,
allowUnderground,
false,
32f,
out PathUnit.Position startPosA,
out PathUnit.Position startPosB,
out float startDistSqrA,
out _) || !PathManager.FindPathPosition(
endPos,
ItemClass.Service.Road,
NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle,
info.m_vehicleType,
undergroundTarget,
false,
32f,
out PathUnit.Position endPosA,
out PathUnit.Position endPosB,
out float endDistSqrA,
out _)) {
return false;
}

if (!startBothWays || startDistSqrA < 10f) {
startPosB = default;
}

if (!endBothWays || endDistSqrA < 10f) {
endPosB = default;
}

// NON-STOCK CODE START
PathCreationArgs args;
args.extPathType = ExtPathType.None;
args.extVehicleType = vehicleType;
args.vehicleId = vehicleId;
args.spawned = (vehicleData.m_flags & Vehicle.Flags.Spawned) != 0;
args.buildIndex = Singleton<SimulationManager>.instance.m_currentBuildIndex;
args.startPosA = startPosA;
args.startPosB = startPosB;
args.endPosA = endPosA;
args.endPosB = endPosB;
args.vehiclePosition = default;
args.laneTypes = NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle;
args.vehicleTypes = info.m_vehicleType;
args.maxLength = 20000f;
args.isHeavyVehicle = IsHeavyVehicle();
args.hasCombustionEngine = CombustionEngine();
args.ignoreBlocked = IgnoreBlocked(vehicleId, ref vehicleData);
args.ignoreFlooded = false;
args.ignoreCosts = false;
args.randomParking = false;
args.stablePath = false;
args.skipQueue = (vehicleData.m_flags & Vehicle.Flags.Spawned) != 0;

if (!CustomPathManager._instance.CustomCreatePath(
out uint path,
ref Singleton<SimulationManager>.instance.m_randomizer,
args)) {
return false;
}

Log._DebugIf(
logParkingAi,
() => $"CustomCarAI.CustomStartPathFind({vehicleId}): " +
$"Path-finding starts for vehicle {vehicleId}, path={path}, " +
$"extVehicleType={vehicleType}, startPosA.segment={startPosA.m_segment}, " +
$"startPosA.lane={startPosA.m_lane}, info.m_vehicleType={info.m_vehicleType}, " +
$"endPosA.segment={endPosA.m_segment}, endPosA.lane={endPosA.m_lane}");

// NON-STOCK CODE END
if (vehicleData.m_path != 0u) {
Singleton<PathManager>.instance.ReleasePath(vehicleData.m_path);
}

vehicleData.m_path = path;
vehicleData.m_flags |= Vehicle.Flags.WaitingPath;
return true;
}

[RedirectMethod]
[UsedImplicitly]
public static ushort CustomCheckOtherVehicle(ushort vehicleId,
Expand Down
Loading