CitiesSkylinesMods / TMPE

Cities: Skylines Traffic Manager: President Edition
https://steamcommunity.com/sharedfiles/filedetails/?id=1637663252
MIT License
574 stars 85 forks source link

Disable despawning by vehicle type #1434

Closed Marconius6 closed 2 years ago

Marconius6 commented 2 years ago

Describe your idea

I like to play with despawning disabled, for a more realistic and challenging experience. However, I've been noticing more and more that trains are... kind of terrible; their AI seems limited at best, and unlike road traffic, you have relatively few options to do deal with them (no lights, and they ignore yield signs half the time).

So I would like to be able to play with despawning disabled for most things, but trains still despawning as in vanilla, if they get stuck. I think this would be a good compromise, and seems relatively easy to implement as well.

Specifically, I would put a list in the options menu under the "disable despawning" setting, that would allow you to choose exactly which vehicles you want to disable despawning for. A similar list already exists under the Maintenance options for one-time despawning.

lokpro commented 2 years ago

I think so. I thought the Maintenance options one-time despawning checkboxes was also for the (!🚗) icon but found it isn't.

originalfoo commented 2 years ago

Just checked the despawn code (notably it all routes through VehicleBehaviorManager.MayDespawn(Vehicle)) and there is currently no distinction of vehicle type in that method.

public bool MayDespawn(ref Vehicle vehicleData) {
    return !Options.disableDespawning
        || ((vehicleData.m_flags2 & (Vehicle.Flags2.Blown | Vehicle.Flags2.Floating)) != 0)
        || (vehicleData.m_flags & Vehicle.Flags.Parking) != 0;
}

Call sites would either need updating to pass in ExtVehicleType, or the method itself would need udpating to determine that (via vehicleData.Info).

image

krzychu124 commented 2 years ago

@aubergine10 we just need to pass vehicle id. It shouldn't be too hard. I'll try to create PR with changes later today.