Cities: Skylines

Cities: Skylines

Vehicle Effects 1.9.5
Thaok 1 Nov, 2016 @ 6:16am
Adding new effects
Hi Acc3ss Violation, thank you for this great mod!
I was also thinking about something like this (only for sounds), but didn't had the time for all the problems to solve. Currently, I'm working on some new sound effects, mainly for trains:

-turbo diesel engines (load-dependent, and with separate state for the delayed turbo rpm)
-direct current trains (older metro EMUs and such).
-door closing and braking sounds

The engine sounds use some kind of crossfading technique (similar to e.g. fmod) to use different samples for each speed or load interval.

Until now I simply compiled them into your mod, but I just realized it should be possible to offer new effects as seprate mods or workshop items, since they should only be coupled via the game object name.

So far, the only problem I see with this is the case when a user subscribed to your mod, but not to an effect mod required for a vehicle. Then your mod will report a missing effect error. Instead, it would be nice, if it would silently fall-back on a default effect (maybe explicitly defined in the xml?). Or the vehicle author needed to define the effect mod (and possible also your mod) as workshop dependencies...

I think some kind of effect "plugin" architecture would be better than extending your mod for every new vehicle effect. Maybe only some generic effects like braking and door closing could be integrated.

What do you think?
Last edited by Thaok; 2 Nov, 2016 @ 2:54pm
< >
Showing 1-15 of 20 comments
Acc3ss Violation  [developer] 13 Nov, 2016 @ 11:31am 
I like the idea of a 'plugin' system, the loading order of the mods would be important, but it's not that difficult to ensure this mod loads last. With the fallback effect specified in the .xml config as well.
EDIT: Loading order is probably not even relevant.
Last edited by Acc3ss Violation; 13 Nov, 2016 @ 12:54pm
Thaok 17 Nov, 2016 @ 2:03am 
Work on the effects is coming along quite well. I put them into a separate mod some time ago now. So far, your mod always loaded second (probably because of the name coming later in the alphabet), or loading order is irrelevant as you said. Anyways, it always worked.

A simple optional "fallback" attribute for the effects would be nice. Just like this:
<Effect name="Train Movement" replacement="Turbo Diesel Train Movement 100" fallback="Diesel Train Movement">

I am also thinking about a possibility to bundle effect definitions for multiple vehicles in a single mod, I think that would make life easier for authors having many items in the workshop.

One way to implement this: your mod scans other mods for some marker object name and then tries to load xmls from a subdirectory of that mod. Or even simpler: you could just scan every vehicle asset dir for multiple xmls with a "VehicleEffects" prefix (to not mess with other definitions, e.g. for subbuildings) This way each author could upload a dummy vehicle with the definitions and wouldn't have to create a new mod for that (not everybody could do that).
(A rather ugly workaround, requiring no changes to your code, would be placing all definitions in the single big xml of a dummy vehicle, but this could quickly get confusing.)

Also, this way, one could offer definitions for vehicles, which may never get updated by their authors. Definitions bundeled individually with a vehicle could always be given precendence, in case an author is just late with updating.



Last edited by Thaok; 17 Nov, 2016 @ 2:26am
Acc3ss Violation  [developer] 1 Dec, 2016 @ 2:06am 
First of all, thanks for the 1.6 fixes, saved me some work figuring that out. Secondly, I should have hit "subscribe to discussion" a while ago, I wondered why I didn't get notified :P

The loading order does seem relevant, but I had an idea for a 'plugin' system that allows a mod to register itself as a plugin in OnCreated and then indicitate it is done setting up in OnLevelLoaded while this mod will wait for all registered plugins to be done before it updates the vehicles. I also was under the impression that C:S 1.6 would add something to influence mod loading order, but

The fallback should be easy enough to implement in the way you suggested, so I want to get on that as soon as possible.

Bundeling definition files would be nice because you wouldn't have to update all assets individually. I think using a mod would be preferably (a template C# script could be provided) with Vehicle Effects checking for a certain naming convention in mod names and then loading xml files from the folder of that mod. Something like having "Vehicle Effects Definiton" as a required prefix for the mod name. That would make it fairly easy to give these lower priority than definitions included with vehicles. It could also be used for adding effects to a vehicle which isn't updated.

On a sidenote, the update to Unity 5.4 also means that particle system modules can be accessed trough code. That should make creating custom particle effects a bit easier.
Last edited by Acc3ss Violation; 1 Dec, 2016 @ 2:44am
Thaok 1 Dec, 2016 @ 3:16am 
You're welcome!
A plugin registration mechanism would be great. I took a look at the games's mod loading code and it just traverses a Dictionary, which doesn't guarantee any order. Probably we were only lucky so far.

