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

Master to harmony branch, resolved conflicts, savegame compatibility fix #428

Merged
merged 179 commits into from
Jul 15, 2019
Merged
Show file tree
Hide file tree
Changes from 178 commits
Commits
Show all changes
179 commits
Select commit Hold shift + click to select a range
67b3318
Added 'Release LABS' build configuration and LABS preprocessor instru…
krzychu124 May 24, 2019
68aafeb
Merge branch 'master' into 326-differentiate-labs-and-stable
krzychu124 May 24, 2019
95f51ae
Update TrafficManagerMod.cs
originalfoo May 28, 2019
2e92cfb
Update ModsCompatibilityChecker.cs
originalfoo May 28, 2019
cecbeb6
Made version static again to fix Menu UI
originalfoo May 28, 2019
b4b737c
Update ModsCompatibilityChecker.cs
originalfoo May 28, 2019
f58990c
Specify TMPE branch on incompatible mod checker dialog
originalfoo May 28, 2019
1eabb10
Update ModsCompatibilityChecker.cs
originalfoo May 28, 2019
63982a6
Update VersionLabel.cs
originalfoo May 29, 2019
d4afd0f
Partial implementation for detect and delete of local TMPE build
originalfoo May 29, 2019
b9e57ac
#225: Regular vehicles do not change lanes at toll booths
VictorPhilipp May 31, 2019
4891a21
Update IncompatibleModsPanel.cs
originalfoo Jun 3, 2019
959fe78
Correctly detect and delete local TMPE builds
originalfoo Jun 3, 2019
72a92cb
Update IncompatibleModsPanel.cs
originalfoo Jun 3, 2019
48cd41d
Update IncompatibleModsPanel.cs
originalfoo Jun 3, 2019
a5d9caa
Refactored to allow detection of multiple local builds
originalfoo Jun 4, 2019
3cc1098
Fixed inline variable declaration that was breaking build
originalfoo Jun 6, 2019
290e9ca
Update ModsCompatibilityChecker.cs
originalfoo Jun 6, 2019
b914f90
Fix path display for local builds
originalfoo Jun 6, 2019
f600d00
Removed unnecessary events
originalfoo Jun 6, 2019
366bfde
#225: emergency vehicles do not change lanes at toll booths
VictorPhilipp Jun 6, 2019
da99c7f
#259:
VictorPhilipp Jun 7, 2019
a61f0cc
#259: corrected junction check at transition nodes
VictorPhilipp Jun 7, 2019
bb85e62
- Fixed minor issues regarding saving/loading junction restrictions
VictorPhilipp Jun 7, 2019
c99d4da
Use actual array size instead of fixed MAX_VEHICLE_COUNT constant
dymanoid Jun 8, 2019
cec8307
Merge pull request #358 from krzychu124/minor-fixes
VictorPhilipp Jun 8, 2019
84384e9
Translate `Delete` and `Unsibscribe` buttons
originalfoo Jun 9, 2019
26d55d1
Remove panel when unsubscribing
originalfoo Jun 10, 2019
4e8c8dd
Detect offline or --noWorkshop states
originalfoo Jun 10, 2019
57dfc56
Improved offline detection
originalfoo Jun 10, 2019
9ebe88c
Code cleanup and comments
originalfoo Jun 10, 2019
7018932
Code clean up and comments.
originalfoo Jun 10, 2019
6ea6d35
Reverted to just hiding the button, rather than whole panel
originalfoo Jun 10, 2019
daf55a8
Remove TMPE.GlobalConfigGeberator project
originalfoo Jun 10, 2019
1c6e0a1
Update lang_zh.txt
originalfoo Jun 10, 2019
cda3cd9
Merge pull request #374 from krzychu124/367-remove-obsolete-global-co…
originalfoo Jun 10, 2019
1b426eb
Merge pull request #375 from krzychu124/336-chinese-translation
originalfoo Jun 11, 2019
fc3447b
Update TMPE.sln
originalfoo Jun 13, 2019
4e23218
Merge branch 'master' into 326-differentiate-labs-and-stable
originalfoo Jun 13, 2019
852da65
Update lang_pl.txt
originalfoo Jun 13, 2019
ee69f7a
GUI settings page for keyboard shortcuts. TMPE main window and 6 most…
kvakvs Jun 16, 2019
7e9fd61
FIXME: Added Shift+S stay in lane to shortcuts, but it works only if …
kvakvs Jun 16, 2019
2cb3d37
Added KeyMapping.cs to the C# project
kvakvs Jun 16, 2019
5120694
Minor: Downgrade C# syntax version
kvakvs Jun 16, 2019
9ceb18f
Implement changes after review
dymanoid Jun 16, 2019
7acb367
Speed limits MPH/kmph option added, textures added, default speed lim…
kvakvs Jun 16, 2019
7156c43
Editorconfig file instructs the IDE to use 8 space indentation and ta…
kvakvs Jun 16, 2019
88f3103
Review notes on translations
kvakvs Jun 16, 2019
3874b3d
Fixed keyboard to become keybinds; Added DE/RU translations
kvakvs Jun 17, 2019
1e10393
Added missing languages as copy of english
kvakvs Jun 17, 2019
d68efff
Missed/misplaced one line in RU translation
kvakvs Jun 17, 2019
01673af
Merge pull request #359 from krzychu124/259-parking-ai-loop
FireController1847 Jun 17, 2019
7250add
Merge pull request #355 from krzychu124/225-lane-changes-happen-at-to…
FireController1847 Jun 17, 2019
1f671ed
Update lang_pl.txt
kvakvs Jun 17, 2019
7899408
Removed speed index everywhere and using floats now; New textures 5..140
kvakvs Jun 17, 2019
d6761c6
Make CI happy
kvakvs Jun 17, 2019
f30a37c
Tabified files; Fixed Shift+S/Delete shortcuts in lane connector
kvakvs Jun 17, 2019
f55b54e
Fixed unlimited speed setting
kvakvs Jun 18, 2019
8bfd1e6
Custom speed limits are not applied while loading save game
kvakvs Jun 18, 2019
8533bef
Use IsValidRange instead of > 0
kvakvs Jun 18, 2019
02d16c9
Check this.IsVisible before checking keys
kvakvs Jun 18, 2019
4679569
Added dummy button to speed limits; added 90 MPH
kvakvs Jun 19, 2019
0d8cd85
Remove the deprecated functions, unused after we started using float …
kvakvs Jun 19, 2019
b400887
Remove newline between variables
kvakvs Jun 19, 2019
cf2a754
Removed bool variable which was always true
kvakvs Jun 19, 2019
0f468b1
Dynamic Window Width & Center Rows
FireController1847 Jun 20, 2019
1c57b4b
Specify Texture Size
FireController1847 Jun 20, 2019
a9a2217
Make Constant
FireController1847 Jun 20, 2019
bbb5a40
Merge pull request #1 from FireController1847/mph-speed-limits
kvakvs Jun 20, 2019
c2f4798
Add MPH Signs
FireController1847 Jun 20, 2019
eabcb18
Add More Languages
FireController1847 Jun 20, 2019
57fe851
Center More Things
FireController1847 Jun 20, 2019
d95859d
Remane 'Policies & Restrictions' tab to just 'Policies'
originalfoo Jun 20, 2019
7f9ea6a
New ESC readonly shortcut; Removed tool shortcuts by default; Shift+;…
kvakvs Jun 20, 2019
f6f04d1
KM/H => km/h
FireController1847 Jun 20, 2019
eb63347
Refactor Textures
FireController1847 Jun 20, 2019
eb2192f
Slightly Reduce Sign Size
FireController1847 Jun 20, 2019
fd9a2ee
Fix Folder Capitalization
FireController1847 Jun 20, 2019
56c6cf2
Shorten one phrase in PL translation
kvakvs Jun 20, 2019
ddaffca
Merge pull request #2 from FireController1847/mph-speed-limits
kvakvs Jun 20, 2019
67be383
Style selector option; MPH can be toggled from the speeds palette
kvakvs Jun 20, 2019
fd2675b
British signs added, style selector for MPH added, translations
kvakvs Jun 20, 2019
ef63527
Fixed km/h in debug overlay for vehicles
kvakvs Jun 21, 2019
ee50d3c
Update TLM/TLM/UI/TrafficManagerTool.cs
kvakvs Jun 21, 2019
c181f0c
Small rounding bug with GetLockFreeGameSpeedLimit; Save/load should w…
kvakvs Jun 21, 2019
eadc4df
Update PL translation
kvakvs Jun 22, 2019
2145ec4
Update DE translation
kvakvs Jun 22, 2019
c245319
Fix kmph in 'set lane limit' debug log
kvakvs Jun 22, 2019
d532bce
mph -> MPH; Fixed Settings being out of sync with MPH checkbox in the…
kvakvs Jun 22, 2019
2bae412
Conflict detection for keyboard shortcuts in TM:PE and in the Game
kvakvs Jun 22, 2019
370222b
Conflict detection improved. TMPE keys now have categories to disting…
kvakvs Jun 22, 2019
a369f11
Merge pull request #362 from dymanoid/master
FireController1847 Jun 23, 2019
c511807
Update PL translations
kvakvs Jun 23, 2019
fd5e7d4
Merge pull request #384 from kvakvs/mph-speed-limits
FireController1847 Jun 23, 2019
7b1f4e3
Merge branch 'master' of https://github.com/krzychu124/Cities-Skyline…
krzychu124 Jun 23, 2019
4732b1e
Merge branch 'master' into 326-differentiate-labs-and-stable
originalfoo Jun 25, 2019
44a8af0
Merge branch 'master' into keyboard-shortcuts-ui
kvakvs Jun 25, 2019
ebf71f7
Undo the dreadful tab indent in .editorconfig
originalfoo Jun 25, 2019
515057d
Update ModsCompatibilityChecker.cs
originalfoo Jun 25, 2019
a240a52
Update ModsCompatibilityChecker.cs
originalfoo Jun 25, 2019
ebb5bd2
Update ModsCompatibilityChecker.cs
originalfoo Jun 25, 2019
4c91dcb
Merge pull request #392 from krzychu124/aubergine10-editorconfig
FireController1847 Jun 25, 2019
6fb820f
Update IncompatibleModsPanel.cs
originalfoo Jun 26, 2019
811e0bb
Update ModsCompatibilityChecker.cs
originalfoo Jun 26, 2019
9d23732
.gitignore /TLM/.vs/config/applicationhost.config
originalfoo Jun 26, 2019
fa16ae0
Delete applicationhost.config
originalfoo Jun 26, 2019
c7924ba
Ignore entire .vs/ folder
originalfoo Jun 26, 2019
d510469
Merge pull request #395 from krzychu124/aubergine10-ignore-vs-apphost
originalfoo Jun 26, 2019
ef7122a
Update README for upcoming 10.21 release
originalfoo Jun 26, 2019
e9b9218
Improved formatting of header (logo, centering, etc)
originalfoo Jun 27, 2019
554bb9a
Added draft of 10.21 to changelog, added heading styles
originalfoo Jun 27, 2019
28407b0
Changelog update: basic offline support for Origin users
originalfoo Jun 27, 2019
489f43b
Untabify UI files
kvakvs Jun 28, 2019
365c9e6
Untabify KeyMapping files and rename/regroup classes one per file in …
kvakvs Jun 28, 2019
0799d5a
Reindent MainMenuPanel
kvakvs Jun 28, 2019
a656f21
Untabify and remove unused directives
kvakvs Jun 28, 2019
321b3fb
Explicitly set C# language version to 7.3
krzychu124 Jun 28, 2019
cfd7395
Translations adjusted; Main menu button has tooltip now
kvakvs Jun 29, 2019
b337cd4
Refactored keybinds editor to allow a second keybind per setting (WIP)
kvakvs Jun 29, 2019
d1d6e47
Refactored GUI for Keybinds settings; X button to clear
kvakvs Jun 30, 2019
9f6fbbc
Update Main Menu tooltip; Null exception in Main Menu tooltip
kvakvs Jun 30, 2019
edf831a
Formatting & added keybinds feature, etc
originalfoo Jun 30, 2019
4af5287
Groups for keybinds settings; Dual settings displayed in 1 row
kvakvs Jun 30, 2019
26e868a
Clear lane connections now has first key readonly (Delete)
kvakvs Jun 30, 2019
7ab1417
Updated langVersion value to latest
krzychu124 Jun 30, 2019
eafc7ca
Updated langVersion value to latest
krzychu124 Jun 30, 2019
1e437c9
Merge pull request #398 from krzychu124/explicit-csharp-version
FireController1847 Jun 30, 2019
dbc21ca
Merge pull request #333 from krzychu124/326-differentiate-labs-and-st…
FireController1847 Jun 30, 2019
537dbf6
Merge branch 'master' into keyboard-shortcuts-ui
originalfoo Jun 30, 2019
a33333c
Vehicle limit fix after incomplete merge
krzychu124 Jul 1, 2019
d9bd167
Merge with master, resolved conflict with TrafficManagerMod.cs
krzychu124 Jul 1, 2019
59277cd
Fixed hanging Press any key state on keybind buttons
kvakvs Jul 1, 2019
87eda10
Attempting to exclude self from offline TMPE mod check
originalfoo Jul 1, 2019
b8ec7fa
Use `ModuleVersionId` Guid instead of build
originalfoo Jul 1, 2019
c92d05b
Fixed method name typo
originalfoo Jul 1, 2019
c50f096
Improved logging
originalfoo Jul 1, 2019
e976397
Include PR #400
originalfoo Jul 1, 2019
095cd0f
Include mod path in logging of skipped local builds
originalfoo Jul 1, 2019
fc90187
GameVersion numbers update
krzychu124 Jul 1, 2019
a9a03aa
Detect _any_ other version of TM:PE, regardless of online vs. offline
originalfoo Jul 1, 2019
739e62d
Modal handling fixed; Key conflict finding fixed
kvakvs Jul 2, 2019
49db07c
Minor code cleanup
originalfoo Jul 2, 2019
eff32b2
Review notes; Renamings; PL translation update
kvakvs Jul 2, 2019
d9e8813
StyleCop SA1200: Moved usings inside namespace
kvakvs Jul 2, 2019
308ca3c
Update changelogs
originalfoo Jul 2, 2019
4b3acab
Removed #370 from changelog as it's moved to next milestone
originalfoo Jul 2, 2019
9e48b06
Merge pull request #400 from krzychu124/exclude-self-from-checker
originalfoo Jul 2, 2019
7a7f0a6
Use wordWrap=true on UILabels for keybinds for long translations
kvakvs Jul 2, 2019
d4903e5
Merge branch 'master' into keyboard-shortcuts-ui
originalfoo Jul 2, 2019
2496104
Update mod and game version
originalfoo Jul 2, 2019
f154c33
Merge pull request #403 from krzychu124/ver-10.21
originalfoo Jul 2, 2019
c5c2223
Merge branch 'master' into keyboard-shortcuts-ui
originalfoo Jul 2, 2019
92e3494
Mnetion #403 - game version update
originalfoo Jul 2, 2019
66a9258
Merge pull request #382 from kvakvs/keyboard-shortcuts-ui
originalfoo Jul 2, 2019
29299f6
Blur position and zOrder fix
krzychu124 Jul 2, 2019
c67af20
Changelog update for #404 and #382
originalfoo Jul 2, 2019
01023ad
Merge pull request #396 from krzychu124/aubergine10-v10.21-prep
originalfoo Jul 2, 2019
7e5b560
Merge pull request #404 from krzychu124/incompatible-checker-blur-fix
originalfoo Jul 2, 2019
be496b6
Added release date to changelogs
originalfoo Jul 2, 2019
7194dbe
Merge pull request #405 from krzychu124/fix-dates
originalfoo Jul 2, 2019
c607b36
Update lang_zh.txt
Emphasia Jul 4, 2019
816d83b
Refactor changelog
originalfoo Jul 6, 2019
1a3fa30
Only perform logging in DEBUG builds
originalfoo Jul 6, 2019
de201aa
Version 10.21.1 hotfix
originalfoo Jul 6, 2019
750972d
Merge pull request #413 from krzychu124/fix-411
originalfoo Jul 6, 2019
c6e9728
Merge pull request #412 from krzychu124/changelog-updates
originalfoo Jul 6, 2019
0aa0c80
Updated changelogs for 10.21.1
originalfoo Jul 6, 2019
8f93a80
Merge branch 'master' into 10.21.1-hotfix
originalfoo Jul 6, 2019
012a4c9
Merge pull request #414 from krzychu124/10.21.1-hotfix
originalfoo Jul 6, 2019
381bdb5
Update CHANGELOG.md
krzychu124 Jul 6, 2019
40791c8
Merge pull request #417 from Emphasia/10.21
originalfoo Jul 8, 2019
613a3b6
Added complete history of Traffic++
originalfoo Jul 8, 2019
36631b9
Merge pull request #422 from krzychu124/changelog-tpp
originalfoo Jul 9, 2019
20e7300
Merge branch 'master' of https://github.com/krzychu124/Cities-Skyline…
krzychu124 Jul 10, 2019
83fb981
Merge branch '119-migration-to-harmony' of https://github.com/krzychu…
krzychu124 Jul 10, 2019
9b3996c
Moved type and old legacy type given different namespaces
kvakvs Jul 14, 2019
6ec4c8c
ConfigData members and Config untabified
kvakvs Jul 15, 2019
7948df5
Merge pull request #427 from kvakvs/119-migration-to-harmony-savegamefix
krzychu124 Jul 15, 2019
2b179bb
Update lang_template.txt
originalfoo Jul 15, 2019
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
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
Expand Down Expand Up @@ -183,9 +183,9 @@ UpgradeLog*.htm
FakesAssemblies/
/logo/

