-
Content Count
41 -
Joined
-
Last Visited
Community Reputation
16 FavourableAbout Strdate
-
Rank
Hitchhiker
Recent Profile Visitors
-
TransferManager reverse engineering
Strdate replied to Kmeld's topic in Cities: Skylines Modding - Open Discussion
You must use C# reflection (google it) There is already a mod that changes the Transfer Manager behavior, but I myself didn't check it out. You can look at its source code. Check out this tutorial how to attach debugger to Cities:Skylines and how to decompile the code if you didn't do that already. By the way, as a matter of principle I would not recommend inheritance as a good way how to change the code (it causes bugs). You can use Harmony to redirect method calls. But for now that is probably too advanced, so play with the code anyhow you can. Hope this helped at least a little bit although it doesn't answer your question.- 2 Replies
-
- transfer manager
- transfer
-
(and 2 more)
Tagged with:
-
Not enough goods to sell
Strdate replied to cromabianca's topic in Cities: Skylines General Discussion
Sorry for reviving such and old thread, but it still appears in the google search so this still can help someone. I encountered the not enough goods problem when building an island city without industry. It took me some time looking through the game code to find where is the problem, but in the end I found out that the bottleneck is the capacity of the outside connections. There is a limit on how much you import. Thankfully, there is already a (not much known) mod that resolves that so solving this problem is is as easy as installing the mod and setting the new limits. Configure Outside Connections' Limits Read the description for more details. It's really easy to use. -
Cities: Skylines Campus announced!
Strdate replied to Avanya's topic in Cities: Skylines General Discussion
I am afraid that this dlc won't touch the default education system too much. Or at least I got that notion from reading the announcement and the first diary... Because otherwise the devs would not boast about the stuff like city policies, if there were much important changes to be made. I expect something like Parklife, although campuses might be a bit more interesting than parks.- 10 Replies
-
- dlc
- cities skylines
-
(and 2 more)
Tagged with:
-
Custom Audio for Assets?
Strdate replied to OwiHH's topic in Cities: Skylines Modding - Open Discussion
After some testing I think I finally found out how it all works. Maybe after everything is clear I could make a tutorial out of this Let's start with this OnAssetLoaded(string name, object asset, Dictionary<string, byte[]> userData) The "name" variable is a beautified name of the asset without the prefix or whatever. So, in my opinion, you actually can receive two asset called "New Asset". Because of this it's not a good idea to use this name as a key when you want to store something from the userData. Thankfully, you can take the "asset", cast it into BuildingInfo or whatever and use the name of the prefab itself. This includes the prefix (which is the name of the file or workshop id) plus a dot, plus the actual prefab name, plus "_Data" postfix (For example "6558756.New Asset_Data"). That's good, you can use this as an unique key to access the data at any given point. The "userData" dictionary is a dictionary containing data of all mods taking advantage of the IAssetDataExtension, thus you shouldn't keep it all but only check for the data saved by your mod, otherwise the asset data will be unnecessarily saved by multiple mods at once. (Well, in fact if you only store the reference to the dictionary it shouldn't be such a problem, but you should keep in mind that it is shared by others and some other mod could, for example, delete your data. Thus I think it is a better idea to copy what you need and disregard the rest of the dictionary) Now let's look at this public void OnAssetSaved(string name, object asset, out Dictionary<string, byte[]> userData) "name" - again, simple name of the asset "asset" - There is where the problems start. Imagine that you have your userData ready and besides saving them with the asset you would like to update the prefab-data dictionary, so that you can load them when the asset is reloaded (Inbetween saving the asset and reloading the asset the OnAssetLoaded method WON'T be called unless you are reloading the whole editor!!) You would again cast the "asset" to BuildingInfo and read the name, in the good faith that you would receive the same key as when you are doing this thing in the OnAssetLoaded method. But you would be wrong. This time, the name of the asset doesn't contain the prefix (or at least that is my experience) and the rest of the name could be out-of-date! If the user renames the asset when it's being saved, you don't see this change when this method is called. My question is: is there any way to get the prefix, so I can obtain the correct key? I receive the correct asset name in the "name" variable and can add the "_Data" postfix myself, but I don't see how to get the prefix. "userData" - Warning! This is not the same dictionary as you will receive in the OnLevelLoaded method. It will be merged with the dictionaries of all other mods. There is a code concept which might illustrate it all better: /* Untested snippet */ public class AssetDataExtension : IAssetDataExtension { public AssetDataExtension instance; /* Dictionary of assets and their data */ private Dictionary<string,byte[]> myModData = new Dictionary<string,byte[]>(); public AssetDataExtension() { instance = this; } public void OnAssetLoaded(string name, object asset, Dictionary<string, byte[]> userData) { BuildingInfo info = asset as BuildingInfo; if (info != null) { if( userData.ContainsKey( "MyModKey" ) ) { if( ModLoading.IsInAssetEditor ) { myModData[ info.name ] = userData[ "myModKey" ]; } else { // Let's hope for no duplicates? myModData[ name ] = userData[ myModKey ]; } } } } public void OnAssetSaved(string name, object asset, out Dictionary<string, byte[]> userData) { byte[] data = SomeClass.SerializeMyData(); if(data != null) { userData = new Dictionary<string,byte[]>(); userData[ "myModKey" ] = data; myModData[ name ] = data; } } public byte[] GetAssetData(BuildingInfo info) { if(ModLoading.IsInAssetEditor) { return myModData[ GetNameWithoutPrefixAndPostfix( info.name ) ]; } else { return myModData[ info.name ]; } } private string GetNameWithoutPrefixAndPostfix(string str) { ... } public void OnCreated(IAssetData assetData) { } public void OnReleased() { // reset saved data myModData = new Dictionary<string,byte[]>(); } And about the compatibility with the LSM mod. The author replied to my topic, you can see how it is going there https://steamcommunity.com/workshop/filedetails/discussion/667342976/2605804632891559366/ EDIT: Tested it, with the code above you really can end up with Assets with the same name that clash. So this must be somehow solved. -
Very nice! There are my suggestions: a) Maybe I didn't look well enough, but an option to modify both trees at once would be nice. There could be a checkbox or something like that. b) What did always irk me about the old version was the missing option to add some kind of offset to the distance so the trees and poles don't overlap and the spacing is regular. Screenshot Maybe there even doesn't have to be an option, but the offset could be computed automatically? c) (somehow related to previous one) I think that most of the people don't set different distances of trees and lampposts on the same road, so there could be a single slider to change all the distances at once. d) I don't know how much difficult it is, but maybe an option to have lampposts on both sides of the street even on the small roads?
- 81 Replies
-
- mod
- development
-
(and 1 more)
Tagged with:
-
Custom Audio for Assets?
Strdate replied to OwiHH's topic in Cities: Skylines Modding - Open Discussion
I thought that if two assets have the same name it could cause problems. -
Custom Audio for Assets?
Strdate replied to OwiHH's topic in Cities: Skylines Modding - Open Discussion
Yes, I've already created an issue on github. You are right that it is still faster than saving it in a separate file, even from the perspective of how many lines of code it takes. I save the data in a dictionary with the key being the asset's name (for example BuildingInfo.name) without the dot prefix (i would save it with the prefix as well, but sometimes it is there and sometimes it is not...). I am not sure if it's safe against duplicates though. -
Custom Audio for Assets?
Strdate replied to OwiHH's topic in Cities: Skylines Modding - Open Discussion
Sooo, today I was playing with the IAssetDataExtension interface (not for custom audio, but something else) and found out that it is not working with the Loading Screen Mod - the OnAssetLoaded method is never called. That sucks. By the way, it is all a bit clumsy because apparently you have to store the data yourself in some kind of dictionary - as I searched through the source files, there is no way to access the data if you don't save them somewhere when the OnAssetLoaded method is called. (Or, as always, I miss something) -
Smart Intersection Builder - Issues
Strdate replied to Strdate's topic in Cities: Skylines Modding - Open Discussion
Harmony really seems to cause problems. Some completely unrelated mods (RealTime) started reporting errors just by the presence of my mod, even when it was disabled and no detour launched. I guess it must be because the game is confused by the presence of more Harmony DLLs. Probably I do something wrong. I put the dll next to my mod's. Maybe it is due to the version? I use net 3.5 version of Harmony. For now I went back to the old detour library and everything seems fine... -
Smart Intersection Builder - Issues
Strdate replied to Strdate's topic in Cities: Skylines Modding - Open Discussion
Thanks! I am used to reloading the game every time But the file copying script is really good. At least the DLCs are the same. Nonetheless it is really hard to reproduce issues as these... I would use the patch annotations as well, but at some point (now that piece of code is gone) I needed to trigger one patch by the other, which is not possible when patching whole assembly simultaneously. -
Smart Intersection Builder - Issues
Strdate posted a topic in Cities: Skylines Modding - Open Discussion
Hi! It is again me, needing some help! Who else would it be? I am trying to sort out issues I am having with my Smart Intersection Builder mod. Some people report really odd behavior, probably caused by the detours that I use in the mod. It may be caused (partially) by the industries DLC, which I unfortunately don't own. Does anyone know if the game DLLs differ in some way when that DLC is installed? In particular the Assembly-CSharp.dll and ICities.dll. Would be somebody with industries so nice and uploaded them for me? (The path should be something like this C:\Program Files (x86)\Steam\steamapps\common\Cities_Skylines\Cities_Data\Managed\ ) By the way, even during the development I faced some problems using Harmony. In Particular, I was unable to unpatch the methods using this. It just would not work. harmonyInstance.Unpatch(OriginalMethod, HarmonyPatchType.Prefix); But this method works (at least on my computer): harmonyInstance.UnpatchAll(HarmonyID); I will research it a bit more, this is just in case somebody has already encountered this... I never had problems with the old patching library. -
Custom Building AIs
Strdate replied to boformer's topic in Cities: Skylines Modding - Open Discussion
I am sorry for breaking my promise to look at how the ships work! Apparently you managed to find everything out in the meantime. Now, as always, it will be me who will be learning... Good job! -
Roundabout Builder Mod
Strdate replied to ghosty20's topic in Cities: Skylines Modding - Open Discussion
There you go! Welcome to Smart Intersection Builder! It has its flaws tho so when you need to build something more sophisticated it will be probably quicker to do it by hand, but for the ones who prefer functionality over beauty it could work -
Giveaway: Celebrating 4 years of Cities: Skylines
Strdate replied to boformer's topic in Cities: Skylines General Discussion
I don't know what this is all about, but I've just released a new mod, can I get a cookie? For you I went to check how many hours I have on record and it is feeble 157 hours. On Cities in Motion 2 I have 152, rest in peace, I wish there was modding support at that time... I would take the Rock City Radio if there is something left! -
Custom Building AIs
Strdate replied to boformer's topic in Cities: Skylines Modding - Open Discussion
I can try it. To be frank, at this moment I have no idea how to do it. I know a bit about car behavior, but with ships you pretty much have to start from the scratch, as there probably never was demand to alter their behavior. I check what's in TMPE. Currently I decided to finish the "Smart Intersection Plopper". It is nasty and buggy as hell, it won't probably be a big hit, but I would like to have it off myself. Then this is definitely what I would like to work on.