Maybe you could also emit an event _after_ replacing the effects? I would like my engine sound effects to scan for using VehicleInfos and set appropriate acceleration and braking values. That would save editing each vehicle in asset editor (Btw. Asset Vehicle Editor can't save anymore, iirc. a signature mismatch.)

As for definition bundling via mod, the script should be setup/placed for run-time compilation to keep things simple. Most vehicle authors may never have touched VS, so that might be a barrier else.

At the moment I am fighting some stupid bug concerning duplicate prefab names, I can't explain to me. It just occurs for _some_ local copies of published CRPs - even if there is not a single other copy of the file on the system... I used these to prepare effect definitions using the actual steam IDs, which worked fine before 1.6.

More serious, vehicle effects only get loaded for some vehicles on startup. But using the effect reloading shortcut always works. Not sure what's going on there. Loading order problems can't explain that...

Also, with 1.6, there is now some strange global reverb (sounds like a big cavern). Fortunately, it's easy to disable, at the moment I am using this code for my plugin:
private void SetGlobalReverb(bool value) { var reverbZone = GameObject.Find("Reverb Zone"); if(reverbZone == null) return; var audioReverbZone = reverbZone.GetComponent<AudioReverbZone>(); if (audioReverbZone == null) return; Debug.Log("disabling reverb"); //audioReverbZone.reverbPreset = AudioReverbPreset.Off; audioReverbZone.enabled = value; }
Changing the preset to a default instead of disabling didn't show any reliable results.

On the plus side, there is now a finer volume/distance-dependency and doppler effects. Either these are new or some mod messed them up before 1.6... ;-)
Last edited by Thaok; 1 Dec, 2016 @ 3:21am
Acc3ss Violation  [developer] 1 Dec, 2016 @ 4:36am 
I have a 'plugin system' in place now, but I just realized it would be much easier to just use an event before and after the vehicle update instead of the current implementation. Time to change that again.

The duplicate prefab error also happens to 2 of my workshop items, it's not just local copies. No clue what causes it, the local copies work fine.

And that bug with not loading for some vehicles is really strange, maybe some prefabs aren't actually loaded at that point, but that doesn't make a lot of sense either. As far as I know, OnLevelLoaded comes after all prefabs are loaded.
Thaok 1 Dec, 2016 @ 5:01am 
Yes, events should be a much easier solution. Still thinking of how to "link" your mod dynamically into the plugin without starting to hack using reflection and such. Probably that's trivial, but I'm still relatively new to C# (normally working with C++).

I just managed to kill a big SVN working copy including my plugin and other projects, there was an invalid junction during commit and that probably was a problem. Nothing is lost, but it will take some time to get it working again...

In the mean time I will leave the preview videos for the plugin here (to provide some motivation :-) :

Direct Current: https://www.youtube.com/watch?v=IDGUpY2xam8&t=3s
Specialized variant for Sprague-Thomson: https://www.youtube.com/watch?v=Rif0Cvy_aWI
Turbo Diesel: https://www.youtube.com/watch?v=3rE_EXe2tvA

Those updates always mess things up...

Acc3ss Violation  [developer] 1 Dec, 2016 @ 5:18am 
Just add VehicleEffects.dll as a reference to your project and you should be good to go.
You can do a check to see if a mod with the correct workshop id is subscribed before using anything from the dll to ensure it's available for use. No need to do that when testing though. I'll update the plugin system and provide an example later.
And those sound effects are amazing :D
Last edited by Acc3ss Violation; 1 Dec, 2016 @ 5:19am
[Delta ²k5] 1 Dec, 2016 @ 6:23am 
Um, nice idea - I had the same thing in mind as I got some really sweet metro sounds which fit my assets :) - so I wanted to ask about something like that, but somehow forgot to do so, lol.

Nice to see it's happening... If you want you can also get my metro sound and bundle it as it's really generic. Gonna record some video of that later I guess :) (The files used are from my old GTA IV installation *cough*)
Thaok 1 Dec, 2016 @ 7:00am 
Nice to hear it's that simple, I knew I was thinking too complicated...

@Delta
Generic sounds could be bundled with VE mod itself. On the other hand, with sounds one always wants to change and adjust something and with your own plugin mod you could do so independently and quickly. However, we can shift effects back and forth between mods anytime.
[Delta ²k5] 1 Dec, 2016 @ 8:08am 
Yeah, I just thought those sounds would fit quiet many metro trains, so I offered them :) for sure I could provide them later on, but yeah - here is some preview on those:

https://youtu.be/uUiU3u4uJBY
Thaok 1 Dec, 2016 @ 9:08am 
Nice sounds, a bit on the quieter side. :) To be clear, any future effect plugins are meant to be used by everyone, not just their authors.
Acc3ss Violation  [developer] 1 Dec, 2016 @ 9:22am 
The event plugin system is in place, so you guys can use it if you want. Sample code is in the Github readme in case you need it :)
Thaok 1 Dec, 2016 @ 9:30am 
Thank you very much, already working on it. :)
Thaok 1 Dec, 2016 @ 10:54am 
After realizing I actually did not subscribe to Vehicle Effects (...), and disabling the subscription check, the plugin mechanics finally seems to work as it should. :)

Also the mysterious partial effect update seems just to be caused by an uncaught exception during particle effect creation. Somewhere in DieselSmoke.CreateEffectObject(), probably related to the Unity version changes you already mentioned. (Btw. is there a way to link a debugger to the C# / IL part of the CSL process?)

I will do some further testing and report any problems.

So, whats left on my todo list for now:
-testing vehicle info acc/brake update
-testing positive subscription check
-duplicate prefab nonsense
-if necessary repairing asset vehicle editor (as a last resort we could decompile and fix it)
Last edited by Thaok; 1 Dec, 2016 @ 10:57am
Slick Gamble 1 Dec, 2016 @ 7:44pm 
I'm sure you two already know, but the patch for the sirens introduced a simulated doppler effect for trains, metro, emergency vehicles. Not sure about traffic, harder to judge. Those train sounds brought the biggest smile, music to my ears.
< >
Showing 1-15 of 20 comments
Per page: 1530 50