Skip to content

Commit f6595dc

Browse files
authored
Merge pull request #428 from krzychu124/119-migration-to-harmony-merged
Master to harmony branch, resolved conflicts, savegame compatibility fix
2 parents d69eb91 + 2b179bb commit f6595dc

File tree

246 files changed

+33838
-32393
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

246 files changed

+33838
-32393
lines changed

.gitignore

+5-5
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ publish/
125125
# Publish Web Output
126126
*.[Pp]ublish.xml
127127
*.azurePubxml
128-
# TODO: Comment the next line if you want to checkin your web deploy settings
128+
# TODO: Comment the next line if you want to checkin your web deploy settings
129129
# but database connection strings (with potential passwords) will be unencrypted
130130
*.pubxml
131131
*.publishproj
@@ -183,9 +183,9 @@ UpgradeLog*.htm
183183
FakesAssemblies/
184184
/logo/
185185

186-
# MSVS 2017 artifacts
187-
/.vs/slnx.sqlite
188-
/TLM/.vs/TMPE/*
186+
# MSVS 2017, IntelliJ IDEA/Rider artifacts
187+
.vs/
188+
.idea/
189189

190190
# Dependecies game dlls
191-
/TLM/dependencies
191+
/TLM/dependencies

CHANGELOG.md

+1,789-893
Large diffs are not rendered by default.

TLM/.editorconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*.{cs,vb}]
4+
indent_style = space
5+
indent_size = 4
6+
trim_trailing_whitespace = true
7+
8+
[*.cs]
9+
# csharp_new_line_before_open_brace = methods

TLM/.vs/config/applicationhost.config

-1,028
This file was deleted.

TLM/CSUtil.Commons/CSUtil.Commons.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
1414
<TargetFrameworkProfile />
15+
<LangVersion>latest</LangVersion>
1516
</PropertyGroup>
1617
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1718
<DebugSymbols>true</DebugSymbols>
+72-78
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,75 @@
1-
using ColossalFramework;
2-
using TrafficManager.RedirectionFramework.Attributes;
3-
using System;
4-
using System.Collections.Generic;
5-
using System.Text;
6-
using TrafficManager.Custom.PathFinding;
7-
using TrafficManager.Geometry;
8-
using TrafficManager.Manager;
9-
using TrafficManager.Manager.Impl;
10-
using TrafficManager.Traffic;
11-
using TrafficManager.Traffic.Data;
12-
using TrafficManager.Traffic.Enums;
13-
using UnityEngine;
14-
using static TrafficManager.Custom.PathFinding.CustomPathManager;
1+
namespace TrafficManager.Custom.AI {
2+
using API.Traffic.Data;
3+
using API.Traffic.Enums;
4+
using ColossalFramework;
5+
using Custom.PathFinding;
6+
using Manager.Impl;
7+
using RedirectionFramework.Attributes;
8+
using Traffic.Data;
9+
using UnityEngine;
1510

16-
namespace TrafficManager.Custom.AI {
17-
[TargetType(typeof(AmbulanceAI))]
18-
public class CustomAmbulanceAI : CarAI {
19-
[RedirectMethod]
20-
public bool CustomStartPathFind(ushort vehicleID, ref Vehicle vehicleData, Vector3 startPos, Vector3 endPos, bool startBothWays, bool endBothWays, bool undergroundTarget) {
21-
ExtVehicleType vehicleType = ExtVehicleManager.Instance.OnStartPathFind(vehicleID, ref vehicleData, (vehicleData.m_flags & Vehicle.Flags.Emergency2) != 0 ? ExtVehicleType.Emergency : ExtVehicleType.Service);
11+
[TargetType(typeof(AmbulanceAI))]
12+
public class CustomAmbulanceAI : CarAI {
13+
[RedirectMethod]
14+
public bool CustomStartPathFind(ushort vehicleID, ref Vehicle vehicleData, Vector3 startPos, Vector3 endPos, bool startBothWays, bool endBothWays, bool undergroundTarget) {
15+
ExtVehicleType vehicleType = ExtVehicleManager.Instance.OnStartPathFind(vehicleID, ref vehicleData, (vehicleData.m_flags & Vehicle.Flags.Emergency2) != 0 ? ExtVehicleType.Emergency : ExtVehicleType.Service);
2216

23-
VehicleInfo info = this.m_info;
24-
bool allowUnderground = (vehicleData.m_flags & (Vehicle.Flags.Underground | Vehicle.Flags.Transition)) != 0;
25-
PathUnit.Position startPosA;
26-
PathUnit.Position startPosB;
27-
float startDistSqrA;
28-
float startDistSqrB;
29-
PathUnit.Position endPosA;
30-
PathUnit.Position endPosB;
31-
float endDistSqrA;
32-
float endDistSqrB;
33-
if (CustomPathManager.FindPathPosition(startPos, ItemClass.Service.Road, NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle, info.m_vehicleType, allowUnderground, false, 32f, out startPosA, out startPosB, out startDistSqrA, out startDistSqrB) &&
34-
CustomPathManager.FindPathPosition(endPos, ItemClass.Service.Road, NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle, info.m_vehicleType, undergroundTarget, false, 32f, out endPosA, out endPosB, out endDistSqrA, out endDistSqrB)) {
35-
if (!startBothWays || startDistSqrA < 10f) {
36-
startPosB = default(PathUnit.Position);
37-
}
38-
if (!endBothWays || endDistSqrA < 10f) {
39-
endPosB = default(PathUnit.Position);
40-
}
41-
uint path;
42-
// NON-STOCK CODE START
43-
PathCreationArgs args;
44-
args.extPathType = ExtPathType.None;
45-
args.extVehicleType = vehicleType;
46-
args.vehicleId = vehicleID;
47-
args.spawned = (vehicleData.m_flags & Vehicle.Flags.Spawned) != 0;
48-
args.buildIndex = Singleton<SimulationManager>.instance.m_currentBuildIndex;
49-
args.startPosA = startPosA;
50-
args.startPosB = startPosB;
51-
args.endPosA = endPosA;
52-
args.endPosB = endPosB;
53-
args.vehiclePosition = default(PathUnit.Position);
54-
args.laneTypes = NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle;
55-
args.vehicleTypes = info.m_vehicleType;
56-
args.maxLength = 20000f;
57-
args.isHeavyVehicle = this.IsHeavyVehicle();
58-
args.hasCombustionEngine = this.CombustionEngine();
59-
args.ignoreBlocked = this.IgnoreBlocked(vehicleID, ref vehicleData);
60-
args.ignoreFlooded = false;
61-
args.ignoreCosts = false;
62-
args.randomParking = false;
63-
args.stablePath = false;
64-
args.skipQueue = (vehicleData.m_flags & Vehicle.Flags.Spawned) != 0;
17+
VehicleInfo info = this.m_info;
18+
bool allowUnderground = (vehicleData.m_flags & (Vehicle.Flags.Underground | Vehicle.Flags.Transition)) != 0;
19+
PathUnit.Position startPosA;
20+
PathUnit.Position startPosB;
21+
float startDistSqrA;
22+
float startDistSqrB;
23+
PathUnit.Position endPosA;
24+
PathUnit.Position endPosB;
25+
float endDistSqrA;
26+
float endDistSqrB;
27+
if (CustomPathManager.FindPathPosition(startPos, ItemClass.Service.Road, NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle, info.m_vehicleType, allowUnderground, false, 32f, out startPosA, out startPosB, out startDistSqrA, out startDistSqrB) &&
28+
CustomPathManager.FindPathPosition(endPos, ItemClass.Service.Road, NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle, info.m_vehicleType, undergroundTarget, false, 32f, out endPosA, out endPosB, out endDistSqrA, out endDistSqrB)) {
29+
if (!startBothWays || startDistSqrA < 10f) {
30+
startPosB = default(PathUnit.Position);
31+
}
32+
if (!endBothWays || endDistSqrA < 10f) {
33+
endPosB = default(PathUnit.Position);
34+
}
35+
uint path;
36+
// NON-STOCK CODE START
37+
PathCreationArgs args;
38+
args.extPathType = ExtPathType.None;
39+
args.extVehicleType = vehicleType;
40+
args.vehicleId = vehicleID;
41+
args.spawned = (vehicleData.m_flags & Vehicle.Flags.Spawned) != 0;
42+
args.buildIndex = Singleton<SimulationManager>.instance.m_currentBuildIndex;
43+
args.startPosA = startPosA;
44+
args.startPosB = startPosB;
45+
args.endPosA = endPosA;
46+
args.endPosB = endPosB;
47+
args.vehiclePosition = default(PathUnit.Position);
48+
args.laneTypes = NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle;
49+
args.vehicleTypes = info.m_vehicleType;
50+
args.maxLength = 20000f;
51+
args.isHeavyVehicle = this.IsHeavyVehicle();
52+
args.hasCombustionEngine = this.CombustionEngine();
53+
args.ignoreBlocked = this.IgnoreBlocked(vehicleID, ref vehicleData);
54+
args.ignoreFlooded = false;
55+
args.ignoreCosts = false;
56+
args.randomParking = false;
57+
args.stablePath = false;
58+
args.skipQueue = (vehicleData.m_flags & Vehicle.Flags.Spawned) != 0;
6559

66-
if (CustomPathManager._instance.CustomCreatePath(out path, ref Singleton<SimulationManager>.instance.m_randomizer, args)) {
67-
// NON-STOCK CODE END
68-
if (vehicleData.m_path != 0u) {
69-
Singleton<PathManager>.instance.ReleasePath(vehicleData.m_path);
70-
}
71-
vehicleData.m_path = path;
72-
vehicleData.m_flags |= Vehicle.Flags.WaitingPath;
73-
return true;
74-
}
75-
} else {
76-
PathfindFailure(vehicleID, ref vehicleData);
77-
}
78-
return false;
79-
}
80-
}
81-
}
60+
if (CustomPathManager._instance.CustomCreatePath(out path, ref Singleton<SimulationManager>.instance.m_randomizer, args)) {
61+
// NON-STOCK CODE END
62+
if (vehicleData.m_path != 0u) {
63+
Singleton<PathManager>.instance.ReleasePath(vehicleData.m_path);
64+
}
65+
vehicleData.m_path = path;
66+
vehicleData.m_flags |= Vehicle.Flags.WaitingPath;
67+
return true;
68+
}
69+
} else {
70+
PathfindFailure(vehicleID, ref vehicleData);
71+
}
72+
return false;
73+
}
74+
}
75+
}

TLM/TLM/Custom/AI/CustomBusAI.cs

+68-74
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,71 @@
1-
using ColossalFramework;
2-
using TrafficManager.RedirectionFramework.Attributes;
3-
using System;
4-
using System.Collections.Generic;
5-
using System.Text;
6-
using TrafficManager.Custom.PathFinding;
7-
using TrafficManager.Geometry;
8-
using TrafficManager.Manager;
9-
using TrafficManager.Traffic;
10-
using TrafficManager.Traffic.Data;
11-
using TrafficManager.Traffic.Enums;
12-
using UnityEngine;
13-
using static TrafficManager.Custom.PathFinding.CustomPathManager;
1+
namespace TrafficManager.Custom.AI {
2+
using API.Traffic.Data;
3+
using API.Traffic.Enums;
4+
using ColossalFramework;
5+
using Custom.PathFinding;
6+
using RedirectionFramework.Attributes;
7+
using Traffic.Data;
8+
using UnityEngine;
149

15-
namespace TrafficManager.Custom.AI {
16-
[TargetType(typeof(BusAI))]
17-
public class CustomBusAI : CarAI {
18-
[RedirectMethod]
19-
public bool CustomStartPathFind(ushort vehicleID, ref Vehicle vehicleData, Vector3 startPos, Vector3 endPos, bool startBothWays, bool endBothWays, bool undergroundTarget) {
20-
VehicleInfo info = this.m_info;
21-
bool allowUnderground = (vehicleData.m_flags & (Vehicle.Flags.Underground | Vehicle.Flags.Transition)) != 0;
22-
PathUnit.Position startPosA;
23-
PathUnit.Position startPosB;
24-
float startDistSqrA;
25-
float startDistSqrB;
26-
PathUnit.Position endPosA;
27-
PathUnit.Position endPosB;
28-
float endDistSqrA;
29-
float endDistSqrB;
30-
if (CustomPathManager.FindPathPosition(startPos, ItemClass.Service.Road, NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle, info.m_vehicleType, allowUnderground, false, 32f, out startPosA, out startPosB, out startDistSqrA, out startDistSqrB) &&
31-
CustomPathManager.FindPathPosition(endPos, ItemClass.Service.Road, NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle, info.m_vehicleType, undergroundTarget, false, 32f, out endPosA, out endPosB, out endDistSqrA, out endDistSqrB)) {
32-
if (!startBothWays || startDistSqrA < 10f) {
33-
startPosB = default(PathUnit.Position);
34-
}
35-
if (!endBothWays || endDistSqrA < 10f) {
36-
endPosB = default(PathUnit.Position);
37-
}
38-
uint path;
39-
// NON-STOCK CODE START
40-
PathCreationArgs args;
41-
args.extPathType = ExtPathType.None;
42-
args.extVehicleType = ExtVehicleType.Bus;
43-
args.vehicleId = vehicleID;
44-
args.spawned = (vehicleData.m_flags & Vehicle.Flags.Spawned) != 0;
45-
args.buildIndex = Singleton<SimulationManager>.instance.m_currentBuildIndex;
46-
args.startPosA = startPosA;
47-
args.startPosB = startPosB;
48-
args.endPosA = endPosA;
49-
args.endPosB = endPosB;
50-
args.vehiclePosition = default(PathUnit.Position);
51-
args.laneTypes = NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle;
52-
args.vehicleTypes = info.m_vehicleType;
53-
args.maxLength = 20000f;
54-
args.isHeavyVehicle = this.IsHeavyVehicle();
55-
args.hasCombustionEngine = this.CombustionEngine();
56-
args.ignoreBlocked = this.IgnoreBlocked(vehicleID, ref vehicleData);
57-
args.ignoreFlooded = false;
58-
args.randomParking = false;
59-
args.ignoreCosts = false;
60-
args.stablePath = true;
61-
args.skipQueue = true;
10+
[TargetType(typeof(BusAI))]
11+
public class CustomBusAI : CarAI {
12+
[RedirectMethod]
13+
public bool CustomStartPathFind(ushort vehicleID, ref Vehicle vehicleData, Vector3 startPos, Vector3 endPos, bool startBothWays, bool endBothWays, bool undergroundTarget) {
14+
VehicleInfo info = this.m_info;
15+
bool allowUnderground = (vehicleData.m_flags & (Vehicle.Flags.Underground | Vehicle.Flags.Transition)) != 0;
16+
PathUnit.Position startPosA;
17+
PathUnit.Position startPosB;
18+
float startDistSqrA;
19+
float startDistSqrB;
20+
PathUnit.Position endPosA;
21+
PathUnit.Position endPosB;
22+
float endDistSqrA;
23+
float endDistSqrB;
24+
if (CustomPathManager.FindPathPosition(startPos, ItemClass.Service.Road, NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle, info.m_vehicleType, allowUnderground, false, 32f, out startPosA, out startPosB, out startDistSqrA, out startDistSqrB) &&
25+
CustomPathManager.FindPathPosition(endPos, ItemClass.Service.Road, NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle, info.m_vehicleType, undergroundTarget, false, 32f, out endPosA, out endPosB, out endDistSqrA, out endDistSqrB)) {
26+
if (!startBothWays || startDistSqrA < 10f) {
27+
startPosB = default(PathUnit.Position);
28+
}
29+
if (!endBothWays || endDistSqrA < 10f) {
30+
endPosB = default(PathUnit.Position);
31+
}
32+
uint path;
33+
// NON-STOCK CODE START
34+
PathCreationArgs args;
35+
args.extPathType = ExtPathType.None;
36+
args.extVehicleType = ExtVehicleType.Bus;
37+
args.vehicleId = vehicleID;
38+
args.spawned = (vehicleData.m_flags & Vehicle.Flags.Spawned) != 0;
39+
args.buildIndex = Singleton<SimulationManager>.instance.m_currentBuildIndex;
40+
args.startPosA = startPosA;
41+
args.startPosB = startPosB;
42+
args.endPosA = endPosA;
43+
args.endPosB = endPosB;
44+
args.vehiclePosition = default(PathUnit.Position);
45+
args.laneTypes = NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle;
46+
args.vehicleTypes = info.m_vehicleType;
47+
args.maxLength = 20000f;
48+
args.isHeavyVehicle = this.IsHeavyVehicle();
49+
args.hasCombustionEngine = this.CombustionEngine();
50+
args.ignoreBlocked = this.IgnoreBlocked(vehicleID, ref vehicleData);
51+
args.ignoreFlooded = false;
52+
args.randomParking = false;
53+
args.ignoreCosts = false;
54+
args.stablePath = true;
55+
args.skipQueue = true;
6256

63-
if (CustomPathManager._instance.CustomCreatePath(out path, ref Singleton<SimulationManager>.instance.m_randomizer, args)) {
64-
// NON-STOCK CODE END
57+
if (CustomPathManager._instance.CustomCreatePath(out path, ref Singleton<SimulationManager>.instance.m_randomizer, args)) {
58+
// NON-STOCK CODE END
6559

66-
if (vehicleData.m_path != 0u) {
67-
Singleton<PathManager>.instance.ReleasePath(vehicleData.m_path);
68-
}
69-
vehicleData.m_path = path;
70-
vehicleData.m_flags |= Vehicle.Flags.WaitingPath;
71-
return true;
72-
}
73-
}
74-
return false;
75-
}
76-
}
77-
}
60+
if (vehicleData.m_path != 0u) {
61+
Singleton<PathManager>.instance.ReleasePath(vehicleData.m_path);
62+
}
63+
vehicleData.m_path = path;
64+
vehicleData.m_flags |= Vehicle.Flags.WaitingPath;
65+
return true;
66+
}
67+
}
68+
return false;
69+
}
70+
}
71+
}

0 commit comments

Comments
 (0)