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 ;
15
10
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 ) ;
22
16
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 ;
65
59
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
+ }
0 commit comments