Nightinggale

[MODS] Nightinggale's mods list

Recommended Posts

Nightinggale    968

Updated both mods to apply a custom color to the buildings. While they still look like the vanilla buildings they share kamin with, they are now green to make it clear that they are in fact different buildings. Purely cosmetic update.

Share this post


Link to post
Share on other sites
Nightinggale    968

I started a new project, which is a liquid reservoir with multiple ports.

20190506232353_1.thumb.jpg.64bef693f8625207abc1b57507de4d43.jpg

It does work as in all 3 inputs adds to the internal storage and all 3 outputs takes from the internal storage.

 

However this isn't the real project. It's just a small project to get easy to see feedback for the real project. What I'm actually working on is an engine to add more ports. ONI is designed with 1 input and 1 output in mind. It can go up to 2 for each, though there are limitations. What I have here (and on GitHub) is a set of files, which are intended to be added to any mod and they allow as many ports as needed. 10 isn't a problem. I have full RGB control of the ports and while I have only tested with water, it seems that I can use the same code for liquids, gasses and solids. Adding a conveyor belt with coal, which goes directly into a modded coal generator seems doable.

 

This is tricky to work with because this isn't meant to be modded. We can see it in the ONI dll file, but the important parts are private. This means to get anywhere I had to start by figuring out how to access private data and methods like they are public. Doable, but not trivial even after I got it working. It requires custom coding for each method and it's not just copy paste.

 

I haven't released anything compiled yet because it's still glitchy. The added ports doesn't exist in the same realm as Klei ports, hence they can be placed on top of each other. I think I know how to deal with this, but once again I need to deal with private methods meaning it will take time. Also ports are currently only displayed for finished buildings because the preview is glitchy. The ports doesn't follow the mouse and just stays behind.

  • Like 4

Share this post


Link to post
Share on other sites
Nightinggale    968

I managed to get the user interface nailed down to something, which is usable by most modders. You no longer have to edit 3 files in order to add even a single port.

 

// config class
private static readonly PortDisplayLiquidOutput outputPort1 = new PortDisplayLiquidOutput(new CellOffset(0, 1), new Color(0.5f, 0.5f, 0.5f));
// ConfigureBuildingTemplate
conduitDispenser1.AssignPort(outputPort1);
// AttachPort
go.AddComponent<PortDisplayLiquid>().AssignPort(ID, outputPort1);

First the port is set with an offset and a color. If the color is skipped, it will just get a default color (green/write).

There are 6 types as in Gas/Liquid/Solid and Input/Output for each.

AssignPort to dispenser and consumer (both modded, but works like vanilla except for the assign port code). There is no need to assign data, which it gets from the port (offset, conduit type etc) and you can actually get a useful dispenser with no code other than assigning the port.

When building it assigns the port again, this time it is for screen drawing. ID is added as it allows the code to be self configuring apart from those 3 lines.

Errors are detected at compile time like placing a gas port in the liquid overlay or an input port on a dispenser. This not only make it easy to set up, but also hard to not find and fix bugs right away.

 

What remains now is to fix the bug where more than one port can exist on a single cell and this will become usable. Sure ports are still not drawn on templates, but right now I don't have a clue to how to fix that and being just a graphical glitch, I think we can live with it, at least until somebody figures out how to solve it.

  • Like 1

Share this post


Link to post
Share on other sites
SharraShimada    651

If i understand you right, we "just" need a conveyor filter, and a bunch of modded machines, and we could feed all of the machines with the materials directly, without dupes or sweepers. This would be a perfect "All automation" mod.

Share this post


Link to post
Share on other sites
Nightinggale    968
22 minutes ago, SharraShimada said:

If i understand you right, we "just" need a conveyor filter, and a bunch of modded machines, and we could feed all of the machines with the materials directly, without dupes or sweepers. This would be a perfect "All automation" mod.

That's one option and it sounds like a really interesting one too, though you forgot to mention solid "reservoirs". We can add 5 output to those and set filters on each if we like. I code with modding freedom in mind, meaning what we need is people with good ideas. The code itself shouldn't be the limiting factor.

 

