CitiesSkylinesMods / TMPE

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

Prop Switcher: Changing the lanes connectors ignores the prop switcher rules for the street arrows #1064

Open klyte45 opened 3 years ago

klyte45 commented 3 years ago

Describe the problem

In Prop Switcher there's a feature that allows global or per network switching props, what also support decals switching. Well, the problem seems that the TMPE ignores the rule - at least since last version that usually caches the value.

Steps to reproduce

  1. Enable the Prop Switcher
  2. In game, create a rule to change some arrows
  3. Create the change lanes
  4. You will see the rule written will not be applied

Extra: seems the arrow doesn't get back to its default if you remove all links from a lane.

Log files

N/A

Screenshots?

image

Notes or questions?

I believe it can be easily solved if right after changing the lane rules, then call to RenderManager.instance.UpdateGroups(i);, being i the current editing quadrant. The lack of this call can cause this kind of error if the switched prop have a associated effect, like lights: image (the pole is gone, but the light still there)

Feel free to talk with me if need more information.

kianzarrin commented 3 years ago

Extra: seems the arrow doesn't get back to its default if you remove all links from a lane.

you should use lane arrow tool -> select the node -> and press delete

kianzarrin commented 3 years ago

what will happen if you force a node update (eg select the node using NC)

also it would be interesting to see if this has anything to do with Loading Order (I doubt it because I think you are patching NetLane.RenderInstance() and not RoadBaseAI.UpdateLanes()

klyte45 commented 3 years ago

Yep, prop switcher goes directly on NetLane. The issue there is that the rules are cached and only recalculated while in CalculateGroupData method in NetLane.

PS: in older versions of Prop Switcher, this problem didn't exist because the rules were calculated every frame, on RenderInstance()

originalfoo commented 2 years ago

@kianzarrin does the Notifier API facilitate anything here? Eg. Could prop switcher be notified when lane arrows/connectors change?

kianzarrin commented 2 years ago

Yes TMPE notifier can be use when lane arrows change. I used this to update render data in my Adaptive Networks mod. But Notifier is only in TMPE 11.6

kianzarrin commented 2 years ago

Wait notifier is useful to notify prop switcher not the other way around

kianzarrin commented 2 years ago

You should trigger update lanes

kianzarrin commented 2 years ago

Sorry ignore my last comment. didn't read the issue properly.

klyte45 commented 2 years ago

So should I integrate Prop Switcher with TMPE to solve this issue from my side? Is there some kind of facade in TMPE to I connect my mod without issues if the code changes?

kianzarrin commented 2 years ago

TMPE notifier is part of TMPE API and must not change. for not it is only supported in TMPE test so you can start working on it but you should only publish your work to WS when TMPE stable has been released (unless if you have a beta version).

klyte45 commented 2 years ago

Well, I'll check this out later

About the release, I just need to know in which mod version it will be available to I set to fallback if the current version isn't the one supported. Then it will be ready to be released at workshop anytime, since it only will get the TMPE implementation if the version constraint is true. TMPE dlls have a release versioning in the own file, right?

kianzarrin commented 2 years ago

I hope there won't be problems with regards to missing symbols.

In any case TMPE test is V11.6 so check for that.

klyte45 commented 2 years ago

I have a pattern I use in my mods based in Klyte Commons. I revisited it recently to fix issues related to missing symbols - that was causing some immediate crashes in game.

I was already using a separated class that refers the other dll, and with this recent change I deleted all hard references from the code and made a indirect object creation after getting sure the mod with that version is installed. So, no risks involved for releasing it before TMPE getting updated, plus it would work if the user is subscribed to beta channel workshop item (presuming that it have the same DLL name from the official mod)

originalfoo commented 2 years ago

presuming that it have the same DLL name from the official mod

Yup, .dll file names are always same for past few years.