-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #427 from kvakvs/119-migration-to-harmony-savegamefix
Fixes Harmony savegame compat with the pre-Harmony master
- Loading branch information
Showing
111 changed files
with
26,129 additions
and
26,259 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} |
Oops, something went wrong.