However I just ran into a (minor?) setback. It turns out that Klei implemented ConduitFlow for gas and liquid pipes, but when adding solid "pipes" they decided to use SolidConduitFlow instead. Since ConduitFlow and SolidConduitFlow isn't compatible, part of my plan is ruined. That's not the same as the end goal isn't doable, it just require more coding. I better ignore solid for now and fix the issue where ports can be on top of each other. Once that issue is fixed, liquid and gas ports should work well enough to be used in mods and then an updated version with solid support can come later.

Share this post


Link to post
Share on other sites
SharraShimada    651

Maybe you should take this to Klei. They are into modding support all along, and coming near the release date, they should have an open mind for suggestions to adapt certain code to make modding a bit easier. 

Share this post


Link to post
Share on other sites
Nightinggale    968

I fixed the port display on previews. It turned out the problem was my own eagerness for performance. I cache the location of the port instead of calculating it for each screen update. Now it resets the cache if it's a preview and the ports are drawn as intended. It still relies on the cache for buildings under construction and completed, meaning the cache is still getting the job done for the vast majority of buildings.

Now the only known issues for gas and liquid are if a preview port is on top of an existing port, the preview is drawn on top of the existing. The game skips drawing the preview. I don't fix this because it's not trivial to solve and it's actually faster from a performance point of view to just ignore the issue.

The other issue is that I need to provide the RGB values for ports and while the inputs are Color.white, the output is an unknown green. My default color is a different shade of green. I don't think I will fix this either because in some cases default ports can have a different meaning for the code. This makes it fine to have default colors as darkened green and darkened white. Remember it's just default colors and they can be set on a per port setup.

19 hours ago, SharraShimada said:

