-
Content Count
41 -
Joined
-
Last Visited
Content Type
Profiles
Forums
Omnibus
News
Features
Downloads
City Journals
Calendar
Gallery
Everything posted by Strdate
-
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 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. -
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. -
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. -
Custom Building AIs
Strdate replied to boformer's topic in Cities: Skylines Modding - Open Discussion
Nice! Maybe it would be even possible to create a mod that would save and load the custom AI libraries directly to/from the assets. With that you could do for example buildings with working clocks without need to install additional mods. -
Custom Animation Loader (CAL): Mesh Animations for Buildings
Strdate replied to boformer's topic in Cities: Skylines Modding - Open Discussion
Thanks for the explanation. But you don't create your own custom class there, do you - you just initialize/edit existing AI classes...? I've already spent some time looking how traffic manager works and that is the place I would like to start with this if possible. I see a great potential for custom animations regarding the transportation everywhere - railway crossings + barriers in general, ship locks... Draw bridges sound the best. It all requires traffic logic. Thanks for the offer! For now I really don't have anything to contribute with, if it was on the agenda I can always create a pull request.- 39 Replies
-
- cities skylines
- modding
-
(and 2 more)
Tagged with:
-
Custom Animation Loader (CAL): Mesh Animations for Buildings
Strdate replied to boformer's topic in Cities: Skylines Modding - Open Discussion
Cool! I spotted that you are planning to do drawbridges and similar stuff with this as well. I can't wait for it! Yesterday was released a turntable pack in the workshop and it's just begging to be animated. How do (or would) you approach that? Do you want to create custom DrawbridgeAI? I would love to know how to create custom service buildings but don't know how to load them in the game afterwards. The drawbridges, turntables etc. require overriding vehicle behavior method which cannot be done without breaking the compatibility with TMPE. Thus there needs to be some kind of native support from it. I don't know if anybody knows the guy behind the TMPE, but he seems to be inactive recently. There is a guy who took over his work and is maintaining it. (You probably know about it). It all can be done with some kind of virtual junctions. For that three things are needed: a) The ability to save and load timed traffic light (TTL) setup to/from assets. (Interchange creators would probably appreciate this as well!) b) Call from TMPE to the asset when TTL step changes so that the animation is triggered c) Ship paths with traffic light junctions Something like: STEP 1: Bridge is down, cars are going, STEP 2: Cars stop, call to building to draw the bridge, 3: Bridge up, 4: Bridge going down The users could even edit the length of the steps 1 and 3... There are people with definitely help with that, i have some ideas how to make point a) but I am struggling with finishing anything In any case, I am very interested in this! And I am very curious how everything is made.- 39 Replies
-
- cities skylines
- modding
-
(and 2 more)
Tagged with:
-
For a while I am facing a problem with UI Dropdowns. Simply, if there are too many items many of them will be neither visible nor accessible. When I implemented the UI dropdown I copied it from other mods (Parallel road tool, originally probably from CimTools) so I looked for inspiration there. But the parallel road mod seems to be facing the exact same problem - many items are inaccessible. I even found there something called something like "TextFieldDropdown" suggesting that there would be a text field for searching thru the list, but it was not implemented. When looking at the code of UIDropDown, I found this interesting field - public UIScrollbar listScrollbar { ... } Adding a scrollbar to the dropdown selection list would solve all my problems, but I didn't figure out how to do it. I looked in many places in the game, but didn't find a single dropdown which would have a scrollbar! So I can't copy it from anywhere. This is +/- where I am at with my code: public class UINetInfoDropDown : UIDropDown { private NetInfo[] m_netInfos; private SortedDictionary<string, NetInfo> m_dictionary; public UINetInfoDropDown() { atlas = ResourceLoader.GetAtlas("Ingame"); size = new Vector2(90f, 30f); listBackground = "GenericPanelLight"; itemHeight = 25; itemHover = "ListItemHover"; itemHighlight = "ListItemHighlight"; normalBgSprite = "ButtonMenu"; disabledBgSprite = "ButtonMenuDisabled"; hoveredBgSprite = "ButtonMenuHovered"; focusedBgSprite = "ButtonMenu"; listWidth = 90; listHeight = 1000; listPosition = UIDropDown.PopupListPosition.Below; clampListToScreen = true; foregroundSpriteMode = UIForegroundSpriteMode.Stretch; popupColor = new Color32(45, 52, 61, 255); popupTextColor = new Color32(170, 170, 170, 255); zOrder = 1; textScale = 0.8f; verticalAlignment = UIVerticalAlignment.Middle; horizontalAlignment = UIHorizontalAlignment.Left; selectedIndex = 0; textFieldPadding = new RectOffset(8, 0, 8, 0); itemPadding = new RectOffset(14, 0, 8, 0); UIButton button = AddUIComponent<UIButton>(); triggerButton = button; button.atlas = ResourceLoader.GetAtlas("Ingame"); button.text = ""; button.size = size; button.relativePosition = new Vector3(0f, 0f); button.textVerticalAlignment = UIVerticalAlignment.Middle; button.textHorizontalAlignment = UIHorizontalAlignment.Left; button.normalFgSprite = "IconDownArrow"; button.hoveredFgSprite = "IconDownArrowHovered"; button.pressedFgSprite = "IconDownArrowPressed"; button.focusedFgSprite = "IconDownArrowFocused"; button.disabledFgSprite = "IconDownArrowDisabled"; button.foregroundSpriteMode = UIForegroundSpriteMode.Fill; button.horizontalAlignment = UIHorizontalAlignment.Right; button.verticalAlignment = UIVerticalAlignment.Middle; button.zOrder = 0; button.textScale = 0.8f; // Does not work - UIScrollbar sbar = AddUIComponent<UIScrollbar>(); listScrollbar = sbar; sbar.width = 20; sbar.height = 1000; sbar.scrollSize = 40; sbar.relativePosition = new Vector2(0, height); eventSizeChanged += new PropertyChangedEventHandler<Vector2>((c, t) => { button.size = t; listWidth = (int)t.x; }); Populate(); } ... } When I open the scene explorer there is some kind of item in the place where the scrollbar should be, but nothing is visible. Maybe the problem is with setting the sprites; I don't know. I would appreciate any help!
-
UI: Scrollbars & Dropdowns
Strdate replied to Strdate's topic in Cities: Skylines Modding - Open Discussion
Thank you! That explains everything. Well, people would be probably complaining to me in the comments as well if it was not possible. It seems that people without mouse wheels are endangered species today (silent cry). I shamelessly released the mod with what I thought was a broken dropdown and decided to wait to see what would happen. Nothing happened, so I concluded people probably weren't using it at all Besides, I was mildly annoyed that you can't at least use arrow keys to navigate it. Now I realized that this crucial line of code was missing... builtinKeyNavigation = true; It is not in the original code from SamsamTS and the "copy-paste modders" like me of course didn't add it to the code afterwards. I think there is no reason why this should not be always enabled... I think that I will mothball the textfields and scrollbars for now as this is much simpler solution. Thanks for the links, at least there is someone who tackled this problem. I will take a look at it. -
UI: Scrollbars & Dropdowns
Strdate replied to Strdate's topic in Cities: Skylines Modding - Open Discussion
Up to the small changes I use the exact source code as you, I just created a dedicated class for it. Do you think that the size of the popup matters? The popup does fit to the screen thanks to the clampListToScreen parameter. (However people with resolution smaller than 1000px might have problem) What keys do you use to scroll the list? Do you use the mouse wheel? (My mouse wheel is not working and I am used to do without it) I do see the scrollbar in CTRL+R, but that's all. I tried pushing it to front as well but didn't work. Moreover, if you try to inspect it with CTRL+F, the popup hides and the scrollbar is destroyed, so then I see NullPointerExceptions everywhere. When I was looking thru the UIDropDown class I found this - GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.listScrollbar.gameObject); this.m_ActiveScrollbar = gameObject.GetComponent<UIScrollbar>(); float d = base.PixelsToUnits(); Vector3 a = this.m_Popup.transform.TransformDirection(Vector3.right); Vector3 position = this.m_Popup.transform.position + a * (size2.x - this.m_ActiveScrollbar.width) * d; this.m_ActiveScrollbar.transform.parent = this.m_Popup.transform; this.m_ActiveScrollbar.transform.position = position; this.m_ActiveScrollbar.anchor = (UIAnchorStyle.Top | UIAnchorStyle.Bottom); this.m_ActiveScrollbar.height = this.m_Popup.height; this.m_Popup.width -= this.m_ActiveScrollbar.width; this.m_Popup.scrollbar = this.m_ActiveScrollbar; this.m_Popup.eventSizeChanged += delegate(UIComponent component, Vector2 size) { this.m_ActiveScrollbar.height = component.height; }; This code is executed every time the popup is shown. The scrollbar is copied every time and the height is set to to the one of the popup. But it does not seem to happen in my case. Edit: I put a breakpoint with dnSpy in the code above and it indeed gets executed. So hopefully the problem is still only with visibility/setup... -
How to add UI button?
Strdate replied to aubergine18's topic in Cities: Skylines Modding - Open Discussion
Well I am not sure, the buttons are created every time the game is loaded.- 24 Replies
-
- modding
- cities skylines
-
(and 2 more)
Tagged with:
-
Roundabout Builder Mod
Strdate replied to ghosty20's topic in Cities: Skylines Modding - Open Discussion
Crossings mod is about something else, there you place nodes onto existing roads. And about Move It - I know about its undo feature. In fact, I spent hours studying that mod I have created some kind of road wrappers heavily inspired by the implementation in Move It. We will see how it's gonna work out. (It is such a shame that I am recreating things that have already been done. For example, for the ones who know what I am talking about, the "MoveableNode" or "MoveableSegment" classes and overall the ActionQueue mechanism in Move It could find so much use in other mods as well. I think it is time for some kind of CimTools 2.0, with detour management, high level UI classes, net wrappers and many many other stuff. I wish to make something like this some day. But I am diverting a lot for now.) The problem is that mostly I know how to "do stuff" in the game, but one thing is to know how to build the road and the other to calculate the angles. Anyway, it is not like I was stuck, but it takes time to research. (And you have to be in mood to do it) -
How to add UI button?
Strdate replied to aubergine18's topic in Cities: Skylines Modding - Open Discussion
There is one problem related to this: it seems that time to time the UI buttons get despawned. I don't know much about this issue. But when I looked in the Crossings mod, in the Update() method there is a check whether the button still exists and if not, it is respawned. It seems pretty ugly, I don't do it in myself, but I can't tell much about it.- 24 Replies
-
- modding
- cities skylines
-
(and 2 more)
Tagged with:
-
Roundabout Builder Mod
Strdate replied to ghosty20's topic in Cities: Skylines Modding - Open Discussion
It is different in a few aspects - With the roundabout builder mod you select one intersection. Then a graph search happens which creates a list of roads inside the radius (these roads get erased) and splits the ones on borders. You end up with a list of nodes which you connect to create a roundabout (plus some details, sometimes for example you have to insert extra nodes). When the user is placing an intersection there is no node you could start from. Moreover, there is no list of nodes to which I can connect the adjacent roads, I have to detect these nodes myself somehow. When you are placing an intersection on a highway, the highway is not always straight. You must somehow bend the roads for the result to look well. Problem no. 2: Unlike from the roundabouts, the user can often end up with a result they are not happy about. The solution would be a back button. That is a far bigger problem than would many people think. Problem no. 3: You need reflection to do all this. Sorry if this answer is too technical