# MSVS 2017 artifacts
/.vs/slnx.sqlite
/TLM/.vs/TMPE/*
# MSVS 2017, IntelliJ IDEA/Rider artifacts
.vs/
.idea/

# Dependecies game dlls
/TLM/dependencies
/TLM/dependencies
2,682 changes: 1,789 additions & 893 deletions CHANGELOG.md

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions TLM/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*.{cs,vb}]
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.cs]
# csharp_new_line_before_open_brace = methods
1,028 changes: 0 additions & 1,028 deletions TLM/.vs/config/applicationhost.config

This file was deleted.

1 change: 1 addition & 0 deletions TLM/CSUtil.Commons/CSUtil.Commons.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
150 changes: 72 additions & 78 deletions TLM/TLM/Custom/AI/CustomAmbulanceAI.cs
Original file line number Diff line number Diff line change
@@ -1,81 +1,75 @@
using ColossalFramework;
using TrafficManager.RedirectionFramework.Attributes;
using System;
using System.Collections.Generic;
using System.Text;
using TrafficManager.Custom.PathFinding;
using TrafficManager.Geometry;
using TrafficManager.Manager;
using TrafficManager.Manager.Impl;
using TrafficManager.Traffic;
using TrafficManager.Traffic.Data;
using TrafficManager.Traffic.Enums;
using UnityEngine;
using static TrafficManager.Custom.PathFinding.CustomPathManager;
namespace TrafficManager.Custom.AI {
using API.Traffic.Data;
using API.Traffic.Enums;
using ColossalFramework;
using Custom.PathFinding;
using Manager.Impl;
using RedirectionFramework.Attributes;
using Traffic.Data;
using UnityEngine;

namespace TrafficManager.Custom.AI {
[TargetType(typeof(AmbulanceAI))]
public class CustomAmbulanceAI : CarAI {
[RedirectMethod]
public bool CustomStartPathFind(ushort vehicleID, ref Vehicle vehicleData, Vector3 startPos, Vector3 endPos, bool startBothWays, bool endBothWays, bool undergroundTarget) {
ExtVehicleType vehicleType = ExtVehicleManager.Instance.OnStartPathFind(vehicleID, ref vehicleData, (vehicleData.m_flags & Vehicle.Flags.Emergency2) != 0 ? ExtVehicleType.Emergency : ExtVehicleType.Service);
[TargetType(typeof(AmbulanceAI))]
public class CustomAmbulanceAI : CarAI {
[RedirectMethod]
public bool CustomStartPathFind(ushort vehicleID, ref Vehicle vehicleData, Vector3 startPos, Vector3 endPos, bool startBothWays, bool endBothWays, bool undergroundTarget) {
ExtVehicleType vehicleType = ExtVehicleManager.Instance.OnStartPathFind(vehicleID, ref vehicleData, (vehicleData.m_flags & Vehicle.Flags.Emergency2) != 0 ? ExtVehicleType.Emergency : ExtVehicleType.Service);

VehicleInfo info = this.m_info;
bool allowUnderground = (vehicleData.m_flags & (Vehicle.Flags.Underground | Vehicle.Flags.Transition)) != 0;
PathUnit.Position startPosA;
PathUnit.Position startPosB;
float startDistSqrA;
float startDistSqrB;
PathUnit.Position endPosA;
PathUnit.Position endPosB;
float endDistSqrA;
float endDistSqrB;
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) &&
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)) {
if (!startBothWays || startDistSqrA < 10f) {
startPosB = default(PathUnit.Position);
}
if (!endBothWays || endDistSqrA < 10f) {
endPosB = default(PathUnit.Position);
}
uint path;
// 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(PathUnit.Position);
args.laneTypes = NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle;
args.vehicleTypes = info.m_vehicleType;
args.maxLength = 20000f;
args.isHeavyVehicle = this.IsHeavyVehicle();
args.hasCombustionEngine = this.CombustionEngine();
args.ignoreBlocked = this.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;
VehicleInfo info = this.m_info;
bool allowUnderground = (vehicleData.m_flags & (Vehicle.Flags.Underground | Vehicle.Flags.Transition)) != 0;
PathUnit.Position startPosA;
PathUnit.Position startPosB;
float startDistSqrA;
float startDistSqrB;
PathUnit.Position endPosA;
PathUnit.Position endPosB;
float endDistSqrA;
float endDistSqrB;
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) &&
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)) {
if (!startBothWays || startDistSqrA < 10f) {
startPosB = default(PathUnit.Position);
}
if (!endBothWays || endDistSqrA < 10f) {
endPosB = default(PathUnit.Position);
}
uint path;
// 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(PathUnit.Position);
args.laneTypes = NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle;
args.vehicleTypes = info.m_vehicleType;
args.maxLength = 20000f;
args.isHeavyVehicle = this.IsHeavyVehicle();
args.hasCombustionEngine = this.CombustionEngine();
args.ignoreBlocked = this.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 path, ref Singleton<SimulationManager>.instance.m_randomizer, args)) {
// 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;
}
} else {
PathfindFailure(vehicleID, ref vehicleData);
}
return false;
}
}
}
if (CustomPathManager._instance.CustomCreatePath(out path, ref Singleton<SimulationManager>.instance.m_randomizer, args)) {
// 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;
}
} else {
PathfindFailure(vehicleID, ref vehicleData);
}
return false;
}
}
}
142 changes: 68 additions & 74 deletions TLM/TLM/Custom/AI/CustomBusAI.cs
Original file line number Diff line number Diff line change
@@ -1,77 +1,71 @@
using ColossalFramework;
using TrafficManager.RedirectionFramework.Attributes;
using System;
using System.Collections.Generic;
using System.Text;
using TrafficManager.Custom.PathFinding;
using TrafficManager.Geometry;
using TrafficManager.Manager;
using TrafficManager.Traffic;
using TrafficManager.Traffic.Data;
using TrafficManager.Traffic.Enums;
using UnityEngine;
using static TrafficManager.Custom.PathFinding.CustomPathManager;
namespace TrafficManager.Custom.AI {
using API.Traffic.Data;
using API.Traffic.Enums;
using ColossalFramework;
using Custom.PathFinding;
using RedirectionFramework.Attributes;
using Traffic.Data;
using UnityEngine;

namespace TrafficManager.Custom.AI {
[TargetType(typeof(BusAI))]
public class CustomBusAI : CarAI {
[RedirectMethod]
public bool CustomStartPathFind(ushort vehicleID, ref Vehicle vehicleData, Vector3 startPos, Vector3 endPos, bool startBothWays, bool endBothWays, bool undergroundTarget) {
VehicleInfo info = this.m_info;
bool allowUnderground = (vehicleData.m_flags & (Vehicle.Flags.Underground | Vehicle.Flags.Transition)) != 0;
PathUnit.Position startPosA;
PathUnit.Position startPosB;
float startDistSqrA;
float startDistSqrB;
PathUnit.Position endPosA;
PathUnit.Position endPosB;
float endDistSqrA;
float endDistSqrB;
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) &&
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)) {
if (!startBothWays || startDistSqrA < 10f) {
startPosB = default(PathUnit.Position);
}
if (!endBothWays || endDistSqrA < 10f) {
endPosB = default(PathUnit.Position);
}
uint path;
// NON-STOCK CODE START
PathCreationArgs args;
args.extPathType = ExtPathType.None;
args.extVehicleType = ExtVehicleType.Bus;
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(PathUnit.Position);
args.laneTypes = NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle;
args.vehicleTypes = info.m_vehicleType;
args.maxLength = 20000f;
args.isHeavyVehicle = this.IsHeavyVehicle();
args.hasCombustionEngine = this.CombustionEngine();
args.ignoreBlocked = this.IgnoreBlocked(vehicleID, ref vehicleData);
args.ignoreFlooded = false;
args.randomParking = false;
args.ignoreCosts = false;
args.stablePath = true;
args.skipQueue = true;
[TargetType(typeof(BusAI))]
public class CustomBusAI : CarAI {
[RedirectMethod]
public bool CustomStartPathFind(ushort vehicleID, ref Vehicle vehicleData, Vector3 startPos, Vector3 endPos, bool startBothWays, bool endBothWays, bool undergroundTarget) {
VehicleInfo info = this.m_info;
bool allowUnderground = (vehicleData.m_flags & (Vehicle.Flags.Underground | Vehicle.Flags.Transition)) != 0;
PathUnit.Position startPosA;
PathUnit.Position startPosB;
float startDistSqrA;
float startDistSqrB;
PathUnit.Position endPosA;
PathUnit.Position endPosB;
float endDistSqrA;
float endDistSqrB;
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) &&
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)) {
if (!startBothWays || startDistSqrA < 10f) {
startPosB = default(PathUnit.Position);
}
if (!endBothWays || endDistSqrA < 10f) {
endPosB = default(PathUnit.Position);
}
uint path;
// NON-STOCK CODE START
PathCreationArgs args;
args.extPathType = ExtPathType.None;
args.extVehicleType = ExtVehicleType.Bus;
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(PathUnit.Position);
args.laneTypes = NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle;
args.vehicleTypes = info.m_vehicleType;
args.maxLength = 20000f;
args.isHeavyVehicle = this.IsHeavyVehicle();
args.hasCombustionEngine = this.CombustionEngine();
args.ignoreBlocked = this.IgnoreBlocked(vehicleID, ref vehicleData);
args.ignoreFlooded = false;
args.randomParking = false;
args.ignoreCosts = false;
args.stablePath = true;
args.skipQueue = true;

if (CustomPathManager._instance.CustomCreatePath(out path, ref Singleton<SimulationManager>.instance.m_randomizer, args)) {
// NON-STOCK CODE END
if (CustomPathManager._instance.CustomCreatePath(out path, ref Singleton<SimulationManager>.instance.m_randomizer, args)) {
// 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;
}
}
return false;
}
}
}
if (vehicleData.m_path != 0u) {
Singleton<PathManager>.instance.ReleasePath(vehicleData.m_path);
}
vehicleData.m_path = path;
vehicleData.m_flags |= Vehicle.Flags.WaitingPath;
return true;
}
}
return false;
}
}
}
Loading