Maybe you should take this to Klei. They are into modding support all along, and coming near the release date, they should have an open mind for suggestions to adapt certain code to make modding a bit easier. 

 I looked more into this issue and Klei would need to review like 4k of lines. I can get around it with most likely something like 20-50 lines. While I disagree with their design decision when they wrote the code in question (maybe it was based on something I haven't noticed), I would say it's not worth it to change now. Besides odds are that I'm the only modder to encounter this problem because when I'm done, people can just copy my file and they don't even have to know the issue ever existed in the first place.

Share this post


Link to post
Share on other sites
SuperCorgi    3

Some really cool work going on here. I was interested in how you go about adding a second output port for something that outputs two different elements and quickly got turned away from wanting to figure it out. Wouldn't even dare think about how to get a third port. I would love to see this when its finished.

What you should probably do is upload this to the workshop so other mods can list it as a dependency. The mods can then simply reference the library without having to copy/paste the code into their own project.

Share this post


Link to post
Share on other sites
Nightinggale    968

I released "High Flow Storage" (see the top). It adds storage with extra input/output port pairs. It adds liquid (3 pairs), gas (3 pairs), gas (5 pairs).

12 hours ago, SuperCorgi said:

Some really cool work going on here. I was interested in how you go about adding a second output port for something that outputs two different elements and quickly got turned away from wanting to figure it out. Wouldn't even dare think about how to get a third port. I would love to see this when its finished.

Yeah I noticed you stole my idea regarding piped outputs on the electrolyzer. I have had a working mod with 2 outputs for a week now, but I choose not to upload it because my next mod is to make a package of buildings with piped output, not just the electrolyzer. Now I don't have restrictions when adding anything whatsoever.

As for the coding difficulty, well yeah it's not trivial. My goal was from the start to take something, which is really complex and make a frontend, which is much easier to use. Also the hard part should be reusable because I don't feel like repeating this work.

12 hours ago, SuperCorgi said:

What you should probably do is upload this to the workshop so other mods can list it as a dependency. The mods can then simply reference the library without having to copy/paste the code into their own project.

I thought about this quite a bit. There are multiple solutions, each one having tradeoffs. I wrote ModCheck for RimWorld (yes it mods the mod loading code, but not the game code), which is distributed as a DLL file, which other mods can include in their distributions. Other mods can also just add ModCheck as a required mod. It looks really good on paper, but it's not perfect. The main problem is that happens when I update ModCheck? It will end up with multiple versions of the DLL, which is a mess. It has code to handle this case, but it's far from perfect. It mainly throws an error, which tells that players should report to the mod creators that they should upgrade as well as a workaround for players. Not great, but it works.

The other issue is that each update has to be backward compatible. Say it ends up being used in 200 mods (not unrealistic) and each mod has 3 xml files using ModCheck. That's 600 files. Updating in a way, which requires all files using ModCheck to be updated is not really an option. This has put severe restrictions on the development. It haven't stopped development, just made it more time consuming and a lot harder.

 

The option I picked this time is a lot easier for me. I have one folder with the files to include and I get MSVS to include them not as files, but as link. This means it doesn't copy the files and I only have one copy the files, not a copy in each mod. This means one bugfix and all I have to do is recompile all mods and they are all fixed.

All the classes in the library are internal. This means they are public within the dll file, but unreachable from other dll files. This means if the library is updated in a way, which requires modification to all existing mods, the existing mods will still work because they will stay with the version they had access to at compile time. This means I can't end up with "I really should do this, but I can't because it will break all the existing mods on Steam, hence break all savegames people have with those mods".

Share this post


Link to post
Share on other sites
SuperCorgi    3
1 hour ago, Nightinggale said:

Yeah I noticed you stole my idea regarding piped outputs on the electrolyzer. I have had a working mod with 2 outputs for a week now, but I choose not to upload it because my next mod is to make a package of buildings with piped output, not just the electrolyzer. Now I don't have restrictions when adding anything whatsoever.

Woops! Yeah its why I initially thought about how to do 2 outputs, although after I gave it some thought I really prefer a version with just one output. It just... feels better without deviating too much from its initial design. I know there'll be people who will love having everything piped from your idea though.

 

4 hours ago, Nightinggale said:

The option I picked this time is a lot easier for me. I have one folder with the files to include and I get MSVS to include them not as files, but as link. This means it doesn't copy the files and I only have one copy the files, not a copy in each mod. This means one bugfix and all I have to do is recompile all mods and they are all fixed.


Fair enough, I can understand that. I'm starting some concepts for something and I'm constantly asking myself about "what will this do to current saves if I change this later on". I actually mentioned the idea because I dabbled in RimWorld modding as well and HugsLib did that.

Share this post


Link to post
Share on other sites
SharraShimada    651

@Nightinggale did you change something to the rotate-code at all? I noticed the therme aquatuner can rotate 360°, but not mirroring anymore. It may caused by another mod i´m using, but i did not notice this prior to installing your 4-input/4-output system. So i assume its related somewhat to that. 

Share this post


Link to post
Share on other sites
Nightinggale    968
13 minutes ago, SharraShimada said:

did you change something to the rotate-code at all? I noticed the therme aquatuner can rotate 360°, but not mirroring anymore.

If my mod triggers this, then I exposed an existing bug in Klei's code because I didn't do anything to rotation other than what Klei is already doing. To be specific:

The new buildings have assigned which of the Klei rotation rules apply to them.

The port code asks an existing building where a cell is when it has offset (whatever) when taking the current rotation into account. Klei's own port drawing code makes precisely the same call.

Nothing else in the mod has touched upon rotation/mirroring.

Share this post


Link to post
Share on other sites
Nightinggale    968

I just started a new game without any mods. Aquatuner flipped as expected. I added High Flow Storage and no change to the aquatuner. It's completely as I would expect. I'm not sure what is causing it in your end, but it actually sounds interesting.

Share this post


Link to post
Share on other sites
Nightinggale    968

Updated High Flow Storage.

- The following can now be configured in the config file: storage capacity, build time and construction cost

- Gas storage for vertical pipes can now be flipped to support flows both going up and going down

 

PortDisplay is updated to allow 2 offsets for each port. One is the default one while the other is used for any rotated orientation. This allows using flipping a building to be used for alternative port layout, not just mirroring the default layout. The default alternative layout is null, meaning the default layout will be used. This feature only needs to be filled out when it's actually used.

Share this post


Link to post
Share on other sites
Nightinggale    968

While working on drawing ports on the overlays, I noticed that the port icons are GameObjects and once placed, they stay on the cell they are assigned to until the GameObject is being drawn again or disabled. I decided to use this information to make lists of ports, which can change placement or graphics and lists of ports, which are fixed for as long as the overlay doesn't change. Those lists are generated when the items are generated. Now when it is told to draw the ports, it will pick the right list and draw the ports from that list. Even better when a port is being drawn, it starts by getting location and color and only draw if those changed. Obviously changing overlay will force all ports to redraw.

The visual impression is the same. No change there. The only difference is that the High Flow Storage mod now only draws or disables port graphics when changing overlay.

Now I need to hook this up to operational and status items (error marker and stopped if port not connected). This will be optional on a per port basis. I also need to add support for solid "pipes" and then I think the library would be good to use for multiple mods.

Share this post


Link to post
Share on other sites
Nightinggale    968

Added a new mod "Player Controlled Switch", which grants the player control of switches. It makes the switch baseclass act like debug is always enabled, hence switching without dupe interaction.

Share this post


Link to post
Share on other sites
Nightinggale    968

Released the More Temperature Sensors mod. It adds 3 new temperature sensors, which can be used to measure temperature on: buildings, tiles and items on the floor (or falling in mid air).

 

The item sensor can also be used as an item detector if set to over 5000 C or below -270 C or similar. The point is it's active when there are no items and if it deactivate on items, you get a true/false on the presence of an item. Works sort of like a pressure plate, but not being in the floor it can be on top of doors or in mid air. It also doesn't trigger on dupes walking on it, only items.

Share this post


Link to post
Share on other sites
Nightinggale    968

Renamed the mod "More Temperature Sensors" into "Sensory Overload" because it is growing and adding non-temperature sensors.

Added config file to set max slider value for gas and liquid pressure sensors. Increased default max gas pressure from 20 kg to 50 kg.

Added Liquid Element sensor. Removed power usage from Gas Element sensor (that one has always annoyed me).

1 hour ago, Rainbowdesign said:

That would actually be fairly easy to add because the modded dispenser has the vanilla code for filtering. I only used it with an empty inverted filter meaning it accepts everything, but still the code is there. It's just a matter of calling it correctly. What would be nice would be some sort of port with a GUI you can set and a port, which outputs whatever is not set in ports with filters as this will allow outputting say crude oil, petroleum and "the rest" aka toilet accidents and whatever else could end up in your oil unintentionally. I have messed around with GUIs for sensors and it looks like they aren't that difficult to add, at least not if you can reuse existing GUIs. Keep in mind that you have to set the strings when adding a GUI, meaning a reused GUI is just reusing the button and slider layout and you can set your own text.

 

I thought about something like this, but decided not to make it mainly for balance issues. There is a liquid filter taking up 3 cells and using 120 W. If I add a building, which is 2x3 cells, has internal storage and can filter out 2 items without power usage, then the vanilla filter becomes completely pointless.

Share this post


Link to post
Share on other sites
Rainbowdesign    173
1 hour ago, Nightinggale said:

There is a liquid filter taking up 3 cells and using 120 W. If I add a building, which is 2x3 cells, has internal storage and can filter out 2 items without power usage, then the vanilla filter becomes completely pointless.

 

You can emulate the filter with automation, thats why i decided in my mod to reduce the power consumption to 10w the same as the liquid shutoff.

Also you could add automation to the reservoir:

https://github.com/javisar/ONI-Modloader/issues/40

 

Btw there is something else that would be cool to have:

A plumbing station that is a reservoir where you can get water bottles from the reservoir content and that takes water bottles and pump them into an outpipe.

Edited by Rainbowdesign

Share this post


Link to post
Share on other sites
Nightinggale    968
26 minutes ago, Rainbowdesign said:

You can emulate the filter with automation, thats why i decided in my mod to reduce the power consumption to 10w the same as the liquid shutoff.

Good point. Also the other day I learned from another thread that the gas/liquid shutoff valves just need to be connected to power and the 10 W only counts towards overloading the wire. They do not actually pull any joules, meaning they do not actually use power. Granted this is likely a bug, but it does make the 120 W for the filters rather pointless and unbalanced.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now