public bool CustomFindPathPosition(ushort instanceID, ref CitizenInstance citizenData, Vector3 pos, NetInfo.LaneType laneTypes, VehicleInfo.VehicleType vehicleTypes, bool allowUnderground, out PathUnit.Position position) { return(CustomPathManager.FindCitizenPathPosition(pos, laneTypes, vehicleTypes, NetInfo.LaneType.None, VehicleInfo.VehicleType.None, (citizenData.m_flags & CitizenInstance.Flags.CannotUseTransport) == CitizenInstance.Flags.None, allowUnderground, out position)); }
/// <summary> /// Starts path-finding of the walking path from parking position <paramref name="parkPos"/> to target position <paramref name="targetPos"/>. /// </summary> /// <param name="parkPos">Parking position</param> /// <param name="targetPos">Target position</param> /// <returns></returns> internal bool CalculateReturnPath(Vector3 parkPos, Vector3 targetPos) { #if DEBUG bool citDebug = (GlobalConfig.Instance.Debug.CitizenInstanceId == 0 || GlobalConfig.Instance.Debug.CitizenInstanceId == instanceId) && (GlobalConfig.Instance.Debug.CitizenId == 0 || GlobalConfig.Instance.Debug.CitizenId == GetCitizenId()) && (GlobalConfig.Instance.Debug.SourceBuildingId == 0 || GlobalConfig.Instance.Debug.SourceBuildingId == Singleton <CitizenManager> .instance.m_instances.m_buffer[instanceId].m_sourceBuilding) && (GlobalConfig.Instance.Debug.TargetBuildingId == 0 || GlobalConfig.Instance.Debug.TargetBuildingId == Singleton <CitizenManager> .instance.m_instances.m_buffer[instanceId].m_targetBuilding) ; bool debug = GlobalConfig.Instance.Debug.Switches[2] && citDebug; bool fineDebug = GlobalConfig.Instance.Debug.Switches[4] && citDebug; #endif ReleaseReturnPath(); PathUnit.Position parkPathPos; PathUnit.Position targetPathPos = default(PathUnit.Position); bool foundParkPathPos = CustomPathManager.FindCitizenPathPosition(parkPos, NetInfo.LaneType.Pedestrian, VehicleInfo.VehicleType.None, false, false, out parkPathPos); bool foundTargetPathPos = foundParkPathPos && CustomPathManager.FindCitizenPathPosition(targetPos, NetInfo.LaneType.Pedestrian, VehicleInfo.VehicleType.None, false, false, out targetPathPos); if (foundParkPathPos && foundTargetPathPos) { PathUnit.Position dummyPathPos = default(PathUnit.Position); uint pathId; PathCreationArgs args; args.extPathType = ExtCitizenInstance.ExtPathType.WalkingOnly; args.extVehicleType = ExtVehicleType.None; args.vehicleId = 0; args.spawned = true; args.buildIndex = Singleton <SimulationManager> .instance.m_currentBuildIndex; args.startPosA = parkPathPos; args.startPosB = dummyPathPos; args.endPosA = targetPathPos; args.endPosB = dummyPathPos; args.vehiclePosition = dummyPathPos; args.laneTypes = NetInfo.LaneType.Pedestrian | NetInfo.LaneType.PublicTransport; args.vehicleTypes = VehicleInfo.VehicleType.None; args.maxLength = 20000f; args.isHeavyVehicle = false; args.hasCombustionEngine = false; args.ignoreBlocked = false; args.ignoreFlooded = false; args.ignoreCosts = false; args.randomParking = false; args.stablePath = false; args.skipQueue = false; if (CustomPathManager._instance.CreatePath(out pathId, ref Singleton <SimulationManager> .instance.m_randomizer, args)) { #if DEBUG if (debug) { Log._Debug($"ExtCitizenInstance.CalculateReturnPath: Path-finding starts for return path of citizen instance {instanceId}, path={pathId}, parkPathPos.segment={parkPathPos.m_segment}, parkPathPos.lane={parkPathPos.m_lane}, targetPathPos.segment={targetPathPos.m_segment}, targetPathPos.lane={targetPathPos.m_lane}"); } #endif returnPathId = pathId; returnPathState = ExtPathState.Calculating; return(true); } else { #if DEBUG if (debug) { Log._Debug($"ExtCitizenInstance.CalculateReturnPath: Could not create return path for citizen instance {instanceId}"); } #endif } } else { #if DEBUG if (debug) { Log._Debug($"ExtCitizenInstance.CalculateReturnPath: Could not find path position(s) for either the parking position or target position of citizen instance {instanceId}: foundParkPathPos={foundParkPathPos} foundTargetPathPos={foundTargetPathPos}"); } #endif } return(false); }