1. This forum is obsolete and read-only. Feel free to contact us at support.keenswh.com

Resource Source/Sink Filtering

Discussion in 'Source Code' started by nobin, Sep 6, 2016.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. nobin

    nobin Trainee Engineer

    Messages:
    1
    Just started looking through the published code and wanted to try to tackle something that always bothered me:

    Problem

    Batteries will happily draw power from a reactor (and thus drain uranium) when recharging even when other power sources (solar panels) are available (assuming those other power sources don't fully satisfy the max input the battery can draw).

    As uranium can be fairly precious in survival and is much more portable and salvageable than power locked in a battery, it always seemed a little strange to automatically drain uranium to charge batteries; when playing, I would prefer to slowly charge batteries off solar panels in most cases rather than to quickly charge off uranium. I know the reactor(s) could be manually disabled while the battery is recharging, but this is error-prone and tedious.

    (Possible) Solution
    So, I looked through the code and found that the resource distribution system would need to be modified to allow power sinks to provide a whitelist and/or blacklist of power sources that they will drain from. The distributor component would then need to be modified to take these list(s) into consideration when distributing available power to sinks; changes would be around this area:
    https://github.com/KeenSoftwareHous...nents/MyResourceDistributorComponent.cs#L1489

    Once this source/sink filtering is in place, the stock battery block could be modified to add some option to control whether it recharges from reactors; or if the functionality is exposed through the ModAPI a mod could introduce a new advanced form of battery block (I'm assuming, not super-familiar with the existing mod API yet).

    Just wanted to get a feel from the developers and community about this problem and possible solution. If people think the solution is worth-while, then I can code it up and create a pull request.
     
    Last edited: Sep 6, 2016
  2. Bleuhazenfurfle

    Bleuhazenfurfle Apprentice Engineer

    Messages:
    284
    Sill the best solution I've personally seen so far: over here which itself links to over here.

    TL;DR — Sounds basically the same, except using a group specifier on individual blocks (nothing more than a dropdown, and simple dialog) — which is typically easier than putting blocks into lists — and then controlling the flow between groups with bridging blocks (the first of which being the battery).
     
Thread Status:
This last post in this thread was made more than 31 days old.